https://github.com/strd6/priority_queue
A JavaScript PriorityQueue
https://github.com/strd6/priority_queue
coffeescript priority-queue
Last synced: 9 months ago
JSON representation
A JavaScript PriorityQueue
- Host: GitHub
- URL: https://github.com/strd6/priority_queue
- Owner: STRd6
- Created: 2009-06-07T01:59:36.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2017-11-12T03:34:27.000Z (about 8 years ago)
- Last Synced: 2025-04-13T02:42:07.515Z (9 months ago)
- Topics: coffeescript, priority-queue
- Language: CoffeeScript
- Homepage:
- Size: 57.6 KB
- Stars: 29
- Watchers: 3
- Forks: 12
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Description
-----------
A priority queue is a handy data structure with many uses. From graph search
algorithms to simple job queues, having this in your toolbelt will help to give
you a solid foundation.
Features
--------
* Simple to use and understand.
* Creates a single PriorityQueue constructor.
* Instantiate via `PriorityQueue()` or `new PriorityQueue()`
* Offers both highest first and lowest first ordering.
* Test suite included.
The default is highest priority first, but when doing something like A* you want lowest priority first... it handles it: `queue = PriorityQueue({low: true});` Boom!
Example Usage
-------------
# Highest priority first
queue = PriorityQueue()
queue.push("b", 5)
queue.push("a", 10)
queue.pop() # => "a"
queue.pop() # => "b"
# Lowest priority first
queue = PriorityQueue
low: true
queue.push("x", 5)
queue.push("y", 10)
queue.pop() # => "x"
queue.pop() # => "y"
License
-------
MIT