Multiset<E>.of constructor

Multiset<E>.of(
  1. Iterable<E> other
)

Creates a Multiset that contains all elements of other.

Implementation

factory Multiset.of(Iterable<E> other) {
  if (other is Multiset<E>) {
    return Multiset<E>._(Map.of(other._container), other._length);
  } else if (other is Set<E>) {
    return Multiset<E>._(
        Map.fromIterables(other, repeat(1, count: other.length)),
        other.length);
  } else {
    return Multiset<E>()..addAll(other);
  }
}