Files
kotlin-fork/libraries/stdlib/js/irRuntime/generated/_ArraysJs.kt
T

1356 lines
51 KiB
Kotlin

/*
* Copyright 2010-2019 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.
*/
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.js.*
import primitiveArrayConcat
import withType
/**
* Returns a [List] that wraps the original array.
*/
public actual fun <T> Array<out T>.asList(): List<T> {
return ArrayList<T>(this.unsafeCast<Array<Any?>>())
}
/**
* Returns a [List] that wraps the original array.
*/
@kotlin.internal.InlineOnly
public actual inline fun ByteArray.asList(): List<Byte> {
return this.unsafeCast<Array<Byte>>().asList()
}
/**
* Returns a [List] that wraps the original array.
*/
@kotlin.internal.InlineOnly
public actual inline fun ShortArray.asList(): List<Short> {
return this.unsafeCast<Array<Short>>().asList()
}
/**
* Returns a [List] that wraps the original array.
*/
@kotlin.internal.InlineOnly
public actual inline fun IntArray.asList(): List<Int> {
return this.unsafeCast<Array<Int>>().asList()
}
/**
* Returns a [List] that wraps the original array.
*/
@kotlin.internal.InlineOnly
public actual inline fun LongArray.asList(): List<Long> {
return this.unsafeCast<Array<Long>>().asList()
}
/**
* Returns a [List] that wraps the original array.
*/
@kotlin.internal.InlineOnly
public actual inline fun FloatArray.asList(): List<Float> {
return this.unsafeCast<Array<Float>>().asList()
}
/**
* Returns a [List] that wraps the original array.
*/
@kotlin.internal.InlineOnly
public actual inline fun DoubleArray.asList(): List<Double> {
return this.unsafeCast<Array<Double>>().asList()
}
/**
* Returns a [List] that wraps the original array.
*/
@kotlin.internal.InlineOnly
public actual inline fun BooleanArray.asList(): List<Boolean> {
return this.unsafeCast<Array<Boolean>>().asList()
}
/**
* Returns a [List] that wraps the original array.
*/
public actual fun CharArray.asList(): List<Char> {
return object : AbstractList<Char>(), RandomAccess {
override val size: Int get() = this@asList.size
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(element: Char): Boolean = this@asList.contains(element)
override fun get(index: Int): Char = this@asList[index]
override fun indexOf(element: Char): Int = this@asList.indexOf(element)
override fun lastIndexOf(element: Char): Int = this@asList.lastIndexOf(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.
*
* The elements of other types are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.1")
public actual infix fun <T> Array<out T>.contentDeepEquals(other: Array<out T>): Boolean {
return contentDeepEqualsImpl(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")
public actual fun <T> Array<out T>.contentDeepHashCode(): Int {
return contentDeepHashCodeInternal()
}
/**
* 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")
public actual fun <T> Array<out T>.contentDeepToString(): String {
return contentDeepToStringImpl()
}
/**
* 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.
*
* The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.1")
public actual infix fun <T> Array<out T>.contentEquals(other: Array<out T>): Boolean {
return contentEqualsInternal(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.
*
* The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.1")
public actual infix fun ByteArray.contentEquals(other: ByteArray): Boolean {
return contentEqualsInternal(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.
*
* The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.1")
public actual infix fun ShortArray.contentEquals(other: ShortArray): Boolean {
return contentEqualsInternal(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.
*
* The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.1")
public actual infix fun IntArray.contentEquals(other: IntArray): Boolean {
return contentEqualsInternal(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.
*
* The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.1")
public actual infix fun LongArray.contentEquals(other: LongArray): Boolean {
return contentEqualsInternal(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.
*
* The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.1")
public actual infix fun FloatArray.contentEquals(other: FloatArray): Boolean {
return contentEqualsInternal(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.
*
* The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.1")
public actual infix fun DoubleArray.contentEquals(other: DoubleArray): Boolean {
return contentEqualsInternal(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.
*
* The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.1")
public actual infix fun BooleanArray.contentEquals(other: BooleanArray): Boolean {
return contentEqualsInternal(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.
*
* The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.1")
public actual infix fun CharArray.contentEquals(other: CharArray): Boolean {
return contentEqualsInternal(other)
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.1")
public actual fun <T> Array<out T>.contentHashCode(): Int {
return contentHashCodeInternal()
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.1")
public actual fun ByteArray.contentHashCode(): Int {
return contentHashCodeInternal()
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.1")
public actual fun ShortArray.contentHashCode(): Int {
return contentHashCodeInternal()
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.1")
public actual fun IntArray.contentHashCode(): Int {
return contentHashCodeInternal()
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.1")
public actual fun LongArray.contentHashCode(): Int {
return contentHashCodeInternal()
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.1")
public actual fun FloatArray.contentHashCode(): Int {
return contentHashCodeInternal()
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.1")
public actual fun DoubleArray.contentHashCode(): Int {
return contentHashCodeInternal()
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.1")
public actual fun BooleanArray.contentHashCode(): Int {
return contentHashCodeInternal()
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.1")
public actual fun CharArray.contentHashCode(): Int {
return contentHashCodeInternal()
}
/**
* 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")
public actual fun <T> Array<out T>.contentToString(): String {
return arrayToString(this as Array<*>)
}
/**
* 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")
public actual fun ByteArray.contentToString(): String {
return arrayToString(this as Array<*>)
}
/**
* 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")
public actual fun ShortArray.contentToString(): String {
return arrayToString(this as Array<*>)
}
/**
* 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")
public actual fun IntArray.contentToString(): String {
return arrayToString(this as Array<*>)
}
/**
* 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")
public actual fun LongArray.contentToString(): String {
return arrayToString(this as Array<*>)
}
/**
* 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")
public actual fun FloatArray.contentToString(): String {
return arrayToString(this as Array<*>)
}
/**
* 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")
public actual fun DoubleArray.contentToString(): String {
return arrayToString(this as Array<*>)
}
/**
* 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")
public actual fun BooleanArray.contentToString(): String {
return arrayToString(this as Array<*>)
}
/**
* 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")
public actual fun CharArray.contentToString(): String {
return arrayToString(this as Array<*>)
}
/**
* 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 [destinationOffset],
* or when that index is out of the [destination] array indices range.
*
* @return the [destination] array.
*/
@SinceKotlin("1.3")
@kotlin.internal.InlineOnly
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual inline fun <T> Array<out T>.copyInto(destination: Array<T>, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): Array<T> {
arrayCopy(this, destination, destinationOffset, startIndex, endIndex)
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 [destinationOffset],
* or when that index is out of the [destination] array indices range.
*
* @return the [destination] array.
*/
@SinceKotlin("1.3")
@kotlin.internal.InlineOnly
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual inline fun ByteArray.copyInto(destination: ByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): ByteArray {
arrayCopy(this.unsafeCast<Array<Byte>>(), destination.unsafeCast<Array<Byte>>(), destinationOffset, startIndex, endIndex)
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 [destinationOffset],
* or when that index is out of the [destination] array indices range.
*
* @return the [destination] array.
*/
@SinceKotlin("1.3")
@kotlin.internal.InlineOnly
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual inline fun ShortArray.copyInto(destination: ShortArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): ShortArray {
arrayCopy(this.unsafeCast<Array<Short>>(), destination.unsafeCast<Array<Short>>(), destinationOffset, startIndex, endIndex)
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 [destinationOffset],
* or when that index is out of the [destination] array indices range.
*
* @return the [destination] array.
*/
@SinceKotlin("1.3")
@kotlin.internal.InlineOnly
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual inline fun IntArray.copyInto(destination: IntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): IntArray {
arrayCopy(this.unsafeCast<Array<Int>>(), destination.unsafeCast<Array<Int>>(), destinationOffset, startIndex, endIndex)
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 [destinationOffset],
* or when that index is out of the [destination] array indices range.
*
* @return the [destination] array.
*/
@SinceKotlin("1.3")
@kotlin.internal.InlineOnly
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual inline fun LongArray.copyInto(destination: LongArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): LongArray {
arrayCopy(this.unsafeCast<Array<Long>>(), destination.unsafeCast<Array<Long>>(), destinationOffset, startIndex, endIndex)
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 [destinationOffset],
* or when that index is out of the [destination] array indices range.
*
* @return the [destination] array.
*/
@SinceKotlin("1.3")
@kotlin.internal.InlineOnly
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual inline fun FloatArray.copyInto(destination: FloatArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): FloatArray {
arrayCopy(this.unsafeCast<Array<Float>>(), destination.unsafeCast<Array<Float>>(), destinationOffset, startIndex, endIndex)
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 [destinationOffset],
* or when that index is out of the [destination] array indices range.
*
* @return the [destination] array.
*/
@SinceKotlin("1.3")
@kotlin.internal.InlineOnly
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual inline fun DoubleArray.copyInto(destination: DoubleArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): DoubleArray {
arrayCopy(this.unsafeCast<Array<Double>>(), destination.unsafeCast<Array<Double>>(), destinationOffset, startIndex, endIndex)
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 [destinationOffset],
* or when that index is out of the [destination] array indices range.
*
* @return the [destination] array.
*/
@SinceKotlin("1.3")
@kotlin.internal.InlineOnly
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual inline fun BooleanArray.copyInto(destination: BooleanArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): BooleanArray {
arrayCopy(this.unsafeCast<Array<Boolean>>(), destination.unsafeCast<Array<Boolean>>(), destinationOffset, startIndex, endIndex)
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 [destinationOffset],
* or when that index is out of the [destination] array indices range.
*
* @return the [destination] array.
*/
@SinceKotlin("1.3")
@kotlin.internal.InlineOnly
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
public actual inline fun CharArray.copyInto(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): CharArray {
arrayCopy(this.unsafeCast<Array<Char>>(), destination.unsafeCast<Array<Char>>(), destinationOffset, startIndex, endIndex)
return destination
}
/**
* Returns new array which is a copy of the original array.
*
* @sample samples.collections.Arrays.CopyOfOperations.copyOf
*/
@Suppress("ACTUAL_WITHOUT_EXPECT", "NOTHING_TO_INLINE")
public actual inline fun <T> Array<out T>.copyOf(): Array<T> {
return this.asDynamic().slice()
}
/**
* Returns new array which is a copy of the original array.
*
* @sample samples.collections.Arrays.CopyOfOperations.copyOf
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline fun ByteArray.copyOf(): ByteArray {
return this.asDynamic().slice()
}
/**
* Returns new array which is a copy of the original array.
*
* @sample samples.collections.Arrays.CopyOfOperations.copyOf
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline fun ShortArray.copyOf(): ShortArray {
return this.asDynamic().slice()
}
/**
* Returns new array which is a copy of the original array.
*
* @sample samples.collections.Arrays.CopyOfOperations.copyOf
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline fun IntArray.copyOf(): IntArray {
return this.asDynamic().slice()
}
/**
* Returns new array which is a copy of the original array.
*
* @sample samples.collections.Arrays.CopyOfOperations.copyOf
*/
public actual fun LongArray.copyOf(): LongArray {
return withType("LongArray", this.asDynamic().slice())
}
/**
* Returns new array which is a copy of the original array.
*
* @sample samples.collections.Arrays.CopyOfOperations.copyOf
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline fun FloatArray.copyOf(): FloatArray {
return this.asDynamic().slice()
}
/**
* Returns new array which is a copy of the original array.
*
* @sample samples.collections.Arrays.CopyOfOperations.copyOf
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline fun DoubleArray.copyOf(): DoubleArray {
return this.asDynamic().slice()
}
/**
* Returns new array which is a copy of the original array.
*
* @sample samples.collections.Arrays.CopyOfOperations.copyOf
*/
public actual fun BooleanArray.copyOf(): BooleanArray {
return withType("BooleanArray", this.asDynamic().slice())
}
/**
* Returns new array which is a copy of the original array.
*
* @sample samples.collections.Arrays.CopyOfOperations.copyOf
*/
public actual fun CharArray.copyOf(): CharArray {
return withType("CharArray", this.asDynamic().slice())
}
/**
* 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
*/
public actual fun ByteArray.copyOf(newSize: Int): ByteArray {
require(newSize >= 0) { "Invalid new array size: $newSize." }
return fillFrom(this, ByteArray(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
*/
public actual fun ShortArray.copyOf(newSize: Int): ShortArray {
require(newSize >= 0) { "Invalid new array size: $newSize." }
return fillFrom(this, ShortArray(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
*/
public actual fun IntArray.copyOf(newSize: Int): IntArray {
require(newSize >= 0) { "Invalid new array size: $newSize." }
return fillFrom(this, IntArray(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
*/
public actual fun LongArray.copyOf(newSize: Int): LongArray {
require(newSize >= 0) { "Invalid new array size: $newSize." }
return withType("LongArray", arrayCopyResize(this, newSize, 0L))
}
/**
* 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
*/
public actual fun FloatArray.copyOf(newSize: Int): FloatArray {
require(newSize >= 0) { "Invalid new array size: $newSize." }
return fillFrom(this, FloatArray(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
*/
public actual fun DoubleArray.copyOf(newSize: Int): DoubleArray {
require(newSize >= 0) { "Invalid new array size: $newSize." }
return fillFrom(this, DoubleArray(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
*/
public actual fun BooleanArray.copyOf(newSize: Int): BooleanArray {
require(newSize >= 0) { "Invalid new array size: $newSize." }
return withType("BooleanArray", arrayCopyResize(this, newSize, false))
}
/**
* 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
*/
public actual fun CharArray.copyOf(newSize: Int): CharArray {
require(newSize >= 0) { "Invalid new array size: $newSize." }
return withType("CharArray", fillFrom(this, CharArray(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
*/
@Suppress("ACTUAL_WITHOUT_EXPECT")
public actual fun <T> Array<out T>.copyOf(newSize: Int): Array<T?> {
require(newSize >= 0) { "Invalid new array size: $newSize." }
return arrayCopyResize(this, newSize, null)
}
/**
* 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`
*/
@Suppress("ACTUAL_WITHOUT_EXPECT")
public actual fun <T> Array<out T>.copyOfRange(fromIndex: Int, toIndex: Int): Array<T> {
AbstractList.checkRangeIndexes(fromIndex, toIndex, size)
return this.asDynamic().slice(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`
*/
public actual fun ByteArray.copyOfRange(fromIndex: Int, toIndex: Int): ByteArray {
AbstractList.checkRangeIndexes(fromIndex, toIndex, size)
return this.asDynamic().slice(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`
*/
public actual fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray {
AbstractList.checkRangeIndexes(fromIndex, toIndex, size)
return this.asDynamic().slice(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`
*/
public actual fun IntArray.copyOfRange(fromIndex: Int, toIndex: Int): IntArray {
AbstractList.checkRangeIndexes(fromIndex, toIndex, size)
return this.asDynamic().slice(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`
*/
public actual fun LongArray.copyOfRange(fromIndex: Int, toIndex: Int): LongArray {
AbstractList.checkRangeIndexes(fromIndex, toIndex, size)
return withType("LongArray", this.asDynamic().slice(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`
*/
public actual fun FloatArray.copyOfRange(fromIndex: Int, toIndex: Int): FloatArray {
AbstractList.checkRangeIndexes(fromIndex, toIndex, size)
return this.asDynamic().slice(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`
*/
public actual fun DoubleArray.copyOfRange(fromIndex: Int, toIndex: Int): DoubleArray {
AbstractList.checkRangeIndexes(fromIndex, toIndex, size)
return this.asDynamic().slice(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`
*/
public actual fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int): BooleanArray {
AbstractList.checkRangeIndexes(fromIndex, toIndex, size)
return withType("BooleanArray", this.asDynamic().slice(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`
*/
public actual fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray {
AbstractList.checkRangeIndexes(fromIndex, toIndex, size)
return withType("CharArray", this.asDynamic().slice(fromIndex, toIndex))
}
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
@Suppress("ACTUAL_WITHOUT_EXPECT", "NOTHING_TO_INLINE")
public actual inline operator fun <T> Array<out T>.plus(element: T): Array<T> {
return this.asDynamic().concat(arrayOf(element))
}
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline operator fun ByteArray.plus(element: Byte): ByteArray {
return plus(byteArrayOf(element))
}
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline operator fun ShortArray.plus(element: Short): ShortArray {
return plus(shortArrayOf(element))
}
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline operator fun IntArray.plus(element: Int): IntArray {
return plus(intArrayOf(element))
}
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline operator fun LongArray.plus(element: Long): LongArray {
return plus(longArrayOf(element))
}
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline operator fun FloatArray.plus(element: Float): FloatArray {
return plus(floatArrayOf(element))
}
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline operator fun DoubleArray.plus(element: Double): DoubleArray {
return plus(doubleArrayOf(element))
}
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline operator fun BooleanArray.plus(element: Boolean): BooleanArray {
return plus(booleanArrayOf(element))
}
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline operator fun CharArray.plus(element: Char): CharArray {
return plus(charArrayOf(element))
}
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
*/
@Suppress("ACTUAL_WITHOUT_EXPECT")
public actual operator fun <T> Array<out T>.plus(elements: Collection<T>): Array<T> {
return arrayPlusCollection(this, elements)
}
/**
* 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<Byte>): ByteArray {
var index = size
val result = this.copyOf(size + 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<Short>): ShortArray {
var index = size
val result = this.copyOf(size + 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<Int>): IntArray {
var index = size
val result = this.copyOf(size + 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<Long>): LongArray {
return arrayPlusCollection(this, elements)
}
/**
* 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<Float>): FloatArray {
var index = size
val result = this.copyOf(size + 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<Double>): DoubleArray {
var index = size
val result = this.copyOf(size + 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<Boolean>): BooleanArray {
return arrayPlusCollection(this, elements)
}
/**
* 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<Char>): CharArray {
var index = size
val result = this.copyOf(size + 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.
*/
@Suppress("ACTUAL_WITHOUT_EXPECT", "NOTHING_TO_INLINE")
public actual inline operator fun <T> Array<out T>.plus(elements: Array<out T>): Array<T> {
return this.asDynamic().concat(elements)
}
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline operator fun ByteArray.plus(elements: ByteArray): ByteArray {
return primitiveArrayConcat(this, elements)
}
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline operator fun ShortArray.plus(elements: ShortArray): ShortArray {
return primitiveArrayConcat(this, elements)
}
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline operator fun IntArray.plus(elements: IntArray): IntArray {
return primitiveArrayConcat(this, elements)
}
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline operator fun LongArray.plus(elements: LongArray): LongArray {
return primitiveArrayConcat(this, elements)
}
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline operator fun FloatArray.plus(elements: FloatArray): FloatArray {
return primitiveArrayConcat(this, elements)
}
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline operator fun DoubleArray.plus(elements: DoubleArray): DoubleArray {
return primitiveArrayConcat(this, elements)
}
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline operator fun BooleanArray.plus(elements: BooleanArray): BooleanArray {
return primitiveArrayConcat(this, elements)
}
/**
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
*/
@Suppress("NOTHING_TO_INLINE")
public actual inline operator fun CharArray.plus(elements: CharArray): CharArray {
return primitiveArrayConcat(this, elements)
}
/**
* Returns an array containing all elements of the original array and then the given [element].
*/
@Suppress("ACTUAL_WITHOUT_EXPECT", "NOTHING_TO_INLINE")
public actual inline fun <T> Array<out T>.plusElement(element: T): Array<T> {
return this.asDynamic().concat(arrayOf(element))
}
/**
* Sorts the array in-place.
*/
public actual fun IntArray.sort(): Unit {
this.asDynamic().sort()
}
/**
* Sorts the array in-place.
*/
public actual fun LongArray.sort(): Unit {
if (size > 1) sort { a: Long, b: Long -> a.compareTo(b) }
}
/**
* Sorts the array in-place.
*/
public actual fun ByteArray.sort(): Unit {
this.asDynamic().sort()
}
/**
* Sorts the array in-place.
*/
public actual fun ShortArray.sort(): Unit {
this.asDynamic().sort()
}
/**
* Sorts the array in-place.
*/
public actual fun DoubleArray.sort(): Unit {
this.asDynamic().sort()
}
/**
* Sorts the array in-place.
*/
public actual fun FloatArray.sort(): Unit {
this.asDynamic().sort()
}
/**
* Sorts the array in-place.
*/
public actual fun CharArray.sort(): Unit {
this.asDynamic().sort()
}
/**
* Sorts the array in-place according to the natural order of its elements.
*
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
*/
public actual fun <T : Comparable<T>> Array<out T>.sort(): Unit {
if (size > 1) sortArray(this)
}
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
*/
public fun <T> Array<out T>.sort(comparison: (a: T, b: T) -> Int): Unit {
if (size > 1) sortArrayWith(this, comparison)
}
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@kotlin.internal.InlineOnly
public inline fun ByteArray.sort(noinline comparison: (a: Byte, b: Byte) -> Int): Unit {
asDynamic().sort(comparison)
}
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@kotlin.internal.InlineOnly
public inline fun ShortArray.sort(noinline comparison: (a: Short, b: Short) -> Int): Unit {
asDynamic().sort(comparison)
}
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@kotlin.internal.InlineOnly
public inline fun IntArray.sort(noinline comparison: (a: Int, b: Int) -> Int): Unit {
asDynamic().sort(comparison)
}
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@kotlin.internal.InlineOnly
public inline fun LongArray.sort(noinline comparison: (a: Long, b: Long) -> Int): Unit {
asDynamic().sort(comparison)
}
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@kotlin.internal.InlineOnly
public inline fun FloatArray.sort(noinline comparison: (a: Float, b: Float) -> Int): Unit {
asDynamic().sort(comparison)
}
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@kotlin.internal.InlineOnly
public inline fun DoubleArray.sort(noinline comparison: (a: Double, b: Double) -> Int): Unit {
asDynamic().sort(comparison)
}
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@kotlin.internal.InlineOnly
public inline fun CharArray.sort(noinline comparison: (a: Char, b: Char) -> Int): Unit {
asDynamic().sort(comparison)
}
/**
* Sorts the array in-place according to the order specified by the given [comparator].
*
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
*/
public actual fun <T> Array<out T>.sortWith(comparator: Comparator<in T>): Unit {
if (size > 1) sortArrayWith(this, comparator)
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public actual fun ByteArray.toTypedArray(): Array<Byte> {
return js("[]").slice.call(this)
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public actual fun ShortArray.toTypedArray(): Array<Short> {
return js("[]").slice.call(this)
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public actual fun IntArray.toTypedArray(): Array<Int> {
return js("[]").slice.call(this)
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public actual fun LongArray.toTypedArray(): Array<Long> {
return js("[]").slice.call(this)
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public actual fun FloatArray.toTypedArray(): Array<Float> {
return js("[]").slice.call(this)
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public actual fun DoubleArray.toTypedArray(): Array<Double> {
return js("[]").slice.call(this)
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public actual fun BooleanArray.toTypedArray(): Array<Boolean> {
return js("[]").slice.call(this)
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public actual fun CharArray.toTypedArray(): Array<Char> {
return Array(size) { index -> this[index] }
}