MutableMap
A mutable sorted map module which allows customize compare behavior.
Same as Belt.Map
, but mutable.
t
REStype t<'k, 'v, 'id>
id
REStype id<'key, 'id> = Belt_Id.comparable<'key, 'id>
make
RESlet make: (~id: id<'k, 'id>) => t<'k, 'a, 'id>
clear
RESlet clear: t<'a, 'b, 'c> => unit
isEmpty
RESlet isEmpty: t<'a, 'b, 'c> => bool
has
RESlet has: (t<'k, 'a, 'b>, 'k) => bool
cmpU
RESlet cmpU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, (. 'a, 'a) => int) => int
cmp
RESlet 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.
eqU
RESlet eqU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, (. 'a, 'a) => bool) => bool
eq
RESlet 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.
forEachU
RESlet forEachU: (t<'k, 'a, 'id>, (. 'k, 'a) => unit) => unit
forEach
RESlet 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.
reduceU
RESlet reduceU: (t<'k, 'a, 'id>, 'b, (. 'b, 'k, 'a) => 'b) => 'b
reduce
RESlet 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 ... kNare the keys of all bindings in
m(in increasing order), and
d1 ... dN` are the associated data.
everyU
RESlet everyU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => bool
every
RESlet every: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool
every(m, p)
checks if all the bindings of the map satisfy the predicate p
.
someU
RESlet someU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => bool
some
RESlet 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
.
size
RESlet size: t<'k, 'a, 'id> => int
toList
RESlet toList: t<'k, 'a, 'id> => list<('k, 'a)>
In increasing order.
toArray
RESlet toArray: t<'k, 'a, 'id> => array<('k, 'a)>
fromArray
RESlet fromArray: (array<('k, 'a)>, ~id: id<'k, 'id>) => t<'k, 'a, 'id>
keysToArray
RESlet keysToArray: t<'k, 'a, 'b> => array<'k>
valuesToArray
RESlet valuesToArray: t<'b, 'a, 'c> => array<'a>
minKey
RESlet minKey: t<'k, 'a, 'b> => option<'k>
minKeyUndefined
RESlet minKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k>
maxKey
RESlet maxKey: t<'k, 'a, 'b> => option<'k>
maxKeyUndefined
RESlet maxKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k>
minimum
RESlet minimum: t<'k, 'a, 'b> => option<('k, 'a)>
minUndefined
RESlet minUndefined: t<'k, 'a, 'b> => Js.undefined<('k, 'a)>
maximum
RESlet maximum: t<'k, 'a, 'b> => option<('k, 'a)>
maxUndefined
RESlet maxUndefined: t<'k, 'a, 'b> => Js.undefined<('k, 'a)>
get
RESlet get: (t<'k, 'a, 'id>, 'k) => option<'a>
getUndefined
RESlet getUndefined: (t<'k, 'a, 'id>, 'k) => Js.undefined<'a>
getWithDefault
RESlet getWithDefault: (t<'k, 'a, 'id>, 'k, 'a) => 'a
getExn
RESlet getExn: (t<'k, 'a, 'id>, 'k) => 'a
checkInvariantInternal
RESlet checkInvariantInternal: t<'a, 'b, 'c> => unit
Raise when invariant is not held.
remove
RESlet remove: (t<'k, 'a, 'id>, 'k) => unit
remove(m, x)
do the in-place modification.
removeMany
RESlet removeMany: (t<'k, 'a, 'id>, array<'k>) => unit
set
RESlet set: (t<'k, 'a, 'id>, 'k, 'a) => unit
set(m, x, y)
do the in-place modification
updateU
RESlet updateU: (t<'k, 'a, 'id>, 'k, (. option<'a>) => option<'a>) => unit
update
RESlet update: (t<'k, 'a, 'id>, 'k, option<'a> => option<'a>) => unit
mergeMany
RESlet mergeMany: (t<'k, 'a, 'id>, array<('k, 'a)>) => unit
mapU
RESlet mapU: (t<'k, 'a, 'id>, (. 'a) => 'b) => t<'k, 'b, 'id>
map
RESlet 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.
mapWithKeyU
RESlet mapWithKeyU: (t<'k, 'a, 'id>, (. 'k, 'a) => 'b) => t<'k, 'b, 'id>
mapWithKey
RESlet mapWithKey: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id>