Module type Core_map_intf.Accessors

module type Accessors = sig .. end

type ('a, 'b, 'comparator) t 
type ('a, 'b, 'comparator) tree 
type 'a key 
type ('a, 'comparator, 'z) options 
val invariants : ('k, 'comparator, ('k, 'v, 'comparator) t -> bool)
options
Test if invariants of internal AVL search tree hold.
val is_empty : ('a, 'b, 'c) t -> bool
Test whether a map is empty or not.
val length : ('a, 'b, 'c) t -> int
length map
Returns number of elements in map.
val add : ('k, 'comparator,
('k, 'v, 'comparator) t ->
key:'k key ->
data:'v -> ('k, 'v, 'comparator) t)
options
returns a new map with the specified new binding; if the key was already bound, its previous binding disappears.
val add_multi : ('k, 'comparator,
('k, 'v list, 'comparator) t ->
key:'k key ->
data:'v -> ('k, 'v list, 'comparator) t)
options
if key is not present then add a singleton list, otherwise, cons data on the head of the existing list.
val change : ('k, 'comparator,
('k, 'v, 'comparator) t ->
'k key ->
('v option -> 'v option) -> ('k, 'v, 'comparator) t)
options
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, 'comparator,
('k, 'v, 'comparator) t ->
'k key -> 'v option)
options
returns the value bound to the given key, raising Not_found if none such exists
val find_exn : ('k, 'comparator,
('k, 'v, 'comparator) t ->
'k key -> 'v)
options
val remove : ('k, 'comparator,
('k, 'v, 'comparator) t ->
'k key ->
('k, 'v, 'comparator) t)
options
returns a new map with any binding for the key in question removed
val mem : ('k, 'comparator,
('k, 'a, 'comparator) t ->
'k key -> bool)
options
mem map key tests whether map contains a binding for key
val iter : ('k, 'v, 'a) t ->
f:(key:'k key -> data:'v -> unit) -> unit
iterator for map
val iter2 : ('k, 'comparator,
('k, 'v1, 'comparator) t ->
('k, 'v2, 'comparator) t ->
f:(key:'k key ->
data:[ `Both of 'v1 * 'v2 | `Left of 'v1 | `Right of 'v2 ] -> unit) ->
unit)
options
Iterate two maps side by side. Complexity of this function is O(M+N). If two inputs are (0, a); (1, a) and (1, b); (2, b), f will be called with (0, `Left a); (1, `Both (a, b)); (2, `Right b)
val map : ('k, 'v1, 'comparator) t ->
f:('v1 -> 'v2) -> ('k, 'v2, 'comparator) t
returns new map with bound values replaced by f applied to the bound values
val mapi : ('k, 'v1, 'comparator) t ->
f:(key:'k key -> data:'v1 -> 'v2) ->
('k, 'v2, 'comparator) t
like map, but function takes both key and data as arguments
val fold : ('k, 'v, 'b) t ->
init:'a ->
f:(key:'k key -> data:'v -> 'a -> 'a) -> 'a
folds over keys and data in map in increasing order of key.
val fold_right : ('k, 'v, 'b) t ->
init:'a ->
f:(key:'k key -> data:'v -> 'a -> 'a) -> 'a
folds over keys and data in map in decreasing order of key.
val filter : ('k, 'comparator,
('k, 'v, 'comparator) t ->
f:(key:'k key -> data:'v -> bool) ->
('k, 'v, 'comparator) t)
options
val filter_map : ('k, 'comparator,
('k, 'v1, 'comparator) t ->
f:('v1 -> 'v2 option) -> ('k, 'v2, 'comparator) t)
options
returns new map with bound values filtered by f applied to the bound values
val filter_mapi : ('k, 'comparator,
('k, 'v1, 'comparator) t ->
f:(key:'k key -> data:'v1 -> 'v2 option) ->
('k, 'v2, 'comparator) t)
options
like filter_map, but function takes both key and data as arguments
val compare_direct : ('k, 'comparator,
('v -> 'v -> int) ->
('k, 'v, 'comparator) t ->
('k, 'v, 'comparator) t -> int)
options
Total ordering between maps. The first argument is a total ordering used to compare data associated with equal keys in the two maps.
val equal : ('k, 'comparator,
('v -> 'v -> bool) ->
('k, 'v, 'comparator) t ->
('k, 'v, 'comparator) t -> bool)
options
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
returns list of keys in map
val data : ('a, 'v, 'b) t -> 'v list
returns list of data in map
val to_alist : ('k, 'v, 'a) t ->
('k key * 'v) list
creates association list from map. No guarantee about order.

Additional operations on maps

val merge : ('k, 'comparator,
('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)
options
merges two maps
val symmetric_diff : ('k, 'comparator,
('k, 'v, 'comparator) t ->
('k, 'v, 'comparator) t ->
data_equal:('v -> 'v -> bool) ->
('k key *
[ `Left of 'v | `Right of 'v | `Unequal of 'v * 'v ])
list)
options
symmetric_diff t1 t2 ~data_equal returns a list of changes between t1 and t2. It is intended to be efficient in the case where t1 and t2 share a large amount of structure.
val min_elt : ('k, 'v, 'a) t ->
('k key * 'v) option
min_elt map
Returns Some (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
Returns Some (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
same semantics as similar functions in List
val exists : ('k, 'v, 'a) t -> f:('v -> bool) -> bool
val fold_range_inclusive : ('k, 'comparator,
('k, 'v, 'comparator) t ->
min:'k key ->
max:'k key ->
init:'a ->
f:(key:'k key -> data:'v -> 'a -> 'a) -> 'a)
options
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, 'comparator,
('k, 'v, 'comparator) t ->
min:'k key ->
max:'k key ->
('k key * 'v) list)
options
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, 'comparator,
('k, 'v, 'comparator) t ->
'k key ->
('k key * 'v) option)
options
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, 'comparator,
('k, 'v, 'comparator) t ->
'k key ->
('k key * 'v) option)
options
rank t k if k is in t, returns the number of keys strictly less than k in t, otherwise None
val rank : ('k, 'comparator,
('k, 'v, 'comparator) t ->
'k key -> int option)
options
val to_tree : ('k, 'v, 'comparator) t ->
('k key, 'v, 'comparator)
tree