Belt_MutableMap
undefined
module Int = Belt_MutableMapInt
undefined
module String = Belt_MutableMapString
t
type t<'k, 'v, 'id>
id
type id<'key, 'id> = Belt_Id.comparable<'key, 'id>
make
let make: (~id: id<'k, 'id>) => t<'k, 'a, 'id>
clear
let clear: t<'a, 'b, 'c> => unit
isEmpty
let isEmpty: t<'a, 'b, 'c> => bool
has
let has: (t<'k, 'a, 'b>, 'k) => bool
cmpU
let cmpU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, (. 'a, 'a) => int) => int
cmp
cmp(m1, m2, cmp)
First compare by size, if size is the same, compare by
key, value pair.
let cmp: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => int) => int
eqU
let eqU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, (. 'a, 'a) => bool) => bool
eq
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.
let eq: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => bool) => bool
forEachU
let forEachU: (t<'k, 'a, 'id>, (. 'k, 'a) => unit) => unit
forEach
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.
let forEach: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unit
reduceU
let reduceU: (t<'k, 'a, 'id>, 'b, (. 'b, 'k, 'a) => 'b) => 'b
reduce
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.
let reduce: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'b
everyU
let everyU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => bool
every
every(m, p)
checks if all the bindings of the map satisfy the predicate
p
.
let every: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool
someU
let someU: (t<'k, 'a, 'id>, (. 'k, 'a) => bool) => bool
some
some(m, p)
checks if at least one binding of the map satisfy the
predicate p
.
let some: (t<'k, 'a, 'id>, ('k, 'a) => bool) => bool
size
let size: t<'k, 'a, 'id> => int
toList
In increasing order.
let toList: t<'k, 'a, 'id> => list<('k, 'a)>
toArray
let toArray: t<'k, 'a, 'id> => array<('k, 'a)>
fromArray
let fromArray: (array<('k, 'a)>, ~id: id<'k, 'id>) => t<'k, 'a, 'id>
keysToArray
let keysToArray: t<'k, 'a, 'b> => array<'k>
valuesToArray
let valuesToArray: t<'a, 'a0, 'b> => array<'a0>
minKey
let minKey: t<'k, 'a, 'b> => option<'k>
minKeyUndefined
let minKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k>
maxKey
let maxKey: t<'k, 'a, 'b> => option<'k>
maxKeyUndefined
let maxKeyUndefined: t<'k, 'a, 'b> => Js.undefined<'k>
minimum
let minimum: t<'k, 'a, 'b> => option<('k, 'a)>
minUndefined
let minUndefined: t<'k, 'a, 'b> => Js.undefined<('k, 'a)>
maximum
let maximum: t<'k, 'a, 'b> => option<('k, 'a)>
maxUndefined
let maxUndefined: t<'k, 'a, 'b> => Js.undefined<('k, 'a)>
get
let get: (t<'k, 'a, 'id>, 'k) => option<'a>
getUndefined
let getUndefined: (t<'k, 'a, 'id>, 'k) => Js.undefined<'a>
getWithDefault
let getWithDefault: (t<'k, 'a, 'id>, 'k, 'a) => 'a
getExn
let getExn: (t<'k, 'a, 'id>, 'k) => 'a
checkInvariantInternal
Raise when invariant is not held.
let checkInvariantInternal: t<'a, 'b, 'c> => unit
remove
remove(m, x)
do the in-place modification.
let remove: (t<'k, 'a, 'id>, 'k) => unit
removeMany
let removeMany: (t<'k, 'a, 'id>, array<'k>) => unit
set
set(m, x, y)
do the in-place modification
let set: (t<'k, 'a, 'id>, 'k, 'a) => unit
updateU
let updateU: (t<'k, 'a, 'id>, 'k, (. option<'a>) => option<'a>) => unit
update
let update: (t<'k, 'a, 'id>, 'k, option<'a> => option<'a>) => unit
mergeMany
let mergeMany: (t<'k, 'a, 'id>, array<('k, 'a)>) => unit
mapU
let mapU: (t<'k, 'a, 'id>, (. 'a) => 'b) => t<'k, 'b, 'id>
map
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.
let map: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id>
mapWithKeyU
let mapWithKeyU: (t<'k, 'a, 'id>, (. 'k, 'a) => 'b) => t<'k, 'b, 'id>
mapWithKey
let mapWithKey: (t<'k, 'a, 'id>, ('k, 'a) => 'b) => t<'k, 'b, 'id>