withBase method

void withBase(
  1. _SetFactory<E> base
)

Uses base as the collection type for all sets created by this builder.

// Iterates over elements in ascending order.
new SetBuilder<int>()..withBase(() => new SplayTreeSet<int>());

// Uses custom equality.
new SetBuilder<int>()..withBase(() => new LinkedHashSet<int>(
    equals: (int a, int b) => a % 255 == b % 255,
    hashCode: (int n) => (n % 255).hashCode));

The set returned by base must be empty, mutable, and each call must instantiate and return a new object. The methods difference, intersection and union of the returned set must create sets of the same type.

Use withDefaultBase to reset base to the default value.

Implementation

void withBase(_SetFactory<E> base) {
  ArgumentError.checkNotNull(base, 'base');
  _setFactory = base;
  _setSafeSet(_createSet()..addAll(_set));
}