Module gamejs/math/binaryheap

Binary Heap implementation from Eloquent JavaScript

See

http://eloquentjavascript.net/appendix2.html

Class BinaryHeap

Instance Methods


BinaryHeap (scoreFunction)

Parameters

scoreFunction

See


BinaryHeap.prototype.pop (element)

Return first element from heap.

Parameters

Object element

Returns

Object element

BinaryHeap.prototype.push (element)

Add element to heap.

Parameters

Object element

BinaryHeap.prototype.remove (element)

Remove the given element from the heap.

Parameters

Object element

Returns

true if the node was round and removed or fals otherwise

Throws

{Error} if node not found

BinaryHeap.prototype.size ()

Number of elements in heap.