Module type Gmap.S
Output signature of the functor Make
Constructors
val empty : t
empty
is the empty map.
Basic operations
val is_empty : t -> bool
is_empty m
returnstrue
if the mapm
is empty,false
otherwise.
val cardinal : t -> int
cardinal m
returns the number of bindings of the mapm
.
Lookup operations
Insertion and removal operations
val add_unless_bound : 'a key -> 'a -> t -> t option
add_unless_bound key value m
returnsSome m'
, a map containing the same bindings asm
, plus a binding ofkey
tovalue
. Or,None
ifkey
was already bound inm
.
val add : 'a key -> 'a -> t -> t
add key value m
returns a map containing the same bindings asm
, plus a binding ofkey
tovalue
. Ifkey
was already bound inm
, the previous binding disappears.
Bindings
Selection of bindings
Higher-order functions
type eq
=
{
f : a. 'a key -> 'a -> 'a -> bool;
}
The function type for the equal operation, using a record type for "first-class" semi-explicit polymorphism.
val equal : eq -> t -> t -> bool
equal p m m'
tests whether the mapsm
andm'
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.
type mapper
=
{
f : a. 'a key -> 'a -> 'a;
}
The function type for the map operation, using a record type for "first-class" semi-explicit polymorphism.
val map : mapper -> t -> t
map f m
returns a map with the same domain asm
, where the associated bindingb
has been replaced by the result of the application off
tob
. The bindings are passed tof
in increasing order with respect to the ordering over the type of the keys.
val iter : (b -> unit) -> t -> unit
iter f m
appliesf
to all bindings inm
. The bindings are passed in increasing order with respect to the ordering over the type of keys.
val fold : (b -> 'a -> 'a) -> t -> 'a -> 'a
fold f m acc
computes(f bN .. (f b1 acc))
, whereb1 .. bN
are the bindings ofm
in increasing order with respect to the ordering over the type of the keys.
val for_all : (b -> bool) -> t -> bool
for_all p m
checks if all bindings of the mapm
satisfy the predicatep
.
val exists : (b -> bool) -> t -> bool
exists p m
checks if at least one binding of the mapm
satisfiesp
.
val filter : (b -> bool) -> t -> t
filter p m
returns the map with all the bindings inm
that satisfyp
.
type merger
=
{
f : a. 'a key -> 'a option -> 'a option -> 'a option;
}
The function type for the merge operation, using a record type for "first-class" semi-explicit polymorphism.
val merge : merger -> t -> t -> t
merge f m m'
computes a map whose keys is a subset of keys ofm
andm'
. The presence of each such binding, and the corresponding value, is determined with the functionf
.
type unionee
=
{
f : a. 'a key -> 'a -> 'a -> 'a option;
}
The function type for the union operation, using a record type for "first-class" semi-explicit polymorphism.