Module Kcas_data.Stack Source Last-In First-Out (LIFO) stack.
The interface provides a subset of the OCaml Stdlib.Stack module. add_seq is not provided at all. Compositional versions of iter , fold , pop , and top are not provided.
The implementation is essentially a Treiber stack with randomized exponential backoff and support for constant time length .
Common interfaceThe type of stacks containing elements of type 'a.
Raised when pop or top is applied to an empty stack.
create () returns a new empty stack.
copy s returns a copy of the stack s.
of_seq xs creates a stack from the sequence xs.
Compositional interfaceExplicit transaction log passing on stacks.
Non-compositional interfaceis_empty s determines whether the stack s is empty.
length s returns the length of the stack s.
clear s removes all elements from the stack s.
swap s1 s2 exchanges the contents of the stacks s1 and s2.
to_seq s returns a concurrency and parallelism safe sequence for iterating through the elements of the stack top to bottom.
The sequence is based on a constant time, O(1), snapshot of the stack and modifications of the stack have no effect on the sequence.
Source val push : 'a -> 'a t -> unitpush x s adds the element x to the top of the stack s.
Source val pop_opt : 'a t -> 'a optionpop_opt s removes and returns the topmost element of the stack s, or None if the stack is empty.
pop_all s removes and returns a concurrency and parallelism safe sequence for iterating through all the elements that were in the stack top to bottom.
Source val pop_blocking : ?timeoutf :float -> 'a t -> 'a pop_blocking s removes and returns the topmost element of the stack s, or blocks waiting for the queue to become non-empty.
Source val top_opt : 'a t -> 'a optiontop_opt s returns the topmost element in stack s, or None if the stack is empty.
Source val top_blocking : ?timeoutf :float -> 'a t -> 'a top_blocking s returns the topmost element in stack s, or blocks waiting for the queue to become non-empty.
pop s removes and returns the topmost element in stack s, or raises Empty if the stack is empty.
top s returns the topmost element in stack s, or raises Empty if the stack is empty.
Source val iter : ('a -> unit) -> 'a t -> unititer f s is equivalent to Seq.iter f (to_seq s).
Source val fold : ('b -> 'a -> 'b ) -> 'b -> 'a t -> 'b fold f s is equivalent to Seq.fold_left f a (to_seq s).