priority_queue
Priority queue for Crystal
Installation
-
Add the dependency to your
shard.yml
:dependencies: priority_queue: github: ktanaka101/priority_queue
-
Run
shards install
Usage
require "priority_queue"
q = PriorityQueue(Int32).build
q << 3
q << 1
q << 2
q << 5
q << 4
q.pop #=> 5
q.pop #=> 4
q.pop #=> 3
q.pop #=> 2
q.pop #=> 1
# #pop raises IndexError if empty
q = PriorityQueue(Int32).build
q.pop #=> raise IndexError
# #pop? returns nil if empty
q = PriorityQueue(Int32).build
q.pop? #=> nil
Contributing
- Fork it (https://github.com/ktanaka101/priority_queue/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- ktanaka101 - creator and maintainer