Map of element to occurrence count. Audited: 2026-06-12 11:26 EDT
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; }