English | 简体中文

api-docs / org.ktorm.entity / groupBy

groupBy

inline fun <E : Any, K> EntitySequence<E, *>.groupBy(
    keySelector: (E) -> K
): Map<K, List<E>>
(source code)

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

The returned map preserves the entry iteration order of the keys produced from the original sequence.

The operation is terminal.

inline fun <E : Any, K, V> EntitySequence<E, *>.groupBy(
    keySelector: (E) -> K,
    valueTransform: (E) -> V
): Map<K, List<V>>
(source code)

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 returns a map where each group key is
associated with a list of corresponding values.

The returned map preserves the entry iteration order of the keys produced from the original sequence.

The operation is terminal.