English | 简体中文

api-docs / org.ktorm.entity / associateByTo

associateByTo

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

Populate and return the destination mutable map with key-value pairs, where key is provided by the keySelector
function applied to each element of the given sequence and value is the element itself.

If any two elements have the same key returned by keySelector the last one gets added to the map.

The operation is terminal.

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

Populate and return the destination mutable map with key-value pairs, where key is provided by the keySelector
function and value is provided by the valueTransform function applied to elements of the given sequence.

If any two elements have the same key returned by keySelector the last one gets added to the map.

The operation is terminal.