logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Stdlib.Stack - no description

Documentation

       Module Stack
        : (moduleStdlib__Stack)

       Unsynchronized accesses

       Unsynchronized  accesses  to  a  stack  may lead to an invalid queue state.  Thus, concurrent accesses to
       stacks must be synchronized (for instance with a Mutex.t ).

       type!'at

       The type of stacks containing elements of type 'a .

       exceptionEmpty

       Raised when Stack.pop or Stack.top is applied to an empty stack.

       valcreate : unit->'at

       Return a new stack, initially empty.

       valpush : 'a->'at->unitpushxs adds the element x at the top of stack s .

       valpop : 'at->'apops removes and returns the topmost element in stack s , or raises Stack.Empty if the stack is empty.

       valpop_opt : 'at->'aoptionpop_opts removes and returns the topmost element in stack s , or returns None if the stack is empty.

       Since 4.08

       valdrop : 'at->unitdrops removes the topmost element in stack s , or raises Stack.Empty if the stack is empty.

       Since 5.1

       valtop : 'at->'atops returns the topmost element in stack s , or raises Stack.Empty if the stack is empty.

       valtop_opt : 'at->'aoptiontop_opts returns the topmost element in stack s , or None if the stack is empty.

       Since 4.08

       valclear : 'at->unit

       Discard all elements from a stack.

       valcopy : 'at->'at

       Return a copy of the given stack.

       valis_empty : 'at->bool

       Return true if the given stack is empty, false otherwise.

       vallength : 'at->int

       Return the number of elements in a stack. Time complexity O(1)

       valiter : ('a->unit)->'at->unititerfs applies f in turn to all elements of s , from the element at the top of the stack to the element
       at the bottom of the stack. The stack itself is unchanged.

       valfold : ('acc->'a->'acc)->'acc->'at->'accfoldfaccus is (f(...(f(faccux1)x2)...)xn) where x1 is the top of  the  stack,  x2  the  second
       element, and xn the bottom element. The stack is unchanged.

       Since 4.03

   StacksandSequencesvalto_seq : 'at->'aSeq.t

       Iterate on the stack, top to bottom.  It is safe to modify the stack during iteration.

       Since 4.07

       valadd_seq : 'at->'aSeq.t->unit

       Add the elements from the sequence on the top of the stack.

       Since 4.07

       valof_seq : 'aSeq.t->'at

       Create a stack from the sequence.

       Since 4.07

OCamldoc                                           2025-06-12                                   Stdlib.Stack(3o)

Module

       Module   Stdlib.Stack

Name

       Stdlib.Stack - no description

See Also