groupByTo

inline fun <E : Any, K, M : MutableMap<in K, MutableList<E>>> EntitySequence<E, *>.groupByTo(destination: M, keySelector: (E) -> K): M(source)

Group elements of the original sequence by the key returned by the given keySelector function applied to each element and put to the destination map each group key associated with a list of corresponding elements.

The operation is terminal.


inline fun <E : Any, K, V, M : MutableMap<in K, MutableList<V>>> EntitySequence<E, *>.groupByTo(destination: M, keySelector: (E) -> K, valueTransform: (E) -> V): M(source)

Group 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 put to the destination map each group key associated with a list of corresponding values.

The operation is terminal.