# maxKPriorityQueue

> **maxKPriorityQueue**<`K`, `V`>(`k`, `keyOrder`, `entries?`): [`KPriorityQueue`](/reference/knotkit/heap/interfaces/kpriorityqueue/)<`K`, `V`>

Defined in: [packages/heap/src/priority-queue.ts:723](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/heap/src/priority-queue.ts#L723)

Create a max priority queue over a k-ary heap: same contract as [maxPriorityQueue](/reference/knotkit/heap/functions/maxpriorityqueue/), with up to `k` children per node.

## Type Parameters

### K

`K`

### V

`V`

## Parameters

### k

`number`

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

### keyOrder

[`Order`](/reference/knotkit/heap/type-aliases/order/)<`K`>

Total ordering over the keys.

### entries?

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

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

## Returns

[`KPriorityQueue`](/reference/knotkit/heap/interfaces/kpriorityqueue/)<`K`, `V`>

## Example

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

## Throws

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

## Throws

With code `DUPLICATE_VALUE` when `entries` carries one value twice.
