MutableStack
First in last out stack. This module implements stacks, with in-place modification.
t
REStype t<'a>
make
RESlet make: unit => t<'a>
Returns a new stack, initially empty.
clear
RESlet clear: t<'a> => unit
Discard all elements from the stack.
copy
RESlet copy: t<'a> => t<'a>
copy(x)
O(1) operation, return a new stack.
push
RESlet push: (t<'a>, 'a) => unit
popUndefined
RESlet popUndefined: t<'a> => Js.undefined<'a>
pop
RESlet pop: t<'a> => option<'a>
topUndefined
RESlet topUndefined: t<'a> => Js.undefined<'a>
top
RESlet top: t<'a> => option<'a>
isEmpty
RESlet isEmpty: t<'a> => bool
size
RESlet size: t<'a> => int
forEachU
RESlet forEachU: (t<'a>, (. 'a) => unit) => unit
forEach
RESlet forEach: (t<'a>, 'a => unit) => unit
dynamicPopIterU
RESlet dynamicPopIterU: (t<'a>, (. 'a) => unit) => unit
dynamicPopIter
RESlet dynamicPopIter: (t<'a>, 'a => unit) => unit
dynamicPopIter(s, f)
apply f
to each element of s
. The item is poped before applying f
, s
will be empty after this opeartion. This function is useful for worklist algorithm.