Skip to content

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.

T extends DefinedValue

The type of elements in the heap.

new BlockingBinaryHeap<T>(precedes, iterable, options): BlockingBinaryHeap<T>

Defined in: packages/data/src/heap/blocking-binary-heap.ts:30

OrderPredicate<T>

Iterable<T, any, any> | undefined

BlockingBinaryHeapOptions<T>

BlockingBinaryHeap<T>

readonly capacity: 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.

IWaitableHeap.capacity


readonly precedes: 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.

IWaitableHeap.precedes

[iterator](): Iterator<T>

Defined in: packages/data/src/heap/blocking-binary-heap.ts:47

Iterator<T>

IWaitableHeap.[iterator]


clear(): void

Defined in: packages/data/src/heap/blocking-binary-heap.ts:51

Removes all elements from the collection.

void

IWaitableHeap.clear


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.

number

IWaitableHeap.count


extract(): T | undefined

Defined in: packages/data/src/heap/blocking-binary-heap.ts:95

Removes and returns the root item of the heap.

T | undefined

The root item of the heap, or undefined if the heap is empty.

IWaitableHeap.extract


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.

T

The item to replace.

T | undefined

IWaitableHeap.extractAndInsert


insert(item): void

Defined in: packages/data/src/heap/blocking-binary-heap.ts:62

Inserts an item into the heap.

T

The item to insert.

void

IWaitableHeap.insert


insertAll(items): void

Defined in: packages/data/src/heap/blocking-binary-heap.ts:67

Inserts every item into the heap.

readonly T[]

The items to insert.

void

IWaitableHeap.insertAll


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.

T

T | undefined

IWaitableHeap.insertAndExtract


peek(): T | undefined

Defined in: packages/data/src/heap/blocking-binary-heap.ts:105

Returns the root item of the heap without removing it.

T | undefined

The root item of the heap, or undefined if the heap is empty.

IWaitableHeap.peek


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.

T

AbortSignal | null

Optional abort signal to cancel the operation.

Promise<void>

IHeap.insert

IWaitableHeap.waitInsert


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.

Iterable<T>

AbortSignal | null

Optional abort signal to cancel the operation.

Promise<void>

IHeap.insertAll

IWaitableHeap.waitInsertAll