Module Base__Stack
module type S = sig ... endinclude S
val t_of_sexp : (Base.Sexp.t -> 'a) -> Base.Sexp.t -> 'a tval sexp_of_t : ('a -> Base.Sexp.t) -> 'a t -> Base.Sexp.t
include Base.Invariant.S1 with type 'a t := 'a t
val invariant : ('a -> unit) -> 'a t -> unit
fold, iter, find, and find_map visit the elements in order from the top of the stack to the bottom. to_list and to_array return the elements in order from the top of the stack to the bottom.
Iteration functions (iter, fold, etc.) have unspecified behavior (although they should still be memory-safe) when the stack is mutated while they are running (e.g. by having the passed-in function call push or pop on the stack).
include Base.Container.S1 with type 'a t := 'a t
val mem : 'a t -> 'a -> equal:('a -> 'a -> bool) -> boolval length : 'a t -> intval is_empty : 'a t -> boolval iter : 'a t -> f:('a -> unit) -> unitval fold : 'a t -> init:'accum -> f:('accum -> 'a -> 'accum) -> 'accumval fold_result : 'a t -> init:'accum -> f:('accum -> 'a -> ('accum, 'e) Base.Result.t) -> ('accum, 'e) Base.Result.tval fold_until : 'a t -> init:'accum -> f:('accum -> 'a -> ('accum, 'final) Base__.Container_intf.Export.Continue_or_stop.t) -> finish:('accum -> 'final) -> 'finalval exists : 'a t -> f:('a -> bool) -> boolval for_all : 'a t -> f:('a -> bool) -> boolval count : 'a t -> f:('a -> bool) -> intval sum : (module Base__.Container_intf.Summable with type t = 'sum) -> 'a t -> f:('a -> 'sum) -> 'sumval find : 'a t -> f:('a -> bool) -> 'a optionval find_map : 'a t -> f:('a -> 'b option) -> 'b optionval to_list : 'a t -> 'a listval to_array : 'a t -> 'a arrayval min_elt : 'a t -> compare:('a -> 'a -> int) -> 'a optionval max_elt : 'a t -> compare:('a -> 'a -> int) -> 'a option
val of_list : 'a list -> 'a tof_list lreturns a stack whose top is the first element ofland bottom is the last element ofl.
val create : unit -> _ tcreate ()returns an empty stack.
val singleton : 'a -> 'a tsingleton acreates a new stack containing onlya.
val push : 'a t -> 'a -> unitpush t aaddsato the top of stackt.
val pop : 'a t -> 'a optionpop tremoves and returns the top element oftasSome a, or returnsNoneiftis empty.
val pop_exn : 'a t -> 'aval top : 'a t -> 'a optiontop treturnsSome a, whereais the top oft, unlessis_empty t, in which casetopreturnsNone.
val until_empty : 'a t -> ('a -> unit) -> unituntil_empty t frepeatedly pops an elementaoff oftand runsf a, untiltbecomes empty. It is fine iffadds more elements tot, in which case the most-recently-added element will be processed next.
val capacity : _ t -> intcapacity treturns the length of the array backingt.
val set_capacity : _ t -> int -> unitset_capacity t capacitysets the length of the array backingttomax capacity (length t). To shrink as much as possible, doset_capacity t 0.