You are currently looking at the v6.0 - v8.2 docs (Reason v3.6 syntax edition). You can find the latest API docs here.
(These docs cover all versions between v3 to v8 and are equivalent to the old BuckleScript docs before the rebrand)
MutableMap
A mutable sorted map module which allows customize compare behavior.
Same as Belt.Map
, but mutable.
t
REtype t('k, 'v, 'id);
id
REtype id('key, 'id) = Belt_Id.comparable('key, 'id);
make
RElet make: (~id: id('k, 'id)) => t('k, 'a, 'id);
clear
RElet clear: t('a, 'b, 'c) => unit;
isEmpty
RElet isEmpty: t('a, 'b, 'c) => bool;
has
RElet has: (t('k, 'a, 'b), 'k) => bool;
cmpU
RElet cmpU: (t('k, 'a, 'id), t('k, 'a, 'id), [@bs] (('a, 'a) => int)) => int;
cmp
RElet 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
RElet eqU: (t('k, 'a, 'id), t('k, 'a, 'id), [@bs] (('a, 'a) => bool)) => bool;
eq
RElet 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
RElet forEachU: (t('k, 'a, 'id), [@bs] (('k, 'a) => unit)) => unit;
forEach
RElet 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
RElet reduceU: (t('k, 'a, 'id), 'b, [@bs] (('b, 'k, 'a) => 'b)) => 'b;
reduce
RElet 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
RElet everyU: (t('k, 'a, 'id), [@bs] (('k, 'a) => bool)) => bool;
every
RElet 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
RElet someU: (t('k, 'a, 'id), [@bs] (('k, 'a) => bool)) => bool;
some
RElet 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
RElet size: t('k, 'a, 'id) => int;
toList
RElet toList: t('k, 'a, 'id) => list(('k, 'a));
In increasing order.
toArray
RElet toArray: t('k, 'a, 'id) => array(('k, 'a));
fromArray
RElet fromArray: (array(('k, 'a)), ~id: id('k, 'id)) => t('k, 'a, 'id);
keysToArray
RElet keysToArray: t('k, 'a, 'b) => array('k);
valuesToArray
RElet valuesToArray: t('b, 'a, 'c) => array('a);
minKey
RElet minKey: t('k, 'a, 'b) => option('k);
minKeyUndefined
RElet minKeyUndefined: t('k, 'a, 'b) => Js.undefined('k);
maxKey
RElet maxKey: t('k, 'a, 'b) => option('k);
maxKeyUndefined
RElet maxKeyUndefined: t('k, 'a, 'b) => Js.undefined('k);
minimum
RElet minimum: t('k, 'a, 'b) => option(('k, 'a));
minUndefined
RElet minUndefined: t('k, 'a, 'b) => Js.undefined(('k, 'a));
maximum
RElet maximum: t('k, 'a, 'b) => option(('k, 'a));
maxUndefined
RElet maxUndefined: t('k, 'a, 'b) => Js.undefined(('k, 'a));
get
RElet get: (t('k, 'a, 'id), 'k) => option('a);
getUndefined
RElet getUndefined: (t('k, 'a, 'id), 'k) => Js.undefined('a);
getWithDefault
RElet getWithDefault: (t('k, 'a, 'id), 'k, 'a) => 'a;
getExn
RElet getExn: (t('k, 'a, 'id), 'k) => 'a;
checkInvariantInternal
RElet checkInvariantInternal: t('a, 'b, 'c) => unit;
Raise when invariant is not held.
remove
RElet remove: (t('k, 'a, 'id), 'k) => unit;
remove(m, x)
do the in-place modification.
removeMany
RElet removeMany: (t('k, 'a, 'id), array('k)) => unit;
set
RElet set: (t('k, 'a, 'id), 'k, 'a) => unit;
set(m, x, y)
do the in-place modification
updateU
RElet updateU: (t('k, 'a, 'id), 'k, [@bs] (option('a) => option('a))) => unit;
update
RElet update: (t('k, 'a, 'id), 'k, option('a) => option('a)) => unit;
mergeMany
RElet mergeMany: (t('k, 'a, 'id), array(('k, 'a))) => unit;
mapU
RElet mapU: (t('k, 'a, 'id), [@bs] ('a => 'b)) => t('k, 'b, 'id);
map
RElet 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
RElet mapWithKeyU: (t('k, 'a, 'id), [@bs] (('k, 'a) => 'b)) => t('k, 'b, 'id);
mapWithKey
RElet mapWithKey: (t('k, 'a, 'id), ('k, 'a) => 'b) => t('k, 'b, 'id);