W3cubDocs

/Kotlin

mapIndexedTo

Platform and version requirements: JVM (1.0), JS (1.0), 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
@ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> UIntArray.mapIndexedTo(
    destination: C, 
    transform: (index: Int, UInt) -> R
): C
@ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> ULongArray.mapIndexedTo(
    destination: C, 
    transform: (index: Int, ULong) -> R
): C
@ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> UByteArray.mapIndexedTo(
    destination: C, 
    transform: (index: Int, UByte) -> R
): C
@ExperimentalUnsignedTypes inline fun <R, C : MutableCollection<in R>> UShortArray.mapIndexedTo(
    destination: C, 
    transform: (index: Int, UShort) -> 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.

Platform and version requirements: JVM (1.0), JS (1.0), 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.

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