package gmap

  1. Overview
  2. Docs

Output signature of the functor Make

Key

type 'a key

The type for keys whose lookup value is 'a.

Map

type t

The type of the map

Constructors

val empty : t

empty is the empty map.

val singleton : 'a key -> 'a -> t

singleton key value creates a map with the single provided binding.

Basic operations

val is_empty : t -> bool

is_empty t is true if the map is empty, false otherwise.

val cardinal : t -> int

cardinal t is the number of bindings in t.

Lookup operations

val mem : 'a key -> t -> bool

mem key t is true if key is bound in t.

val find : 'a key -> t -> 'a option

find key t is the value Some value of key in t, None if key is not bound in t.

val get : 'a key -> t -> 'a

find key t is the value of key in t.

Insertion and removal operations

val add : 'a key -> 'a -> t -> t

add key value t adds the binding V (key, value) to t.

val remove : 'a key -> t -> t

remove key t removes the binding from t.

Bindings

type v =
  1. | V : 'a key * 'a -> v
    (*

    The type for a binding: a key and its value.

    *)

Selection

val min_binding : t -> v option

min_binding t is the minimal binding in t, None if t is empty.

val max_binding : t -> v option

max_binding t is the maximal binding in t, None if t is empty.

val any_binding : t -> v option

any_binding t is any binding in t, None if t is empty.

val bindings : t -> v list

bindings t is the list of bindings in t.

Lookup

val findv : 'a key -> t -> v option

findv key t is the binding Some v of key in t, None if key is not bound in t.

val getv : 'a key -> t -> v

getv key t is the binding of key in t.

Insertion

val addv : v -> t -> t

addv v t adds the binding v to t.

Equality

val equal : (v -> v -> bool) -> t -> t -> bool

equal p t t' is true if all bindings of t and t' satisfy p

Higher-order functions

val iter : (v -> unit) -> t -> unit

iter f t iterates over t and applies f to each binding.

val fold : (v -> 'a -> 'a) -> t -> 'a -> 'a

fold f t acc folds over the bindings of t with f, starting with acc.

val for_all : (v -> bool) -> t -> bool

for_all p t is true if all bindings in t satisfy p, false otherwise.

val exists : (v -> bool) -> t -> bool

exists p t is true if some binding in t satisfies p, false otherwise.

val filter : (v -> bool) -> t -> t

filter p t is the map of all bindings in t that satisfy p.

val merge : (v option -> v option -> v option) -> t -> t -> t

merge f t t' merges t and t' by using the result of f for every binding.

val union : (v -> v -> v option) -> t -> t -> t

union f t t' is the union of t and t'. If the same binding is defined in both maps, the result of f is used.

Pretty printer

val pp : Format.formatter -> t -> unit

pp fmt t is a pretty printer of the map t.

OCaml

Innovation. Community. Security.