module Lwt_sequence:Mutable sequence of elementssig
..end
type 'a
t
'a
type 'a
node
'a
in a sequenceval get : 'a node -> 'a
val set : 'a node -> 'a -> unit
val remove : 'a node -> unit
val create : unit -> 'a t
create ()
creates a new empty sequenceval is_empty : 'a t -> bool
true
iff the given sequence is emptyval length : 'a t -> int
n
is the number of elements in the
sequence.val add_l : 'a -> 'a t -> 'a node
add_l x s
adds x
to the left of the sequence s
val add_r : 'a -> 'a t -> 'a node
add_l x s
adds x
to the right of the sequence s
exception Empty
take_l
and tale_s
and when the sequence
is emptyval take_l : 'a t -> 'a
take_l x s
remove and returns the leftmost element of s
Empty
if the sequence is emptyval take_r : 'a t -> 'a
take_l x s
remove and returns the rightmost element of s
Empty
if the sequence is emptyval take_opt_l : 'a t -> 'a option
take_opt_l x s
remove and returns Some x
where x
is the
leftmost element of s
or None
if s
is emptyval take_opt_r : 'a t -> 'a option
take_opt_l x s
remove and returns Some x
where x
is the
rightmost element of s
or None
if s
is emptyval transfer_l : 'a t -> 'a t -> unit
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.val transfer_r : 'a t -> 'a t -> unit
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.val iter_l : ('a -> unit) -> 'a t -> unit
iter_l f s
applies f
on all elements of s
starting from
the leftval iter_r : ('a -> unit) -> 'a t -> unit
iter_l f s
applies f
on all elements of s
starting from
the rightval iter_node_l : ('a node -> unit) -> 'a t -> unit
iter_l f s
applies f
on all nodes of s
starting from
the leftval iter_node_r : ('a node -> unit) -> 'a t -> unit
iter_l f s
applies f
on all nodes of s
starting from
the rightval 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 of s
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 of s