API / Belt / Belt_MutableStack

Belt_MutableStack

First in last out stack. This module implements stacks, with in-place modification.

t

type t<'a>

make

Returns a new stack, initially empty.

let make: unit => t<'a>

clear

Discard all elements from the stack.

let clear: t<'a> => unit

copy

copy(x) O(1) operation, return a new stack.

let copy: t<'a> => t<'a>

push

let push: (t<'a>, 'a) => unit

popUndefined

let popUndefined: t<'a> => Js.undefined<'a>

pop

let pop: t<'a> => option<'a>

topUndefined

let topUndefined: t<'a> => Js.undefined<'a>

top

let top: t<'a> => option<'a>

isEmpty

let isEmpty: t<'a> => bool

size

let size: t<'a> => int

forEachU

let forEachU: (t<'a>, (. 'a) => unit) => unit

forEach

let forEach: (t<'a>, 'a => unit) => unit

dynamicPopIterU

let dynamicPopIterU: (t<'a>, (. 'a) => unit) => unit

dynamicPopIter

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.

let dynamicPopIter: (t<'a>, 'a => unit) => unit