Defined in: packages/heap/src/priority-queue.ts:205
A mutable indexed priority queue over a k-ary heap layout: same contract
as BinaryPriorityQueue, with up to k children per node. Flatter
tree, fewer sift levels, more comparisons per sift-down level — the same
tradeoff KHeap documents.
Extends
Section titled “Extends”PriorityQueueSurface<K,V>
Type Parameters
Section titled “Type Parameters”K
V
Properties
Section titled “Properties”
readonlysize:number
Defined in: packages/heap/src/priority-queue.ts:80
Number of entries. O(1). The queue is empty when this is 0.
Inherited from
Section titled “Inherited from”
readonlypeek: () =>V
Defined in: packages/heap/src/priority-queue.ts:89
Return the value of the extreme entry — minimum key for min kinds, maximum key for max kinds — without removing it. O(1).
Property syntax for the same variance reason as push.
Returns
Section titled “Returns”V
Throws
Section titled “Throws”With code EMPTY when the queue is empty.
Inherited from
Section titled “Inherited from”peekEntry
Section titled “peekEntry”
readonlypeekEntry: () => readonly [K,V]
Defined in: packages/heap/src/priority-queue.ts:99
Return a fresh readonly [key, value] tuple for the extreme entry,
without removing it. O(1). Each call allocates its own tuple, so
mutating a returned tuple cannot corrupt the queue.
Property syntax for the same variance reason as push.
Returns
Section titled “Returns”readonly [K, V]
Throws
Section titled “Throws”With code EMPTY when the queue is empty.
Inherited from
Section titled “Inherited from”PriorityQueueSurface.peekEntry
readonlypop: () =>V
Defined in: packages/heap/src/priority-queue.ts:108
Remove and return the value of the extreme entry. O(log n) binary, O(k log_k n) k-ary.
Property syntax for the same variance reason as push.
Returns
Section titled “Returns”V
Throws
Section titled “Throws”With code EMPTY when the queue is empty.
Inherited from
Section titled “Inherited from”popEntry
Section titled “popEntry”
readonlypopEntry: () => readonly [K,V]
Defined in: packages/heap/src/priority-queue.ts:118
Remove the extreme entry and return a fresh readonly [key, value]
tuple for it. Same cost and freshness contract as pop and
peekEntry.
Property syntax for the same variance reason as push.
Returns
Section titled “Returns”readonly [K, V]
Throws
Section titled “Throws”With code EMPTY when the queue is empty.
Inherited from
Section titled “Inherited from”
readonlypush: (key,value) =>void
Defined in: packages/heap/src/priority-queue.ts:130
Insert a new entry and restore the heap invariant. O(log n) binary, O(k log_k n) k-ary — sift-up compares once per level.
Property syntax on purpose: method-syntax parameters compare
bivariantly, which would let this interface’s implementations widen
unsoundly through the PriorityQueue union (see the interface comment).
Parameters
Section titled “Parameters”K
V
Returns
Section titled “Returns”void
Throws
Section titled “Throws”With code DUPLICATE_VALUE when value
is already resident. A value becomes pushable again after it is popped.
Inherited from
Section titled “Inherited from”updateKey
Section titled “updateKey”
readonlyupdateKey: (key,value) =>void
Defined in: packages/heap/src/priority-queue.ts:143
Replace the key of a resident value and restore the heap invariant in the one direction the change requires. O(log n) binary, O(k log_k n) k-ary; O(1) when the new key compares equal to the old, in which case nothing moves and only the stored key (the whole entry object) is replaced.
Property syntax for the same variance reason as push.
Parameters
Section titled “Parameters”K
V
Returns
Section titled “Returns”void
Throws
Section titled “Throws”With code VALUE_NOT_FOUND when value
is not resident.
Inherited from
Section titled “Inherited from”PriorityQueueSurface.updateKey
readonlykeyOf: (value) =>K
Defined in: packages/heap/src/priority-queue.ts:152
Return the key currently stored for value. O(1) average.
Property syntax for the same variance reason as push.
Parameters
Section titled “Parameters”V
Returns
Section titled “Returns”K
Throws
Section titled “Throws”With code VALUE_NOT_FOUND when value
is not resident.
Inherited from
Section titled “Inherited from”
readonlyhas: (value) =>boolean
Defined in: packages/heap/src/priority-queue.ts:158
Return true when value is resident. O(1) average.
Property syntax for the same variance reason as push.
Parameters
Section titled “Parameters”V
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”
readonlyclear: () =>void
Defined in: packages/heap/src/priority-queue.ts:166
Remove every entry, keeping the kind, arity, and key order. O(n): the value index is released along with the entries. Every previously resident value can be pushed again.
Property syntax for the same variance reason as push.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”entries
Section titled “entries”
readonlyentries: () =>IterableIterator<readonly [K,V]>
Defined in: packages/heap/src/priority-queue.ts:178
Walk the entries lazily as fresh readonly [key, value] tuples in
internal heap-array order, which is neither sorted nor insertion order:
the extreme entry comes first and every parent precedes its children.
O(n) for a full walk, O(1) extra space besides each yielded tuple. Does
not mutate the queue. The walk reads the live array, so changing the
queue while a walk is open is unsupported: the walk still ends, but
which entries it yields is unspecified.
Property syntax for the same variance reason as push.
Returns
Section titled “Returns”IterableIterator<readonly [K, V]>
Inherited from
Section titled “Inherited from”[iterator]
Section titled “[iterator]”
readonly[iterator]: () =>IterableIterator<readonly [K,V]>
Defined in: packages/heap/src/priority-queue.ts:180
The same walk as entries, as the same function, so for (const [key, value] of queue) works.
Returns
Section titled “Returns”IterableIterator<readonly [K, V]>
Inherited from
Section titled “Inherited from”PriorityQueueSurface.[iterator]
readonlykind:"k-priority-queue-min"|"k-priority-queue-max"
Defined in: packages/heap/src/priority-queue.ts:207
Storage layout and extraction direction. Either 'k-priority-queue-min' or 'k-priority-queue-max'.
readonlyarity:number
Defined in: packages/heap/src/priority-queue.ts:209
Number of children per node, fixed at construction.