Module Lwt_sequence
Mutable sequence of elements (deprecated)
Operation on nodes
val get : 'a node -> 'a
Returns the contents of a node
val set : 'a node -> 'a -> unit
Change the contents of a node
val remove : 'a node -> unit
Removes a node from the sequence it is part of. It does nothing if the node has already been removed.
Operations on sequence
val create : unit -> 'a t
create ()
creates a new empty sequence
val is_empty : 'a t -> bool
Returns
true
iff the given sequence is empty
val length : 'a t -> int
Returns 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 -> 'a
take_l x s
remove and returns the leftmost element ofs
- raises Empty
if the sequence is empty
val take_r : 'a t -> 'a
take_l x s
remove and returns the rightmost element ofs
- raises Empty
if the sequence is empty
val take_opt_l : 'a t -> 'a option
take_opt_l x s
remove and returnsSome x
wherex
is the leftmost element ofs
orNone
ifs
is empty
val take_opt_r : 'a t -> 'a option
take_opt_l x s
remove and returnsSome x
wherex
is the rightmost element ofs
orNone
ifs
is empty
Sequence iterators
val iter_l : ('a -> unit) -> 'a t -> unit
iter_l f s
appliesf
on all elements ofs
starting from the left
val iter_r : ('a -> unit) -> 'a t -> unit
iter_l f s
appliesf
on all elements ofs
starting from the right
val iter_node_l : ('a node -> unit) -> 'a t -> unit
iter_l f s
appliesf
on all nodes ofs
starting from the left
val iter_node_r : ('a node -> unit) -> 'a t -> unit
iter_l f s
appliesf
on all nodes ofs
starting from the right
val fold_l : ('a -> 'b -> 'b) -> 'a t -> 'b -> 'b
fold_l f s
is:fold_l f s x = f en (... (f e2 (f e1 x)))
where
e1
,e2
, ...,en
are the elements ofs
val fold_r : ('a -> 'b -> 'b) -> 'a t -> 'b -> 'b
fold_r f s
is:fold_r f s x = f e1 (f e2 (... (f en x)))
where
e1
,e2
, ...,en
are the elements ofs
val find_node_opt_l : ('a -> bool) -> 'a t -> 'a node option
find_node_opt_l f s
returnsSome x
, wherex
is the first node ofs
starting from the left that satisfiesf
orNone
if none exists.
val find_node_opt_r : ('a -> bool) -> 'a t -> 'a node option
find_node_opt_r f s
returnsSome x
, wherex
is the first node ofs
starting from the right that satisfiesf
orNone
if none exists.