package ke

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

The type of queues containing elements of type 'a.

exception Empty

Raised when push_exn or N.push_exn is applied to an empty queue.

exception Full

Raised when peek_exn, pop_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) Bigarray.kind -> ('a, 'b) t * int

Return a new queue, initially empty with the real capacity of it.

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

Number of elements in the queue.

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

Free cells availables on the queue.

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

push_exn q x adds the elements x at the end of the queue q and returns the new queue q'. It raises Full if the given queue q is full.

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

push q x is the same as push_exn but returns None if it fails.

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

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

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

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

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

peek q returns the first element in the given queue q. If q is empty, it returns None. The given queue q is unchanged.

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

peek_exn q returns the first element in the given queue q. If q is empty, it raises Empty.

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

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

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

cons q x adds element x at the front of the given queue q. It raises Empty if the given queue q is full or the new queue q'.

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

Return a copy of the given queue.

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

Discard all elements from a queue.

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.

/ *

val unsafe_bigarray : ('a, 'b) t -> ('a, 'b, Bigarray.c_layout) Bigarray.Array1.t
val from : ('a, 'b, Bigarray.c_layout) Bigarray.Array1.t -> ('a, 'b) t
OCaml

Innovation. Community. Security.