SplayTreeSet([int compare(E key1, E key2), bool isValidKey(potentialKey) ])

Create a new SplayTreeSet with the given compare function.

If the compare function is omitted, it defaults to Comparable.compare, and the elements must be comparable.

A provided compare function may not work on all objects. It may not even work on all E instances.

For operations that add elements to the set, the user is supposed to not pass in objects that doesn't work with the compare function.

The methods contains, remove, lookup, removeAll or retainAll are typed to accept any object(s), and the isValidKey test can used to filter those objects before handing them to the compare function.

If isValidKey is provided, only values satisfying isValidKey(other) are compared using the compare method in the methods mentioned above. If the isValidKey function returns false for an object, it is assumed to not be in the set.

If omitted, the isValidKey function defaults to checking against the type parameter: other is E.

Source

SplayTreeSet([int compare(E key1, E key2), bool isValidKey(potentialKey)])
    : _comparator = compare ?? _defaultCompare<E>(),
      _validKey = isValidKey ?? ((v) => v is E);