package owl-base

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Owl_utils_stackSource

Type definition
Sourcetype 'a t

Type of a stack.

Basic functions
Sourceval make : unit -> 'a t

``make ()`` creates an empty stack.

Sourceval push : 'a t -> 'a -> unit

``push stack x`` pushes ``x`` into ``stack``.

Sourceval pop : 'a t -> 'a option

``pop stack`` pops the top element in ``stack``. It returns ``None`` if the ``stack`` is empty.

Sourceval 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.

Sourceval is_empty : 'a t -> bool

Returns ``true`` if the stack is empty, otherwise ``false``.

Sourceval 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``.

Sourceval memq : 'a t -> 'a -> bool

Similar to ``mem`` but physical equality is used for comparing values.

Sourceval to_array : 'a t -> 'a array

``to_array stack`` converts the elements in ``stack`` into an array.

OCaml

Innovation. Community. Security.