mapIndexedTo

Common
JVM
JS
Native
1.0
inline fun <T, R, C : MutableCollection<in R>> Array<out T>.mapIndexedTo(
    destination: C,
    transform: (index: Int, T) -> R
): C
inline fun <R, C : MutableCollection<in R>> ByteArray.mapIndexedTo(
    destination: C,
    transform: (index: Int, Byte) -> R
): C
inline fun <R, C : MutableCollection<in R>> ShortArray.mapIndexedTo(
    destination: C,
    transform: (index: Int, Short) -> R
): C
inline fun <R, C : MutableCollection<in R>> IntArray.mapIndexedTo(
    destination: C,
    transform: (index: Int, Int) -> R
): C
inline fun <R, C : MutableCollection<in R>> LongArray.mapIndexedTo(
    destination: C,
    transform: (index: Int, Long) -> R
): C
inline fun <R, C : MutableCollection<in R>> FloatArray.mapIndexedTo(
    destination: C,
    transform: (index: Int, Float) -> R
): C
inline fun <R, C : MutableCollection<in R>> DoubleArray.mapIndexedTo(
    destination: C,
    transform: (index: Int, Double) -> R
): C
inline fun <R, C : MutableCollection<in R>> BooleanArray.mapIndexedTo(
    destination: C,
    transform: (index: Int, Boolean) -> R
): C
inline fun <R, C : MutableCollection<in R>> CharArray.mapIndexedTo(
    destination: C,
    transform: (index: Int, Char) -> R
): C

Applies the given transform function to each element and its index in the original array and appends the results to the given destination.

Parameters

transform - function that takes the index of an element and the element itself and returns the result of the transform applied to the element.

Common
JVM
JS
Native
1.0
inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapIndexedTo(
    destination: C,
    transform: (index: Int, T) -> R
): C

Applies the given transform function to each element and its index in the original collection and appends the results to the given destination.

Parameters

transform - function that takes the index of an element and the element itself and returns the result of the transform applied to the element.