Set
Edit on GitHubA Set is an unordered collection of unique values. Operations on a Set
mutate the internal state, so it never needs to be re-assigned.
Values
Set.make
Creates a new, empty set.
Set.makeSized
Creates a new, empty set with an initial storage size for the given number of elements.
Set.add
Adds a new value to the set. If the value already exists, nothing happens.
Set.contains
Returns true
if the set contains the given value.
Set.remove
Removes the given value from the set.
Set.size
Returns the number of values within the set.
Set.isEmpty
Returns true
if the set contains no values.
Set.clear
Removes all values from the set.
Set.forEach
Iterates the given function over each value in the set.
Set.reduce
Reduces all values within a set to a single value. The reducer function is called with the accumulator and the current value.
Set.toList
Returns a list from the values of a set.
Set.fromList
Creates a set from a list.
Set.toArray
Returns an array from the values of a set.
Set.fromArray
Creates a set from an array.
Set.filter
Keeps all values that the predicate returned true
for from the set.
Set.reject
Removes all values that the predicate returned true
for from the set.
Set.union
Creates a set from the union of the given sets.
Set.intersect
Creates a set from the intersection of the given sets.
Set.diff
Creates a set from the difference of the given sets.