package ocaml-base-compiler
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=c2d706432f93ba85bd3383fa451d74543c32a4e84a1afaf3e8ace18f7f097b43
doc/stdlib/Stdlib/Queue/index.html
Module Stdlib.QueueSource
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.
The type of queues containing elements of type 'a.
Raised when Queue.take or Queue.peek is applied to an empty queue.
take q removes and returns the first element in queue q, or raises Empty if the queue is empty.
take_opt q removes and returns the first element in queue q, or returns None if the queue is empty.
peek q returns the first element in queue q, without removing it from the queue, or raises Empty if the queue is empty.
peek_opt q returns the first element in queue q, without removing it from the queue, or returns None if the queue is empty.
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.
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.
transfer q1 q2 adds all of q1's elements at the end of the queue q2, then clears q1. It is equivalent to the sequence iter (fun x -> add x q2) q1; clear q1, but runs in constant time.
Iterators
Iterate on the queue, in front-to-back order. The behavior is not specified if the queue is modified during the iteration.
Add the elements from a sequence to the end of the queue.