Module Belt.MutableStack

Belt.MutableStack

An FILO(first in last out) stack data structure

First in last out stack.

This module implements stacks, with in-place modification.

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

    a new stack, initially empty.

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

Discard all elements from the stack.

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

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

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