copyInto

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
fun <T> Array<out T>.copyInto(
    destination: Array<T>, 
    destinationOffset: Int = 0, 
    startIndex: Int = 0, 
    endIndex: Int = size
): Array<T>
fun ByteArray.copyInto(
    destination: ByteArray, 
    destinationOffset: Int = 0, 
    startIndex: Int = 0, 
    endIndex: Int = size
): ByteArray
fun ShortArray.copyInto(
    destination: ShortArray, 
    destinationOffset: Int = 0, 
    startIndex: Int = 0, 
    endIndex: Int = size
): ShortArray
fun IntArray.copyInto(
    destination: IntArray, 
    destinationOffset: Int = 0, 
    startIndex: Int = 0, 
    endIndex: Int = size
): IntArray
fun LongArray.copyInto(
    destination: LongArray, 
    destinationOffset: Int = 0, 
    startIndex: Int = 0, 
    endIndex: Int = size
): LongArray
fun FloatArray.copyInto(
    destination: FloatArray, 
    destinationOffset: Int = 0, 
    startIndex: Int = 0, 
    endIndex: Int = size
): FloatArray
fun DoubleArray.copyInto(
    destination: DoubleArray, 
    destinationOffset: Int = 0, 
    startIndex: Int = 0, 
    endIndex: Int = size
): DoubleArray
fun BooleanArray.copyInto(
    destination: BooleanArray, 
    destinationOffset: Int = 0, 
    startIndex: Int = 0, 
    endIndex: Int = size
): BooleanArray
fun CharArray.copyInto(
    destination: CharArray, 
    destinationOffset: Int = 0, 
    startIndex: Int = 0, 
    endIndex: Int = size
): CharArray

Copies this array or its subrange into the destination array and returns that array.

It's allowed to pass the same array in the destination and even specify the subrange so that it overlaps with the destination range.

Parameters

destination - the array to copy to.

destinationOffset - the position in the destination array to copy to, 0 by default.

startIndex - the beginning (inclusive) of the subrange to copy, 0 by default.

endIndex - the end (exclusive) of the subrange to copy, size of this array by default.

Exceptions

IndexOutOfBoundsException - or IllegalArgumentException when startIndex or endIndex is out of range of this array indices or when startIndex > endIndex.

IndexOutOfBoundsException - when the subrange doesn't fit into the destination array starting at the specified destinationOffset, or when that index is out of the destination array indices range.

Return the destination array.

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
@ExperimentalUnsignedTypes fun UIntArray.copyInto(
    destination: UIntArray, 
    destinationOffset: Int = 0, 
    startIndex: Int = 0, 
    endIndex: Int = size
): UIntArray
@ExperimentalUnsignedTypes fun ULongArray.copyInto(
    destination: ULongArray, 
    destinationOffset: Int = 0, 
    startIndex: Int = 0, 
    endIndex: Int = size
): ULongArray
@ExperimentalUnsignedTypes fun UByteArray.copyInto(
    destination: UByteArray, 
    destinationOffset: Int = 0, 
    startIndex: Int = 0, 
    endIndex: Int = size
): UByteArray
@ExperimentalUnsignedTypes fun UShortArray.copyInto(
    destination: UShortArray, 
    destinationOffset: Int = 0, 
    startIndex: Int = 0, 
    endIndex: Int = size
): UShortArray

Copies this array or its subrange into the destination array and returns that array.

It's allowed to pass the same array in the destination and even specify the subrange so that it overlaps with the destination range.

Parameters

destination - the array to copy to.

destinationOffset - the position in the destination array to copy to, 0 by default.

startIndex - the beginning (inclusive) of the subrange to copy, 0 by default.

endIndex - the end (exclusive) of the subrange to copy, size of this array by default.

Exceptions

IndexOutOfBoundsException - or IllegalArgumentException when startIndex or endIndex is out of range of this array indices or when startIndex > endIndex.

IndexOutOfBoundsException - when the subrange doesn't fit into the destination array starting at the specified destinationOffset, or when that index is out of the destination array indices range.

Return the destination array.

© 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/copy-into.html