withBase method

void withBase(
  1. _MapFactory<K, V> base
)

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

// Iterates over elements in ascending order.
new MapBuilder<int, String>()
  ..withBase(() => new SplayTreeMap<int, String>());

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

The map returned by base must be empty, mutable, and each call must instantiate and return a new object.

Use withDefaultBase to reset base to the default value.

Implementation

void withBase(_MapFactory<K, V> base) {
  ArgumentError.checkNotNull(base, 'base');
  _mapFactory = base;
  _setSafeMap(_createMap()..addAll(_map));
}