BinaryHeap
BinaryHeap
Min-Heap implementation with a score function. The data structure is a binary heap where elements are removed in order defined by scoring function
Kind: global class
- BinaryHeap
- new BinaryHeap(scoreFunction)
- .scoreFunction :
function
- .isBinaryHeap :
boolean
- .pop() ⇒
T
- .peek() ⇒
T
|undefined
- .delete(node) ⇒
boolean
- .deleteByIndex(i)
- .clear()
- .contains(node) ⇒
boolean
- .isEmpty() ⇒
boolean
- .size() ⇒
number
- .updateElementScore(node) ⇒
boolean
- .push(el)
new BinaryHeap(scoreFunction)
Param | Type |
---|---|
scoreFunction | function |
binaryHeap.scoreFunction : function
Kind: instance property of BinaryHeap
binaryHeap.isBinaryHeap : boolean
Useful for type checks
Kind: instance property of BinaryHeap
Read only: true
binaryHeap.pop() ⇒ T
Kind: instance method of BinaryHeap
binaryHeap.peek() ⇒ T
| undefined
Kind: instance method of BinaryHeap
binaryHeap.delete(node) ⇒ boolean
Kind: instance method of BinaryHeap
Param | Type |
---|---|
node | T |
binaryHeap.deleteByIndex(i)
NOTE: Unsafe method, use at your own risk
Kind: instance method of BinaryHeap
Param | Type |
---|---|
i | number |
binaryHeap.clear()
Remove all the data from the heap
Kind: instance method of BinaryHeap
binaryHeap.contains(node) ⇒ boolean
Kind: instance method of BinaryHeap
Param | Type |
---|---|
node | T |
binaryHeap.isEmpty() ⇒ boolean
Kind: instance method of BinaryHeap
binaryHeap.size() ⇒ number
Kind: instance method of BinaryHeap
binaryHeap.updateElementScore(node) ⇒ boolean
Kind: instance method of BinaryHeap
Returns: boolean
- false if element is not found, true otherwise
Param | Type |
---|---|
node | T |
binaryHeap.push(el)
Kind: instance method of BinaryHeap
Param | Type |
---|---|
el | T |