Module Belt.MutableMap
The top level provides generic mutable map operations.
It also has two specialized inner modules Belt.MutableMap.Int and Belt.MutableMap.String
module Int : sig ... endmodule Int: { ... };module String : sig ... endmodule String: { ... };A mutable sorted map module which allows customize compare behavior.
Same as Belt.Map, but mutable.
type ('k, 'v, 'id) ttype t('k, 'v, 'id);type ('key, 'id) id =
(module Belt__.Belt_Id.Comparable
with type identity = 'id
and type t = 'key)type id('key, 'id) =
(module Belt__.Belt_Id.Comparable
with type identity = 'id
and type t = 'key);val make : id:('k, 'id) id -> ('k, 'a, 'id) tlet make: id:id('k, 'id) => t('k, 'a, 'id);val clear : (_, _, _) t -> unitlet clear: t(_, _, _) => unit;val isEmpty : (_, _, _) t -> boollet isEmpty: t(_, _, _) => bool;val has : ('k, _, _) t -> 'k -> boollet has: t('k, _, _) => 'k => bool;val cmpU :
('k, 'a, 'id) t ->
('k, 'a, 'id) t ->
('a -> 'a -> int) Js.Fn.arity2 ->
intlet cmpU:
t('k, 'a, 'id) =>
t('k, 'a, 'id) =>
Js.Fn.arity2(('a => 'a => int)) =>
int;val cmp : ('k, 'a, 'id) t -> ('k, 'a, 'id) t -> ('a -> 'a -> int) -> intlet cmp: t('k, 'a, 'id) => t('k, 'a, 'id) => ('a => 'a => int) => int;cmp m1 m2 cmp First compare by size, if size is the same, compare by key, value pair
val eqU :
('k, 'a, 'id) t ->
('k, 'a, 'id) t ->
('a -> 'a -> bool) Js.Fn.arity2 ->
boollet eqU:
t('k, 'a, 'id) =>
t('k, 'a, 'id) =>
Js.Fn.arity2(('a => 'a => bool)) =>
bool;val eq : ('k, 'a, 'id) t -> ('k, 'a, 'id) t -> ('a -> 'a -> bool) -> boollet eq: t('k, 'a, 'id) => t('k, 'a, 'id) => ('a => 'a => bool) => bool;eq m1 m2 eqf tests whether the maps m1 and m2 are equal, that is, contain equal keys and associate them with equal data. eqf is the equality predicate used to compare the data associated with the keys.
val forEachU : ('k, 'a, 'id) t -> ('k -> 'a -> unit) Js.Fn.arity2 -> unitlet forEachU: t('k, 'a, 'id) => Js.Fn.arity2(('k => 'a => unit)) => unit;val forEach : ('k, 'a, 'id) t -> ('k -> 'a -> unit) -> unitlet forEach: t('k, 'a, 'id) => ('k => 'a => unit) => unit;forEach m f applies f to all bindings in map m. f receives the 'k 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 ->
'blet reduceU:
t('k, 'a, 'id) =>
'b =>
Js.Fn.arity3(('b => 'k => 'a => 'b)) =>
'b;val reduce : ('k, 'a, 'id) t -> 'b -> ('b -> 'k -> 'a -> 'b) -> 'blet reduce: t('k, 'a, 'id) => 'b => ('b => 'k => 'a => 'b) => 'b;reduce 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 -> boollet everyU: t('k, 'a, 'id) => Js.Fn.arity2(('k => 'a => bool)) => bool;val every : ('k, 'a, 'id) t -> ('k -> 'a -> bool) -> boollet every: t('k, 'a, 'id) => ('k => 'a => bool) => bool;every m p checks if all the bindings of the map satisfy the predicate p.
val someU : ('k, 'a, 'id) t -> ('k -> 'a -> bool) Js.Fn.arity2 -> boollet someU: t('k, 'a, 'id) => Js.Fn.arity2(('k => 'a => bool)) => bool;val some : ('k, 'a, 'id) t -> ('k -> 'a -> bool) -> boollet some: t('k, 'a, 'id) => ('k => 'a => bool) => bool;some m p checks if at least one binding of the map satisfy the predicate p.
val size : ('k, 'a, 'id) t -> intlet size: t('k, 'a, 'id) => int;val toList : ('k, 'a, 'id) t -> ('k * 'a) listlet toList: t('k, 'a, 'id) => list(('k, 'a));In increasing order
val toArray : ('k, 'a, 'id) t -> ('k * 'a) arraylet toArray: t('k, 'a, 'id) => array(('k, 'a));In increasing order
val fromArray : ('k * 'a) array -> id:('k, 'id) id -> ('k, 'a, 'id) tlet fromArray: array(('k, 'a)) => id:id('k, 'id) => t('k, 'a, 'id);val keysToArray : ('k, _, _) t -> 'k arraylet keysToArray: t('k, _, _) => array('k);val valuesToArray : (_, 'a, _) t -> 'a arraylet valuesToArray: t(_, 'a, _) => array('a);val minKey : ('k, _, _) t -> 'k optionlet minKey: t('k, _, _) => option('k);val minKeyUndefined : ('k, _, _) t -> 'k Js.undefinedlet minKeyUndefined: t('k, _, _) => Js.undefined('k);val maxKey : ('k, _, _) t -> 'k optionlet maxKey: t('k, _, _) => option('k);val maxKeyUndefined : ('k, _, _) t -> 'k Js.undefinedlet maxKeyUndefined: t('k, _, _) => Js.undefined('k);val minimum : ('k, 'a, _) t -> ('k * 'a) optionlet minimum: t('k, 'a, _) => option(('k, 'a));val minUndefined : ('k, 'a, _) t -> ('k * 'a) Js.undefinedlet minUndefined: t('k, 'a, _) => Js.undefined(('k, 'a));val maximum : ('k, 'a, _) t -> ('k * 'a) optionlet maximum: t('k, 'a, _) => option(('k, 'a));val maxUndefined : ('k, 'a, _) t -> ('k * 'a) Js.undefinedlet maxUndefined: t('k, 'a, _) => Js.undefined(('k, 'a));val get : ('k, 'a, 'id) t -> 'k -> 'a optionlet get: t('k, 'a, 'id) => 'k => option('a);val getUndefined : ('k, 'a, 'id) t -> 'k -> 'a Js.undefinedlet getUndefined: t('k, 'a, 'id) => 'k => Js.undefined('a);val getWithDefault : ('k, 'a, 'id) t -> 'k -> 'a -> 'alet getWithDefault: t('k, 'a, 'id) => 'k => 'a => 'a;val getExn : ('k, 'a, 'id) t -> 'k -> 'alet getExn: t('k, 'a, 'id) => 'k => 'a;val checkInvariantInternal : (_, _, _) t -> unitlet checkInvariantInternal: t(_, _, _) => unit;raise when invariant is not held
val remove : ('k, 'a, 'id) t -> 'k -> unitlet remove: t('k, 'a, 'id) => 'k => unit;remove m x do the in-place modification,
val removeMany : ('k, 'a, 'id) t -> 'k array -> unitlet removeMany: t('k, 'a, 'id) => array('k) => unit;val set : ('k, 'a, 'id) t -> 'k -> 'a -> unitlet set: t('k, 'a, 'id) => 'k => 'a => unit;set m x y do the in-place modification
val updateU :
('k, 'a, 'id) t ->
'k ->
('a option -> 'a option) Js.Fn.arity1 ->
unitlet updateU:
t('k, 'a, 'id) =>
'k =>
Js.Fn.arity1((option('a) => option('a))) =>
unit;val update : ('k, 'a, 'id) t -> 'k -> ('a option -> 'a option) -> unitlet update: t('k, 'a, 'id) => 'k => (option('a) => option('a)) => unit;val mergeMany : ('k, 'a, 'id) t -> ('k * 'a) array -> unitlet mergeMany: t('k, 'a, 'id) => array(('k, 'a)) => unit;val mapU : ('k, 'a, 'id) t -> ('a -> 'b) Js.Fn.arity1 -> ('k, 'b, 'id) tlet mapU: t('k, 'a, 'id) => Js.Fn.arity1(('a => 'b)) => t('k, 'b, 'id);val map : ('k, 'a, 'id) t -> ('a -> 'b) -> ('k, 'b, 'id) tlet map: t('k, 'a, 'id) => ('a => 'b) => t('k, 'b, 'id);map 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) tlet mapWithKeyU:
t('k, 'a, 'id) =>
Js.Fn.arity2(('k => 'a => 'b)) =>
t('k, 'b, 'id);val mapWithKey : ('k, 'a, 'id) t -> ('k -> 'a -> 'b) -> ('k, 'b, 'id) tlet mapWithKey: t('k, 'a, 'id) => ('k => 'a => 'b) => t('k, 'b, 'id);