Skip to content

minKPriorityQueue<K, V>(k, keyOrder, entries?): KPriorityQueue<K, V>

Defined in: packages/heap/src/priority-queue.ts:696

Create a min priority queue over a k-ary heap: same contract as minPriorityQueue, with up to k children per node.

K

V

number

Arity: children per node. Must be a safe integer >= 2.

Order<K>

Total ordering over the keys.

Iterable<readonly [K, V], any, any>

Optional initial [key, value] pairs, in iteration order.

KPriorityQueue<K, V>

const pq = minKPriorityQueue(4, numberOrder, [[5, 'a'], [1, 'b'], [3, 'c']])
pq.peek() // 'b'

With code INVALID_ARITY when k is not a safe integer of at least 2.

With code DUPLICATE_VALUE when entries carries one value twice.