Module Stack.Xt

Explicit transaction log passing on stacks.

val is_empty : xt:'x Kcas.Xt.t -> 'a t -> bool

is_empty s determines whether the stack s is empty.

val length : xt:'x Kcas.Xt.t -> 'a t -> int

length s returns the length of the stack s.

val clear : xt:'x Kcas.Xt.t -> 'a t -> unit

clear s removes all elements from the stack s.

val swap : xt:'x Kcas.Xt.t -> 'a t -> 'a t -> unit

swap s1 s2 exchanges the contents of the stacks s1 and s2.

val to_seq : xt:'x Kcas.Xt.t -> 'a t -> 'a Stdlib.Seq.t

to_seq s returns a domain 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.

val push : xt:'x Kcas.Xt.t -> 'a -> 'a t -> unit

push x s adds the element x to the top of the stack s.

val pop_opt : xt:'x Kcas.Xt.t -> 'a t -> 'a option

pop_opt s removes and returns the topmost element of the stack s, or None if the stack is empty.

val top_opt : xt:'x Kcas.Xt.t -> 'a t -> 'a option

top_opt s returns the topmost element in stack s, or None if the stack is empty.