countBy method

Map<T, int> countBy()

Map of element to occurrence count.

Implementation

Map<T, int> countBy() {
  final Map<T, int> out = <T, int>{};
  for (final T e in this) {
    out[e] = (out[e] ?? 0) + 1;
  }
  return out;
}