associateBy

inline 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.

For instances where the keys repeat, the last key/value pair will be added to the array.


inline 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.

For instances where the keys repeat, the last key/value pair will be added to the array.