Module Map.Dict
This module seprate identity from data, it is a bit more verboe but slightly more efficient due to the fact that there is no need to pack identity and data back after each operation
Advanced usage only
type ('key, 'value, 'id) ttype ('key, 'id) cmpval empty : ('k, 'v, 'id) tval isEmpty : ('k, 'v, 'id) t -> boolval has : ('k, 'a, 'id) t -> 'k -> cmp:('k, 'id) cmp -> boolval cmpU :
('k, 'v, 'id) t ->
('k, 'v, 'id) t ->
kcmp:('k, 'id) cmp ->
vcmp:('v -> 'v -> int) Js.Fn.arity2 ->
intval cmp :
('k, 'v, 'id) t ->
('k, 'v, 'id) t ->
kcmp:('k, 'id) cmp ->
vcmp:('v -> 'v -> int) ->
intval eqU :
('k, 'a, 'id) t ->
('k, 'a, 'id) t ->
kcmp:('k, 'id) cmp ->
veq:('a -> 'a -> bool) Js.Fn.arity2 ->
boolval eq :
('k, 'a, 'id) t ->
('k, 'a, 'id) t ->
kcmp:('k, 'id) cmp ->
veq:('a -> 'a -> bool) ->
booleq m1 m2 cmp 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 findFirstByU :
('k, 'v, 'id) t ->
('k -> 'v -> bool) Js.Fn.arity2 ->
('k * 'v) optionval findFirstBy : ('k, 'v, 'id) t -> ('k -> 'v -> bool) -> ('k * 'v) optionfindFirstBy m p uses funcion f to find the first key value pair to match predicate p.
let s0 = fromArray ~id:(module IntCmp) [|4,"4";1,"1";2,"2,"3""|];;
findFirstBy s0 (fun k v -> k = 4 ) = option (4, "4");;val forEachU : ('k, 'a, 'id) t -> ('k -> 'a -> unit) Js.Fn.arity2 -> unitval forEach : ('k, 'a, 'id) t -> ('k -> 'a -> unit) -> unitforEach m f applies f to all bindings in map m. f receives the key as first argument, and the associated value as second argument. The bindings are passed to f in increasing order with respect to the ordering over the type of the keys.
val reduceU :
('k, 'a, 'id) t ->
'b ->
('b -> 'k -> 'a -> 'b) Js.Fn.arity3 ->
'bval reduce : ('k, 'a, 'id) t -> 'b -> ('b -> 'k -> 'a -> 'b) -> 'breduce m a f computes (f kN dN ... (f k1 d1 a)...), where k1 ... kN are the keys of all bindings in m (in increasing order), and d1 ... dN are the associated data.
val everyU : ('k, 'a, 'id) t -> ('k -> 'a -> bool) Js.Fn.arity2 -> boolval every : ('k, 'a, 'id) t -> ('k -> 'a -> bool) -> boolevery m p checks if all the bindings of the map satisfy the predicate p. Order unspecified
val someU : ('k, 'a, 'id) t -> ('k -> 'a -> bool) Js.Fn.arity2 -> boolval some : ('k, 'a, 'id) t -> ('k -> 'a -> bool) -> boolsome m p checks if at least one binding of the map satisfy the predicate p. Order unspecified
val size : ('k, 'a, 'id) t -> intval toList : ('k, 'a, 'id) t -> ('k * 'a) listIn increasing order.
val toArray : ('k, 'a, 'id) t -> ('k * 'a) arrayval fromArray : ('k * 'a) array -> cmp:('k, 'id) cmp -> ('k, 'a, 'id) tval keysToArray : ('k, 'a, 'id) t -> 'k arrayval valuesToArray : ('k, 'a, 'id) t -> 'a arrayval minKey : ('k, _, _) t -> 'k optionval minKeyUndefined : ('k, _, _) t -> 'k Js.undefinedval maxKey : ('k, _, _) t -> 'k optionval maxKeyUndefined : ('k, _, _) t -> 'k Js.undefinedval minimum : ('k, 'a, _) t -> ('k * 'a) optionval minUndefined : ('k, 'a, _) t -> ('k * 'a) Js.undefinedval maximum : ('k, 'a, _) t -> ('k * 'a) optionval maxUndefined : ('k, 'a, _) t -> ('k * 'a) Js.undefinedval get : ('k, 'a, 'id) t -> 'k -> cmp:('k, 'id) cmp -> 'a optionval getUndefined :
('k, 'a, 'id) t ->
'k ->
cmp:('k, 'id) cmp ->
'a Js.undefinedval getWithDefault : ('k, 'a, 'id) t -> 'k -> 'a -> cmp:('k, 'id) cmp -> 'aval getExn : ('k, 'a, 'id) t -> 'k -> cmp:('k, 'id) cmp -> 'aval checkInvariantInternal : (_, _, _) t -> unitraise when invariant is not held
val remove : ('a, 'b, 'id) t -> 'a -> cmp:('a, 'id) cmp -> ('a, 'b, 'id) tremove m x returns a map containing the same bindings as m, except for x which is unbound in the returned map.
val removeMany :
('a, 'b, 'id) t ->
'a array ->
cmp:('a, 'id) cmp ->
('a, 'b, 'id) tval set : ('a, 'b, 'id) t -> 'a -> 'b -> cmp:('a, 'id) cmp -> ('a, 'b, 'id) tset m x y returns a map containing the same bindings as m, plus a binding of x to y. If x was already bound in m, its previous binding disappears.
val updateU :
('a, 'b, 'id) t ->
'a ->
('b option -> 'b option) Js.Fn.arity1 ->
cmp:('a, 'id) cmp ->
('a, 'b, 'id) tval update :
('a, 'b, 'id) t ->
'a ->
('b option -> 'b option) ->
cmp:('a, 'id) cmp ->
('a, 'b, 'id) tval mergeU :
('a, 'b, 'id) t ->
('a, 'c, 'id) t ->
('a -> 'b option -> 'c option -> 'd option) Js.Fn.arity3 ->
cmp:('a, 'id) cmp ->
('a, 'd, 'id) tval merge :
('a, 'b, 'id) t ->
('a, 'c, 'id) t ->
('a -> 'b option -> 'c option -> 'd option) ->
cmp:('a, 'id) cmp ->
('a, 'd, 'id) tmerge m1 m2 f computes a map whose keys is a subset of keys of m1 and of m2. The presence of each such binding, and the corresponding value, is determined with the function f.
val mergeMany :
('a, 'b, 'id) t ->
('a * 'b) array ->
cmp:('a, 'id) cmp ->
('a, 'b, 'id) tval keepU :
('k, 'a, 'id) t ->
('k -> 'a -> bool) Js.Fn.arity2 ->
('k, 'a, 'id) tval keep : ('k, 'a, 'id) t -> ('k -> 'a -> bool) -> ('k, 'a, 'id) tkeep m p returns the map with all the bindings in m that satisfy predicate p.
val partitionU :
('k, 'a, 'id) t ->
('k -> 'a -> bool) Js.Fn.arity2 ->
('k, 'a, 'id) t * ('k, 'a, 'id) tval partition :
('k, 'a, 'id) t ->
('k -> 'a -> bool) ->
('k, 'a, 'id) t * ('k, 'a, 'id) tpartition m p returns a pair of maps (m1, m2), where m1 contains all the bindings of s that satisfy the predicate p, and m2 is the map with all the bindings of s that do not satisfy p.
val split :
('a, 'b, 'id) t ->
'a ->
cmp:('a, 'id) cmp ->
(('a, 'b, 'id) t * ('a, 'b, 'id) t) * 'b optionsplit x m returns a triple (l, data, r), where l is the map with all the bindings of m whose key is strictly less than x; r is the map with all the bindings of m whose key is strictly greater than x; data is None if m contains no binding for x, or Some v if m binds v to x.
val mapU : ('k, 'a, 'id) t -> ('a -> 'b) Js.Fn.arity1 -> ('k, 'b, 'id) tval map : ('k, 'a, 'id) t -> ('a -> 'b) -> ('k, 'b, 'id) tmap m f returns a map with same domain as m, where the associated value a of all bindings of m has been replaced by the result of the application of f to a. The bindings are passed to f in increasing order with respect to the ordering over the type of the keys.
val mapWithKeyU :
('k, 'a, 'id) t ->
('k -> 'a -> 'b) Js.Fn.arity2 ->
('k, 'b, 'id) tval mapWithKey : ('k, 'a, 'id) t -> ('k -> 'a -> 'b) -> ('k, 'b, 'id) t