Skip to main content

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

new BinaryHeap(scoreFunction)

ParamType
scoreFunctionfunction

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

ParamType
nodeT

binaryHeap.deleteByIndex(i)

NOTE: Unsafe method, use at your own risk

Kind: instance method of BinaryHeap

ParamType
inumber

binaryHeap.clear()

Remove all the data from the heap

Kind: instance method of BinaryHeap

binaryHeap.contains(node) ⇒ boolean

Kind: instance method of BinaryHeap

ParamType
nodeT

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

ParamType
nodeT

binaryHeap.push(el)

Kind: instance method of BinaryHeap

ParamType
elT