Deque

lib/Deque.gob

A double-ended queue: elements are pushed and popped at either end in constant time, amortized over the growth of its storage, and read at any index in constant time. Index 0 is the front.

let queue = Deque.new(16)
Deque.pushBack(queue, start)
while let Some(here) = Deque.popFront(queue) { ... }
type Deque a
fun new : fun(Int) -> Deque a

An empty Deque with room for capacity elements before it must grow.

fun fromArray : fun(Array a) -> Deque a

Copies: a Deque and an Array never share their elements.

fun toArray : fun(Deque a) -> Array a

The elements from front to back, copied.

fun pushBack : fun(Deque a, a) -> Unit
fun pushFront : fun(Deque a, a) -> Unit
fun popFront : fun(Deque a) -> Option a
fun popBack : fun(Deque a) -> Option a
fun at : fun(Deque a, Int) -> Option a

The element i from the front, or None past either end. xs[i] is the one that panics.

fun front : fun(Deque a) -> Option a
fun back : fun(Deque a) -> Option a
fun isEmpty : fun(Deque a) -> Bool
fun clear : fun(Deque a) -> Unit

Drop every element, keeping the capacity.

fun append : fun(Deque a, Deque a) -> Deque a

A new Deque: the elements of xs, then those of ys.

instance Index (Deque a)
instance SetIndex (Deque a)
instance Length (Deque a)
instance Iterator (Deque a)

Front to back.

instance Add (Deque a)
instance Semigroup (Deque a)
instance Monoid (Deque a)
instance Foldable Deque
instance Functor Deque
instance Eq (Deque a) : Eq a

Equal when they have the same length and equal elements from the front, whatever their capacity and wherever in their storage the front is.

instance Debug (Deque a) : Debug a

The call that builds it, Deque.fromArray([x, ...]), front to back.

instance Show (Deque a) : Debug a

What its Debug prints: a container's text shows its elements' Debug, so that a string in it is quoted.