Abstract
Abstract
sizeReturns the current number of elements in the heap.
The number of elements in the heap.
Abstract
[iterator]Makes the AbstractHeap
iterable.
Note: The traversal follows the order of the underlying array, not the priority order.
If true
, the iterator will traverse the heap in reverse order.
An iterator yielding heap elements in the specified order.
Abstract
addAdds a new node to the heap while maintaining the heap property.
The node to add to the heap.
Abstract
clearRemoves all elements from the heap.
Abstract
decreaseAbstract
entriesReturns an iterator for traversing all elements in the heap.
Note: The traversal follows the order of the underlying array, not the priority order.
Optional
reversed: booleanIf true
, the iterator will traverse the heap in reverse order.
An iterator yielding heap elements in the specified order.
Abstract
forExecutes a callback function for each element in the heap.
Note: The traversal follows the order of the underlying array, not the priority order.
Element of each iteration.
The index of the current element being processed in the heap.
The heap instance being iterated.
Optional
thisArg: anyAbstract
increaseAbstract
keysReturns an iterator for traversing just the key values in the heap.
Note: The traversal follows the order of the underlying array, not the priority order.
If true
, the iterator will traverse the heap in reverse order.
Abstract
peekReturns the top element of the heap without removing it.
The top element or undefined
if heap is empty.
Abstract
popRemoves and returns the top element of the heap.
The removed top element or undefined
if heap is empty.
Abstract
removeRemoves a specific element from anywhere in the heap.
The element to remove.
true
if element was found and removed, false
if not found.
An abstract base class for implementing heap data structures.
Provides a common interface for both min-heap and max-heap implementations.