swap method

void swap(
  1. HashSet<T> other
)

Exchanges the contents of this set with those of other.

Implementation

void swap(HashSet<T> other) {
  final temp = _container.toSet();
  _container.clear();
  _container.addAll(other._container);
  other._container.clear();
  other._container.addAll(temp);
}