BinaryHeap
Defined in: packages/data/src/heap/binary-heap.ts:20
An unbounded binary heap.
For a capacity, use BoundedBinaryHeap (throws when full) or
BlockingBinaryHeap (waits).
Type Parameters
Section titled “Type Parameters”T extends DefinedValue
The type of elements in the heap.
Implements
Section titled “Implements”IHeap<T>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new BinaryHeap<
T>(precedes,iterable?,options?):BinaryHeap<T>
Defined in: packages/data/src/heap/binary-heap.ts:23
Parameters
Section titled “Parameters”precedes
Section titled “precedes”OrderPredicate<T>
iterable?
Section titled “iterable?”Iterable<T, any, any>
options?
Section titled “options?”Returns
Section titled “Returns”BinaryHeap<T>
Properties
Section titled “Properties”precedes
Section titled “precedes”
readonlyprecedes:OrderPredicate<T>
Defined in: packages/data/src/heap/binary-heap.ts:24
Strict weak ordering: precedes(a, b) is true when a outranks b.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”[iterator]()
Section titled “[iterator]()”[iterator]():
Iterator<T>
Defined in: packages/data/src/heap/binary-heap.ts:39
Returns
Section titled “Returns”Iterator<T>
Implementation of
Section titled “Implementation of”clear()
Section titled “clear()”clear():
void
Defined in: packages/data/src/heap/binary-heap.ts:43
Removes all elements from the collection.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”count()
Section titled “count()”count():
number
Defined in: packages/data/src/heap/binary-heap.ts:47
The number of elements in the collection.
A method, not a getter: its async counterpart needs a round trip to the backing store, and a member must have the same shape in both.
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”extract()
Section titled “extract()”extract():
T|undefined
Defined in: packages/data/src/heap/binary-heap.ts:63
Removes and returns the root item of the heap.
Returns
Section titled “Returns”T | undefined
The root item of the heap, or undefined if the heap is empty.
Implementation of
Section titled “Implementation of”extractAndInsert()
Section titled “extractAndInsert()”extractAndInsert(
item):T|undefined
Defined in: packages/data/src/heap/binary-heap.ts:97
Extracts the root item from the heap and inserts a new item in one operation.
Parameters
Section titled “Parameters”T
The item to replace.
Returns
Section titled “Returns”T | undefined
Implementation of
Section titled “Implementation of”insert()
Section titled “insert()”insert(
item):void
Defined in: packages/data/src/heap/binary-heap.ts:51
Inserts an item into the heap.
Parameters
Section titled “Parameters”T
The item to insert.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”insertAll()
Section titled “insertAll()”insertAll(
items):void
Defined in: packages/data/src/heap/binary-heap.ts:56
Inserts every item into the heap.
Parameters
Section titled “Parameters”readonly T[]
The items to insert.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”insertAndExtract()
Section titled “insertAndExtract()”insertAndExtract(
item):T|undefined
Defined in: packages/data/src/heap/binary-heap.ts:81
Inserts an item into the heap and then extracts and returns the root item in one operation.
Parameters
Section titled “Parameters”T
The item to insert and extract.
Returns
Section titled “Returns”T | undefined
Implementation of
Section titled “Implementation of”peek()
Section titled “peek()”peek():
T|undefined
Defined in: packages/data/src/heap/binary-heap.ts:109
Returns the root item of the heap without removing it.
Returns
Section titled “Returns”T | undefined
The root item of the heap, or undefined if the heap is empty.