BoundedBinaryHeap
Defined in: packages/data/src/heap/bounded-binary-heap.ts:21
A binary heap that holds at most capacity items and throws once full.
Type Parameters
Section titled “Type Parameters”T extends DefinedValue
The type of elements in the heap.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new BoundedBinaryHeap<
T>(precedes,iterable,options):BoundedBinaryHeap<T>
Defined in: packages/data/src/heap/bounded-binary-heap.ts:27
Parameters
Section titled “Parameters”precedes
Section titled “precedes”OrderPredicate<T>
iterable
Section titled “iterable”Iterable<T, any, any> | undefined
options
Section titled “options”Returns
Section titled “Returns”BoundedBinaryHeap<T>
Properties
Section titled “Properties”capacity
Section titled “capacity”
readonlycapacity:number
Defined in: packages/data/src/heap/bounded-binary-heap.ts:25
The maximum number of elements the collection can hold.
Note: Infinity is not a legal value here — an unbounded type omits this
mixin.
Implementation of
Section titled “Implementation of”precedes
Section titled “precedes”
readonlyprecedes:OrderPredicate<T>
Defined in: packages/data/src/heap/bounded-binary-heap.ts:28
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/bounded-binary-heap.ts:40
Returns
Section titled “Returns”Iterator<T>
Implementation of
Section titled “Implementation of”clear()
Section titled “clear()”clear():
void
Defined in: packages/data/src/heap/bounded-binary-heap.ts:44
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/bounded-binary-heap.ts:48
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/bounded-binary-heap.ts:79
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/bounded-binary-heap.ts:92
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/bounded-binary-heap.ts:59
Same as IHeap.insert, but throws once the heap is full.
Parameters
Section titled “Parameters”T
Returns
Section titled “Returns”void
Throws
Section titled “Throws”If the operation would exceed the heap’s capacity.
IHeap.insert
Implementation of
Section titled “Implementation of”insertAll()
Section titled “insertAll()”insertAll(
items):void
Defined in: packages/data/src/heap/bounded-binary-heap.ts:73
Same as IHeap.insertAll, but throws once the heap is full. Nothing is
inserted when it throws — the check is made against the whole batch.
Parameters
Section titled “Parameters”readonly T[]
Returns
Section titled “Returns”void
Throws
Section titled “Throws”If the operation would exceed the heap’s capacity.
IHeap.insertAll
Implementation of
Section titled “Implementation of”insertAndExtract()
Section titled “insertAndExtract()”insertAndExtract(
item):T|undefined
Defined in: packages/data/src/heap/bounded-binary-heap.ts:88
Net-zero on the element count, so no capacity check is needed.
Parameters
Section titled “Parameters”T
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/bounded-binary-heap.ts:83
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.