BlockingBinaryHeap
Defined in: packages/data/src/heap/blocking-binary-heap.ts:23
A binary heap that holds at most capacity items, and whose waitInsert
suspends until room frees up instead of throwing.
insert still throws — this type adds a way to wait, it does not change the
way to fail.
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 BlockingBinaryHeap<
T>(precedes,iterable,options):BlockingBinaryHeap<T>
Defined in: packages/data/src/heap/blocking-binary-heap.ts:30
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”BlockingBinaryHeap<T>
Properties
Section titled “Properties”capacity
Section titled “capacity”
readonlycapacity:number
Defined in: packages/data/src/heap/blocking-binary-heap.ts:28
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/blocking-binary-heap.ts:31
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/blocking-binary-heap.ts:47
Returns
Section titled “Returns”Iterator<T>
Implementation of
Section titled “Implementation of”clear()
Section titled “clear()”clear():
void
Defined in: packages/data/src/heap/blocking-binary-heap.ts:51
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/blocking-binary-heap.ts:58
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/blocking-binary-heap.ts:95
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/blocking-binary-heap.ts:114
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”IWaitableHeap.extractAndInsert
insert()
Section titled “insert()”insert(
item):void
Defined in: packages/data/src/heap/blocking-binary-heap.ts:62
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/blocking-binary-heap.ts:67
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/blocking-binary-heap.ts:110
Net-zero on the element count, so no permit changes hands.
Parameters
Section titled “Parameters”T
Returns
Section titled “Returns”T | undefined
Implementation of
Section titled “Implementation of”IWaitableHeap.insertAndExtract
peek()
Section titled “peek()”peek():
T|undefined
Defined in: packages/data/src/heap/blocking-binary-heap.ts:105
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.
Implementation of
Section titled “Implementation of”waitInsert()
Section titled “waitInsert()”waitInsert(
item,signal?):Promise<void>
Defined in: packages/data/src/heap/blocking-binary-heap.ts:76
Same as insert, but waits for capacity if the operation would exceed it.
Parameters
Section titled “Parameters”T
signal?
Section titled “signal?”AbortSignal | null
Optional abort signal to cancel the operation.
Returns
Section titled “Returns”Promise<void>
IHeap.insert
Implementation of
Section titled “Implementation of”waitInsertAll()
Section titled “waitInsertAll()”waitInsertAll(
items,signal?):Promise<void>
Defined in: packages/data/src/heap/blocking-binary-heap.ts:81
Same as insertAll, but waits for capacity if the operation would exceed
it. The whole batch lands at once, never interleaved with another
waiter’s.
Parameters
Section titled “Parameters”Iterable<T>
signal?
Section titled “signal?”AbortSignal | null
Optional abort signal to cancel the operation.
Returns
Section titled “Returns”Promise<void>
IHeap.insertAll