package ke

  1. Overview
  2. Docs
type 'a t

The type of queues containing elements of type 'a.

exception Empty

Raised when peek_exn or pop_exn is applied to an empty queue.

val empty : 'a t

An empty queue.

val is_empty : 'a t -> bool

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

val length : 'a t -> int

Number of elements in the queue.

val push : 'a t -> 'a -> 'a t

Push element at the end of the queue.

val cons : 'a t -> 'a -> 'a t

Push element at the front of the queue.

val peek : 'a t -> 'a option

peek q returns the first element in the queue q, without removing it from the queue. If q is empty, it returns None.

val peek_exn : 'a t -> 'a

Same as peek but it raises an exception if q is empty.

val pop : 'a t -> ('a * 'a t) option

Get and remove the first element. If q is empty, it returns None.

val pop_exn : 'a t -> 'a * 'a t

Same as pop but it raises an exception if q is empty.

val tail : 'a t -> ('a t * 'a) option

Get and remove the last element. If q is empty, it returns None.

val tail_exn : 'a t -> 'a t * 'a

Same as tail but it raises an exception if q is empty.

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

val rev_iter : ('a -> unit) -> 'a t -> unit

rev_iter f q applies f in turn to all elements of q, from the most recently entered to the least recently entered. The queue itself is unchanged.

val fold : ('acc -> 'x -> 'acc) -> 'acc -> 'x t -> 'acc

fold f a q is equivalent to List.fold_left f a l, where l is the list of q's elements. The queue remains unchanged.

val pp : ?sep:unit Fmt.t -> 'a Fmt.t -> 'a t Fmt.t

Pretty-printer of t.

val dump : 'a Fmt.t -> 'a t Fmt.t

Human-readable pretty-printer of t.

OCaml

Innovation. Community. Security.