# MutQueue

`enum MutQueue[a: Type, r: Eff]`Source
`case MutQueue(Region[r], Ref[Array[a, r], r], Ref[Int32, r])`

Represents a mutable priority queue. Explanation of component types (left to right): Component 1: The region capability the queue is associated with. Component 2: A reference to the backing array. Component 3: A reference to the number of elements in the mutable priority queue.

The maximum element (if it exists) can always be accessed in constant time.

## Definitions

`def dequeue(mq: MutQueue[a, r]): Option[a] \ r with Order[a]`

Removes and optionally returns the top element of `mq`.

`def enqueue(mq: MutQueue[a, r], x: a): Unit \ r with Order[a]`

Enqueues an element `x` into a `mq`.

`def enqueueAll(mq: MutQueue[a, r], m: m[a]): Unit \ r with Order[a], Iterable[m]`

Enqueues each element in `l` into `mq`.

`def isEmpty(mq: MutQueue[a, r]): Bool \ r`

Returns whether `mq` is empty.

`def iterator(rc: Region[r1], mq: MutQueue[a, r2]): Iterator[a, r1 + r2, r1] \ r1 + r2`

Returns an iterator over `mq`.

Modifying `mq` during iteration is undefined and not recommended.

`def new(rc: Region[r]): MutQueue[a, r] \ r`

Returns an empty MutQueue.

`def peek(mq: MutQueue[a, r]): Option[a] \ r`

Optionally returns the top element of `mq`.

`def size(mq: MutQueue[a, r]): Int32 \ r`

Returns the number of elements in `mq`.

`def toArray(rc: Region[r1], mq: MutQueue[a, r2]): Array[a, r1] \ r1 + r2`

Returns an Array representation of `mq`.

Note that a MutQueue's element order depends on the order in which the elements were enqueued.

`def toList(mq: MutQueue[a, r]): List[a] \ r with Order[a]`

Returns a List representation of `mq`.

Note that a MutQueue's element order depends on the order in which the elements were enqueued.

`def toNel(mq: MutQueue[a, r]): Option[Nel[a]] \ r with Order[a]`

Optionally returns a Nel representation of `mq`.

`def toString(mq: MutQueue[a, r]): String \ r with ToString[a]`

Returns a String representation of the mutable priority queue `mq`.