copyInto

external fun <T> Array<out T>.copyInto(destination: Array<T>, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): Array<T>(source)

Copies this range into destination, supporting overlapping ranges, and returns it.

The source range includes startIndex and excludes endIndex. Overlapping copies within the same array preserve the original source values in either direction. Both ranges are checked before any elements are written, even for an empty copy. Referenced objects are shared, not cloned.

Receiver

the array to copy from.

Return

the same destination array.

Parameters

destination

the array to receive the elements.

destinationOffset

the index at which to start writing in destination.

startIndex

the inclusive source index; defaults to zero.

endIndex

the exclusive source index; defaults to the source size.

Type Parameters

T

the destination element type.

Throws

if either range is outside its array or endIndex is less than startIndex.


external fun BooleanArray.copyInto(destination: BooleanArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): BooleanArray(source)
external fun ByteArray.copyInto(destination: ByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): ByteArray(source)
external fun CharArray.copyInto(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): CharArray(source)
external fun ShortArray.copyInto(destination: ShortArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): ShortArray(source)
external fun IntArray.copyInto(destination: IntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): IntArray(source)
external fun LongArray.copyInto(destination: LongArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): LongArray(source)
external fun FloatArray.copyInto(destination: FloatArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): FloatArray(source)
external fun DoubleArray.copyInto(destination: DoubleArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): DoubleArray(source)
external fun UByteArray.copyInto(destination: UByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): UByteArray(source)
external fun UShortArray.copyInto(destination: UShortArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): UShortArray(source)
external fun UIntArray.copyInto(destination: UIntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): UIntArray(source)
external fun ULongArray.copyInto(destination: ULongArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): ULongArray(source)

Copies this range into destination, supporting overlapping ranges, and returns it.

The source range includes startIndex and excludes endIndex. Overlapping copies within the same array preserve the original source values in either direction. Both ranges are checked before any elements are written, even for an empty copy.

Receiver

the array to copy from.

Return

the same destination array.

Parameters

destination

the array to receive the elements.

destinationOffset

the index at which to start writing in destination.

startIndex

the inclusive source index; defaults to zero.

endIndex

the exclusive source index; defaults to the source size.

Throws

if either range is outside its array or endIndex is less than startIndex.