operator []= method

  1. @override
void operator []=(
  1. V key,
  2. K value
)
override

Associates the key with the given value.

If the key was already in the map, its associated value is changed. Otherwise the key/value pair is added to the map.

Implementation

@override
void operator []=(V key, K value) {
  // ignore: collection_methods_unrelated_type
  var prev = _dualWeakMap._mapValues[_EntryKey<V, K>(key)];
  if (prev != null) {
    // Only modify if different:
    if (prev.payload != value) {
      _dualWeakMap._mapValues.remove(prev);
      _dualWeakMap._map.remove(prev.keyEntry);
      _dualWeakMap.put(value, key);
    }
    return;
  }

  _dualWeakMap.put(value, key);
}