All Downloads are FREE. Search and download functionalities are using the official Maven repository.

generated._ArraysJvm.kt Maven / Gradle / Ivy

There is a newer version: 2.0.0-RC1
Show newest version
/*
 * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license 
 * that can be found in the license/LICENSE.txt file.
 */

@file:kotlin.jvm.JvmMultifileClass
@file:kotlin.jvm.JvmName("ArraysKt")

package kotlin.collections

//
// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//

import kotlin.*
import kotlin.text.*
import kotlin.comparisons.*

/**
 * Returns a list containing all elements that are instances of specified class.
 */
public fun  Array<*>.filterIsInstance(klass: Class): List {
    return filterIsInstanceTo(ArrayList(), klass)
}

/**
 * Appends all elements that are instances of specified class to the given [destination].
 */
public fun , R> Array<*>.filterIsInstanceTo(destination: C, klass: Class): C {
    @Suppress("UNCHECKED_CAST")
    for (element in this) if (klass.isInstance(element)) destination.add(element as R)
    return destination
}

/**
 * Returns a [List] that wraps the original array.
 */
public actual fun  Array.asList(): List {
    return ArraysUtilJVM.asList(this)
}

/**
 * Returns a [List] that wraps the original array.
 */
public actual fun ByteArray.asList(): List {
    return object : AbstractList(), RandomAccess {
        override val size: Int get() = [email protected]
        override fun isEmpty(): Boolean = [email protected]()
        override fun contains(element: Byte): Boolean = [email protected](element)
        override fun get(index: Int): Byte = this@asList[index]
        override fun indexOf(element: Byte): Int = [email protected](element)
        override fun lastIndexOf(element: Byte): Int = [email protected](element)
    }
}

/**
 * Returns a [List] that wraps the original array.
 */
public actual fun ShortArray.asList(): List {
    return object : AbstractList(), RandomAccess {
        override val size: Int get() = [email protected]
        override fun isEmpty(): Boolean = [email protected]()
        override fun contains(element: Short): Boolean = [email protected](element)
        override fun get(index: Int): Short = this@asList[index]
        override fun indexOf(element: Short): Int = [email protected](element)
        override fun lastIndexOf(element: Short): Int = [email protected](element)
    }
}

/**
 * Returns a [List] that wraps the original array.
 */
public actual fun IntArray.asList(): List {
    return object : AbstractList(), RandomAccess {
        override val size: Int get() = [email protected]
        override fun isEmpty(): Boolean = [email protected]()
        override fun contains(element: Int): Boolean = [email protected](element)
        override fun get(index: Int): Int = this@asList[index]
        override fun indexOf(element: Int): Int = [email protected](element)
        override fun lastIndexOf(element: Int): Int = [email protected](element)
    }
}

/**
 * Returns a [List] that wraps the original array.
 */
public actual fun LongArray.asList(): List {
    return object : AbstractList(), RandomAccess {
        override val size: Int get() = [email protected]
        override fun isEmpty(): Boolean = [email protected]()
        override fun contains(element: Long): Boolean = [email protected](element)
        override fun get(index: Int): Long = this@asList[index]
        override fun indexOf(element: Long): Int = [email protected](element)
        override fun lastIndexOf(element: Long): Int = [email protected](element)
    }
}

/**
 * Returns a [List] that wraps the original array.
 */
public actual fun FloatArray.asList(): List {
    return object : AbstractList(), RandomAccess {
        override val size: Int get() = [email protected]
        override fun isEmpty(): Boolean = [email protected]()
        override fun contains(element: Float): Boolean = [email protected](element)
        override fun get(index: Int): Float = this@asList[index]
        override fun indexOf(element: Float): Int = [email protected](element)
        override fun lastIndexOf(element: Float): Int = [email protected](element)
    }
}

/**
 * Returns a [List] that wraps the original array.
 */
public actual fun DoubleArray.asList(): List {
    return object : AbstractList(), RandomAccess {
        override val size: Int get() = [email protected]
        override fun isEmpty(): Boolean = [email protected]()
        override fun contains(element: Double): Boolean = [email protected](element)
        override fun get(index: Int): Double = this@asList[index]
        override fun indexOf(element: Double): Int = [email protected](element)
        override fun lastIndexOf(element: Double): Int = [email protected](element)
    }
}

/**
 * Returns a [List] that wraps the original array.
 */
public actual fun BooleanArray.asList(): List {
    return object : AbstractList(), RandomAccess {
        override val size: Int get() = [email protected]
        override fun isEmpty(): Boolean = [email protected]()
        override fun contains(element: Boolean): Boolean = [email protected](element)
        override fun get(index: Int): Boolean = this@asList[index]
        override fun indexOf(element: Boolean): Int = [email protected](element)
        override fun lastIndexOf(element: Boolean): Int = [email protected](element)
    }
}

/**
 * Returns a [List] that wraps the original array.
 */
public actual fun CharArray.asList(): List {
    return object : AbstractList(), RandomAccess {
        override val size: Int get() = [email protected]
        override fun isEmpty(): Boolean = [email protected]()
        override fun contains(element: Char): Boolean = [email protected](element)
        override fun get(index: Int): Char = this@asList[index]
        override fun indexOf(element: Char): Int = [email protected](element)
        override fun lastIndexOf(element: Char): Int = [email protected](element)
    }
}

/**
 * Searches the array or the range of the array for the provided [element] using the binary search algorithm.
 * The array is expected to be sorted according to the specified [comparator], otherwise the result is undefined.
 * 
 * If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
 * 
 * @return the index of the element, if it is contained in the array within the specified range;
 * otherwise, the inverted insertion point `(-insertion point - 1)`.
 * The insertion point is defined as the index at which the element should be inserted,
 * so that the array (or the specified subrange of array) still remains sorted according to the specified [comparator].
 */
public fun  Array.binarySearch(element: T, comparator: Comparator, fromIndex: Int = 0, toIndex: Int = size): Int {
    return java.util.Arrays.binarySearch(this, fromIndex, toIndex, element, comparator)
}

/**
 * Searches the array or the range of the array for the provided [element] using the binary search algorithm.
 * The array is expected to be sorted, otherwise the result is undefined.
 * 
 * If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
 * 
 * @return the index of the element, if it is contained in the array within the specified range;
 * otherwise, the inverted insertion point `(-insertion point - 1)`.
 * The insertion point is defined as the index at which the element should be inserted,
 * so that the array (or the specified subrange of array) still remains sorted.
 */
public fun  Array.binarySearch(element: T, fromIndex: Int = 0, toIndex: Int = size): Int {
    return java.util.Arrays.binarySearch(this, fromIndex, toIndex, element)
}

/**
 * Searches the array or the range of the array for the provided [element] using the binary search algorithm.
 * The array is expected to be sorted, otherwise the result is undefined.
 * 
 * If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
 * 
 * @return the index of the element, if it is contained in the array within the specified range;
 * otherwise, the inverted insertion point `(-insertion point - 1)`.
 * The insertion point is defined as the index at which the element should be inserted,
 * so that the array (or the specified subrange of array) still remains sorted.
 */
public fun ByteArray.binarySearch(element: Byte, fromIndex: Int = 0, toIndex: Int = size): Int {
    return java.util.Arrays.binarySearch(this, fromIndex, toIndex, element)
}

/**
 * Searches the array or the range of the array for the provided [element] using the binary search algorithm.
 * The array is expected to be sorted, otherwise the result is undefined.
 * 
 * If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
 * 
 * @return the index of the element, if it is contained in the array within the specified range;
 * otherwise, the inverted insertion point `(-insertion point - 1)`.
 * The insertion point is defined as the index at which the element should be inserted,
 * so that the array (or the specified subrange of array) still remains sorted.
 */
public fun ShortArray.binarySearch(element: Short, fromIndex: Int = 0, toIndex: Int = size): Int {
    return java.util.Arrays.binarySearch(this, fromIndex, toIndex, element)
}

/**
 * Searches the array or the range of the array for the provided [element] using the binary search algorithm.
 * The array is expected to be sorted, otherwise the result is undefined.
 * 
 * If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
 * 
 * @return the index of the element, if it is contained in the array within the specified range;
 * otherwise, the inverted insertion point `(-insertion point - 1)`.
 * The insertion point is defined as the index at which the element should be inserted,
 * so that the array (or the specified subrange of array) still remains sorted.
 */
public fun IntArray.binarySearch(element: Int, fromIndex: Int = 0, toIndex: Int = size): Int {
    return java.util.Arrays.binarySearch(this, fromIndex, toIndex, element)
}

/**
 * Searches the array or the range of the array for the provided [element] using the binary search algorithm.
 * The array is expected to be sorted, otherwise the result is undefined.
 * 
 * If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
 * 
 * @return the index of the element, if it is contained in the array within the specified range;
 * otherwise, the inverted insertion point `(-insertion point - 1)`.
 * The insertion point is defined as the index at which the element should be inserted,
 * so that the array (or the specified subrange of array) still remains sorted.
 */
public fun LongArray.binarySearch(element: Long, fromIndex: Int = 0, toIndex: Int = size): Int {
    return java.util.Arrays.binarySearch(this, fromIndex, toIndex, element)
}

/**
 * Searches the array or the range of the array for the provided [element] using the binary search algorithm.
 * The array is expected to be sorted, otherwise the result is undefined.
 * 
 * If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
 * 
 * @return the index of the element, if it is contained in the array within the specified range;
 * otherwise, the inverted insertion point `(-insertion point - 1)`.
 * The insertion point is defined as the index at which the element should be inserted,
 * so that the array (or the specified subrange of array) still remains sorted.
 */
public fun FloatArray.binarySearch(element: Float, fromIndex: Int = 0, toIndex: Int = size): Int {
    return java.util.Arrays.binarySearch(this, fromIndex, toIndex, element)
}

/**
 * Searches the array or the range of the array for the provided [element] using the binary search algorithm.
 * The array is expected to be sorted, otherwise the result is undefined.
 * 
 * If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
 * 
 * @return the index of the element, if it is contained in the array within the specified range;
 * otherwise, the inverted insertion point `(-insertion point - 1)`.
 * The insertion point is defined as the index at which the element should be inserted,
 * so that the array (or the specified subrange of array) still remains sorted.
 */
public fun DoubleArray.binarySearch(element: Double, fromIndex: Int = 0, toIndex: Int = size): Int {
    return java.util.Arrays.binarySearch(this, fromIndex, toIndex, element)
}

/**
 * Searches the array or the range of the array for the provided [element] using the binary search algorithm.
 * The array is expected to be sorted, otherwise the result is undefined.
 * 
 * If the array contains multiple elements equal to the specified [element], there is no guarantee which one will be found.
 * 
 * @return the index of the element, if it is contained in the array within the specified range;
 * otherwise, the inverted insertion point `(-insertion point - 1)`.
 * The insertion point is defined as the index at which the element should be inserted,
 * so that the array (or the specified subrange of array) still remains sorted.
 */
public fun CharArray.binarySearch(element: Char, fromIndex: Int = 0, toIndex: Int = size): Int {
    return java.util.Arrays.binarySearch(this, fromIndex, toIndex, element)
}

/**
 * Returns `true` if the two specified arrays are *deeply* equal to one another,
 * i.e. contain the same number of the same elements in the same order.
 * 
 * If two corresponding elements are nested arrays, they are also compared deeply.
 * If any of arrays contains itself on any nesting level the behavior is undefined.
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline infix fun  Array.contentDeepEquals(other: Array): Boolean {
    return java.util.Arrays.deepEquals(this, other)
}

/**
 * Returns a hash code based on the contents of this array as if it is [List].
 * Nested arrays are treated as lists too.
 * 
 * If any of arrays contains itself on any nesting level the behavior is undefined.
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun  Array.contentDeepHashCode(): Int {
    return java.util.Arrays.deepHashCode(this)
}

/**
 * Returns a string representation of the contents of this array as if it is a [List].
 * Nested arrays are treated as lists too.
 * 
 * If any of arrays contains itself on any nesting level that reference
 * is rendered as `"[...]"` to prevent recursion.
 * 
 * @sample samples.collections.Arrays.ContentOperations.contentDeepToString
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun  Array.contentDeepToString(): String {
    return java.util.Arrays.deepToString(this)
}

/**
 * Returns `true` if the two specified arrays are *structurally* equal to one another,
 * i.e. contain the same number of the same elements in the same order.
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline infix fun  Array.contentEquals(other: Array): Boolean {
    return java.util.Arrays.equals(this, other)
}

/**
 * Returns `true` if the two specified arrays are *structurally* equal to one another,
 * i.e. contain the same number of the same elements in the same order.
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline infix fun ByteArray.contentEquals(other: ByteArray): Boolean {
    return java.util.Arrays.equals(this, other)
}

/**
 * Returns `true` if the two specified arrays are *structurally* equal to one another,
 * i.e. contain the same number of the same elements in the same order.
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline infix fun ShortArray.contentEquals(other: ShortArray): Boolean {
    return java.util.Arrays.equals(this, other)
}

/**
 * Returns `true` if the two specified arrays are *structurally* equal to one another,
 * i.e. contain the same number of the same elements in the same order.
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline infix fun IntArray.contentEquals(other: IntArray): Boolean {
    return java.util.Arrays.equals(this, other)
}

/**
 * Returns `true` if the two specified arrays are *structurally* equal to one another,
 * i.e. contain the same number of the same elements in the same order.
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline infix fun LongArray.contentEquals(other: LongArray): Boolean {
    return java.util.Arrays.equals(this, other)
}

/**
 * Returns `true` if the two specified arrays are *structurally* equal to one another,
 * i.e. contain the same number of the same elements in the same order.
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline infix fun FloatArray.contentEquals(other: FloatArray): Boolean {
    return java.util.Arrays.equals(this, other)
}

/**
 * Returns `true` if the two specified arrays are *structurally* equal to one another,
 * i.e. contain the same number of the same elements in the same order.
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline infix fun DoubleArray.contentEquals(other: DoubleArray): Boolean {
    return java.util.Arrays.equals(this, other)
}

/**
 * Returns `true` if the two specified arrays are *structurally* equal to one another,
 * i.e. contain the same number of the same elements in the same order.
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline infix fun BooleanArray.contentEquals(other: BooleanArray): Boolean {
    return java.util.Arrays.equals(this, other)
}

/**
 * Returns `true` if the two specified arrays are *structurally* equal to one another,
 * i.e. contain the same number of the same elements in the same order.
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline infix fun CharArray.contentEquals(other: CharArray): Boolean {
    return java.util.Arrays.equals(this, other)
}

/**
 * Returns a hash code based on the contents of this array as if it is [List].
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun  Array.contentHashCode(): Int {
    return java.util.Arrays.hashCode(this)
}

/**
 * Returns a hash code based on the contents of this array as if it is [List].
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun ByteArray.contentHashCode(): Int {
    return java.util.Arrays.hashCode(this)
}

/**
 * Returns a hash code based on the contents of this array as if it is [List].
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun ShortArray.contentHashCode(): Int {
    return java.util.Arrays.hashCode(this)
}

/**
 * Returns a hash code based on the contents of this array as if it is [List].
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun IntArray.contentHashCode(): Int {
    return java.util.Arrays.hashCode(this)
}

/**
 * Returns a hash code based on the contents of this array as if it is [List].
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun LongArray.contentHashCode(): Int {
    return java.util.Arrays.hashCode(this)
}

/**
 * Returns a hash code based on the contents of this array as if it is [List].
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun FloatArray.contentHashCode(): Int {
    return java.util.Arrays.hashCode(this)
}

/**
 * Returns a hash code based on the contents of this array as if it is [List].
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun DoubleArray.contentHashCode(): Int {
    return java.util.Arrays.hashCode(this)
}

/**
 * Returns a hash code based on the contents of this array as if it is [List].
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun BooleanArray.contentHashCode(): Int {
    return java.util.Arrays.hashCode(this)
}

/**
 * Returns a hash code based on the contents of this array as if it is [List].
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun CharArray.contentHashCode(): Int {
    return java.util.Arrays.hashCode(this)
}

/**
 * Returns a string representation of the contents of the specified array as if it is [List].
 * 
 * @sample samples.collections.Arrays.ContentOperations.contentToString
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun  Array.contentToString(): String {
    return java.util.Arrays.toString(this)
}

/**
 * Returns a string representation of the contents of the specified array as if it is [List].
 * 
 * @sample samples.collections.Arrays.ContentOperations.contentToString
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun ByteArray.contentToString(): String {
    return java.util.Arrays.toString(this)
}

/**
 * Returns a string representation of the contents of the specified array as if it is [List].
 * 
 * @sample samples.collections.Arrays.ContentOperations.contentToString
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun ShortArray.contentToString(): String {
    return java.util.Arrays.toString(this)
}

/**
 * Returns a string representation of the contents of the specified array as if it is [List].
 * 
 * @sample samples.collections.Arrays.ContentOperations.contentToString
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun IntArray.contentToString(): String {
    return java.util.Arrays.toString(this)
}

/**
 * Returns a string representation of the contents of the specified array as if it is [List].
 * 
 * @sample samples.collections.Arrays.ContentOperations.contentToString
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun LongArray.contentToString(): String {
    return java.util.Arrays.toString(this)
}

/**
 * Returns a string representation of the contents of the specified array as if it is [List].
 * 
 * @sample samples.collections.Arrays.ContentOperations.contentToString
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun FloatArray.contentToString(): String {
    return java.util.Arrays.toString(this)
}

/**
 * Returns a string representation of the contents of the specified array as if it is [List].
 * 
 * @sample samples.collections.Arrays.ContentOperations.contentToString
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun DoubleArray.contentToString(): String {
    return java.util.Arrays.toString(this)
}

/**
 * Returns a string representation of the contents of the specified array as if it is [List].
 * 
 * @sample samples.collections.Arrays.ContentOperations.contentToString
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun BooleanArray.contentToString(): String {
    return java.util.Arrays.toString(this)
}

/**
 * Returns a string representation of the contents of the specified array as if it is [List].
 * 
 * @sample samples.collections.Arrays.ContentOperations.contentToString
 */
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun CharArray.contentToString(): String {
    return java.util.Arrays.toString(this)
}

/**
 * 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.
 * 
 * @param destination the array to copy to.
 * @param destinationOffset the position in the [destination] array to copy to, 0 by default.
 * @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.
 * @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.
 * 
 * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.
 * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationIndex],
 * or when that index is out of the [destination] array indices range.
 * 
 * @return the [destination] array.
 */
@SinceKotlin("1.3")
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual fun  Array.copyInto(destination: Array, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): Array {
    @Suppress("NAME_SHADOWING")
    val endIndex = if (endIndex == -1) size else endIndex // TODO: Remove when default value from expect is fixed
    System.arraycopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
    return destination
}

/**
 * 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.
 * 
 * @param destination the array to copy to.
 * @param destinationOffset the position in the [destination] array to copy to, 0 by default.
 * @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.
 * @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.
 * 
 * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.
 * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationIndex],
 * or when that index is out of the [destination] array indices range.
 * 
 * @return the [destination] array.
 */
@SinceKotlin("1.3")
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual fun ByteArray.copyInto(destination: ByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): ByteArray {
    @Suppress("NAME_SHADOWING")
    val endIndex = if (endIndex == -1) size else endIndex // TODO: Remove when default value from expect is fixed
    System.arraycopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
    return destination
}

/**
 * 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.
 * 
 * @param destination the array to copy to.
 * @param destinationOffset the position in the [destination] array to copy to, 0 by default.
 * @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.
 * @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.
 * 
 * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.
 * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationIndex],
 * or when that index is out of the [destination] array indices range.
 * 
 * @return the [destination] array.
 */
@SinceKotlin("1.3")
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual fun ShortArray.copyInto(destination: ShortArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): ShortArray {
    @Suppress("NAME_SHADOWING")
    val endIndex = if (endIndex == -1) size else endIndex // TODO: Remove when default value from expect is fixed
    System.arraycopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
    return destination
}

/**
 * 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.
 * 
 * @param destination the array to copy to.
 * @param destinationOffset the position in the [destination] array to copy to, 0 by default.
 * @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.
 * @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.
 * 
 * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.
 * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationIndex],
 * or when that index is out of the [destination] array indices range.
 * 
 * @return the [destination] array.
 */
@SinceKotlin("1.3")
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual fun IntArray.copyInto(destination: IntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): IntArray {
    @Suppress("NAME_SHADOWING")
    val endIndex = if (endIndex == -1) size else endIndex // TODO: Remove when default value from expect is fixed
    System.arraycopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
    return destination
}

/**
 * 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.
 * 
 * @param destination the array to copy to.
 * @param destinationOffset the position in the [destination] array to copy to, 0 by default.
 * @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.
 * @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.
 * 
 * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.
 * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationIndex],
 * or when that index is out of the [destination] array indices range.
 * 
 * @return the [destination] array.
 */
@SinceKotlin("1.3")
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual fun LongArray.copyInto(destination: LongArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): LongArray {
    @Suppress("NAME_SHADOWING")
    val endIndex = if (endIndex == -1) size else endIndex // TODO: Remove when default value from expect is fixed
    System.arraycopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
    return destination
}

/**
 * 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.
 * 
 * @param destination the array to copy to.
 * @param destinationOffset the position in the [destination] array to copy to, 0 by default.
 * @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.
 * @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.
 * 
 * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.
 * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationIndex],
 * or when that index is out of the [destination] array indices range.
 * 
 * @return the [destination] array.
 */
@SinceKotlin("1.3")
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual fun FloatArray.copyInto(destination: FloatArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): FloatArray {
    @Suppress("NAME_SHADOWING")
    val endIndex = if (endIndex == -1) size else endIndex // TODO: Remove when default value from expect is fixed
    System.arraycopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
    return destination
}

/**
 * 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.
 * 
 * @param destination the array to copy to.
 * @param destinationOffset the position in the [destination] array to copy to, 0 by default.
 * @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.
 * @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.
 * 
 * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.
 * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationIndex],
 * or when that index is out of the [destination] array indices range.
 * 
 * @return the [destination] array.
 */
@SinceKotlin("1.3")
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual fun DoubleArray.copyInto(destination: DoubleArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): DoubleArray {
    @Suppress("NAME_SHADOWING")
    val endIndex = if (endIndex == -1) size else endIndex // TODO: Remove when default value from expect is fixed
    System.arraycopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
    return destination
}

/**
 * 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.
 * 
 * @param destination the array to copy to.
 * @param destinationOffset the position in the [destination] array to copy to, 0 by default.
 * @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.
 * @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.
 * 
 * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.
 * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationIndex],
 * or when that index is out of the [destination] array indices range.
 * 
 * @return the [destination] array.
 */
@SinceKotlin("1.3")
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual fun BooleanArray.copyInto(destination: BooleanArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): BooleanArray {
    @Suppress("NAME_SHADOWING")
    val endIndex = if (endIndex == -1) size else endIndex // TODO: Remove when default value from expect is fixed
    System.arraycopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
    return destination
}

/**
 * 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.
 * 
 * @param destination the array to copy to.
 * @param destinationOffset the position in the [destination] array to copy to, 0 by default.
 * @param startIndex the beginning (inclusive) of the subrange to copy, 0 by default.
 * @param endIndex the end (exclusive) of the subrange to copy, size of this array by default.
 * 
 * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this array indices or when `startIndex > endIndex`.
 * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationIndex],
 * or when that index is out of the [destination] array indices range.
 * 
 * @return the [destination] array.
 */
@SinceKotlin("1.3")
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual fun CharArray.copyInto(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): CharArray {
    @Suppress("NAME_SHADOWING")
    val endIndex = if (endIndex == -1) size else endIndex // TODO: Remove when default value from expect is fixed
    System.arraycopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
    return destination
}

/**
 * Returns new array which is a copy of the original array.
 * 
 * @sample samples.collections.Arrays.CopyOfOperations.copyOf
 */
@kotlin.internal.InlineOnly
public actual inline fun  Array.copyOf(): Array {
    return java.util.Arrays.copyOf(this, size)
}

/**
 * Returns new array which is a copy of the original array.
 * 
 * @sample samples.collections.Arrays.CopyOfOperations.copyOf
 */
@kotlin.internal.InlineOnly
public actual inline fun ByteArray.copyOf(): ByteArray {
    return java.util.Arrays.copyOf(this, size)
}

/**
 * Returns new array which is a copy of the original array.
 * 
 * @sample samples.collections.Arrays.CopyOfOperations.copyOf
 */
@kotlin.internal.InlineOnly
public actual inline fun ShortArray.copyOf(): ShortArray {
    return java.util.Arrays.copyOf(this, size)
}

/**
 * Returns new array which is a copy of the original array.
 * 
 * @sample samples.collections.Arrays.CopyOfOperations.copyOf
 */
@kotlin.internal.InlineOnly
public actual inline fun IntArray.copyOf(): IntArray {
    return java.util.Arrays.copyOf(this, size)
}

/**
 * Returns new array which is a copy of the original array.
 * 
 * @sample samples.collections.Arrays.CopyOfOperations.copyOf
 */
@kotlin.internal.InlineOnly
public actual inline fun LongArray.copyOf(): LongArray {
    return java.util.Arrays.copyOf(this, size)
}

/**
 * Returns new array which is a copy of the original array.
 * 
 * @sample samples.collections.Arrays.CopyOfOperations.copyOf
 */
@kotlin.internal.InlineOnly
public actual inline fun FloatArray.copyOf(): FloatArray {
    return java.util.Arrays.copyOf(this, size)
}

/**
 * Returns new array which is a copy of the original array.
 * 
 * @sample samples.collections.Arrays.CopyOfOperations.copyOf
 */
@kotlin.internal.InlineOnly
public actual inline fun DoubleArray.copyOf(): DoubleArray {
    return java.util.Arrays.copyOf(this, size)
}

/**
 * Returns new array which is a copy of the original array.
 * 
 * @sample samples.collections.Arrays.CopyOfOperations.copyOf
 */
@kotlin.internal.InlineOnly
public actual inline fun BooleanArray.copyOf(): BooleanArray {
    return java.util.Arrays.copyOf(this, size)
}

/**
 * Returns new array which is a copy of the original array.
 * 
 * @sample samples.collections.Arrays.CopyOfOperations.copyOf
 */
@kotlin.internal.InlineOnly
public actual inline fun CharArray.copyOf(): CharArray {
    return java.util.Arrays.copyOf(this, size)
}

/**
 * Returns new array which is a copy of the original array, resized to the given [newSize].
 * The copy is either truncated or padded at the end with zero values if necessary.
 * 
 * - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].
 * - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with zero values.
 * 
 * @sample samples.collections.Arrays.CopyOfOperations.resizedPrimitiveCopyOf
 */
@kotlin.internal.InlineOnly
public actual inline fun ByteArray.copyOf(newSize: Int): ByteArray {
    return java.util.Arrays.copyOf(this, newSize)
}

/**
 * Returns new array which is a copy of the original array, resized to the given [newSize].
 * The copy is either truncated or padded at the end with zero values if necessary.
 * 
 * - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].
 * - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with zero values.
 * 
 * @sample samples.collections.Arrays.CopyOfOperations.resizedPrimitiveCopyOf
 */
@kotlin.internal.InlineOnly
public actual inline fun ShortArray.copyOf(newSize: Int): ShortArray {
    return java.util.Arrays.copyOf(this, newSize)
}

/**
 * Returns new array which is a copy of the original array, resized to the given [newSize].
 * The copy is either truncated or padded at the end with zero values if necessary.
 * 
 * - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].
 * - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with zero values.
 * 
 * @sample samples.collections.Arrays.CopyOfOperations.resizedPrimitiveCopyOf
 */
@kotlin.internal.InlineOnly
public actual inline fun IntArray.copyOf(newSize: Int): IntArray {
    return java.util.Arrays.copyOf(this, newSize)
}

/**
 * Returns new array which is a copy of the original array, resized to the given [newSize].
 * The copy is either truncated or padded at the end with zero values if necessary.
 * 
 * - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].
 * - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with zero values.
 * 
 * @sample samples.collections.Arrays.CopyOfOperations.resizedPrimitiveCopyOf
 */
@kotlin.internal.InlineOnly
public actual inline fun LongArray.copyOf(newSize: Int): LongArray {
    return java.util.Arrays.copyOf(this, newSize)
}

/**
 * Returns new array which is a copy of the original array, resized to the given [newSize].
 * The copy is either truncated or padded at the end with zero values if necessary.
 * 
 * - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].
 * - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with zero values.
 * 
 * @sample samples.collections.Arrays.CopyOfOperations.resizedPrimitiveCopyOf
 */
@kotlin.internal.InlineOnly
public actual inline fun FloatArray.copyOf(newSize: Int): FloatArray {
    return java.util.Arrays.copyOf(this, newSize)
}

/**
 * Returns new array which is a copy of the original array, resized to the given [newSize].
 * The copy is either truncated or padded at the end with zero values if necessary.
 * 
 * - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].
 * - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with zero values.
 * 
 * @sample samples.collections.Arrays.CopyOfOperations.resizedPrimitiveCopyOf
 */
@kotlin.internal.InlineOnly
public actual inline fun DoubleArray.copyOf(newSize: Int): DoubleArray {
    return java.util.Arrays.copyOf(this, newSize)
}

/**
 * Returns new array which is a copy of the original array, resized to the given [newSize].
 * The copy is either truncated or padded at the end with `false` values if necessary.
 * 
 * - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].
 * - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with `false` values.
 * 
 * @sample samples.collections.Arrays.CopyOfOperations.resizedPrimitiveCopyOf
 */
@kotlin.internal.InlineOnly
public actual inline fun BooleanArray.copyOf(newSize: Int): BooleanArray {
    return java.util.Arrays.copyOf(this, newSize)
}

/**
 * Returns new array which is a copy of the original array, resized to the given [newSize].
 * The copy is either truncated or padded at the end with null char (`\u0000`) values if necessary.
 * 
 * - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].
 * - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with null char (`\u0000`) values.
 * 
 * @sample samples.collections.Arrays.CopyOfOperations.resizedPrimitiveCopyOf
 */
@kotlin.internal.InlineOnly
public actual inline fun CharArray.copyOf(newSize: Int): CharArray {
    return java.util.Arrays.copyOf(this, newSize)
}

/**
 * Returns new array which is a copy of the original array, resized to the given [newSize].
 * The copy is either truncated or padded at the end with `null` values if necessary.
 * 
 * - If [newSize] is less than the size of the original array, the copy array is truncated to the [newSize].
 * - If [newSize] is greater than the size of the original array, the extra elements in the copy array are filled with `null` values.
 * 
 * @sample samples.collections.Arrays.CopyOfOperations.resizingCopyOf
 */
@kotlin.internal.InlineOnly
public actual inline fun  Array.copyOf(newSize: Int): Array {
    return java.util.Arrays.copyOf(this, newSize)
}

/**
 * Returns a new array which is a copy of the specified range of the original array.
 * 
 * @param fromIndex the start of the range (inclusive), must be in `0..array.size`
 * @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
 */
@JvmName("copyOfRangeInline")
@kotlin.internal.InlineOnly
public actual inline fun  Array.copyOfRange(fromIndex: Int, toIndex: Int): Array {
    return if (kotlin.internal.apiVersionIsAtLeast(1, 3, 0)) {
        copyOfRangeImpl(fromIndex, toIndex)
    } else {
        if (toIndex > size) throw IndexOutOfBoundsException("toIndex: $toIndex, size: $size")
        java.util.Arrays.copyOfRange(this, fromIndex, toIndex)
    }
}

/**
 * Returns a new array which is a copy of the specified range of the original array.
 * 
 * @param fromIndex the start of the range (inclusive), must be in `0..array.size`
 * @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
 */
@JvmName("copyOfRangeInline")
@kotlin.internal.InlineOnly
public actual inline fun ByteArray.copyOfRange(fromIndex: Int, toIndex: Int): ByteArray {
    return if (kotlin.internal.apiVersionIsAtLeast(1, 3, 0)) {
        copyOfRangeImpl(fromIndex, toIndex)
    } else {
        if (toIndex > size) throw IndexOutOfBoundsException("toIndex: $toIndex, size: $size")
        java.util.Arrays.copyOfRange(this, fromIndex, toIndex)
    }
}

/**
 * Returns a new array which is a copy of the specified range of the original array.
 * 
 * @param fromIndex the start of the range (inclusive), must be in `0..array.size`
 * @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
 */
@JvmName("copyOfRangeInline")
@kotlin.internal.InlineOnly
public actual inline fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray {
    return if (kotlin.internal.apiVersionIsAtLeast(1, 3, 0)) {
        copyOfRangeImpl(fromIndex, toIndex)
    } else {
        if (toIndex > size) throw IndexOutOfBoundsException("toIndex: $toIndex, size: $size")
        java.util.Arrays.copyOfRange(this, fromIndex, toIndex)
    }
}

/**
 * Returns a new array which is a copy of the specified range of the original array.
 * 
 * @param fromIndex the start of the range (inclusive), must be in `0..array.size`
 * @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
 */
@JvmName("copyOfRangeInline")
@kotlin.internal.InlineOnly
public actual inline fun IntArray.copyOfRange(fromIndex: Int, toIndex: Int): IntArray {
    return if (kotlin.internal.apiVersionIsAtLeast(1, 3, 0)) {
        copyOfRangeImpl(fromIndex, toIndex)
    } else {
        if (toIndex > size) throw IndexOutOfBoundsException("toIndex: $toIndex, size: $size")
        java.util.Arrays.copyOfRange(this, fromIndex, toIndex)
    }
}

/**
 * Returns a new array which is a copy of the specified range of the original array.
 * 
 * @param fromIndex the start of the range (inclusive), must be in `0..array.size`
 * @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
 */
@JvmName("copyOfRangeInline")
@kotlin.internal.InlineOnly
public actual inline fun LongArray.copyOfRange(fromIndex: Int, toIndex: Int): LongArray {
    return if (kotlin.internal.apiVersionIsAtLeast(1, 3, 0)) {
        copyOfRangeImpl(fromIndex, toIndex)
    } else {
        if (toIndex > size) throw IndexOutOfBoundsException("toIndex: $toIndex, size: $size")
        java.util.Arrays.copyOfRange(this, fromIndex, toIndex)
    }
}

/**
 * Returns a new array which is a copy of the specified range of the original array.
 * 
 * @param fromIndex the start of the range (inclusive), must be in `0..array.size`
 * @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
 */
@JvmName("copyOfRangeInline")
@kotlin.internal.InlineOnly
public actual inline fun FloatArray.copyOfRange(fromIndex: Int, toIndex: Int): FloatArray {
    return if (kotlin.internal.apiVersionIsAtLeast(1, 3, 0)) {
        copyOfRangeImpl(fromIndex, toIndex)
    } else {
        if (toIndex > size) throw IndexOutOfBoundsException("toIndex: $toIndex, size: $size")
        java.util.Arrays.copyOfRange(this, fromIndex, toIndex)
    }
}

/**
 * Returns a new array which is a copy of the specified range of the original array.
 * 
 * @param fromIndex the start of the range (inclusive), must be in `0..array.size`
 * @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
 */
@JvmName("copyOfRangeInline")
@kotlin.internal.InlineOnly
public actual inline fun DoubleArray.copyOfRange(fromIndex: Int, toIndex: Int): DoubleArray {
    return if (kotlin.internal.apiVersionIsAtLeast(1, 3, 0)) {
        copyOfRangeImpl(fromIndex, toIndex)
    } else {
        if (toIndex > size) throw IndexOutOfBoundsException("toIndex: $toIndex, size: $size")
        java.util.Arrays.copyOfRange(this, fromIndex, toIndex)
    }
}

/**
 * Returns a new array which is a copy of the specified range of the original array.
 * 
 * @param fromIndex the start of the range (inclusive), must be in `0..array.size`
 * @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
 */
@JvmName("copyOfRangeInline")
@kotlin.internal.InlineOnly
public actual inline fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int): BooleanArray {
    return if (kotlin.internal.apiVersionIsAtLeast(1, 3, 0)) {
        copyOfRangeImpl(fromIndex, toIndex)
    } else {
        if (toIndex > size) throw IndexOutOfBoundsException("toIndex: $toIndex, size: $size")
        java.util.Arrays.copyOfRange(this, fromIndex, toIndex)
    }
}

/**
 * Returns a new array which is a copy of the specified range of the original array.
 * 
 * @param fromIndex the start of the range (inclusive), must be in `0..array.size`
 * @param toIndex the end of the range (exclusive), must be in `fromIndex..array.size`
 */
@JvmName("copyOfRangeInline")
@kotlin.internal.InlineOnly
public actual inline fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray {
    return if (kotlin.internal.apiVersionIsAtLeast(1, 3, 0)) {
        copyOfRangeImpl(fromIndex, toIndex)
    } else {
        if (toIndex > size) throw IndexOutOfBoundsException("toIndex: $toIndex, size: $size")
        java.util.Arrays.copyOfRange(this, fromIndex, toIndex)
    }
}

@SinceKotlin("1.3")
@PublishedApi
@JvmName("copyOfRange")
internal fun  Array.copyOfRangeImpl(fromIndex: Int, toIndex: Int): Array {
    copyOfRangeToIndexCheck(toIndex, size)
    return java.util.Arrays.copyOfRange(this, fromIndex, toIndex)
}

@SinceKotlin("1.3")
@PublishedApi
@JvmName("copyOfRange")
internal fun ByteArray.copyOfRangeImpl(fromIndex: Int, toIndex: Int): ByteArray {
    copyOfRangeToIndexCheck(toIndex, size)
    return java.util.Arrays.copyOfRange(this, fromIndex, toIndex)
}

@SinceKotlin("1.3")
@PublishedApi
@JvmName("copyOfRange")
internal fun ShortArray.copyOfRangeImpl(fromIndex: Int, toIndex: Int): ShortArray {
    copyOfRangeToIndexCheck(toIndex, size)
    return java.util.Arrays.copyOfRange(this, fromIndex, toIndex)
}

@SinceKotlin("1.3")
@PublishedApi
@JvmName("copyOfRange")
internal fun IntArray.copyOfRangeImpl(fromIndex: Int, toIndex: Int): IntArray {
    copyOfRangeToIndexCheck(toIndex, size)
    return java.util.Arrays.copyOfRange(this, fromIndex, toIndex)
}

@SinceKotlin("1.3")
@PublishedApi
@JvmName("copyOfRange")
internal fun LongArray.copyOfRangeImpl(fromIndex: Int, toIndex: Int): LongArray {
    copyOfRangeToIndexCheck(toIndex, size)
    return java.util.Arrays.copyOfRange(this, fromIndex, toIndex)
}

@SinceKotlin("1.3")
@PublishedApi
@JvmName("copyOfRange")
internal fun FloatArray.copyOfRangeImpl(fromIndex: Int, toIndex: Int): FloatArray {
    copyOfRangeToIndexCheck(toIndex, size)
    return java.util.Arrays.copyOfRange(this, fromIndex, toIndex)
}

@SinceKotlin("1.3")
@PublishedApi
@JvmName("copyOfRange")
internal fun DoubleArray.copyOfRangeImpl(fromIndex: Int, toIndex: Int): DoubleArray {
    copyOfRangeToIndexCheck(toIndex, size)
    return java.util.Arrays.copyOfRange(this, fromIndex, toIndex)
}

@SinceKotlin("1.3")
@PublishedApi
@JvmName("copyOfRange")
internal fun BooleanArray.copyOfRangeImpl(fromIndex: Int, toIndex: Int): BooleanArray {
    copyOfRangeToIndexCheck(toIndex, size)
    return java.util.Arrays.copyOfRange(this, fromIndex, toIndex)
}

@SinceKotlin("1.3")
@PublishedApi
@JvmName("copyOfRange")
internal fun CharArray.copyOfRangeImpl(fromIndex: Int, toIndex: Int): CharArray {
    copyOfRangeToIndexCheck(toIndex, size)
    return java.util.Arrays.copyOfRange(this, fromIndex, toIndex)
}

/**
 * Fills original array with the provided value.
 */
public fun  Array.fill(element: T, fromIndex: Int = 0, toIndex: Int = size): Unit {
    java.util.Arrays.fill(this, fromIndex, toIndex, element)
}

/**
 * Fills original array with the provided value.
 */
public fun ByteArray.fill(element: Byte, fromIndex: Int = 0, toIndex: Int = size): Unit {
    java.util.Arrays.fill(this, fromIndex, toIndex, element)
}

/**
 * Fills original array with the provided value.
 */
public fun ShortArray.fill(element: Short, fromIndex: Int = 0, toIndex: Int = size): Unit {
    java.util.Arrays.fill(this, fromIndex, toIndex, element)
}

/**
 * Fills original array with the provided value.
 */
public fun IntArray.fill(element: Int, fromIndex: Int = 0, toIndex: Int = size): Unit {
    java.util.Arrays.fill(this, fromIndex, toIndex, element)
}

/**
 * Fills original array with the provided value.
 */
public fun LongArray.fill(element: Long, fromIndex: Int = 0, toIndex: Int = size): Unit {
    java.util.Arrays.fill(this, fromIndex, toIndex, element)
}

/**
 * Fills original array with the provided value.
 */
public fun FloatArray.fill(element: Float, fromIndex: Int = 0, toIndex: Int = size): Unit {
    java.util.Arrays.fill(this, fromIndex, toIndex, element)
}

/**
 * Fills original array with the provided value.
 */
public fun DoubleArray.fill(element: Double, fromIndex: Int = 0, toIndex: Int = size): Unit {
    java.util.Arrays.fill(this, fromIndex, toIndex, element)
}

/**
 * Fills original array with the provided value.
 */
public fun BooleanArray.fill(element: Boolean, fromIndex: Int = 0, toIndex: Int = size): Unit {
    java.util.Arrays.fill(this, fromIndex, toIndex, element)
}

/**
 * Fills original array with the provided value.
 */
public fun CharArray.fill(element: Char, fromIndex: Int = 0, toIndex: Int = size): Unit {
    java.util.Arrays.fill(this, fromIndex, toIndex, element)
}

/**
 * Returns an array containing all elements of the original array and then the given [element].
 */
public actual operator fun  Array.plus(element: T): Array {
    val index = size
    val result = java.util.Arrays.copyOf(this, index + 1)
    result[index] = element
    return result
}

/**
 * Returns an array containing all elements of the original array and then the given [element].
 */
public actual operator fun ByteArray.plus(element: Byte): ByteArray {
    val index = size
    val result = java.util.Arrays.copyOf(this, index + 1)
    result[index] = element
    return result
}

/**
 * Returns an array containing all elements of the original array and then the given [element].
 */
public actual operator fun ShortArray.plus(element: Short): ShortArray {
    val index = size
    val result = java.util.Arrays.copyOf(this, index + 1)
    result[index] = element
    return result
}

/**
 * Returns an array containing all elements of the original array and then the given [element].
 */
public actual operator fun IntArray.plus(element: Int): IntArray {
    val index = size
    val result = java.util.Arrays.copyOf(this, index + 1)
    result[index] = element
    return result
}

/**
 * Returns an array containing all elements of the original array and then the given [element].
 */
public actual operator fun LongArray.plus(element: Long): LongArray {
    val index = size
    val result = java.util.Arrays.copyOf(this, index + 1)
    result[index] = element
    return result
}

/**
 * Returns an array containing all elements of the original array and then the given [element].
 */
public actual operator fun FloatArray.plus(element: Float): FloatArray {
    val index = size
    val result = java.util.Arrays.copyOf(this, index + 1)
    result[index] = element
    return result
}

/**
 * Returns an array containing all elements of the original array and then the given [element].
 */
public actual operator fun DoubleArray.plus(element: Double): DoubleArray {
    val index = size
    val result = java.util.Arrays.copyOf(this, index + 1)
    result[index] = element
    return result
}

/**
 * Returns an array containing all elements of the original array and then the given [element].
 */
public actual operator fun BooleanArray.plus(element: Boolean): BooleanArray {
    val index = size
    val result = java.util.Arrays.copyOf(this, index + 1)
    result[index] = element
    return result
}

/**
 * Returns an array containing all elements of the original array and then the given [element].
 */
public actual operator fun CharArray.plus(element: Char): CharArray {
    val index = size
    val result = java.util.Arrays.copyOf(this, index + 1)
    result[index] = element
    return result
}

/**
 * Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
 */
public actual operator fun  Array.plus(elements: Collection): Array {
    var index = size
    val result = java.util.Arrays.copyOf(this, index + elements.size)
    for (element in elements) result[index++] = element
    return result
}

/**
 * Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
 */
public actual operator fun ByteArray.plus(elements: Collection): ByteArray {
    var index = size
    val result = java.util.Arrays.copyOf(this, index + elements.size)
    for (element in elements) result[index++] = element
    return result
}

/**
 * Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
 */
public actual operator fun ShortArray.plus(elements: Collection): ShortArray {
    var index = size
    val result = java.util.Arrays.copyOf(this, index + elements.size)
    for (element in elements) result[index++] = element
    return result
}

/**
 * Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
 */
public actual operator fun IntArray.plus(elements: Collection): IntArray {
    var index = size
    val result = java.util.Arrays.copyOf(this, index + elements.size)
    for (element in elements) result[index++] = element
    return result
}

/**
 * Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
 */
public actual operator fun LongArray.plus(elements: Collection): LongArray {
    var index = size
    val result = java.util.Arrays.copyOf(this, index + elements.size)
    for (element in elements) result[index++] = element
    return result
}

/**
 * Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
 */
public actual operator fun FloatArray.plus(elements: Collection): FloatArray {
    var index = size
    val result = java.util.Arrays.copyOf(this, index + elements.size)
    for (element in elements) result[index++] = element
    return result
}

/**
 * Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
 */
public actual operator fun DoubleArray.plus(elements: Collection): DoubleArray {
    var index = size
    val result = java.util.Arrays.copyOf(this, index + elements.size)
    for (element in elements) result[index++] = element
    return result
}

/**
 * Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
 */
public actual operator fun BooleanArray.plus(elements: Collection): BooleanArray {
    var index = size
    val result = java.util.Arrays.copyOf(this, index + elements.size)
    for (element in elements) result[index++] = element
    return result
}

/**
 * Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
 */
public actual operator fun CharArray.plus(elements: Collection): CharArray {
    var index = size
    val result = java.util.Arrays.copyOf(this, index + elements.size)
    for (element in elements) result[index++] = element
    return result
}

/**
 * Returns an array containing all elements of the original array and then all elements of the given [elements] array.
 */
public actual operator fun  Array.plus(elements: Array): Array {
    val thisSize = size
    val arraySize = elements.size
    val result = java.util.Arrays.copyOf(this, thisSize + arraySize)
    System.arraycopy(elements, 0, result, thisSize, arraySize)
    return result
}

/**
 * Returns an array containing all elements of the original array and then all elements of the given [elements] array.
 */
public actual operator fun ByteArray.plus(elements: ByteArray): ByteArray {
    val thisSize = size
    val arraySize = elements.size
    val result = java.util.Arrays.copyOf(this, thisSize + arraySize)
    System.arraycopy(elements, 0, result, thisSize, arraySize)
    return result
}

/**
 * Returns an array containing all elements of the original array and then all elements of the given [elements] array.
 */
public actual operator fun ShortArray.plus(elements: ShortArray): ShortArray {
    val thisSize = size
    val arraySize = elements.size
    val result = java.util.Arrays.copyOf(this, thisSize + arraySize)
    System.arraycopy(elements, 0, result, thisSize, arraySize)
    return result
}

/**
 * Returns an array containing all elements of the original array and then all elements of the given [elements] array.
 */
public actual operator fun IntArray.plus(elements: IntArray): IntArray {
    val thisSize = size
    val arraySize = elements.size
    val result = java.util.Arrays.copyOf(this, thisSize + arraySize)
    System.arraycopy(elements, 0, result, thisSize, arraySize)
    return result
}

/**
 * Returns an array containing all elements of the original array and then all elements of the given [elements] array.
 */
public actual operator fun LongArray.plus(elements: LongArray): LongArray {
    val thisSize = size
    val arraySize = elements.size
    val result = java.util.Arrays.copyOf(this, thisSize + arraySize)
    System.arraycopy(elements, 0, result, thisSize, arraySize)
    return result
}

/**
 * Returns an array containing all elements of the original array and then all elements of the given [elements] array.
 */
public actual operator fun FloatArray.plus(elements: FloatArray): FloatArray {
    val thisSize = size
    val arraySize = elements.size
    val result = java.util.Arrays.copyOf(this, thisSize + arraySize)
    System.arraycopy(elements, 0, result, thisSize, arraySize)
    return result
}

/**
 * Returns an array containing all elements of the original array and then all elements of the given [elements] array.
 */
public actual operator fun DoubleArray.plus(elements: DoubleArray): DoubleArray {
    val thisSize = size
    val arraySize = elements.size
    val result = java.util.Arrays.copyOf(this, thisSize + arraySize)
    System.arraycopy(elements, 0, result, thisSize, arraySize)
    return result
}

/**
 * Returns an array containing all elements of the original array and then all elements of the given [elements] array.
 */
public actual operator fun BooleanArray.plus(elements: BooleanArray): BooleanArray {
    val thisSize = size
    val arraySize = elements.size
    val result = java.util.Arrays.copyOf(this, thisSize + arraySize)
    System.arraycopy(elements, 0, result, thisSize, arraySize)
    return result
}

/**
 * Returns an array containing all elements of the original array and then all elements of the given [elements] array.
 */
public actual operator fun CharArray.plus(elements: CharArray): CharArray {
    val thisSize = size
    val arraySize = elements.size
    val result = java.util.Arrays.copyOf(this, thisSize + arraySize)
    System.arraycopy(elements, 0, result, thisSize, arraySize)
    return result
}

/**
 * Returns an array containing all elements of the original array and then the given [element].
 */
@kotlin.internal.InlineOnly
public actual inline fun  Array.plusElement(element: T): Array {
    return plus(element)
}

/**
 * Sorts the array in-place.
 */
public actual fun IntArray.sort(): Unit {
    if (size > 1) java.util.Arrays.sort(this)
}

/**
 * Sorts the array in-place.
 */
public actual fun LongArray.sort(): Unit {
    if (size > 1) java.util.Arrays.sort(this)
}

/**
 * Sorts the array in-place.
 */
public actual fun ByteArray.sort(): Unit {
    if (size > 1) java.util.Arrays.sort(this)
}

/**
 * Sorts the array in-place.
 */
public actual fun ShortArray.sort(): Unit {
    if (size > 1) java.util.Arrays.sort(this)
}

/**
 * Sorts the array in-place.
 */
public actual fun DoubleArray.sort(): Unit {
    if (size > 1) java.util.Arrays.sort(this)
}

/**
 * Sorts the array in-place.
 */
public actual fun FloatArray.sort(): Unit {
    if (size > 1) java.util.Arrays.sort(this)
}

/**
 * Sorts the array in-place.
 */
public actual fun CharArray.sort(): Unit {
    if (size > 1) java.util.Arrays.sort(this)
}

/**
 * Sorts the array in-place according to the natural order of its elements.
 */
@kotlin.internal.InlineOnly
public actual inline fun > Array.sort(): Unit {
    @Suppress("UNCHECKED_CAST")
    (this as Array).sort()
}

/**
 * Sorts the array in-place according to the natural order of its elements.
 * 
 * @throws ClassCastException if any element of the array is not [Comparable].
 */
public fun  Array.sort(): Unit {
    if (size > 1) java.util.Arrays.sort(this)
}

/**
 * Sorts a range in the array in-place.
 */
public fun  Array.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
    java.util.Arrays.sort(this, fromIndex, toIndex)
}

/**
 * Sorts a range in the array in-place.
 */
public fun ByteArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
    java.util.Arrays.sort(this, fromIndex, toIndex)
}

/**
 * Sorts a range in the array in-place.
 */
public fun ShortArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
    java.util.Arrays.sort(this, fromIndex, toIndex)
}

/**
 * Sorts a range in the array in-place.
 */
public fun IntArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
    java.util.Arrays.sort(this, fromIndex, toIndex)
}

/**
 * Sorts a range in the array in-place.
 */
public fun LongArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
    java.util.Arrays.sort(this, fromIndex, toIndex)
}

/**
 * Sorts a range in the array in-place.
 */
public fun FloatArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
    java.util.Arrays.sort(this, fromIndex, toIndex)
}

/**
 * Sorts a range in the array in-place.
 */
public fun DoubleArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
    java.util.Arrays.sort(this, fromIndex, toIndex)
}

/**
 * Sorts a range in the array in-place.
 */
public fun CharArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit {
    java.util.Arrays.sort(this, fromIndex, toIndex)
}

/**
 * Sorts the array in-place according to the order specified by the given [comparator].
 */
public actual fun  Array.sortWith(comparator: Comparator): Unit {
    if (size > 1) java.util.Arrays.sort(this, comparator)
}

/**
 * Sorts a range in the array in-place with the given [comparator].
 */
public fun  Array.sortWith(comparator: Comparator, fromIndex: Int = 0, toIndex: Int = size): Unit {
    java.util.Arrays.sort(this, fromIndex, toIndex, comparator)
}

/**
 * Returns a *typed* object array containing all of the elements of this primitive array.
 */
public actual fun ByteArray.toTypedArray(): Array {
    val result = arrayOfNulls(size)
    for (index in indices)
        result[index] = this[index]
    @Suppress("UNCHECKED_CAST")
    return result as Array
}

/**
 * Returns a *typed* object array containing all of the elements of this primitive array.
 */
public actual fun ShortArray.toTypedArray(): Array {
    val result = arrayOfNulls(size)
    for (index in indices)
        result[index] = this[index]
    @Suppress("UNCHECKED_CAST")
    return result as Array
}

/**
 * Returns a *typed* object array containing all of the elements of this primitive array.
 */
public actual fun IntArray.toTypedArray(): Array {
    val result = arrayOfNulls(size)
    for (index in indices)
        result[index] = this[index]
    @Suppress("UNCHECKED_CAST")
    return result as Array
}

/**
 * Returns a *typed* object array containing all of the elements of this primitive array.
 */
public actual fun LongArray.toTypedArray(): Array {
    val result = arrayOfNulls(size)
    for (index in indices)
        result[index] = this[index]
    @Suppress("UNCHECKED_CAST")
    return result as Array
}

/**
 * Returns a *typed* object array containing all of the elements of this primitive array.
 */
public actual fun FloatArray.toTypedArray(): Array {
    val result = arrayOfNulls(size)
    for (index in indices)
        result[index] = this[index]
    @Suppress("UNCHECKED_CAST")
    return result as Array
}

/**
 * Returns a *typed* object array containing all of the elements of this primitive array.
 */
public actual fun DoubleArray.toTypedArray(): Array {
    val result = arrayOfNulls(size)
    for (index in indices)
        result[index] = this[index]
    @Suppress("UNCHECKED_CAST")
    return result as Array
}

/**
 * Returns a *typed* object array containing all of the elements of this primitive array.
 */
public actual fun BooleanArray.toTypedArray(): Array {
    val result = arrayOfNulls(size)
    for (index in indices)
        result[index] = this[index]
    @Suppress("UNCHECKED_CAST")
    return result as Array
}

/**
 * Returns a *typed* object array containing all of the elements of this primitive array.
 */
public actual fun CharArray.toTypedArray(): Array {
    val result = arrayOfNulls(size)
    for (index in indices)
        result[index] = this[index]
    @Suppress("UNCHECKED_CAST")
    return result as Array
}

/**
 * Returns a [SortedSet][java.util.SortedSet] of all elements.
 */
public fun > Array.toSortedSet(): java.util.SortedSet {
    return toCollection(java.util.TreeSet())
}

/**
 * Returns a [SortedSet][java.util.SortedSet] of all elements.
 */
public fun ByteArray.toSortedSet(): java.util.SortedSet {
    return toCollection(java.util.TreeSet())
}

/**
 * Returns a [SortedSet][java.util.SortedSet] of all elements.
 */
public fun ShortArray.toSortedSet(): java.util.SortedSet {
    return toCollection(java.util.TreeSet())
}

/**
 * Returns a [SortedSet][java.util.SortedSet] of all elements.
 */
public fun IntArray.toSortedSet(): java.util.SortedSet {
    return toCollection(java.util.TreeSet())
}

/**
 * Returns a [SortedSet][java.util.SortedSet] of all elements.
 */
public fun LongArray.toSortedSet(): java.util.SortedSet {
    return toCollection(java.util.TreeSet())
}

/**
 * Returns a [SortedSet][java.util.SortedSet] of all elements.
 */
public fun FloatArray.toSortedSet(): java.util.SortedSet {
    return toCollection(java.util.TreeSet())
}

/**
 * Returns a [SortedSet][java.util.SortedSet] of all elements.
 */
public fun DoubleArray.toSortedSet(): java.util.SortedSet {
    return toCollection(java.util.TreeSet())
}

/**
 * Returns a [SortedSet][java.util.SortedSet] of all elements.
 */
public fun BooleanArray.toSortedSet(): java.util.SortedSet {
    return toCollection(java.util.TreeSet())
}

/**
 * Returns a [SortedSet][java.util.SortedSet] of all elements.
 */
public fun CharArray.toSortedSet(): java.util.SortedSet {
    return toCollection(java.util.TreeSet())
}

/**
 * Returns a [SortedSet][java.util.SortedSet] of all elements.
 * 
 * Elements in the set returned are sorted according to the given [comparator].
 */
public fun  Array.toSortedSet(comparator: Comparator): java.util.SortedSet {
    return toCollection(java.util.TreeSet(comparator))
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy