Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
get k m
returns Some v
if the current binding of k
in m
is v
, or None
if the key k
is not present. Safe version of find
.
get_or k m ~default
returns the value associated to k
if present, and returns default
otherwise (if k
doesn't belong in m
).
update k f m
calls f (Some v)
if find k m = v
, otherwise it calls f None
. In any case, if the result is None
k
is removed from m
, and if the result is Some v'
then add k v' m
is returned.
choose_opt m
returns one binding of the given map m
, or None
if m
is empty. Safe version of choose
.
min_binding_opt m
returns the smallest binding of the given map m
, or None
if m
is empty. Safe version of min_binding
.
max_binding_opt m
returns the largest binding of the given map m
, or None
if m
is empty. Safe version of max_binding
.
find_opt k m
returns Some v
if the current binding of k
in m
is v
, or None
if the key k
is not present. Safe version of find
.
find_first f m
where f
is a monotonically increasing function, returns the binding of m
with the lowest key k
such that f k
, or raises Not_found
if no such key exists. See Map.S.find_first
.
find_first_opt f m
where f
is a monotonically increasing function, returns an option containing the binding of m
with the lowest key k
such that f k
, or None
if no such key exists. Safe version of find_first
.
val merge_safe :
f:(key -> [ `Left of 'a | `Right of 'b | `Both of 'a * 'b ] -> 'c option) ->
'a t ->
'b t ->
'c t
merge_safe ~f a b
merges the maps a
and b
together.
add_seq m seq
adds the given Seq.t
of bindings to the map m
. Like add_list
. Renamed from add_std_seq
since 3.0.
add_seq ~f m l
adds the given seq l
of bindings to the map m
, using f
to combine values that have the same key. If a key occurs several times, all its bindings are combined using the function f
, with f key v1 v2
being called with v1
occurring later in the seq than v2
.
of_seq seq
builds a map from the given Seq.t
of bindings. Like of_list
. Renamed from of_std_seq
since 3.0.
of_seq_with ~f l
builds a map from the given seq l
of bindings k_i -> v_i
, added in order using add
. If a key occurs several times, all its bindings are combined using the function f
, with f key v1 v2
being called with v1
occurring later in the seq than v2
.
val add_iter : 'a t -> (key * 'a) CCMap.iter -> 'a t
add_iter m iter
adds the given iter
of bindings to the map m
. Like add_list
.
val add_iter_with :
f:(key -> 'a -> 'a -> 'a) ->
'a t ->
(key * 'a) CCMap.iter ->
'a t
add_iter ~f m l
adds the given iter l
of bindings to the map m
, using f
to combine values that have the same key. If a key occurs several times, all its bindings are combined using the function f
, with f key v1 v2
being called with v1
occurring later in the seq than v2
.
val of_iter : (key * 'a) CCMap.iter -> 'a t
of_iter iter
builds a map from the given iter
of bindings. Like of_list
.
val of_iter_with : f:(key -> 'a -> 'a -> 'a) -> (key * 'a) CCMap.iter -> 'a t
of_iter_with ~f l
builds a map from the given iter l
of bindings k_i -> v_i
, added in order using add
. If a key occurs several times, all its bindings are combined using the function f
, with f key v1 v2
being called with v1
occurring later in the iter than v2
.
val to_iter : 'a t -> (key * 'a) CCMap.iter
to_iter m
iterates on the whole map m
, creating an iter
of bindings. Like to_list
.
of_list l
builds a map from the given list l
of bindings k_i -> v_i
, added in order using add
. If a key occurs several times, only its last binding will be present in the result.
of_list_with ~f l
builds a map from the given list l
of bindings k_i -> v_i
, added in order using add
. If a key occurs several times, all its bindings are combined using the function f
, with f key v1 v2
being called with v1
occurring later in the list than v2
.
add_list m l
adds the given list l
of bindings to the map m
.
add_list ~f m l
adds the given list l
of bindings to the map m
, using f
to combine values that have the same key. If a key occurs several times, all its bindings are combined using the function f
, with f key v1 v2
being called with v1
occurring later in the seq than v2
.
val keys : _ t -> key CCMap.iter
keys m
iterates on the keys of m
only, creating an iter
of keys.
val values : 'a t -> 'a CCMap.iter
values m
iterates on the values of m
only, creating an iter
of values.
to_list m
builds a list of the bindings of the given map m
. The order is unspecified.
val pp :
?pp_start:unit CCMap.printer ->
?pp_stop:unit CCMap.printer ->
?pp_arrow:unit CCMap.printer ->
?pp_sep:unit CCMap.printer ->
key CCMap.printer ->
'a CCMap.printer ->
'a t CCMap.printer
pp ?pp_start ?pp_stop ?pp_arrow ?pp_sep pp_key pp_v m
pretty-prints the contents of the map.