module type Accessors =sig
..end
type ('a, 'b, 'comparator)
t
type 'a
key
val is_empty : ('a, 'b, 'c) t -> bool
val length : ('a, 'b, 'c) t -> int
length map
map
.val add : ('k, 'v, 'comparator) t ->
key:'k key ->
data:'v -> ('k, 'v, 'comparator) t
val add_multi : ('k, 'v list, 'comparator) t ->
key:'k key ->
data:'v -> ('k, 'v list, 'comparator) t
val change : ('k, 'v, 'comparator) t ->
'k key ->
('v option -> 'v option) -> ('k, 'v, 'comparator) t
change map key f
updates the given map by changing the value stored
under key
according to f
. Thus, for example, one might write:
change m k (function None -> Some 0 | Some x -> Some (x + 1))
to produce a new map where the integer stored under key k
is
incremented by one (treating an unknown key as zero)
val find : ('k, 'v, 'a) t ->
'k key -> 'v option
Not_found
if none
such existsval find_exn : ('k, 'v, 'a) t ->
'k key -> 'v
val remove : ('k, 'v, 'comparator) t ->
'k key ->
('k, 'v, 'comparator) t
val mem : ('k, 'a, 'b) t ->
'k key -> bool
mem key map
tests whether map
contains a binding for key
val iter : ('k, 'v, 'a) t ->
f:(key:'k key -> data:'v -> unit) -> unit
val map : ('k, 'v1, 'comparator) t ->
f:('v1 -> 'v2) -> ('k, 'v2, 'comparator) t
val mapi : ('k, 'v1, 'comparator) t ->
f:(key:'k key -> data:'v1 -> 'v2) ->
('k, 'v2, 'comparator) t
map
, but function takes both key and data as argumentsval fold : ('k, 'v, 'b) t ->
init:'a ->
f:(key:'k key -> data:'v -> 'a -> 'a) -> 'a
val fold_right : ('k, 'v, 'b) t ->
init:'a ->
f:(key:'k key -> data:'v -> 'a -> 'a) -> 'a
val filter : ('k, 'v, 'comparator) t ->
f:(key:'k key -> data:'v -> bool) ->
('k, 'v, 'comparator) t
val filter_map : ('k, 'v1, 'comparator) t ->
f:('v1 -> 'v2 option) -> ('k, 'v2, 'comparator) t
val filter_mapi : ('k, 'v1, 'comparator) t ->
f:(key:'k key -> data:'v1 -> 'v2 option) ->
('k, 'v2, 'comparator) t
filter_map
, but function takes both key and data as argumentsval compare : ('v -> 'v -> int) ->
('k, 'v, 'comparator) t ->
('k, 'v, 'comparator) t -> int
val equal : ('v -> 'v -> bool) ->
('k, 'v, 'comparator) t ->
('k, 'v, 'comparator) t -> bool
equal cmp m1 m2
tests whether the maps m1
and m2
are equal, that is, contain
equal keys and associate them with equal data. cmp
is the equality predicate used
to compare the data associated with the keys.val keys : ('k, 'a, 'b) t -> 'k key list
val data : ('a, 'v, 'b) t -> 'v list
val to_alist : ('k, 'v, 'a) t ->
('k key * 'v) list
val merge : ('k, 'v1, 'comparator) t ->
('k, 'v2, 'comparator) t ->
f:(key:'k key ->
[ `Both of 'v1 * 'v2 | `Left of 'v1 | `Right of 'v2 ] -> 'v3 option) ->
('k, 'v3, 'comparator) t
val min_elt : ('k, 'v, 'a) t ->
('k key * 'v) option
min_elt map
(key, data)
pair corresponding to the minimum key in
map
, None if empty.val min_elt_exn : ('k, 'v, 'a) t -> 'k key * 'v
val max_elt : ('k, 'v, 'a) t ->
('k key * 'v) option
max_elt map
(key, data)
pair corresponding to the maximum key in
map
, and None if map
is empty.val max_elt_exn : ('k, 'v, 'a) t -> 'k key * 'v
val for_all : ('k, 'v, 'a) t -> f:('v -> bool) -> bool
val exists : ('k, 'v, 'a) t -> f:('v -> bool) -> bool
val fold_range_inclusive : ('k, 'v, 'b) t ->
min:'k key ->
max:'k key ->
init:'a ->
f:(key:'k key -> data:'v -> 'a -> 'a) -> 'a
fold_range_inclusive t ~min ~max ~init ~f
folds f (with initial value ~init) over all keys (and their associated values)
that are in the range min, max
(inclusive).val range_to_alist : ('k, 'v, 'a) t ->
min:'k key ->
max:'k key ->
('k key * 'v) list
range_to_alist t ~min ~max
returns an associative list of the elements whose
keys lie in min, max
(inclusive), with the smallest key being at the head of the
list.val prev_key : ('k, 'v, 'a) t ->
'k key ->
('k key * 'v) option
prev_key t k
returns the largest (key, value) pair in t with key less than k
next_key t k
returns the smallest (key, value) pair in t with key greater than k
val next_key : ('k, 'v, 'a) t ->
'k key ->
('k key * 'v) option
rank t k
if k is in t, returns the number of keys strictly less than k in t,
otherwise Noneval rank : ('k, 'a, 'b) t ->
'k key -> int option
type ('a, 'b, 'comparator)
tree
tree t
returns the underlying binary tree that represents the map. This is useful
if you want to marshal a map between processes. Since the set contains a closure,
it cannot be marshalled between processes that use different executables; however,
the underlying tree can, so long as the tree type hasn't changed.val to_tree : ('k, 'v, 'comparator) t ->
('k key, 'v, 'comparator)
tree