Skip to content

mbish/PriorityQueue.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

== 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

About

A JavaScript PriorityQueue

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published