module A: Direction_T
Operations on the left end of a deque.
val push : 'a -> 'a Cf_deque.t -> 'a Cf_deque.t
push x d
adds the element x
to the end of the deque d
. The
average cost is constant. Worst-case running time is O(log N), which
happens once in every N operations. Not tail-recursive.
val pop : 'a Cf_deque.t -> ('a * 'a Cf_deque.t) option
pop d
returns None
if d
is the empty deque, otherwise it returns
Some (x, d')
where x
is the element on the end of the deque, and
d'
is the remainder of d
with the element x
removed. The average
cost is constant. Worst-case running time is O(log N), which happens
once in every N operations. Not tail-recursive.
val head : 'a Cf_deque.t -> 'a
head d
returns the element at the end of the deque d
. Raises
Not_found
if the deque is empty. Not tail-recursive.
val tail : 'a Cf_deque.t -> 'a Cf_deque.t
tail d
is discards the element at the end of the deque d
. Raises
Not_found
if the deque is empty. Not tail-recursive.
val fold : ('b -> 'a -> 'b) -> 'b -> 'a Cf_deque.t -> 'b
fold f a0 d
is f (... (f (f a0 e0) e1) ...) en
when e0..en
are
the elements of the deque d
. Not tail recursive.
val of_list : 'a list -> 'a Cf_deque.t
Use of_list s
to construct a deque from a list of elements. Th
resulting elements begin at the head of the deque.
val of_seq : 'a Cf_seq.t -> 'a Cf_deque.t
Use of_seq z
to construct a deque from a sequence of elements.
Evaluates the whole sequence and the resulting elements begin at the
head of the deque..
val to_list : 'a Cf_deque.t -> 'a list
to_list d
returns the elements in the deque in the order they would
appear by successive calls of pop d
.
val to_seq : 'a Cf_deque.t -> 'a Cf_seq.t
to_seq d
returns a lazily evaluated sequence of the elements in the
deque in the order they would appear by successive calls of pop d
.
val to_seq2 : 'a Cf_deque.t -> ('a * 'a Cf_deque.t) Cf_seq.t
to_seq2 d
returns a lazily evaluated sequence of the pairs (hd, tl)
obtained by successively calling of pop d
.