countBy method
Map of element to occurrence count, in first-seen order.
All double.nan values are counted under a single NaN key.
Audited: 2026-06-12 11:26 EDT
Implementation
Map<T, int> countBy() =>
// The shared counter is used because a default map gives each NaN its own
// unreachable key, which makes the returned map's `entries` throw.
frequencyMapOf<T>(this);