package ke

  1. Overview
  2. Docs
type ('a, 'b) t

The type of queues containing elements of type 'a.

exception Empty

Raised when peek_exn, pop_exn, N.keep_exn or N.shift_exn is applied to an empty queue.

val is_empty : ('a, 'b) t -> bool

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

val create : ?capacity:int -> ('a, 'b) Stdlib.Bigarray.kind -> ('a, 'b) t

Return a new queue, initially empty.

val capacity : ('a, 'b) t -> int

Returns how many objects t can store.

val length : ('a, 'b) t -> int

Number of elements in the queue.

val push : ('a, 'b) t -> 'a -> unit

push q x adds the elements x at the end of the queue q.

val pop : ('a, 'b) t -> 'a option

pop q removes and returns the first element in queue q. If q is empty, it returns None.

val pop_exn : ('a, 'b) t -> 'a

pop_exn is the same as pop but it raises Empty when the given queue q is empty.

val peek : ('a, 'b) 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, 'b) t -> 'a

Same as peek but it raises Empty if q is empty.

val cons : ('a, 'b) t -> 'a -> unit

cons q x adds element x at the front of the given queue q. It returns None if it fails.

val copy : ('a, 'b) t -> ('a, 'b) t

Return a copy of the given queue.

val clear : ('a, 'b) t -> unit

Discard all elements from a queue.

val compress : ('a, 'b) t -> unit

Compress queue, read cursor will be setted to 0 and data will be move to. This operation allows to provide much more space for a push/N.push operation - but it can not ensure enough free space.

module N : sig ... end
val iter : ('a -> unit) -> ('a, 'b) 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, 'b) t -> unit

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, 'b) 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, 'b) t Fmt.t

Pretty-printer of t.

val dump : 'a Fmt.t -> ('a, 'b) t Fmt.t

Human-readable pretty-printer of t.

OCaml

Innovation. Community. Security.