W3cubDocs

/Kotlin

mapIndexedTo

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.

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.

© 2010–2017 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/map-indexed-to.html