MutDeque

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

Represents a mutable deque.

Explanation of component types (from left to right): The 1st component is a reference the backing array. The 2nd component is a reference to the front index. The 3rd component is a reference to the back index.

If front == back then the deque is empty. Otherwise, the front index always points to an element (going counter-clockwise) and the back index always points to the first empty index (going clockwise).

Definitions

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

Returns an empty MutDeque.

def foldLeft(f: b -> (a -> b \ ef), s: b, d: MutDeque[a, r]): b \ ef + r Source

Applies f to a start value s and all elements in d going from left to right.

That is, the result is of the form: f(...f(f(s, x1), x2)..., xn).

def foldMap(f: a -> b \ ef, d: MutDeque[a, r]): b \ ef + r with Monoid[b] Source

Returns the result of mapping each element and combining the results.

def foldRight(f: a -> (b -> b \ ef), s: b, d: MutDeque[a, r]): b \ ef + r Source

Applies f to a start value s and all elements in d going from right to left.

That is, the result is of the form: f(x1, ...f(xn-1, f(xn, s))...).

def foldRightWithCont(f: a -> ((Unit -> b \ ef + r) -> b \ ef + r), s: b, d: MutDeque[a, r]): b \ ef + r Source

Applies f to a start value z and all elements in d going from right to left.

That is, the result is of the form: f(x1, ...f(xn-1, f(xn, z))...). A foldRightWithCont allows early termination by not calling the continuation.

def forEach(f: a -> Unit \ ef, d: MutDeque[a, r]): Unit \ ef + r Source

Apply the effectful function f to all the elements in the MutDeque d.

def forEachWithIndex(f: Int32 -> (a -> Unit \ ef), d: MutDeque[a, r]): Unit \ ef + r Source

Apply the effectful function f to all the elements in the MutDeque d along with that element's index.

def isEmpty(d: MutDeque[a, r]): Bool \ r Source

Returns true if d is empty.

def iterator(rc: Region[r1], d: MutDeque[a, r2]): Iterator[a, r1 + r2, r1] \ r1 + r2 Source

Returns an iterator over d.

Modifying d while using an iterator has undefined behavior and is dangerous.

def join(sep: String, d: MutDeque[a, r]): String \ r with ToString[a] Source

Returns the concatenation of the string representation of each element in d with sep inserted between each element.

def joinWith(f: a -> String \ ef, sep: String, d: MutDeque[a, r]): String \ ef + r Source

Returns the concatenation of the string representation of each element in d according to f with sep inserted between each element.

def peekBack(d: MutDeque[a, r]): Option[a] \ r Source

Optionally returns the back element. Does not remove it.

def peekFront(d: MutDeque[a, r]): Option[a] \ r Source

Optionally returns the front element. Does not remove it.

def popBack(d: MutDeque[a, r]): Option[a] \ r Source

Returns Some(x) where x is the element at the back. Returns None if d is empty.

def popFront(d: MutDeque[a, r]): Option[a] \ r Source

Returns Some(x) where x is the element at the front. Returns None if d is empty.

def pushBack(x: a, d: MutDeque[a, r]): Unit \ r Source

Pushes x to the back of d.

def pushFront(x: a, d: MutDeque[a, r]): Unit \ r Source

Pushes x to the front of d.

def sameElements(d1: MutDeque[t, r1], d2: MutDeque[t, r2]): Bool \ r1 + r2 with Eq[t] Source

Returns true if MutDeques a and b have the same elements in the same order, i.e. are structurally equal.

def shuffle(rc1: Region[r1], rnd: Random, d: MutDeque[a, r2]): MutDeque[a, r1] \ r2 + r1 + IO Source

Shuffles a copy of d using the Fisher–Yates shuffle.

def size(d: MutDeque[a, r]): Int32 \ r Source

Returns the number of elements in d.

def sum(d: MutDeque[Int32, r]): Int32 \ r Source

Returns the sum of all elements in the deque d.

def sumWith(f: a -> Int32 \ ef, d: MutDeque[a, r]): Int32 \ ef + r Source

Returns the sum of all elements in the deque d according to the function f.

def toArray(rc1: Region[r1], d: MutDeque[a, r2]): Array[a, r1] \ r2 + r1 Source

Returns d as an array.

def toList(d: MutDeque[a, r]): List[a] \ r Source

Returns d as a List.

def toString(d: MutDeque[a, r]): String \ r with ToString[a] Source

Returns a string representation of the given MutDeque d.

def toVector(d: MutDeque[a, r]): Vector[a] \ r Source

Returns d as a vector.