First-in first-out queues.
This module implements queues (FIFOs), with in-place modification.
Warning This module is not thread-safe: each Queue.t value
must be protected from concurrent access (e.g. with a Mutex.t
).
Failure to do so can lead to a crash.
val take : 'a t -> 'a
take q
removes and returns the first element in queue q
,
or raises Empty if the queue is empty.
val peek : 'a t -> 'a
peek q
returns the first element in queue q
, without removing
it from the queue, or raises Empty if the queue is empty.
val iter : ('a -> unit) -> 'a t -> unit
iter f q
applies f
in turn to all elements of q
,
from the least recently entered to the most recently entered.
The queue itself is unchanged.
val fold : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b
fold f accu q
is equivalent to List.fold_left f accu l
,
where l
is the list of q
's elements. The queue remains
unchanged.