package ocaml-base-compiler
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=39f44260382f28d1054c5f9d8bf4753cb7ad64027da792f7938344544da155e8
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.