MutableMap
The top level provides generic mutable map operations.
It also has two specialized inner modules
Belt.MutableMap.Int and Belt.MutableMap.String
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> => unitisEmpty
let isEmpty: t<'a, 'b, 'c> => boolhas
let has: (t<'k, 'a, 'b>, 'k) => boolcmpU
Deprecated
Use cmp instead
let cmpU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => int) => intcmp
let cmp: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => int) => intcmp(m1, m2, cmp) First compare by size, if size is the same, compare by
key, value pair.
eqU
Deprecated
Use eq instead
let eqU: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => bool) => booleq
let eq: (t<'k, 'a, 'id>, t<'k, 'a, 'id>, ('a, 'a) => bool) => booleq(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
Deprecated
Use forEach instead
let forEachU: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unitforEach
let forEach: (t<'k, 'a, 'id>, ('k, 'a) => unit) => unitforEach(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
Deprecated
Use reduce instead
let reduceU: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'breduce
let reduce: (t<'k, 'a, 'id>, 'b, ('b, 'k, 'a) => 'b) => 'breduce(m, a, f), computes(f(kN, dN) ... (f(k1, d1, a))...), wherek1 ...
kNare the keys of all bindings inm(in increasing order), andd1 ... dN`
are the associated data.
everyU
Deprecated
Use every instead
let everyU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => boolevery
let every: (t<'k, 'a, 'id>, ('k, 'a) => bool) => boolevery(m, p) checks if all the bindings of the map satisfy the predicate p.
someU
Deprecated
Use some instead
let someU: (t<'k, 'a, 'id>, ('k, 'a) => bool) => boolsome
let some: (t<'k, 'a, 'id>, ('k, 'a) => bool) => boolsome(m, p) checks if at least one binding of the map satisfy the predicate p.
size
let size: t<'k, 'a, 'id> => inttoList
let toList: t<'k, 'a, 'id> => list<('k, 'a)>In increasing order.
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<'b, 'a, 'c> => array<'a>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) => 'agetExn
let getExn: (t<'k, 'a, 'id>, 'k) => 'agetOrThrow
let getOrThrow: (t<'k, 'a, 'id>, 'k) => 'acheckInvariantInternal
let checkInvariantInternal: t<'a, 'b, 'c> => unitThrow when invariant is not held.
remove
let remove: (t<'k, 'a, 'id>, 'k) => unitremove(m, x) do the in-place modification.
removeMany
let removeMany: (t<'k, 'a, 'id>, array<'k>) => unitset
let set: (t<'k, 'a, 'id>, 'k, 'a) => unitset(m, x, y) do the in-place modification
updateU
Deprecated
Use update instead
let updateU: (t<'k, 'a, 'id>, 'k, option<'a> => option<'a>) => unitupdate
let update: (t<'k, 'a, 'id>, 'k, option<'a> => option<'a>) => unitmergeMany
let mergeMany: (t<'k, 'a, 'id>, array<('k, 'a)>) => unitmapU
Deprecated
Use map instead
let mapU: (t<'k, 'a, 'id>, 'a => 'b) => t<'k, 'b, 'id>map
let 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
Deprecated
Use mapWithKey instead
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>