forked from STRd6/priority_queue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
37 lines (24 loc) · 924 Bytes
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
== Description ==
Ever need a simple priority queue? I sure as hell did. JavaScript doesn't make sharing code easy, so I'm going the extra mile to bring you this: PriorityQueue.js.
== 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
var queue = PriorityQueue();
queue.push("b", 5);
queue.push("a", 10);
queue.pop(); // => "a"
queue.pop(); // => "b"
// Lowest priority first
var queue = PriorityQueue({low: true});
queue.push("x", 5);
queue.push("y", 10);
queue.pop(); // => "x"
queue.pop(); // => "y"
== License ==
MIT