SplayTreeSet<E>.of constructor Null safety

SplayTreeSet<E>.of(
  1. Iterable<E> elements,
  2. [int compare(
    1. E key1,
    2. E key2
    )?,
  3. bool isValidKey(
    1. dynamic potentialKey
    )?]
)

Creates a SplayTreeSet from elements.

The set works as if created by new SplayTreeSet<E>(compare, isValidKey).

All the elements should be valid as arguments to the compare function. Example:

final baseSet = <int>{1, 2, 3};
final setOf = SplayTreeSet<num>.of(baseSet);
print(setOf); // {1, 2, 3}

Implementation

factory SplayTreeSet.of(Iterable<E> elements,
        [int Function(E key1, E key2)? compare,
        bool Function(dynamic potentialKey)? isValidKey]) =>
    SplayTreeSet(compare, isValidKey)..addAll(elements);