flix

0.78.0

MutPriorityQueue

struct MutPriorityQueue[a: Type, r: Eff]Source
r: Region[r]mut values: Array[a, r]mut size: Int32

Type of mutable priority queues.

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.

Type of mutable priority queues, and its functions.

Instances

instance ForEach[MutPriorityQueue[a, r]]Source
type Elm = atype Aef = r
instance Formattable[MutPriorityQueue[a, r]] with Formattable[a], Order[a]Source
type Aef = Aef[a] + r
instance Iterable[MutPriorityQueue[a, r]]Source
type Elm = atype Aef = r

Definitions

def dequeue(mq: MutPriorityQueue[a, r]): Option[a] \ r with Order[a]§ Source

Removes and optionally returns the top element of mq.

def empty(rc: Region[r]): MutPriorityQueue[a, r] \ r§ Source

Returns an empty MutPriorityQueue with a default capacity.

def emptyWithCapacity(rc: Region[r], capacity: Int32): MutPriorityQueue[a, r] \ r§ Source

Returns an empty MutPriorityQueue with the given capacity rounded up to the default capacity.

def enqueue(x: a, mq: MutPriorityQueue[a, r]): Unit \ r with Order[a]§ Source

Enqueues an element x into a mq.

def enqueueAll(m: m, mq: MutPriorityQueue[elt, r]): Unit \ r + Aef[m] with ForEach[m], Order[elt] where ForEach.Elm[m] ~ elt§ Source

Enqueues each element in m into mq.

def forEach(f: a -> Unit \ ef, q: MutPriorityQueue[a, r]): Unit \ ef + r§ Source

Applies f to every element of q.

def isEmpty(mq: MutPriorityQueue[a, r]): Bool \ r§ Source

Returns whether mq is empty.

def iterator(rc: Region[r1], mq: MutPriorityQueue[a, r2]): Iterator[a, r1 + r2, r1] \ r1 + r2§ Source

Returns an iterator over mq.

Modifying mq during iteration is undefined and not recommended.

def minCapacity(): Int32§ Source

Constant which stores the minimum capacity of a MutPriorityQueue.

def nonEmpty(mq: MutPriorityQueue[a, r]): Bool \ r§ Source

Returns whether mq is non-empty.

def peek(mq: MutPriorityQueue[a, r]): Option[a] \ r§ Source

Optionally returns the top element of mq.

def size(mq: MutPriorityQueue[a, r]): Int32 \ r§ Source

Returns the number of elements in mq.

def toArray(rc: Region[r1], mq: MutPriorityQueue[a, r2]): Array[a, r1] \ r1 + r2§ Source

Returns an Array representation of mq.

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

def toList(mq: MutPriorityQueue[a, r]): List[a] \ r with Order[a]§ Source

Returns a List representation of mq.

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

def toNel(mq: MutPriorityQueue[a, r]): Option[Nel[a]] \ r with Order[a]§ Source

Optionally returns a Nel representation of mq.

def toString(mq: MutPriorityQueue[a, r]): String \ r with ToString[a]§ Source

Returns a String representation of the mutable priority queue mq.

def toVector(mq: MutPriorityQueue[a, r]): Vector[a] \ r§ Source

Returns an Vector representation of mq.

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