new BinaryHeap(cmp)
An implementation of the Binary Heap data structure suitable for priority queues.
Parameters:
Name | Type | Description |
---|---|---|
cmp |
compareFunction | A comparison function that determines how the heap is sorted. |
- Source:
Members
(readonly) length :number
The number of elements in the heap.
Type:
- number
- Source:
Methods
deleteRoot() → {data}
Remove the heap's root node, and return it. The root node is whatever comes first as determined by the compareFunction.
- Source:
Returns:
The root node's data.
- Type
- data
indexOf(data) → {number}
Search for a node in the heap.
Parameters:
Name | Type | Description |
---|---|---|
data |
object | The data to search for. |
- Source:
Returns:
The index of the data in the heap, or -1 if it is not found.
- Type
- number
insert(data)
Store a new node in the heap.
Parameters:
Name | Type | Description |
---|---|---|
data |
object | The data to store |
- Source: