Belt_MapString
let empty: t('v);
let isEmpty: t('v) => bool;
let cmpU: t('v) => t('v) => Js.Fn.arity2(('v => 'v => int)) => int;
let eqU: t('v) => t('v) => Js.Fn.arity2(('v => 'v => bool)) => bool;
eq m1 m2
tests whether the maps m1
and m2
are equal, that is, contain equal keys and associate them with equal data.
let findFirstByU:
t('v) =>
Js.Fn.arity2((key => 'v => bool)) =>
option((key, 'v));
findFirstBy m p
uses funcion f
to find the first key value pair to match predicate p
.
let s0 = fromArray ~id:(module IntCmp) [|4,"4";1,"1";2,"2,"3""|];;
findFirstBy s0 (fun k v -> k = 4 ) = option (4, "4");;
let forEachU: t('v) => Js.Fn.arity2((key => 'v => unit)) => unit;
forEach m f
applies f
to all bindings in map m
. f
receives the key 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 reduceU: t('v) => 'v2 => Js.Fn.arity3(('v2 => key => 'v => 'v2)) => 'v2;
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.
let everyU: t('v) => Js.Fn.arity2((key => 'v => bool)) => bool;
every m p
checks if all the bindings of the map satisfy the predicate p
. Order unspecified
let someU: t('v) => Js.Fn.arity2((key => 'v => bool)) => bool;
some m p
checks if at least one binding of the map satisfy the predicate p
. Order unspecified
let size: t('v) => int;
let valuesToArray: t('v) => array('v);
let minKeyUndefined: t(_) => Js.undefined(key);
let maxKeyUndefined: t(_) => Js.undefined(key);
let minUndefined: t('v) => Js.undefined((key, 'v));
let maxUndefined: t('v) => Js.undefined((key, 'v));
let getUndefined: t('v) => key => Js.undefined('v);
let checkInvariantInternal: t(_) => unit;
raise when invariant is not held
remove m x
returns a map containing the same bindings as m
, except for x
which is unbound in the returned map.
set m x y
returns a map containing the same bindings as m
, plus a binding of x
to y
. If x
was already bound in m
, its previous binding disappears.
let updateU: t('v) => key => Js.Fn.arity1((option('v) => option('v))) => t('v);
let mergeU:
t('v) =>
t('v2) =>
Js.Fn.arity3((key => option('v) => option('v2) => option('c))) =>
t('c);
merge m1 m2 f
computes a map whose keys is a subset of keys of m1
and of m2
. The presence of each such binding, and the corresponding value, is determined with the function f
.
let keepU: t('v) => Js.Fn.arity2((key => 'v => bool)) => t('v);
keep m p
returns the map with all the bindings in m
that satisfy predicate p
.
let partitionU: t('v) => Js.Fn.arity2((key => 'v => bool)) => (t('v), t('v));
partition m p
returns a pair of maps (m1, m2)
, where m1
contains all the bindings of s
that satisfy the predicate p
, and m2
is the map with all the bindings of s
that do not satisfy p
.
split x m
returns a triple (l, data, r)
, where l
is the map with all the bindings of m
whose key is strictly less than x
; r
is the map with all the bindings of m
whose key is strictly greater than x
; data
is None
if m
contains no binding for x
, or Some v
if m
binds v
to x
.
let mapU: t('v) => Js.Fn.arity1(('v => 'v2)) => t('v2);
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 mapWithKeyU: t('v) => Js.Fn.arity2((key => 'v => 'v2)) => t('v2);