addAll method

  1. @override
void addAll(
  1. TTMultiMap<V> other
)
inherited

Add all key/value pairs from other.

Note: keyMapping is applied to all incoming keys so keys may be altered or skipped during copying from other.

Depending on characteristics of values collection type operation may or may not change this instance. For example if this instance holds values in a Set then it may not be updated if value already exists.

Implementation

@override
void addAll(TTMultiMap<V> other) {
  ArgumentError.checkNotNull(other, 'other');
  final keyItr = other.keys.iterator as InOrderKeyIterator<V>;

  var newKey = false;
  while (keyItr.moveNext()) {
    final key = _mapKey(keyItr.currentKey);
    // Keys from other may not map usefully to key domain of this.
    if (key.isNotEmpty) {
      newKey |= _addIterable(key.runes.toList(), keyItr.currentValue);
    }
  }

  if (newKey) {
    _version.value.incKeysVersion();
  }

  // Lot of work to determine if value change has occured so just assume it has
  _version.value.incValuesVersion();
}