diff --git a/runtime/src/main/kotlin/kotlin/collections/Grouping.kt b/runtime/src/main/kotlin/kotlin/collections/Grouping.kt index 1c4064b38b6..b77f3b6587f 100644 --- a/runtime/src/main/kotlin/kotlin/collections/Grouping.kt +++ b/runtime/src/main/kotlin/kotlin/collections/Grouping.kt @@ -235,6 +235,15 @@ public inline fun > Grouping.reduceTo if (first) e else operation(key, acc as S, e) } +/** + * Groups elements from the [Grouping] source by key and counts elements in each group. + * + * @return a [Map] associating the key of each group with the count of elements in the group. + * + * @sample samples.collections.Collections.Transformations.groupingByEachCount + */ +@SinceKotlin("1.1") +public fun Grouping.eachCount(): Map = eachCountTo(mutableMapOf()) /** * Groups elements from the [Grouping] source by key and counts elements in each group to the given [destination] map.