Module Caml.Queue
exceptionEmptyRaised when
Queue.takeorQueue.peekis applied to an empty queue.
val create : unit -> 'a tReturn a new queue, initially empty.
val add : 'a -> 'a t -> unitadd x qadds the elementxat the end of the queueq.
val push : 'a -> 'a t -> unitpushis a synonym foradd.
val take : 'a t -> 'atake qremoves and returns the first element in queueq, or raisesEmptyif the queue is empty.
val take_opt : 'a t -> 'a optiontake_opt qremoves and returns the first element in queueq, or returnsNoneif the queue is empty.- since
 - 4.08
 
val pop : 'a t -> 'apopis a synonym fortake.
val peek : 'a t -> 'apeek qreturns the first element in queueq, without removing it from the queue, or raisesEmptyif the queue is empty.
val peek_opt : 'a t -> 'a optionpeek_opt qreturns the first element in queueq, without removing it from the queue, or returnsNoneif the queue is empty.- since
 - 4.08
 
val top : 'a t -> 'atopis a synonym forpeek.
val clear : 'a t -> unitDiscard all elements from a queue.
val is_empty : 'a t -> boolReturn
trueif the given queue is empty,falseotherwise.
val length : 'a t -> intReturn the number of elements in a queue.
val iter : ('a -> unit) -> 'a t -> unititer f qappliesfin turn to all elements ofq, from the least recently entered to the most recently entered. The queue itself is unchanged.
val fold : ('b -> 'a -> 'b) -> 'b -> 'a t -> 'bfold f accu qis equivalent toList.fold_left f accu l, wherelis the list ofq's elements. The queue remains unchanged.
val transfer : 'a t -> 'a t -> unittransfer q1 q2adds all ofq1's elements at the end of the queueq2, then clearsq1. It is equivalent to the sequenceiter (fun x -> add x q2) q1; clear q1, but runs in constant time.
Iterators
val to_seq : 'a t -> 'a Seq.tIterate on the queue, in front-to-back order. The behavior is not defined if the queue is modified during the iteration.
- since
 - 4.07