module type S =sig
..end
val empty : ('a, 'b) T.t
val singleton : 'a T.key -> 'b -> ('a, 'b) T.t
val is_empty : ('a, 'b) T.t -> bool
val cardinal : ('a, 'b) T.t -> int
cardinal map
map
.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
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
Not_found
if none
such existsval find : ('a, 'b) T.t -> 'a T.key -> 'b option
val remove : ('a, 'b) T.t -> 'a T.key -> ('a, 'b) T.t
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
val map : f:('a -> 'b) -> ('c, 'a) T.t -> ('c, 'b) T.t
val mapi : f:(key:'a T.key -> data:'b -> 'c) -> ('a, 'b) T.t -> ('a, 'c) T.t
map
, but function takes both key and data as argumentsval fold : f:(key:'a T.key -> data:'b -> 'c -> 'c) -> ('a, 'b) T.t -> init:'c -> 'c
val fold_right : f:(key:'a T.key -> data:'b -> 'c -> 'c) -> ('a, 'b) T.t -> init:'c -> 'c
val filter : f:(key:'a T.key -> data:'b -> bool) -> ('a, 'b) T.t -> ('a, 'b) T.t
val filter_map : f:('a -> 'b option) -> ('c, 'a) T.t -> ('c, 'b) T.t
val filter_mapi : f:(key:'a T.key -> data:'b -> 'c option) -> ('a, 'b) T.t -> ('a, 'c) T.t
filter_map
, but function takes both key and data as argumentsval compare : ('a -> 'a -> int) -> ('b, 'a) T.t -> ('b, 'a) T.t -> int
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
val has_key : ('a, 'b) T.t -> 'a T.key -> bool
mem
val data : ('a, 'b) T.t -> 'b list
val of_alist : ('a T.key * 'b) list -> [ `Duplicate_key of 'a T.key | `Ok of ('a, 'b) T.t ]
val of_alist_exn : ('a T.key * 'b) list -> ('a, 'b) T.t
val of_alist_multi : ('a T.key * 'b) list -> ('a, 'b list) T.t
val to_alist : ('a, 'b) T.t -> ('a T.key * 'b) list
val combine_alist : ('a T.key * 'b) list -> init:'c -> f:('b -> 'c -> 'c) -> ('a, 'c) T.t
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
val min_elt : ('a, 'b) T.t -> ('a T.key * 'b) option
min_elt map
(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
(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
(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
(key, data)
pair corresponding to the
maximum key in map
, raises an exception if map
is empty.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
listval 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 Noneval rank : ('a, 'b) T.t -> 'a T.key -> int option