groupByTo
inline fun <T, K, M : MutableMap<in K, MutableList<T>>> Sequence<T>.groupByTo(destination: M, keySelector: (T) -> K): M(source)
Groups elements of the original sequence by the key returned by the given keySelector function applied to each element and puts to the destination map each group key associated with a list of corresponding elements.
Since Kotlin
1.0Return
The destination map.
The operation is terminal.
Samples
inline fun <T, K, V, M : MutableMap<in K, MutableList<V>>> Sequence<T>.groupByTo( destination: M, keySelector: (T) -> K, valueTransform: (T) -> V): M(source)
Groups values returned by the valueTransform function applied to each element of the original sequence by the key returned by the given keySelector function applied to the element and puts to the destination map each group key associated with a list of corresponding values.
Since Kotlin
1.0Return
The destination map.
The operation is terminal.