Library
Module
Module type
Parameter
Class
Class type
Output signature of the functor Make
val empty : t
empty
is the empty map.
singleton key value
creates a one-element map that contains a binding value
for key
.
val is_empty : t -> bool
is_empty m
returns true
if the map m
is empty, false
otherwise.
val cardinal : t -> int
cardinal m
returns the number of bindings of the map m
.
find key m
returns Some v
if the binding of key
in m
is v
, or None
if key
is not bound m
.
add_unless_bound key value m
returns Some m'
, a map containing the same bindings as m
, plus a binding of key
to value
. Or, None
if key
was already bound in m
.
add key value m
returns a map containing the same bindings as m
, plus a binding of key
to value
. If key
was already bound in m
, the previous binding disappears.
remove key m
returns a map containing the same bindings as m
, except for key
which is not bound in the returned map. If key
was not bound in m
, m
is returned unchanged.
update k f m
returns a map containing the same bindings as m
, except for the binding v
of k
. Depending the value of v
, which is f (find k m)
, the binding of k
is added, removed, or updated.
bindings m
returns the list of all bindings in the given map m
. The list is sorted with respect to the ordering over the type of the keys.
findb key m
returns Some b
if the binding of key
in m
is b
, or None
if key
is not bound in t
.
addb_unless_bound b m
returns Some m'
, a map containing the same bindings as m
, plus the binding b
. Or, None
if key
, the first part of b
, was already bound in m
.
addb b m
returns a map containing the same bindings as m
, plus the binding b
. If key
, the first part of b
was already bound in m
, the previous binding disappears.
equal p m m'
tests whether the maps m
and m'
are equal, that is contain equal keys and associate them with equal data. p
is the equality predicate used to compare the data associated with the keys.
iter f m
applies f
to all bindings in m
. The bindings are passed in increasing order with respect to the ordering over the type of keys.
fold f m acc
computes (f bN .. (f b1 acc))
, where b1 .. bN
are the bindings of m
in increasing order over the type of keys.
for_all p m
checks if all bindings of the map m
satisfy the predicate p
.
exists p m
checks if at least one binding of the map m
satisfies p
.
filter p m
returns the map with all the bindings in m
that satisfy p
.
merge f m m'
computes a map whose keys is a subset of keys of m
and m'
. The presence of each such binding, and the corresponding value, is determined with the function f
.
union f m m'
computes a map whose keys is the union of the keys of m
and m'
. When the same binding is defined in both maps, the function f
is used to combine them.
val pp : Format.formatter -> t -> unit
pp fmt m
is a pretty printer of the map m
.