swap method

void swap(
  1. MultiSet<T> other
)

Exchanges the contents of this set with those of other.

Implementation

void swap(MultiSet<T> other) {
  final temp = Map<T, int>.of(_container);
  final tempSize = _size;

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

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