module Stack:sig..end
Differences from the standard module:
pop and top return an option rather than raise Empty.
iter takes a labeled argument.
push takes the stack argument first.
length is O(1)
exception Empty
type 'a t
include Container.S1
to_list and to_array returns the elements in order from the top of
the stack to the bottom.val of_list : 'a list -> 'a tof_list l returns a stack whose top is the first element of l and
* bottom is the last element of l.val invariant : 'a t -> unitval create : unit -> 'a tcreate () returns an empty stack.val push : 'a t -> 'a -> unitpush t x adds x to the top of stack t.val pop : 'a t -> 'a optionpop t returns None if t is empty, otherwise it returns Some x where
x is the top of t and removes x from the top of t.val pop_exn : 'a t -> 'apop_exn t removes and returns the top element of t, raising Empty if
t is empty.val top : 'a t -> 'a optiontop t returns None if t is empty, otherwise it returns Some x where
x is the top of t.val top_exn : 'a t -> 'atop_exn t returns the top element of t, raising Empty if t is empty.val clear : 'a t -> unitclear t discards all elements from t.val copy : 'a t -> 'a tcopy t returns a copy of t.val until_empty : 'a t -> ('a -> unit) -> unituntil_empty t f repeatedly pops an element v off of t and runs f v
until t becomes empty. It is fine if f adds more elements to t, in
which case the most-recently-added element will be processed first.val t_of_sexp : (Sexplib.Sexp.t -> 'a) -> Sexplib.Sexp.t -> 'a tval sexp_of_t : ('a -> Sexplib.Sexp.t) -> 'a t -> Sexplib.Sexp.tval bin_t : 'a Bin_prot.Type_class.t -> 'a t Bin_prot.Type_class.tval bin_read_t : 'a Bin_prot.Unsafe_read_c.reader -> 'a t Bin_prot.Read_ml.readerval bin_read_t_ : 'a Bin_prot.Unsafe_read_c.reader ->
'a t Bin_prot.Unsafe_read_c.readerval bin_read_t__ : 'a Bin_prot.Unsafe_read_c.reader ->
(int -> 'a t) Bin_prot.Unsafe_read_c.readerval bin_reader_t : 'a Bin_prot.Type_class.reader -> 'a t Bin_prot.Type_class.readerval bin_size_t : 'a Bin_prot.Size.sizer -> 'a t Bin_prot.Size.sizerval bin_write_t : 'a Bin_prot.Unsafe_write_c.writer -> 'a t Bin_prot.Write_ml.writerval bin_write_t_ : 'a Bin_prot.Unsafe_write_c.writer ->
'a t Bin_prot.Unsafe_write_c.writerval bin_writer_t : 'a Bin_prot.Type_class.writer -> 'a t Bin_prot.Type_class.writerto_list and to_array returns the elements in order from the top of
the stack to the bottom.of_list l returns a stack whose top is the first element of l and
* bottom is the last element of l.create () returns an empty stack.push t x adds x to the top of stack t.pop t returns None if t is empty, otherwise it returns Some x where
x is the top of t and removes x from the top of t.pop_exn t removes and returns the top element of t, raising Empty if
t is empty.top t returns None if t is empty, otherwise it returns Some x where
x is the top of t.top_exn t returns the top element of t, raising Empty if t is empty.clear t discards all elements from t.copy t returns a copy of t.until_empty t f repeatedly pops an element v off of t and runs f v
until t becomes empty. It is fine if f adds more elements to t, in
which case the most-recently-added element will be processed first.