Int
This module is Belt.Set specialized with value type to be a primitive type.
It is more efficient in general, the API is the same with Belt_Set except its value type is fixed,
and identity is not needed(using the built-in one)
See Belt.Set
value
type value = intThe type of the set elements.
t
type tThe type of sets.
empty
let empty: tfromArray
let fromArray: array<value> => tfromSortedArrayUnsafe
let fromSortedArrayUnsafe: array<value> => tisEmpty
let isEmpty: t => boolhas
let has: (t, value) => booladd
let add: (t, value) => tadd(s, x) If x was already in s, s is returned unchanged.
mergeMany
let mergeMany: (t, array<value>) => tremove
let remove: (t, value) => tremove(m, x) If x was not in m, m is returned reference unchanged.
removeMany
let removeMany: (t, array<value>) => tunion
let union: (t, t) => tintersect
let intersect: (t, t) => tdiff
let diff: (t, t) => tsubset
let subset: (t, t) => boolsubset(s1, s2) tests whether the set s1 is a subset of the set s2.
cmp
let cmp: (t, t) => intTotal ordering between sets. Can be used as the ordering function for doing sets of sets.
eq
let eq: (t, t) => booleq(s1, s2) tests whether the sets s1 and s2 are equal, that is, contain
equal elements.
forEachU
let forEachU: (t, value => unit) => unitforEach
let forEach: (t, value => unit) => unitforEach(s, f) applies f in turn to all elements of s. In increasing order
reduceU
let reduceU: (t, 'a, ('a, value) => 'a) => 'areduce
let reduce: (t, 'a, ('a, value) => 'a) => 'aIterate in increasing order.
everyU
let everyU: (t, value => bool) => boolevery
let every: (t, value => bool) => boolevery(p, s) checks if all elements of the set satisfy the predicate p. Order
unspecified.
someU
let someU: (t, value => bool) => boolsome
let some: (t, value => bool) => boolsome(p, s) checks if at least one element of the set satisfies the predicate
p. Oder unspecified.
keepU
let keepU: (t, value => bool) => tkeep
let keep: (t, value => bool) => tkeep(p, s) returns the set of all elements in s that satisfy predicate p.
partitionU
let partitionU: (t, value => bool) => (t, t)partition
let partition: (t, value => bool) => (t, t)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.
size
let size: t => inttoList
let toList: t => list<value>In increasing order
toArray
let toArray: t => array<value>minimum
let minimum: t => option<value>minUndefined
let minUndefined: t => Js.undefined<value>maximum
let maximum: t => option<value>maxUndefined
let maxUndefined: t => Js.undefined<value>get
let get: (t, value) => option<value>getUndefined
let getUndefined: (t, value) => Js.undefined<value>getExn
let getExn: (t, value) => valuesplit
let split: (t, value) => ((t, t), bool)split(x, s) returns a triple (l, present, r), 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.
checkInvariantInternal
let checkInvariantInternal: t => unitraise when invariant is not held