0.2.3 • Published 11 years ago

min-heap v0.2.3

Weekly downloads
1,537
License
-
Repository
github
Last release
11 years ago

min-heap

API

var MinHeap = require('min-heap').MinHeap;

var heap = new MinHeap;
heap.insert(5);
heap.insert(1);
heap.insert(3);
heap.insert(2);

heap.remove(); // => 1
heap.remove(); // => 2
heap.remove(); // => 3
heap.remove(); // => 5

User-defined scoring function

// Pass user-defined scoring function as first param
// Return value is not cached so should be a fast, pure function
var heap = new MinHeap(function(v) { return v.weight; });

heap.insert({weight: 1, id: "spaghetti"});
heap.insert({weight: 3, id: "courgettes"});

heap.remove(); // => {weight: 1, id: "spaghetti"}
0.2.3

11 years ago

0.2.2

11 years ago

0.2.1

11 years ago

0.2.0

11 years ago

0.1.1

11 years ago

0.0.1

11 years ago