library / org.akop.kotx.ext.collections / kotlin.collections.Iterable

Extensions for kotlin.collections.Iterable

associateBy

fun <V> Iterable<V>.associateBy(keySelector: (V) -> Int): SparseArray<V>

Populates and returns a SparseArray by populating with keys provided by keySelector and values that are the elements themselves.

fun <T, V> Iterable<T>.associateBy(keySelector: (T) -> Int, valueTransform: (T) -> V): SparseArray<V>

Populates and returns a SparseArray by populating with keys provided by keySelector and values provided by valueTransform.

associateByTo

fun <V, M : SparseArray<in V>> Iterable<V>.associateByTo(destination: M, keySelector: (V) -> Int): M

Populates and returns the destination array by populating with keys provided by keySelector and values that are the elements themselves.

fun <T, V, M : SparseArray<in V>> Iterable<T>.associateByTo(destination: M, keySelector: (T) -> Int, valueTransform: (T) -> V): M

Populates and returns the destination array by populating with keys provided by keySelector and values provided by valueTransform.