Constructor
new Heap(valFnopt)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
valFn |
function |
<optional> |
A function to extract the comparison value from an element. Defaults to identity (n => n). |
Classes
Methods
add(el) → {number}
Parameters:
| Name | Type | Description |
|---|---|---|
el |
* | The element to add. |
Returns:
The new index of the added element.
- Type
- number
data() → {Array}
- Description:
- Returns the internal array representation of the heap (excluding the dummy first element).
- Source:
Returns:
The heap elements.
- Type
- Array
size() → {number}
Returns:
The size of the heap.
- Type
- number
take() → {*}
- Description:
- Removes and returns the minimum element (root) from the heap.
- Source:
Returns:
The minimum element.
- Type
- *