Module Belt.MutableSet

Belt.MutableSet

The top level provides generic mutable set operations.

It also has two specialized inner modules Belt.MutableSet.Int and Belt.MutableSet.String

A mutable sorted set module which allows customize compare behavior.

Same as Belt.Set, but mutable.

module Int: { ... };

Specalized when key type is int, more efficient than the generic type

module String: { ... };

Specalized when key type is string, more efficient than the generic type

type t('k, 'id);
type id('k, 'id) = (module Belt__.Belt_Id.Comparable with type identity = 'id and type t = 'k);
let make: id:id('value, 'id) => t('value, 'id);
let fromArray: array('k) => id:id('k, 'id) => t('k, 'id);
let fromSortedArrayUnsafe: array('value) => id:id('value, 'id) => t('value, 'id);
let copy: t('k, 'id) => t('k, 'id);
let isEmpty: t(_, _) => bool;
let has: t('value, _) => 'value => bool;
let add: t('value, 'id) => 'value => unit;
let addCheck: t('value, 'id) => 'value => bool;
let mergeMany: t('value, 'id) => array('value) => unit;
let remove: t('value, 'id) => 'value => unit;
let removeCheck: t('value, 'id) => 'value => bool;
let removeMany: t('value, 'id) => array('value) => unit;
let union: t('value, 'id) => t('value, 'id) => t('value, 'id);
let intersect: t('value, 'id) => t('value, 'id) => t('value, 'id);
let diff: t('value, 'id) => t('value, 'id) => t('value, 'id);
let subset: t('value, 'id) => t('value, 'id) => bool;
let cmp: t('value, 'id) => t('value, 'id) => int;
let eq: t('value, 'id) => t('value, 'id) => bool;
let forEachU: t('value, 'id) => Js.Fn.arity1(('value => unit)) => unit;
let forEach: t('value, 'id) => ('value => unit) => unit;

forEach m f applies f in turn to all elements of m. In increasing order

let reduceU: t('value, 'id) => 'a => Js.Fn.arity2(('a => 'value => 'a)) => 'a;
let reduce: t('value, 'id) => 'a => ('a => 'value => 'a) => 'a;

In increasing order.

let everyU: t('value, 'id) => Js.Fn.arity1(('value => bool)) => bool;
let every: t('value, 'id) => ('value => bool) => bool;

every s p checks if all elements of the set satisfy the predicate p. Order unspecified

let someU: t('value, 'id) => Js.Fn.arity1(('value => bool)) => bool;
let some: t('value, 'id) => ('value => bool) => bool;

some p s checks if at least one element of the set satisfies the predicate p.

let keepU: t('value, 'id) => Js.Fn.arity1(('value => bool)) => t('value, 'id);
let keep: t('value, 'id) => ('value => bool) => t('value, 'id);

keep s p returns the set of all elements in s that satisfy predicate p.

let partitionU: t('value, 'id) => Js.Fn.arity1(('value => bool)) => (t('value, 'id), t('value, 'id));
let partition: t('value, 'id) => ('value => bool) => (t('value, 'id), t('value, 'id));

partition p s returns a pair of sets (s1, s2), where s1 is the set of all the elements of s that satisfy the predicate p, and s2 is the set of all the elements of s that do not satisfy p.

let size: t('value, 'id) => int;
let toList: t('value, 'id) => list('value);

In increasing order

let toArray: t('value, 'id) => array('value);

In increasing order

let minimum: t('value, 'id) => option('value);
let minUndefined: t('value, 'id) => Js.undefined('value);
let maximum: t('value, 'id) => option('value);
let maxUndefined: t('value, 'id) => Js.undefined('value);
let get: t('value, 'id) => 'value => option('value);
let getUndefined: t('value, 'id) => 'value => Js.undefined('value);
let getExn: t('value, 'id) => 'value => 'value;
let split: t('value, 'id) => 'value => ((t('value, 'id), t('value, 'id)), bool);

split s x returns a triple ((l, r), present), where l is the set of elements of s that are strictly less than x; r is the set of elements of s that are strictly greater than x; present is false if s contains no element equal to x, or true if s contains an element equal to x. l,r are freshly made, no sharing with s

let checkInvariantInternal: t(_, _) => unit;

raise when invariant is not held