package octez-libs

  1. Overview
  2. Docs

Parameters

module V : sig ... end

Signature

type t

The type of hash queues holding bindings from K.t to V.t

val create : int -> t

create n creates an empty hash queue of capacity n. New elements added to a full hash queue push the oldest ones out.

val remove : t -> K.t -> unit

remove q k removes the binding from k in q. If k is not bound in c, it does nothing.

val replace : t -> K.t -> V.t -> unit

replace q k v binds the key k to the value v in the queue q. This may or may not cause another binding to be removed, depending on the number of bindings already present in q.

val find_opt : t -> K.t -> V.t option

find_opt q k is Some v if k is bound to v in q. It is None otherwise.

val length : t -> int

length q is the number of bindings held by q.

val capacity : t -> int

capacity q is the number of bindings q can hold: capacity (create n) = n

val clear : t -> unit

clear q removes all bindings from q.

val fold : (K.t -> V.t -> 'a -> 'a) -> t -> 'a -> 'a

fold f q init folds the function f over the bindings of q. The elements are iterated from oldest to newest.

val fold_s : (K.t -> V.t -> 'a -> 'a Lwt.t) -> t -> 'a -> 'a Lwt.t

Folding in the Lwt monad, from oldest to newest.

val fold_es : (K.t -> V.t -> 'a -> ('a, 'error) result Lwt.t) -> t -> 'a -> ('a, 'error) result Lwt.t

Folding in the error monad, from oldest to newest.

val peek : t -> V.t option

Returns the oldest element of the queue when not empty. Returns None when empty.

val take : t -> V.t option

take q removes and returns the oldest element in queue q, or returns None if the queue is empty.

val peek_at_most : t -> int -> V.t list

peek_at_most q n returns the oldest n elements of the queue q. If the queue has less than n elements, returns all elements of the queue.

val take_at_most : t -> int -> V.t list

take_at_most q n removes and returns the oldest n elements of the queue q. If the queue has less than n elements, removes and returns all elements of the queue.

val elements : t -> V.t list

Returns the elements from oldest to newest.

val keys : t -> K.t list

Returns the keys of the elements stored in the queue from oldest to newest.

val bindings : t -> (K.t * V.t) list

Returns the bindings stored in the queue from oldest to newest.

OCaml

Innovation. Community. Security.