the SortedSet element type
the Comparator to use for sorting the values
Optional values: Iterable<T>optional Array of sorted and unique values for initialization
Private Readonly #comparatorPrivate Readonly #valuesSet[Symbol.toStringTag]
the number of elements in this SortedSet
Set[Symbol.iterator]
Adds values to this SortedSet if it does not already contain equal
values. Values are considered equal if the Comparator returns 0.
Add values
const sortedSet = new SortedSet(numberComparator);
sortedSet.add(2);
sortedSet.add(0);
sortedSet.add(new SortedSet(numberComparator, [1, 2, 3]));
console.log([...sortedSet.values()]); // [0, 1, 2, 3]
this
Removes all elements from this SortedSet.
Removes values from this SortedSet if it does contain equal values.
Values are considered equal if the Comparator returns 0.
Remove values
const sortedSet = new SortedSet(numberComparator, [1, 2, 3, 4, 5]);
sortedSet.delete(new SortedSet(numberComparator, [0, 1, 2, 5]))
console.log([...sortedSet.values()]); // [3, 4]
true if this SortedSet has ben modified, otherwise false
Set.entries
Checks if this SortedSet contains all of the values.
Does the set contain 1 and 2?
const sortedSet = new SortedSet(numberComparator, [1, 2, 3]);
const result = sortedSet.has(new SortedSet(numberComparator, [1, 2]));
console.log(result); // true
true if this SortedSet contains all of the values, otherwise false
Set.keys
an Iterable of the values of this SortedSet.
Generated using TypeDoc
A SortedSet uses a Comparator for sorting the values and checking for equality.
Example
Add, delete and iterate