Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: b06a979b01
Fetching contributors…

Cannot retrieve contributors at this time

37 lines (29 sloc) 0.734 kb

jsheap - Heap(Priority Queue) for JavaScitpt -

Usage

var heap = new jsheap();
heap.push(5);
heap.push(6);
heap.push(3);
heap.empty(); // returns false
heap.top(); // returns 3
heap.pop();
heap.top(); // returns 5
heap.pop();
heap.top(); // returns 6
heap.pop();
heap.empty(); // returns true

'top' method will return the minimum value in the queue by default. You can redefine this action. For example, the following script makes 'top' method return maximum value.

var heap = new jsheap(function(a, b) {
    return a > b;
});

License

Copyright © 2011 Shogo Ichinose

Distributed under the MIT License.

Jump to Line
Something went wrong with that request. Please try again.