add method

void add(
  1. T element, [
  2. int count = 1
])

Adds element is not specified, adds the element once.

If count is not specified, adds the element once.

Example:

final ms = MultiSet<String>();
ms.add('a', 3);
print(ms.multiplicity('a')); // Output: 3

Implementation

void add(T element, [int count = 1]) {
  if (count <= 0) return;
  _elements[element] = (_elements[element] ?? 0) + count;
}