Lwt_sequenceMutable sequence of elements (deprecated)
A sequence is an object holding a list of elements which support the following operations:
val get : 'a node -> 'aReturns the contents of a node
val set : 'a node -> 'a -> unitChange the contents of a node
val remove : 'a node -> unitRemoves a node from the sequence it is part of. It does nothing if the node has already been removed.
val create : unit -> 'a tcreate () creates a new empty sequence
val clear : 'a t -> unitRemoves all nodes from the given sequence. The nodes are not actually mutated to note their removal. Only the sequence's pointers are updated.
val is_empty : 'a t -> boolReturns true iff the given sequence is empty
val length : 'a t -> intReturns the number of elements in the given sequence. This is a O(n) operation where n is the number of elements in the sequence.
val take_l : 'a t -> 'atake_l x s remove and returns the leftmost element of s
val take_r : 'a t -> 'atake_r x s remove and returns the rightmost element of s
val take_opt_l : 'a t -> 'a optiontake_opt_l x s remove and returns Some x where x is the leftmost element of s or None if s is empty
val take_opt_r : 'a t -> 'a optiontake_opt_r x s remove and returns Some x where x is the rightmost element of s or None if s is empty
transfer_l s1 s2 removes all elements of s1 and add them at the left of s2. This operation runs in constant time and space.
transfer_r s1 s2 removes all elements of s1 and add them at the right of s2. This operation runs in constant time and space.
Note: it is OK to remove a node while traversing a sequence
val iter_l : ('a -> unit) -> 'a t -> unititer_l f s applies f on all elements of s starting from the left
val iter_r : ('a -> unit) -> 'a t -> unititer_r f s applies f on all elements of s starting from the right
iter_node_l f s applies f on all nodes of s starting from the left
iter_node_r f s applies f on all nodes of s starting from the right
val fold_l : ('a -> 'b -> 'b) -> 'a t -> 'b -> 'bfold_l f s is:
fold_l f s x = f en (... (f e2 (f e1 x)))where e1, e2, ..., en are the elements of s
val fold_r : ('a -> 'b -> 'b) -> 'a t -> 'b -> 'bfold_r f s is:
fold_r f s x = f e1 (f e2 (... (f en x)))where e1, e2, ..., en are the elements of s
find_node_opt_l f s returns Some x, where x is the first node of s starting from the left that satisfies f or None if none exists.
find_node_opt_r f s returns Some x, where x is the first node of s starting from the right that satisfies f or None if none exists.
find_node_l f s returns the first node of s starting from the left that satisfies f or raises Not_found if none exists.