Utils.Stack =============================================================================== This document is auto-generated for Owl's APIs. #11 entries have been extracted. timestamp: 2018-04-16 13:12:54 Github: `{Signature} `_ `{Implementation} `_ Type definition ------------------------------------------------------------------------------- .. code-block:: ocaml type 'a t = { mutable used : int; mutable size : int; mutable data : 'a array; } Type of a stack. Basic functions ------------------------------------------------------------------------------- .. code-block:: ocaml val make : unit -> 'a t ``make ()`` creates an empty stack. `source code `__ .. code-block:: ocaml val push : 'a t -> 'a -> unit ``push stack x`` pushes ``x`` into ``stack``. `source code `__ .. code-block:: ocaml val pop : 'a t -> 'a option ``pop stack`` pops the top element in ``stack``. It returns ``None`` if the ``stack`` is empty. `source code `__ .. code-block:: ocaml val peek : 'a t -> 'a option ``peek stack`` returns the value of top element in ``stack`` but it does not remove the element from the stack. ``None`` is returned if the stack is empty. `source code `__ .. code-block:: ocaml val is_empty : 'a t -> bool Returns ``true`` if the stack is empty, otherwise ``false``. `source code `__ .. code-block:: ocaml val mem : 'a t -> 'a -> bool ``mem stack x`` checks whether ``x`` exist in ``stack``. The complexity is ``O(n)`` where ``n`` is the size of the ``stack``. `source code `__ .. code-block:: ocaml val memq : 'a t -> 'a -> bool Similar to ``mem`` but physical equality is used for comparing values. `source code `__ .. code-block:: ocaml val to_array : 'a t -> 'a array ``to_array stack`` converts the elements in ``stack`` into an array. `source code `__