Module type Core_map_intf.Gen.S


module type S = sig .. end

val empty : ('a, 'b) T.t
the empty map

map with one key, data pair
val singleton : 'a T.key -> 'b -> ('a, 'b) T.t
val is_empty : ('a, 'b) T.t -> bool
Test whether a map is empty or not.
val cardinal : ('a, 'b) T.t -> int
cardinal map
Returns number of elements in map.

returns a new map with the specified new binding; if the key was already bound, its previous binding disappears.
val add : key:'a T.key -> data:'b -> ('a, 'b) T.t -> ('a, 'b) T.t
val add_multi : key:'a T.key -> data:'b -> ('a, 'b list) T.t -> ('a, 'b list) T.t
if key is not present then add a singleton list, otherwise, cons data on the head of the existing list.

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 change : ('a, 'b) T.t -> 'a T.key -> ('b option -> 'b option) -> ('a, 'b) T.t
val find_exn : ('a, 'b) T.t -> 'a T.key -> 'b
returns the value bound to the given key, raising Not_found if none such exists
val find : ('a, 'b) T.t -> 'a T.key -> 'b option
val remove : ('a, 'b) T.t -> 'a T.key -> ('a, 'b) T.t
returns a new map with any binding for the key in question removed
val mem : ('a, 'b) T.t -> 'a T.key -> bool
mem key map tests whether map contains a binding for key
val iter : f:(key:'a T.key -> data:'b -> unit) -> ('a, 'b) T.t -> unit
iterator for map
val map : f:('a -> 'b) -> ('c, 'a) T.t -> ('c, 'b) T.t
returns new map with bound values replaced by f applied to the bound values
val mapi : f:(key:'a T.key -> data:'b -> 'c) -> ('a, 'b) T.t -> ('a, 'c) T.t
like map, but function takes both key and data as arguments
val fold : f:(key:'a T.key -> data:'b -> 'c -> 'c) -> ('a, 'b) T.t -> init:'c -> 'c
folds over keys and data in map
val fold_right : f:(key:'a T.key -> data:'b -> 'c -> 'c) -> ('a, 'b) T.t -> init:'c -> 'c
folds over keys and data in map in reverse order
val filter : f:(key:'a T.key -> data:'b -> bool) -> ('a, 'b) T.t -> ('a, 'b) T.t
filter for map
val filter_map : f:('a -> 'b option) -> ('c, 'a) T.t -> ('c, 'b) T.t
returns new map with bound values filtered by f applied to the bound values
val filter_mapi : f:(key:'a T.key -> data:'b -> 'c option) -> ('a, 'b) T.t -> ('a, 'c) T.t
like filter_map, but function takes both key and data as arguments
val compare : ('a -> 'a -> int) -> ('b, 'a) T.t -> ('b, 'a) T.t -> int
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 : ('a -> 'a -> bool) -> ('b, 'a) T.t -> ('b, 'a) T.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 : ('a, 'b) T.t -> 'a T.key list
returns list of keys in map
val has_key : ('a, 'b) T.t -> 'a T.key -> bool
equivalent to mem
val data : ('a, 'b) T.t -> 'b list
returns list of data in map
val of_alist : ('a T.key * 'b) list -> [ `Duplicate_key of 'a T.key | `Ok of ('a, 'b) T.t ]
creates map from association list with unique keys
val of_alist_exn : ('a T.key * 'b) list -> ('a, 'b) T.t
creates map from association list with unique keys. Raises Failure if duplicate 'a keys are found.
val of_alist_multi : ('a T.key * 'b) list -> ('a, 'b list) T.t
creates map from association list with possibly repeated keys.
val to_alist : ('a, 'b) T.t -> ('a T.key * 'b) list
creates association list from map. No guarantee about order.

Additional operations on maps

val combine_alist : ('a T.key * 'b) list -> init:'c -> f:('b -> 'c -> 'c) -> ('a, 'c) T.t
combines an association list into a map, folding together the bound values (for experts only)
val merge : f:(key:'a T.key -> 'b option -> 'c option -> 'd option) ->
('a, 'b) T.t -> ('a, 'c) T.t -> ('a, 'd) T.t
merges two maps
val min_elt : ('a, 'b) T.t -> ('a T.key * 'b) option
min_elt map
Returns Some (key, data) pair corresponding to the minimum key in map, None if empty.
val min_elt_exn : ('a, 'b) T.t -> 'a T.key * 'b
min_elt_exn map
Returns the (key, data) pair corresponding to the minimum key in map, raises Not_found if map is empty.
val max_elt : ('a, 'b) T.t -> ('a T.key * 'b) 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 : ('a, 'b) T.t -> 'a T.key * 'b
max_elt_exn map
Returns the (key, data) pair corresponding to the maximum key in map, raises an exception if map is empty.

same semantics as similar functions in List
val for_all : f:('a -> bool) -> ('b, 'a) T.t -> bool
val exists : f:('a -> bool) -> ('b, 'a) T.t -> bool
val fold_range_inclusive : ('a, 'b) T.t ->
min:'a T.key ->
max:'a T.key -> init:'c -> f:(key:'a T.key -> data:'b -> 'c -> 'c) -> 'c
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 : ('a, 'b) T.t -> min:'a T.key -> max:'a T.key -> ('a T.key * 'b) 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 : ('a, 'b) T.t -> 'a T.key -> 'a T.key option
prev_key t k returns the largest key in t less than k

next_key t k returns the smallest key in t greater than k

val next_key : ('a, 'b) T.t -> 'a T.key -> 'a T.key option
rank t k if k is in t, returns the number of keys strictly less than k in t, otherwise None
val rank : ('a, 'b) T.t -> 'a T.key -> int option