description

# SplayTreeSet<E> constructor

SplayTreeSet<E>([

1. int compare(
   1. E key1,
   2. E key2
   )?,
2. bool isValidKey(
   1. dynamic
   )?

])

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 don'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`.

## Implementation

    SplayTreeSet([
      int Function(E key1, E key2)? compare,
      bool Function(dynamic potentialKey)? isValidKey,
    ]) : _compare = compare ?? _defaultCompare<E>(),
         _validKey = isValidKey;