package lwt
Install
Dune Dependency
Authors
Maintainers
Sources
md5=18742da8b8fe3618e3fa700b7a884fe7
sha512=1c51fdb4d0856c89e2df08a1c0095ef28ebd0f613b07b03d0f66501ca5486515562071291e6d0932e57587ed0c9362c8b92c5c9eddb4d2bb2f5e129986b484a7
doc/lwt/Lwt_sequence/index.html
Module Lwt_sequence
Source
Mutable sequence of elements (deprecated)
A sequence is an object holding a list of elements which support the following operations:
- adding an element to the left or the right in time and space O(1)
- taking an element from the left or the right in time and space O(1)
- removing a previously added element from a sequence in time and space O(1)
- removing an element while the sequence is being transversed.
Type of a sequence holding values of type 'a
Type of a node holding one value of type 'a
in a sequence
Operation on nodes
Removes a node from the sequence it is part of. It does nothing if the node has already been removed.
Operations on sequence
Removes all nodes from the given sequence. The nodes are not actually mutated to note their removal. Only the sequence's pointers are updated.
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.
Exception raised by take_l
and take_r
and when the sequence is empty
take_opt_l x s
remove and returns Some x
where x
is the leftmost element of s
or None
if s
is empty
take_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.
Sequence iterators
Note: it is OK to remove a node while traversing a sequence
iter_l f s
applies f
on all elements of s
starting from the left
iter_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
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
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
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.