package miou

  1. Overview
  2. Docs
Composable concurrency primitives for OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

miou-0.10.0.tbz
sha256=bf1954c6f66ac9d306b3b4f948b19f59d2c327213af930e19d9fbc73f134fa18
sha512=cea8136bf9fef32898c962b4136fd784a20fc8a6626cd19bb7d0a37e798aa7a7f06ea9f19b47f6e03bb1afd477cf46e57d4c6a376601eb282c4fb07d490ca727

doc/miou/Miou_queue/index.html

Module Miou_queueSource

Sourcetype 'a t

The type of queues containing elements of type 'a.

Sourceexception Empty

Raised when dequeue is applied to an empty queue.

Sourceval create : unit -> 'a t

Return a new queue, initially empty.

Sourceval enqueue : 'a t -> 'a -> unit

enqueue q x adds the element x at the end of the queue q.

Sourceval dequeue : 'a t -> 'a

dequeue q removes and returns the first element in queue q, or raises Empty if the queue is empty.

Sourceval peek : 'a t -> 'a

peek q returns the first element in queue q, or raises Empty if the queue is empty. The queue itself is unchanged.

Sourceval is_empty : 'a t -> bool

Return true if the given queue is empty, false otherwise.

Sourceval iter : f:('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.

Sourceval drop : f:('a -> unit) -> 'a t -> unit

drop ~f q applies f in turn to all elements of q and discard all elements of q.

Sourceval length : 'a t -> int

Return the number of elements in a queue.

Sourceval to_list : 'a t -> 'a list

to_list q returns a list of q's elements.

Sourceval transfer : 'a t -> 'a t

transfer q returns new queue in which we have added all of q's elements, then clears q. It's an atomically safe equivalent to the sequence let q' = make () in drop ~f:(fun x -> enqueue q' x) q; q'.