Skip to content

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).

T extends DefinedValue

The type of elements in the heap.

new BinaryHeap<T>(precedes, iterable?, options?): BinaryHeap<T>

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

OrderPredicate<T>

Iterable<T, any, any>

BinaryHeapOptions<T>

BinaryHeap<T>

readonly precedes: OrderPredicate<T>

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

Strict weak ordering: precedes(a, b) is true when a outranks b.

IHeap.precedes

[iterator](): Iterator<T>

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

Iterator<T>

IHeap.[iterator]


clear(): void

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

Removes all elements from the collection.

void

IHeap.clear


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.

number

IHeap.count


extract(): T | undefined

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

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/binary-heap.ts:97

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/binary-heap.ts:51

Inserts an item into the heap.

T

The item to insert.

void

IHeap.insert


insertAll(items): void

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

Inserts every item into the heap.

readonly T[]

The items to insert.

void

IHeap.insertAll


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.

T

The item to insert and extract.

T | undefined

IHeap.insertAndExtract


peek(): T | undefined

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

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