crow/col/mut-stack.crow (source)
mut-stack[t] record mut
(has non-public fields)
Mutable stack.
Elements are pushed and popped from the top of the stack.
Iteration functions move from the bottom to the top.
new[t] t mut-stack(...a t array)
copy[t] t mut-stack(a t mut-stack)
to[t] t mut-stack(a t array)
to[t] t array(a t mut-stack)
is-empty[t] bool(a t mut-stack)
True iff a.size == 0.
size[t] nat64(a t mut-stack)
Number of elements in the stack.
This is O(n).
~=[t] void(a t mut-stack, value t)
Pushes a value to the top of the stack.
~~=[t, col] void(a t mut-stack, values col) (col, t) iterate
iteratePushes many values to the top of the stack.
subscript[t] t(a t mut-stack, index nat64)
Nth element from the bottom.
peek[t] t?(a t mut-stack)
Returns the top element of the stack without removing it.
Returns an empty option iff a is empty.
pop[t] t?(a t mut-stack)
Removes and returns the top element of the stack.
Returns an empty option iff a is empty.