collections/multi_key_group_utils library

Group and aggregate by several keys at once — roadmap #477.

Classes

MultiKey
A composite grouping key built from several selector values.

Functions

aggregateByKeys<T, R>(Iterable<T> items, List<Object? Function(T)> keys, R aggregator(List<T> group)) Map<MultiKey, R>
Groups items by keys and reduces each bucket with aggregator, returning a map from composite key to the aggregate (e.g. a count, sum, or average per (country, year)).
groupByKeys<T>(Iterable<T> items, List<Object? Function(T)> keys) Map<MultiKey, List<T>>
Groups items by applying every selector in keys, bucketing rows whose composite key is equal. Returns a map from MultiKey to the list of items in that bucket, in first-seen insertion order.