API / JavaScript / Belt / MutableStack

MutableStack

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

RE
type t('a);
RE
let make: unit => t('a);

Returns a new stack, initially empty.

RE
let clear: t('a) => unit;

Discard all elements from the stack.

RE
let copy: t('a) => t('a);

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

RE
let push: (t('a), 'a) => unit;
RE
let popUndefined: t('a) => Js.undefined('a);
RE
let pop: t('a) => option('a);
RE
let topUndefined: t('a) => Js.undefined('a);
RE
let top: t('a) => option('a);
RE
let isEmpty: t('a) => bool;
RE
let size: t('a) => int;
RE
let forEachU: (t('a), [@bs] ('a => unit)) => unit;
RE
let forEach: (t('a), 'a => unit) => unit;
RE
let dynamicPopIterU: (t('a), [@bs] ('a => unit)) => unit;
RE
let 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.