swap method

void swap(
  1. MultiMap<K, V> other
)

Exchanges the contents of this map with those of other.

Implementation

void swap(MultiMap<K, V> other) {
  final temp = Map<K, List<V>>.of(_container);
  final tempSize = _size;

  _container.clear();
  _container.addAll(other._container);
  _size = other._size;

  other._container.clear();
  other._container.addAll(temp);
  other._size = tempSize;
}