Commit c83d9513 authored by POTTIER Francois's avatar POTTIER Francois
Browse files

Cleanup in CompactQueue.mli.

parent ceca8d12
(** This module implements a mutable FIFO queue, like [Queue]. However it has a
more compact representation, storing elements contiguously in an array.
(**This module implements a mutable FIFO queue, like OCaml's [Queue] module.
In comparison with [Queue], it uses a more compact internal representation:
elements are stored contiguously in an array. This has a positive impact on
performance: both time and memory consumption are reduced.
This has a nice impact on performance (both time and memory consumption)
when adding and removing many elements.
A drawback of this implementation is that some values will be kept alive
longer than necessary, as they might still be reachable from the internal
array.
*)
The implementation is optimized for maximum throughput. The internal array
is never shrunk, so a queue that has contained many elements in the past
remains large. Furthermore, array slots are not overwritten when elements
are extracted; thus, an element that has appeared in the queue in the past
can remain reachable. These drawbacks are usually acceptable provided that
the queue is thrown away after use. *)
type 'a t
(** The type of a queue. *)
(**The type of a queue. *)
val create : unit -> 'a t
(** [create ()] creates an empty queue. *)
(**[create()] creates an empty queue. *)
val is_empty : 'a t -> bool
(** [is_empty q] tests whether the queue [q] is empty. *)
(**[is_empty q] tests whether the queue [q] is empty. *)
val add : 'a -> 'a t -> unit
(** [add x q] adds the element [x] at the end of the queue [q]. *)
(**[add x q] adds the element [x] at the end of the queue [q]. *)
exception Empty
(** Raised when {!take} is applied to an empty queue. *)
(**[Empty] is raised when {!take} is applied to an empty queue. *)
val take : 'a t -> 'a
(** [take q] removes and returns the first element in queue [q],
or raises {!Empty} if the queue is empty. *)
(**[take q] removes and returns the first element of the queue [q].
It raises {!Empty} if the queue is empty. *)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment