Skip to content

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.

T extends DefinedValue

The type of elements in the heap.

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

Defined in: packages/data/src/heap/bounded-binary-heap.ts:27

OrderPredicate<T>

Iterable<T, any, any> | undefined

BoundedBinaryHeapOptions<T>

BoundedBinaryHeap<T>

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

IBounded.capacity


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

IHeap.precedes

[iterator](): Iterator<T>

Defined in: packages/data/src/heap/bounded-binary-heap.ts:40

Iterator<T>

IHeap.[iterator]


clear(): void

Defined in: packages/data/src/heap/bounded-binary-heap.ts:44

Removes all elements from the collection.

void

IHeap.clear


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.

number

IHeap.count


extract(): T | undefined

Defined in: packages/data/src/heap/bounded-binary-heap.ts:79

Removes and returns the root item of the heap.

T | undefined

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

IHeap.extract


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.

T

The item to replace.

T | undefined

IHeap.extractAndInsert


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.

T

void

If the operation would exceed the heap’s capacity.

IHeap.insert

IHeap.insert


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.

readonly T[]

void

If the operation would exceed the heap’s capacity.

IHeap.insertAll

IHeap.insertAll


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.

T

T | undefined

IHeap.insertAndExtract


peek(): T | undefined

Defined in: packages/data/src/heap/bounded-binary-heap.ts:83

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.

IHeap.peek