From 947fd84f1e4e4731dc10747aa8f98c02a5d1f042 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Tue, 2 Feb 2016 00:54:44 +0300 Subject: [PATCH] Minor: reorder primitive specializations in generated code (according to the order they defined in java). --- js/js.libraries/src/core/kotlin_special.kt | 28 +- libraries/stdlib/src/generated/_Arrays.kt | 9416 ++++++++--------- .../stdlib/src/generated/_Collections.kt | 76 +- libraries/stdlib/src/generated/_Ranges.kt | 88 +- libraries/stdlib/src/generated/_Sequences.kt | 76 +- .../src/templates/engine/Engine.kt | 8 +- 6 files changed, 4846 insertions(+), 4846 deletions(-) diff --git a/js/js.libraries/src/core/kotlin_special.kt b/js/js.libraries/src/core/kotlin_special.kt index 522c2c2b51a..4f474d7e9ca 100644 --- a/js/js.libraries/src/core/kotlin_special.kt +++ b/js/js.libraries/src/core/kotlin_special.kt @@ -146,13 +146,6 @@ public inline fun ShortArray.copyOf(): ShortArray { return this.asDynamic().slice(0) } -/** - * Returns new array which is a copy of the original array. - */ -public fun BooleanArray.copyOf(newSize: Int): BooleanArray { - return arrayCopyResize(this, newSize, false) -} - /** * Returns new array which is a copy of the original array. */ @@ -160,13 +153,6 @@ public fun ByteArray.copyOf(newSize: Int): ByteArray { return arrayCopyResize(this, newSize, 0) } -/** - * Returns new array which is a copy of the original array. - */ -public fun CharArray.copyOf(newSize: Int): CharArray { - return arrayCopyResize(this, newSize, '\u0000') -} - /** * Returns new array which is a copy of the original array. */ @@ -202,6 +188,20 @@ public fun DoubleArray.copyOf(newSize: Int): DoubleArray { return arrayCopyResize(this, newSize, 0.0) } +/** + * Returns new array which is a copy of the original array. + */ +public fun BooleanArray.copyOf(newSize: Int): BooleanArray { + return arrayCopyResize(this, newSize, false) +} + +/** + * Returns new array which is a copy of the original array. + */ +public fun CharArray.copyOf(newSize: Int): CharArray { + return arrayCopyResize(this, newSize, '\u0000') +} + /** * Returns new array which is a copy of the original array. */ diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index 49ccb28e7ae..d341e4ad810 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -21,14 +21,6 @@ public inline operator fun Array.component1(): T { return get(0) } -/** - * Returns 1st *element* from the collection. - */ -@kotlin.internal.InlineOnly -public inline operator fun BooleanArray.component1(): Boolean { - return get(0) -} - /** * Returns 1st *element* from the collection. */ @@ -41,23 +33,7 @@ public inline operator fun ByteArray.component1(): Byte { * Returns 1st *element* from the collection. */ @kotlin.internal.InlineOnly -public inline operator fun CharArray.component1(): Char { - return get(0) -} - -/** - * Returns 1st *element* from the collection. - */ -@kotlin.internal.InlineOnly -public inline operator fun DoubleArray.component1(): Double { - return get(0) -} - -/** - * Returns 1st *element* from the collection. - */ -@kotlin.internal.InlineOnly -public inline operator fun FloatArray.component1(): Float { +public inline operator fun ShortArray.component1(): Short { return get(0) } @@ -81,7 +57,31 @@ public inline operator fun LongArray.component1(): Long { * Returns 1st *element* from the collection. */ @kotlin.internal.InlineOnly -public inline operator fun ShortArray.component1(): Short { +public inline operator fun FloatArray.component1(): Float { + return get(0) +} + +/** + * Returns 1st *element* from the collection. + */ +@kotlin.internal.InlineOnly +public inline operator fun DoubleArray.component1(): Double { + return get(0) +} + +/** + * Returns 1st *element* from the collection. + */ +@kotlin.internal.InlineOnly +public inline operator fun BooleanArray.component1(): Boolean { + return get(0) +} + +/** + * Returns 1st *element* from the collection. + */ +@kotlin.internal.InlineOnly +public inline operator fun CharArray.component1(): Char { return get(0) } @@ -93,14 +93,6 @@ public inline operator fun Array.component2(): T { return get(1) } -/** - * Returns 2nd *element* from the collection. - */ -@kotlin.internal.InlineOnly -public inline operator fun BooleanArray.component2(): Boolean { - return get(1) -} - /** * Returns 2nd *element* from the collection. */ @@ -113,23 +105,7 @@ public inline operator fun ByteArray.component2(): Byte { * Returns 2nd *element* from the collection. */ @kotlin.internal.InlineOnly -public inline operator fun CharArray.component2(): Char { - return get(1) -} - -/** - * Returns 2nd *element* from the collection. - */ -@kotlin.internal.InlineOnly -public inline operator fun DoubleArray.component2(): Double { - return get(1) -} - -/** - * Returns 2nd *element* from the collection. - */ -@kotlin.internal.InlineOnly -public inline operator fun FloatArray.component2(): Float { +public inline operator fun ShortArray.component2(): Short { return get(1) } @@ -153,7 +129,31 @@ public inline operator fun LongArray.component2(): Long { * Returns 2nd *element* from the collection. */ @kotlin.internal.InlineOnly -public inline operator fun ShortArray.component2(): Short { +public inline operator fun FloatArray.component2(): Float { + return get(1) +} + +/** + * Returns 2nd *element* from the collection. + */ +@kotlin.internal.InlineOnly +public inline operator fun DoubleArray.component2(): Double { + return get(1) +} + +/** + * Returns 2nd *element* from the collection. + */ +@kotlin.internal.InlineOnly +public inline operator fun BooleanArray.component2(): Boolean { + return get(1) +} + +/** + * Returns 2nd *element* from the collection. + */ +@kotlin.internal.InlineOnly +public inline operator fun CharArray.component2(): Char { return get(1) } @@ -165,14 +165,6 @@ public inline operator fun Array.component3(): T { return get(2) } -/** - * Returns 3rd *element* from the collection. - */ -@kotlin.internal.InlineOnly -public inline operator fun BooleanArray.component3(): Boolean { - return get(2) -} - /** * Returns 3rd *element* from the collection. */ @@ -185,23 +177,7 @@ public inline operator fun ByteArray.component3(): Byte { * Returns 3rd *element* from the collection. */ @kotlin.internal.InlineOnly -public inline operator fun CharArray.component3(): Char { - return get(2) -} - -/** - * Returns 3rd *element* from the collection. - */ -@kotlin.internal.InlineOnly -public inline operator fun DoubleArray.component3(): Double { - return get(2) -} - -/** - * Returns 3rd *element* from the collection. - */ -@kotlin.internal.InlineOnly -public inline operator fun FloatArray.component3(): Float { +public inline operator fun ShortArray.component3(): Short { return get(2) } @@ -225,7 +201,31 @@ public inline operator fun LongArray.component3(): Long { * Returns 3rd *element* from the collection. */ @kotlin.internal.InlineOnly -public inline operator fun ShortArray.component3(): Short { +public inline operator fun FloatArray.component3(): Float { + return get(2) +} + +/** + * Returns 3rd *element* from the collection. + */ +@kotlin.internal.InlineOnly +public inline operator fun DoubleArray.component3(): Double { + return get(2) +} + +/** + * Returns 3rd *element* from the collection. + */ +@kotlin.internal.InlineOnly +public inline operator fun BooleanArray.component3(): Boolean { + return get(2) +} + +/** + * Returns 3rd *element* from the collection. + */ +@kotlin.internal.InlineOnly +public inline operator fun CharArray.component3(): Char { return get(2) } @@ -237,14 +237,6 @@ public inline operator fun Array.component4(): T { return get(3) } -/** - * Returns 4th *element* from the collection. - */ -@kotlin.internal.InlineOnly -public inline operator fun BooleanArray.component4(): Boolean { - return get(3) -} - /** * Returns 4th *element* from the collection. */ @@ -257,23 +249,7 @@ public inline operator fun ByteArray.component4(): Byte { * Returns 4th *element* from the collection. */ @kotlin.internal.InlineOnly -public inline operator fun CharArray.component4(): Char { - return get(3) -} - -/** - * Returns 4th *element* from the collection. - */ -@kotlin.internal.InlineOnly -public inline operator fun DoubleArray.component4(): Double { - return get(3) -} - -/** - * Returns 4th *element* from the collection. - */ -@kotlin.internal.InlineOnly -public inline operator fun FloatArray.component4(): Float { +public inline operator fun ShortArray.component4(): Short { return get(3) } @@ -297,7 +273,31 @@ public inline operator fun LongArray.component4(): Long { * Returns 4th *element* from the collection. */ @kotlin.internal.InlineOnly -public inline operator fun ShortArray.component4(): Short { +public inline operator fun FloatArray.component4(): Float { + return get(3) +} + +/** + * Returns 4th *element* from the collection. + */ +@kotlin.internal.InlineOnly +public inline operator fun DoubleArray.component4(): Double { + return get(3) +} + +/** + * Returns 4th *element* from the collection. + */ +@kotlin.internal.InlineOnly +public inline operator fun BooleanArray.component4(): Boolean { + return get(3) +} + +/** + * Returns 4th *element* from the collection. + */ +@kotlin.internal.InlineOnly +public inline operator fun CharArray.component4(): Char { return get(3) } @@ -309,14 +309,6 @@ public inline operator fun Array.component5(): T { return get(4) } -/** - * Returns 5th *element* from the collection. - */ -@kotlin.internal.InlineOnly -public inline operator fun BooleanArray.component5(): Boolean { - return get(4) -} - /** * Returns 5th *element* from the collection. */ @@ -329,23 +321,7 @@ public inline operator fun ByteArray.component5(): Byte { * Returns 5th *element* from the collection. */ @kotlin.internal.InlineOnly -public inline operator fun CharArray.component5(): Char { - return get(4) -} - -/** - * Returns 5th *element* from the collection. - */ -@kotlin.internal.InlineOnly -public inline operator fun DoubleArray.component5(): Double { - return get(4) -} - -/** - * Returns 5th *element* from the collection. - */ -@kotlin.internal.InlineOnly -public inline operator fun FloatArray.component5(): Float { +public inline operator fun ShortArray.component5(): Short { return get(4) } @@ -369,7 +345,31 @@ public inline operator fun LongArray.component5(): Long { * Returns 5th *element* from the collection. */ @kotlin.internal.InlineOnly -public inline operator fun ShortArray.component5(): Short { +public inline operator fun FloatArray.component5(): Float { + return get(4) +} + +/** + * Returns 5th *element* from the collection. + */ +@kotlin.internal.InlineOnly +public inline operator fun DoubleArray.component5(): Double { + return get(4) +} + +/** + * Returns 5th *element* from the collection. + */ +@kotlin.internal.InlineOnly +public inline operator fun BooleanArray.component5(): Boolean { + return get(4) +} + +/** + * Returns 5th *element* from the collection. + */ +@kotlin.internal.InlineOnly +public inline operator fun CharArray.component5(): Char { return get(4) } @@ -380,13 +380,6 @@ public operator fun <@kotlin.internal.OnlyInputTypes T> Array.contains(el return indexOf(element) >= 0 } -/** - * Returns `true` if [element] is found in the array. - */ -public operator fun BooleanArray.contains(element: Boolean): Boolean { - return indexOf(element) >= 0 -} - /** * Returns `true` if [element] is found in the array. */ @@ -397,21 +390,7 @@ public operator fun ByteArray.contains(element: Byte): Boolean { /** * Returns `true` if [element] is found in the array. */ -public operator fun CharArray.contains(element: Char): Boolean { - return indexOf(element) >= 0 -} - -/** - * Returns `true` if [element] is found in the array. - */ -public operator fun DoubleArray.contains(element: Double): Boolean { - return indexOf(element) >= 0 -} - -/** - * Returns `true` if [element] is found in the array. - */ -public operator fun FloatArray.contains(element: Float): Boolean { +public operator fun ShortArray.contains(element: Short): Boolean { return indexOf(element) >= 0 } @@ -432,7 +411,28 @@ public operator fun LongArray.contains(element: Long): Boolean { /** * Returns `true` if [element] is found in the array. */ -public operator fun ShortArray.contains(element: Short): Boolean { +public operator fun FloatArray.contains(element: Float): Boolean { + return indexOf(element) >= 0 +} + +/** + * Returns `true` if [element] is found in the array. + */ +public operator fun DoubleArray.contains(element: Double): Boolean { + return indexOf(element) >= 0 +} + +/** + * Returns `true` if [element] is found in the array. + */ +public operator fun BooleanArray.contains(element: Boolean): Boolean { + return indexOf(element) >= 0 +} + +/** + * Returns `true` if [element] is found in the array. + */ +public operator fun CharArray.contains(element: Char): Boolean { return indexOf(element) >= 0 } @@ -444,14 +444,6 @@ public inline fun Array.elementAt(index: Int): T { return get(index) } -/** - * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array. - */ -@kotlin.internal.InlineOnly -public inline fun BooleanArray.elementAt(index: Int): Boolean { - return get(index) -} - /** * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array. */ @@ -464,23 +456,7 @@ public inline fun ByteArray.elementAt(index: Int): Byte { * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array. */ @kotlin.internal.InlineOnly -public inline fun CharArray.elementAt(index: Int): Char { - return get(index) -} - -/** - * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array. - */ -@kotlin.internal.InlineOnly -public inline fun DoubleArray.elementAt(index: Int): Double { - return get(index) -} - -/** - * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array. - */ -@kotlin.internal.InlineOnly -public inline fun FloatArray.elementAt(index: Int): Float { +public inline fun ShortArray.elementAt(index: Int): Short { return get(index) } @@ -504,7 +480,31 @@ public inline fun LongArray.elementAt(index: Int): Long { * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array. */ @kotlin.internal.InlineOnly -public inline fun ShortArray.elementAt(index: Int): Short { +public inline fun FloatArray.elementAt(index: Int): Float { + return get(index) +} + +/** + * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array. + */ +@kotlin.internal.InlineOnly +public inline fun DoubleArray.elementAt(index: Int): Double { + return get(index) +} + +/** + * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array. + */ +@kotlin.internal.InlineOnly +public inline fun BooleanArray.elementAt(index: Int): Boolean { + return get(index) +} + +/** + * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array. + */ +@kotlin.internal.InlineOnly +public inline fun CharArray.elementAt(index: Int): Char { return get(index) } @@ -516,14 +516,6 @@ public inline fun Array.elementAtOrElse(index: Int, defaultValue: (In return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } -/** - * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. - */ -@kotlin.internal.InlineOnly -public inline fun BooleanArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Boolean): Boolean { - return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) -} - /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ @@ -536,23 +528,7 @@ public inline fun ByteArray.elementAtOrElse(index: Int, defaultValue: (Int) -> B * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ @kotlin.internal.InlineOnly -public inline fun CharArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Char): Char { - return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) -} - -/** - * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. - */ -@kotlin.internal.InlineOnly -public inline fun DoubleArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Double): Double { - return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) -} - -/** - * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. - */ -@kotlin.internal.InlineOnly -public inline fun FloatArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Float): Float { +public inline fun ShortArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Short): Short { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -576,7 +552,31 @@ public inline fun LongArray.elementAtOrElse(index: Int, defaultValue: (Int) -> L * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ @kotlin.internal.InlineOnly -public inline fun ShortArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Short): Short { +public inline fun FloatArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Float): Float { + return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) +} + +/** + * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. + */ +@kotlin.internal.InlineOnly +public inline fun DoubleArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Double): Double { + return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) +} + +/** + * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. + */ +@kotlin.internal.InlineOnly +public inline fun BooleanArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Boolean): Boolean { + return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) +} + +/** + * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. + */ +@kotlin.internal.InlineOnly +public inline fun CharArray.elementAtOrElse(index: Int, defaultValue: (Int) -> Char): Char { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -588,14 +588,6 @@ public inline fun Array.elementAtOrNull(index: Int): T? { return this.getOrNull(index) } -/** - * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. - */ -@kotlin.internal.InlineOnly -public inline fun BooleanArray.elementAtOrNull(index: Int): Boolean? { - return this.getOrNull(index) -} - /** * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. */ @@ -608,23 +600,7 @@ public inline fun ByteArray.elementAtOrNull(index: Int): Byte? { * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. */ @kotlin.internal.InlineOnly -public inline fun CharArray.elementAtOrNull(index: Int): Char? { - return this.getOrNull(index) -} - -/** - * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. - */ -@kotlin.internal.InlineOnly -public inline fun DoubleArray.elementAtOrNull(index: Int): Double? { - return this.getOrNull(index) -} - -/** - * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. - */ -@kotlin.internal.InlineOnly -public inline fun FloatArray.elementAtOrNull(index: Int): Float? { +public inline fun ShortArray.elementAtOrNull(index: Int): Short? { return this.getOrNull(index) } @@ -648,7 +624,31 @@ public inline fun LongArray.elementAtOrNull(index: Int): Long? { * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. */ @kotlin.internal.InlineOnly -public inline fun ShortArray.elementAtOrNull(index: Int): Short? { +public inline fun FloatArray.elementAtOrNull(index: Int): Float? { + return this.getOrNull(index) +} + +/** + * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. + */ +@kotlin.internal.InlineOnly +public inline fun DoubleArray.elementAtOrNull(index: Int): Double? { + return this.getOrNull(index) +} + +/** + * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. + */ +@kotlin.internal.InlineOnly +public inline fun BooleanArray.elementAtOrNull(index: Int): Boolean? { + return this.getOrNull(index) +} + +/** + * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. + */ +@kotlin.internal.InlineOnly +public inline fun CharArray.elementAtOrNull(index: Int): Char? { return this.getOrNull(index) } @@ -660,14 +660,6 @@ public inline fun Array.find(predicate: (T) -> Boolean): T? { return firstOrNull(predicate) } -/** - * Returns the first element matching the given [predicate], or `null` if no such element was found. - */ -@kotlin.internal.InlineOnly -public inline fun BooleanArray.find(predicate: (Boolean) -> Boolean): Boolean? { - return firstOrNull(predicate) -} - /** * Returns the first element matching the given [predicate], or `null` if no such element was found. */ @@ -680,23 +672,7 @@ public inline fun ByteArray.find(predicate: (Byte) -> Boolean): Byte? { * Returns the first element matching the given [predicate], or `null` if no such element was found. */ @kotlin.internal.InlineOnly -public inline fun CharArray.find(predicate: (Char) -> Boolean): Char? { - return firstOrNull(predicate) -} - -/** - * Returns the first element matching the given [predicate], or `null` if no such element was found. - */ -@kotlin.internal.InlineOnly -public inline fun DoubleArray.find(predicate: (Double) -> Boolean): Double? { - return firstOrNull(predicate) -} - -/** - * Returns the first element matching the given [predicate], or `null` if no such element was found. - */ -@kotlin.internal.InlineOnly -public inline fun FloatArray.find(predicate: (Float) -> Boolean): Float? { +public inline fun ShortArray.find(predicate: (Short) -> Boolean): Short? { return firstOrNull(predicate) } @@ -720,7 +696,31 @@ public inline fun LongArray.find(predicate: (Long) -> Boolean): Long? { * Returns the first element matching the given [predicate], or `null` if no such element was found. */ @kotlin.internal.InlineOnly -public inline fun ShortArray.find(predicate: (Short) -> Boolean): Short? { +public inline fun FloatArray.find(predicate: (Float) -> Boolean): Float? { + return firstOrNull(predicate) +} + +/** + * Returns the first element matching the given [predicate], or `null` if no such element was found. + */ +@kotlin.internal.InlineOnly +public inline fun DoubleArray.find(predicate: (Double) -> Boolean): Double? { + return firstOrNull(predicate) +} + +/** + * Returns the first element matching the given [predicate], or `null` if no such element was found. + */ +@kotlin.internal.InlineOnly +public inline fun BooleanArray.find(predicate: (Boolean) -> Boolean): Boolean? { + return firstOrNull(predicate) +} + +/** + * Returns the first element matching the given [predicate], or `null` if no such element was found. + */ +@kotlin.internal.InlineOnly +public inline fun CharArray.find(predicate: (Char) -> Boolean): Char? { return firstOrNull(predicate) } @@ -732,14 +732,6 @@ public inline fun Array.findLast(predicate: (T) -> Boolean): T? { return lastOrNull(predicate) } -/** - * Returns the last element matching the given [predicate], or `null` if no such element was found. - */ -@kotlin.internal.InlineOnly -public inline fun BooleanArray.findLast(predicate: (Boolean) -> Boolean): Boolean? { - return lastOrNull(predicate) -} - /** * Returns the last element matching the given [predicate], or `null` if no such element was found. */ @@ -752,23 +744,7 @@ public inline fun ByteArray.findLast(predicate: (Byte) -> Boolean): Byte? { * Returns the last element matching the given [predicate], or `null` if no such element was found. */ @kotlin.internal.InlineOnly -public inline fun CharArray.findLast(predicate: (Char) -> Boolean): Char? { - return lastOrNull(predicate) -} - -/** - * Returns the last element matching the given [predicate], or `null` if no such element was found. - */ -@kotlin.internal.InlineOnly -public inline fun DoubleArray.findLast(predicate: (Double) -> Boolean): Double? { - return lastOrNull(predicate) -} - -/** - * Returns the last element matching the given [predicate], or `null` if no such element was found. - */ -@kotlin.internal.InlineOnly -public inline fun FloatArray.findLast(predicate: (Float) -> Boolean): Float? { +public inline fun ShortArray.findLast(predicate: (Short) -> Boolean): Short? { return lastOrNull(predicate) } @@ -792,7 +768,31 @@ public inline fun LongArray.findLast(predicate: (Long) -> Boolean): Long? { * Returns the last element matching the given [predicate], or `null` if no such element was found. */ @kotlin.internal.InlineOnly -public inline fun ShortArray.findLast(predicate: (Short) -> Boolean): Short? { +public inline fun FloatArray.findLast(predicate: (Float) -> Boolean): Float? { + return lastOrNull(predicate) +} + +/** + * Returns the last element matching the given [predicate], or `null` if no such element was found. + */ +@kotlin.internal.InlineOnly +public inline fun DoubleArray.findLast(predicate: (Double) -> Boolean): Double? { + return lastOrNull(predicate) +} + +/** + * Returns the last element matching the given [predicate], or `null` if no such element was found. + */ +@kotlin.internal.InlineOnly +public inline fun BooleanArray.findLast(predicate: (Boolean) -> Boolean): Boolean? { + return lastOrNull(predicate) +} + +/** + * Returns the last element matching the given [predicate], or `null` if no such element was found. + */ +@kotlin.internal.InlineOnly +public inline fun CharArray.findLast(predicate: (Char) -> Boolean): Char? { return lastOrNull(predicate) } @@ -806,16 +806,6 @@ public fun Array.first(): T { return this[0] } -/** - * Returns first element. - * @throws [NoSuchElementException] if the array is empty. - */ -public fun BooleanArray.first(): Boolean { - if (isEmpty()) - throw NoSuchElementException("Collection is empty.") - return this[0] -} - /** * Returns first element. * @throws [NoSuchElementException] if the array is empty. @@ -830,27 +820,7 @@ public fun ByteArray.first(): Byte { * Returns first element. * @throws [NoSuchElementException] if the array is empty. */ -public fun CharArray.first(): Char { - if (isEmpty()) - throw NoSuchElementException("Collection is empty.") - return this[0] -} - -/** - * Returns first element. - * @throws [NoSuchElementException] if the array is empty. - */ -public fun DoubleArray.first(): Double { - if (isEmpty()) - throw NoSuchElementException("Collection is empty.") - return this[0] -} - -/** - * Returns first element. - * @throws [NoSuchElementException] if the array is empty. - */ -public fun FloatArray.first(): Float { +public fun ShortArray.first(): Short { if (isEmpty()) throw NoSuchElementException("Collection is empty.") return this[0] @@ -880,7 +850,37 @@ public fun LongArray.first(): Long { * Returns first element. * @throws [NoSuchElementException] if the array is empty. */ -public fun ShortArray.first(): Short { +public fun FloatArray.first(): Float { + if (isEmpty()) + throw NoSuchElementException("Collection is empty.") + return this[0] +} + +/** + * Returns first element. + * @throws [NoSuchElementException] if the array is empty. + */ +public fun DoubleArray.first(): Double { + if (isEmpty()) + throw NoSuchElementException("Collection is empty.") + return this[0] +} + +/** + * Returns first element. + * @throws [NoSuchElementException] if the array is empty. + */ +public fun BooleanArray.first(): Boolean { + if (isEmpty()) + throw NoSuchElementException("Collection is empty.") + return this[0] +} + +/** + * Returns first element. + * @throws [NoSuchElementException] if the array is empty. + */ +public fun CharArray.first(): Char { if (isEmpty()) throw NoSuchElementException("Collection is empty.") return this[0] @@ -895,15 +895,6 @@ public inline fun Array.first(predicate: (T) -> Boolean): T { throw NoSuchElementException("No element matching predicate was found.") } -/** - * Returns the first element matching the given [predicate]. - * @throws [NoSuchElementException] if no such element is found. - */ -public inline fun BooleanArray.first(predicate: (Boolean) -> Boolean): Boolean { - for (element in this) if (predicate(element)) return element - throw NoSuchElementException("No element matching predicate was found.") -} - /** * Returns the first element matching the given [predicate]. * @throws [NoSuchElementException] if no such element is found. @@ -917,25 +908,7 @@ public inline fun ByteArray.first(predicate: (Byte) -> Boolean): Byte { * Returns the first element matching the given [predicate]. * @throws [NoSuchElementException] if no such element is found. */ -public inline fun CharArray.first(predicate: (Char) -> Boolean): Char { - for (element in this) if (predicate(element)) return element - throw NoSuchElementException("No element matching predicate was found.") -} - -/** - * Returns the first element matching the given [predicate]. - * @throws [NoSuchElementException] if no such element is found. - */ -public inline fun DoubleArray.first(predicate: (Double) -> Boolean): Double { - for (element in this) if (predicate(element)) return element - throw NoSuchElementException("No element matching predicate was found.") -} - -/** - * Returns the first element matching the given [predicate]. - * @throws [NoSuchElementException] if no such element is found. - */ -public inline fun FloatArray.first(predicate: (Float) -> Boolean): Float { +public inline fun ShortArray.first(predicate: (Short) -> Boolean): Short { for (element in this) if (predicate(element)) return element throw NoSuchElementException("No element matching predicate was found.") } @@ -962,7 +935,34 @@ public inline fun LongArray.first(predicate: (Long) -> Boolean): Long { * Returns the first element matching the given [predicate]. * @throws [NoSuchElementException] if no such element is found. */ -public inline fun ShortArray.first(predicate: (Short) -> Boolean): Short { +public inline fun FloatArray.first(predicate: (Float) -> Boolean): Float { + for (element in this) if (predicate(element)) return element + throw NoSuchElementException("No element matching predicate was found.") +} + +/** + * Returns the first element matching the given [predicate]. + * @throws [NoSuchElementException] if no such element is found. + */ +public inline fun DoubleArray.first(predicate: (Double) -> Boolean): Double { + for (element in this) if (predicate(element)) return element + throw NoSuchElementException("No element matching predicate was found.") +} + +/** + * Returns the first element matching the given [predicate]. + * @throws [NoSuchElementException] if no such element is found. + */ +public inline fun BooleanArray.first(predicate: (Boolean) -> Boolean): Boolean { + for (element in this) if (predicate(element)) return element + throw NoSuchElementException("No element matching predicate was found.") +} + +/** + * Returns the first element matching the given [predicate]. + * @throws [NoSuchElementException] if no such element is found. + */ +public inline fun CharArray.first(predicate: (Char) -> Boolean): Char { for (element in this) if (predicate(element)) return element throw NoSuchElementException("No element matching predicate was found.") } @@ -974,13 +974,6 @@ public fun Array.firstOrNull(): T? { return if (isEmpty()) null else this[0] } -/** - * Returns the first element, or `null` if the array is empty. - */ -public fun BooleanArray.firstOrNull(): Boolean? { - return if (isEmpty()) null else this[0] -} - /** * Returns the first element, or `null` if the array is empty. */ @@ -991,21 +984,7 @@ public fun ByteArray.firstOrNull(): Byte? { /** * Returns the first element, or `null` if the array is empty. */ -public fun CharArray.firstOrNull(): Char? { - return if (isEmpty()) null else this[0] -} - -/** - * Returns the first element, or `null` if the array is empty. - */ -public fun DoubleArray.firstOrNull(): Double? { - return if (isEmpty()) null else this[0] -} - -/** - * Returns the first element, or `null` if the array is empty. - */ -public fun FloatArray.firstOrNull(): Float? { +public fun ShortArray.firstOrNull(): Short? { return if (isEmpty()) null else this[0] } @@ -1026,7 +1005,28 @@ public fun LongArray.firstOrNull(): Long? { /** * Returns the first element, or `null` if the array is empty. */ -public fun ShortArray.firstOrNull(): Short? { +public fun FloatArray.firstOrNull(): Float? { + return if (isEmpty()) null else this[0] +} + +/** + * Returns the first element, or `null` if the array is empty. + */ +public fun DoubleArray.firstOrNull(): Double? { + return if (isEmpty()) null else this[0] +} + +/** + * Returns the first element, or `null` if the array is empty. + */ +public fun BooleanArray.firstOrNull(): Boolean? { + return if (isEmpty()) null else this[0] +} + +/** + * Returns the first element, or `null` if the array is empty. + */ +public fun CharArray.firstOrNull(): Char? { return if (isEmpty()) null else this[0] } @@ -1038,14 +1038,6 @@ public inline fun Array.firstOrNull(predicate: (T) -> Boolean): T? { return null } -/** - * Returns the first element matching the given [predicate], or `null` if element was not found. - */ -public inline fun BooleanArray.firstOrNull(predicate: (Boolean) -> Boolean): Boolean? { - for (element in this) if (predicate(element)) return element - return null -} - /** * Returns the first element matching the given [predicate], or `null` if element was not found. */ @@ -1057,23 +1049,7 @@ public inline fun ByteArray.firstOrNull(predicate: (Byte) -> Boolean): Byte? { /** * Returns the first element matching the given [predicate], or `null` if element was not found. */ -public inline fun CharArray.firstOrNull(predicate: (Char) -> Boolean): Char? { - for (element in this) if (predicate(element)) return element - return null -} - -/** - * Returns the first element matching the given [predicate], or `null` if element was not found. - */ -public inline fun DoubleArray.firstOrNull(predicate: (Double) -> Boolean): Double? { - for (element in this) if (predicate(element)) return element - return null -} - -/** - * Returns the first element matching the given [predicate], or `null` if element was not found. - */ -public inline fun FloatArray.firstOrNull(predicate: (Float) -> Boolean): Float? { +public inline fun ShortArray.firstOrNull(predicate: (Short) -> Boolean): Short? { for (element in this) if (predicate(element)) return element return null } @@ -1097,7 +1073,31 @@ public inline fun LongArray.firstOrNull(predicate: (Long) -> Boolean): Long? { /** * Returns the first element matching the given [predicate], or `null` if element was not found. */ -public inline fun ShortArray.firstOrNull(predicate: (Short) -> Boolean): Short? { +public inline fun FloatArray.firstOrNull(predicate: (Float) -> Boolean): Float? { + for (element in this) if (predicate(element)) return element + return null +} + +/** + * Returns the first element matching the given [predicate], or `null` if element was not found. + */ +public inline fun DoubleArray.firstOrNull(predicate: (Double) -> Boolean): Double? { + for (element in this) if (predicate(element)) return element + return null +} + +/** + * Returns the first element matching the given [predicate], or `null` if element was not found. + */ +public inline fun BooleanArray.firstOrNull(predicate: (Boolean) -> Boolean): Boolean? { + for (element in this) if (predicate(element)) return element + return null +} + +/** + * Returns the first element matching the given [predicate], or `null` if element was not found. + */ +public inline fun CharArray.firstOrNull(predicate: (Char) -> Boolean): Char? { for (element in this) if (predicate(element)) return element return null } @@ -1110,14 +1110,6 @@ public inline fun Array.getOrElse(index: Int, defaultValue: (Int) -> return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } -/** - * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. - */ -@kotlin.internal.InlineOnly -public inline fun BooleanArray.getOrElse(index: Int, defaultValue: (Int) -> Boolean): Boolean { - return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) -} - /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ @@ -1130,23 +1122,7 @@ public inline fun ByteArray.getOrElse(index: Int, defaultValue: (Int) -> Byte): * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ @kotlin.internal.InlineOnly -public inline fun CharArray.getOrElse(index: Int, defaultValue: (Int) -> Char): Char { - return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) -} - -/** - * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. - */ -@kotlin.internal.InlineOnly -public inline fun DoubleArray.getOrElse(index: Int, defaultValue: (Int) -> Double): Double { - return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) -} - -/** - * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. - */ -@kotlin.internal.InlineOnly -public inline fun FloatArray.getOrElse(index: Int, defaultValue: (Int) -> Float): Float { +public inline fun ShortArray.getOrElse(index: Int, defaultValue: (Int) -> Short): Short { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -1170,7 +1146,31 @@ public inline fun LongArray.getOrElse(index: Int, defaultValue: (Int) -> Long): * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. */ @kotlin.internal.InlineOnly -public inline fun ShortArray.getOrElse(index: Int, defaultValue: (Int) -> Short): Short { +public inline fun FloatArray.getOrElse(index: Int, defaultValue: (Int) -> Float): Float { + return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) +} + +/** + * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. + */ +@kotlin.internal.InlineOnly +public inline fun DoubleArray.getOrElse(index: Int, defaultValue: (Int) -> Double): Double { + return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) +} + +/** + * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. + */ +@kotlin.internal.InlineOnly +public inline fun BooleanArray.getOrElse(index: Int, defaultValue: (Int) -> Boolean): Boolean { + return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) +} + +/** + * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this array. + */ +@kotlin.internal.InlineOnly +public inline fun CharArray.getOrElse(index: Int, defaultValue: (Int) -> Char): Char { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } @@ -1181,13 +1181,6 @@ public fun Array.getOrNull(index: Int): T? { return if (index >= 0 && index <= lastIndex) get(index) else null } -/** - * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. - */ -public fun BooleanArray.getOrNull(index: Int): Boolean? { - return if (index >= 0 && index <= lastIndex) get(index) else null -} - /** * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. */ @@ -1198,21 +1191,7 @@ public fun ByteArray.getOrNull(index: Int): Byte? { /** * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. */ -public fun CharArray.getOrNull(index: Int): Char? { - return if (index >= 0 && index <= lastIndex) get(index) else null -} - -/** - * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. - */ -public fun DoubleArray.getOrNull(index: Int): Double? { - return if (index >= 0 && index <= lastIndex) get(index) else null -} - -/** - * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. - */ -public fun FloatArray.getOrNull(index: Int): Float? { +public fun ShortArray.getOrNull(index: Int): Short? { return if (index >= 0 && index <= lastIndex) get(index) else null } @@ -1233,7 +1212,28 @@ public fun LongArray.getOrNull(index: Int): Long? { /** * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. */ -public fun ShortArray.getOrNull(index: Int): Short? { +public fun FloatArray.getOrNull(index: Int): Float? { + return if (index >= 0 && index <= lastIndex) get(index) else null +} + +/** + * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. + */ +public fun DoubleArray.getOrNull(index: Int): Double? { + return if (index >= 0 && index <= lastIndex) get(index) else null +} + +/** + * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. + */ +public fun BooleanArray.getOrNull(index: Int): Boolean? { + return if (index >= 0 && index <= lastIndex) get(index) else null +} + +/** + * Returns an element at the given [index] or `null` if the [index] is out of bounds of this array. + */ +public fun CharArray.getOrNull(index: Int): Char? { return if (index >= 0 && index <= lastIndex) get(index) else null } @@ -1257,18 +1257,6 @@ public fun <@kotlin.internal.OnlyInputTypes T> Array.indexOf(element: T): return -1 } -/** - * Returns first index of [element], or -1 if the array does not contain element. - */ -public fun BooleanArray.indexOf(element: Boolean): Int { - for (index in indices) { - if (element == this[index]) { - return index - } - } - return -1 -} - /** * Returns first index of [element], or -1 if the array does not contain element. */ @@ -1284,31 +1272,7 @@ public fun ByteArray.indexOf(element: Byte): Int { /** * Returns first index of [element], or -1 if the array does not contain element. */ -public fun CharArray.indexOf(element: Char): Int { - for (index in indices) { - if (element == this[index]) { - return index - } - } - return -1 -} - -/** - * Returns first index of [element], or -1 if the array does not contain element. - */ -public fun DoubleArray.indexOf(element: Double): Int { - for (index in indices) { - if (element == this[index]) { - return index - } - } - return -1 -} - -/** - * Returns first index of [element], or -1 if the array does not contain element. - */ -public fun FloatArray.indexOf(element: Float): Int { +public fun ShortArray.indexOf(element: Short): Int { for (index in indices) { if (element == this[index]) { return index @@ -1344,7 +1308,43 @@ public fun LongArray.indexOf(element: Long): Int { /** * Returns first index of [element], or -1 if the array does not contain element. */ -public fun ShortArray.indexOf(element: Short): Int { +public fun FloatArray.indexOf(element: Float): Int { + for (index in indices) { + if (element == this[index]) { + return index + } + } + return -1 +} + +/** + * Returns first index of [element], or -1 if the array does not contain element. + */ +public fun DoubleArray.indexOf(element: Double): Int { + for (index in indices) { + if (element == this[index]) { + return index + } + } + return -1 +} + +/** + * Returns first index of [element], or -1 if the array does not contain element. + */ +public fun BooleanArray.indexOf(element: Boolean): Int { + for (index in indices) { + if (element == this[index]) { + return index + } + } + return -1 +} + +/** + * Returns first index of [element], or -1 if the array does not contain element. + */ +public fun CharArray.indexOf(element: Char): Int { for (index in indices) { if (element == this[index]) { return index @@ -1365,18 +1365,6 @@ public inline fun Array.indexOfFirst(predicate: (T) -> Boolean): Int return -1 } -/** - * Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element. - */ -public inline fun BooleanArray.indexOfFirst(predicate: (Boolean) -> Boolean): Int { - for (index in indices) { - if (predicate(this[index])) { - return index - } - } - return -1 -} - /** * Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element. */ @@ -1392,31 +1380,7 @@ public inline fun ByteArray.indexOfFirst(predicate: (Byte) -> Boolean): Int { /** * Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element. */ -public inline fun CharArray.indexOfFirst(predicate: (Char) -> Boolean): Int { - for (index in indices) { - if (predicate(this[index])) { - return index - } - } - return -1 -} - -/** - * Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element. - */ -public inline fun DoubleArray.indexOfFirst(predicate: (Double) -> Boolean): Int { - for (index in indices) { - if (predicate(this[index])) { - return index - } - } - return -1 -} - -/** - * Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element. - */ -public inline fun FloatArray.indexOfFirst(predicate: (Float) -> Boolean): Int { +public inline fun ShortArray.indexOfFirst(predicate: (Short) -> Boolean): Int { for (index in indices) { if (predicate(this[index])) { return index @@ -1452,7 +1416,43 @@ public inline fun LongArray.indexOfFirst(predicate: (Long) -> Boolean): Int { /** * Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element. */ -public inline fun ShortArray.indexOfFirst(predicate: (Short) -> Boolean): Int { +public inline fun FloatArray.indexOfFirst(predicate: (Float) -> Boolean): Int { + for (index in indices) { + if (predicate(this[index])) { + return index + } + } + return -1 +} + +/** + * Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element. + */ +public inline fun DoubleArray.indexOfFirst(predicate: (Double) -> Boolean): Int { + for (index in indices) { + if (predicate(this[index])) { + return index + } + } + return -1 +} + +/** + * Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element. + */ +public inline fun BooleanArray.indexOfFirst(predicate: (Boolean) -> Boolean): Int { + for (index in indices) { + if (predicate(this[index])) { + return index + } + } + return -1 +} + +/** + * Returns index of the first element matching the given [predicate], or -1 if the array does not contain such element. + */ +public inline fun CharArray.indexOfFirst(predicate: (Char) -> Boolean): Int { for (index in indices) { if (predicate(this[index])) { return index @@ -1473,18 +1473,6 @@ public inline fun Array.indexOfLast(predicate: (T) -> Boolean): Int { return -1 } -/** - * Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element. - */ -public inline fun BooleanArray.indexOfLast(predicate: (Boolean) -> Boolean): Int { - for (index in indices.reversed()) { - if (predicate(this[index])) { - return index - } - } - return -1 -} - /** * Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element. */ @@ -1500,31 +1488,7 @@ public inline fun ByteArray.indexOfLast(predicate: (Byte) -> Boolean): Int { /** * Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element. */ -public inline fun CharArray.indexOfLast(predicate: (Char) -> Boolean): Int { - for (index in indices.reversed()) { - if (predicate(this[index])) { - return index - } - } - return -1 -} - -/** - * Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element. - */ -public inline fun DoubleArray.indexOfLast(predicate: (Double) -> Boolean): Int { - for (index in indices.reversed()) { - if (predicate(this[index])) { - return index - } - } - return -1 -} - -/** - * Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element. - */ -public inline fun FloatArray.indexOfLast(predicate: (Float) -> Boolean): Int { +public inline fun ShortArray.indexOfLast(predicate: (Short) -> Boolean): Int { for (index in indices.reversed()) { if (predicate(this[index])) { return index @@ -1560,7 +1524,43 @@ public inline fun LongArray.indexOfLast(predicate: (Long) -> Boolean): Int { /** * Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element. */ -public inline fun ShortArray.indexOfLast(predicate: (Short) -> Boolean): Int { +public inline fun FloatArray.indexOfLast(predicate: (Float) -> Boolean): Int { + for (index in indices.reversed()) { + if (predicate(this[index])) { + return index + } + } + return -1 +} + +/** + * Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element. + */ +public inline fun DoubleArray.indexOfLast(predicate: (Double) -> Boolean): Int { + for (index in indices.reversed()) { + if (predicate(this[index])) { + return index + } + } + return -1 +} + +/** + * Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element. + */ +public inline fun BooleanArray.indexOfLast(predicate: (Boolean) -> Boolean): Int { + for (index in indices.reversed()) { + if (predicate(this[index])) { + return index + } + } + return -1 +} + +/** + * Returns index of the last element matching the given [predicate], or -1 if the array does not contain such element. + */ +public inline fun CharArray.indexOfLast(predicate: (Char) -> Boolean): Int { for (index in indices.reversed()) { if (predicate(this[index])) { return index @@ -1579,16 +1579,6 @@ public fun Array.last(): T { return this[lastIndex] } -/** - * Returns the last element. - * @throws [NoSuchElementException] if the array is empty. - */ -public fun BooleanArray.last(): Boolean { - if (isEmpty()) - throw NoSuchElementException("Collection is empty.") - return this[lastIndex] -} - /** * Returns the last element. * @throws [NoSuchElementException] if the array is empty. @@ -1603,27 +1593,7 @@ public fun ByteArray.last(): Byte { * Returns the last element. * @throws [NoSuchElementException] if the array is empty. */ -public fun CharArray.last(): Char { - if (isEmpty()) - throw NoSuchElementException("Collection is empty.") - return this[lastIndex] -} - -/** - * Returns the last element. - * @throws [NoSuchElementException] if the array is empty. - */ -public fun DoubleArray.last(): Double { - if (isEmpty()) - throw NoSuchElementException("Collection is empty.") - return this[lastIndex] -} - -/** - * Returns the last element. - * @throws [NoSuchElementException] if the array is empty. - */ -public fun FloatArray.last(): Float { +public fun ShortArray.last(): Short { if (isEmpty()) throw NoSuchElementException("Collection is empty.") return this[lastIndex] @@ -1653,7 +1623,37 @@ public fun LongArray.last(): Long { * Returns the last element. * @throws [NoSuchElementException] if the array is empty. */ -public fun ShortArray.last(): Short { +public fun FloatArray.last(): Float { + if (isEmpty()) + throw NoSuchElementException("Collection is empty.") + return this[lastIndex] +} + +/** + * Returns the last element. + * @throws [NoSuchElementException] if the array is empty. + */ +public fun DoubleArray.last(): Double { + if (isEmpty()) + throw NoSuchElementException("Collection is empty.") + return this[lastIndex] +} + +/** + * Returns the last element. + * @throws [NoSuchElementException] if the array is empty. + */ +public fun BooleanArray.last(): Boolean { + if (isEmpty()) + throw NoSuchElementException("Collection is empty.") + return this[lastIndex] +} + +/** + * Returns the last element. + * @throws [NoSuchElementException] if the array is empty. + */ +public fun CharArray.last(): Char { if (isEmpty()) throw NoSuchElementException("Collection is empty.") return this[lastIndex] @@ -1671,18 +1671,6 @@ public inline fun Array.last(predicate: (T) -> Boolean): T { throw NoSuchElementException("Collection doesn't contain any element matching the predicate.") } -/** - * Returns the last element matching the given [predicate]. - * @throws [NoSuchElementException] if no such element is found. - */ -public inline fun BooleanArray.last(predicate: (Boolean) -> Boolean): Boolean { - for (index in this.indices.reversed()) { - val element = this[index] - if (predicate(element)) return element - } - throw NoSuchElementException("Collection doesn't contain any element matching the predicate.") -} - /** * Returns the last element matching the given [predicate]. * @throws [NoSuchElementException] if no such element is found. @@ -1699,31 +1687,7 @@ public inline fun ByteArray.last(predicate: (Byte) -> Boolean): Byte { * Returns the last element matching the given [predicate]. * @throws [NoSuchElementException] if no such element is found. */ -public inline fun CharArray.last(predicate: (Char) -> Boolean): Char { - for (index in this.indices.reversed()) { - val element = this[index] - if (predicate(element)) return element - } - throw NoSuchElementException("Collection doesn't contain any element matching the predicate.") -} - -/** - * Returns the last element matching the given [predicate]. - * @throws [NoSuchElementException] if no such element is found. - */ -public inline fun DoubleArray.last(predicate: (Double) -> Boolean): Double { - for (index in this.indices.reversed()) { - val element = this[index] - if (predicate(element)) return element - } - throw NoSuchElementException("Collection doesn't contain any element matching the predicate.") -} - -/** - * Returns the last element matching the given [predicate]. - * @throws [NoSuchElementException] if no such element is found. - */ -public inline fun FloatArray.last(predicate: (Float) -> Boolean): Float { +public inline fun ShortArray.last(predicate: (Short) -> Boolean): Short { for (index in this.indices.reversed()) { val element = this[index] if (predicate(element)) return element @@ -1759,7 +1723,43 @@ public inline fun LongArray.last(predicate: (Long) -> Boolean): Long { * Returns the last element matching the given [predicate]. * @throws [NoSuchElementException] if no such element is found. */ -public inline fun ShortArray.last(predicate: (Short) -> Boolean): Short { +public inline fun FloatArray.last(predicate: (Float) -> Boolean): Float { + for (index in this.indices.reversed()) { + val element = this[index] + if (predicate(element)) return element + } + throw NoSuchElementException("Collection doesn't contain any element matching the predicate.") +} + +/** + * Returns the last element matching the given [predicate]. + * @throws [NoSuchElementException] if no such element is found. + */ +public inline fun DoubleArray.last(predicate: (Double) -> Boolean): Double { + for (index in this.indices.reversed()) { + val element = this[index] + if (predicate(element)) return element + } + throw NoSuchElementException("Collection doesn't contain any element matching the predicate.") +} + +/** + * Returns the last element matching the given [predicate]. + * @throws [NoSuchElementException] if no such element is found. + */ +public inline fun BooleanArray.last(predicate: (Boolean) -> Boolean): Boolean { + for (index in this.indices.reversed()) { + val element = this[index] + if (predicate(element)) return element + } + throw NoSuchElementException("Collection doesn't contain any element matching the predicate.") +} + +/** + * Returns the last element matching the given [predicate]. + * @throws [NoSuchElementException] if no such element is found. + */ +public inline fun CharArray.last(predicate: (Char) -> Boolean): Char { for (index in this.indices.reversed()) { val element = this[index] if (predicate(element)) return element @@ -1787,18 +1787,6 @@ public fun <@kotlin.internal.OnlyInputTypes T> Array.lastIndexOf(element: return -1 } -/** - * Returns last index of [element], or -1 if the array does not contain element. - */ -public fun BooleanArray.lastIndexOf(element: Boolean): Int { - for (index in indices.reversed()) { - if (element == this[index]) { - return index - } - } - return -1 -} - /** * Returns last index of [element], or -1 if the array does not contain element. */ @@ -1814,31 +1802,7 @@ public fun ByteArray.lastIndexOf(element: Byte): Int { /** * Returns last index of [element], or -1 if the array does not contain element. */ -public fun CharArray.lastIndexOf(element: Char): Int { - for (index in indices.reversed()) { - if (element == this[index]) { - return index - } - } - return -1 -} - -/** - * Returns last index of [element], or -1 if the array does not contain element. - */ -public fun DoubleArray.lastIndexOf(element: Double): Int { - for (index in indices.reversed()) { - if (element == this[index]) { - return index - } - } - return -1 -} - -/** - * Returns last index of [element], or -1 if the array does not contain element. - */ -public fun FloatArray.lastIndexOf(element: Float): Int { +public fun ShortArray.lastIndexOf(element: Short): Int { for (index in indices.reversed()) { if (element == this[index]) { return index @@ -1874,7 +1838,43 @@ public fun LongArray.lastIndexOf(element: Long): Int { /** * Returns last index of [element], or -1 if the array does not contain element. */ -public fun ShortArray.lastIndexOf(element: Short): Int { +public fun FloatArray.lastIndexOf(element: Float): Int { + for (index in indices.reversed()) { + if (element == this[index]) { + return index + } + } + return -1 +} + +/** + * Returns last index of [element], or -1 if the array does not contain element. + */ +public fun DoubleArray.lastIndexOf(element: Double): Int { + for (index in indices.reversed()) { + if (element == this[index]) { + return index + } + } + return -1 +} + +/** + * Returns last index of [element], or -1 if the array does not contain element. + */ +public fun BooleanArray.lastIndexOf(element: Boolean): Int { + for (index in indices.reversed()) { + if (element == this[index]) { + return index + } + } + return -1 +} + +/** + * Returns last index of [element], or -1 if the array does not contain element. + */ +public fun CharArray.lastIndexOf(element: Char): Int { for (index in indices.reversed()) { if (element == this[index]) { return index @@ -1890,13 +1890,6 @@ public fun Array.lastOrNull(): T? { return if (isEmpty()) null else this[size - 1] } -/** - * Returns the last element, or `null` if the array is empty. - */ -public fun BooleanArray.lastOrNull(): Boolean? { - return if (isEmpty()) null else this[size - 1] -} - /** * Returns the last element, or `null` if the array is empty. */ @@ -1907,21 +1900,7 @@ public fun ByteArray.lastOrNull(): Byte? { /** * Returns the last element, or `null` if the array is empty. */ -public fun CharArray.lastOrNull(): Char? { - return if (isEmpty()) null else this[size - 1] -} - -/** - * Returns the last element, or `null` if the array is empty. - */ -public fun DoubleArray.lastOrNull(): Double? { - return if (isEmpty()) null else this[size - 1] -} - -/** - * Returns the last element, or `null` if the array is empty. - */ -public fun FloatArray.lastOrNull(): Float? { +public fun ShortArray.lastOrNull(): Short? { return if (isEmpty()) null else this[size - 1] } @@ -1942,7 +1921,28 @@ public fun LongArray.lastOrNull(): Long? { /** * Returns the last element, or `null` if the array is empty. */ -public fun ShortArray.lastOrNull(): Short? { +public fun FloatArray.lastOrNull(): Float? { + return if (isEmpty()) null else this[size - 1] +} + +/** + * Returns the last element, or `null` if the array is empty. + */ +public fun DoubleArray.lastOrNull(): Double? { + return if (isEmpty()) null else this[size - 1] +} + +/** + * Returns the last element, or `null` if the array is empty. + */ +public fun BooleanArray.lastOrNull(): Boolean? { + return if (isEmpty()) null else this[size - 1] +} + +/** + * Returns the last element, or `null` if the array is empty. + */ +public fun CharArray.lastOrNull(): Char? { return if (isEmpty()) null else this[size - 1] } @@ -1957,17 +1957,6 @@ public inline fun Array.lastOrNull(predicate: (T) -> Boolean): T? { return null } -/** - * Returns the last element matching the given [predicate], or `null` if no such element was found. - */ -public inline fun BooleanArray.lastOrNull(predicate: (Boolean) -> Boolean): Boolean? { - for (index in this.indices.reversed()) { - val element = this[index] - if (predicate(element)) return element - } - return null -} - /** * Returns the last element matching the given [predicate], or `null` if no such element was found. */ @@ -1982,29 +1971,7 @@ public inline fun ByteArray.lastOrNull(predicate: (Byte) -> Boolean): Byte? { /** * Returns the last element matching the given [predicate], or `null` if no such element was found. */ -public inline fun CharArray.lastOrNull(predicate: (Char) -> Boolean): Char? { - for (index in this.indices.reversed()) { - val element = this[index] - if (predicate(element)) return element - } - return null -} - -/** - * Returns the last element matching the given [predicate], or `null` if no such element was found. - */ -public inline fun DoubleArray.lastOrNull(predicate: (Double) -> Boolean): Double? { - for (index in this.indices.reversed()) { - val element = this[index] - if (predicate(element)) return element - } - return null -} - -/** - * Returns the last element matching the given [predicate], or `null` if no such element was found. - */ -public inline fun FloatArray.lastOrNull(predicate: (Float) -> Boolean): Float? { +public inline fun ShortArray.lastOrNull(predicate: (Short) -> Boolean): Short? { for (index in this.indices.reversed()) { val element = this[index] if (predicate(element)) return element @@ -2037,7 +2004,40 @@ public inline fun LongArray.lastOrNull(predicate: (Long) -> Boolean): Long? { /** * Returns the last element matching the given [predicate], or `null` if no such element was found. */ -public inline fun ShortArray.lastOrNull(predicate: (Short) -> Boolean): Short? { +public inline fun FloatArray.lastOrNull(predicate: (Float) -> Boolean): Float? { + for (index in this.indices.reversed()) { + val element = this[index] + if (predicate(element)) return element + } + return null +} + +/** + * Returns the last element matching the given [predicate], or `null` if no such element was found. + */ +public inline fun DoubleArray.lastOrNull(predicate: (Double) -> Boolean): Double? { + for (index in this.indices.reversed()) { + val element = this[index] + if (predicate(element)) return element + } + return null +} + +/** + * Returns the last element matching the given [predicate], or `null` if no such element was found. + */ +public inline fun BooleanArray.lastOrNull(predicate: (Boolean) -> Boolean): Boolean? { + for (index in this.indices.reversed()) { + val element = this[index] + if (predicate(element)) return element + } + return null +} + +/** + * Returns the last element matching the given [predicate], or `null` if no such element was found. + */ +public inline fun CharArray.lastOrNull(predicate: (Char) -> Boolean): Char? { for (index in this.indices.reversed()) { val element = this[index] if (predicate(element)) return element @@ -2056,17 +2056,6 @@ public fun Array.single(): T { } } -/** - * Returns the single element, or throws an exception if the array is empty or has more than one element. - */ -public fun BooleanArray.single(): Boolean { - return when (size) { - 0 -> throw NoSuchElementException("Collection is empty.") - 1 -> this[0] - else -> throw IllegalArgumentException("Collection has more than one element.") - } -} - /** * Returns the single element, or throws an exception if the array is empty or has more than one element. */ @@ -2081,29 +2070,7 @@ public fun ByteArray.single(): Byte { /** * Returns the single element, or throws an exception if the array is empty or has more than one element. */ -public fun CharArray.single(): Char { - return when (size) { - 0 -> throw NoSuchElementException("Collection is empty.") - 1 -> this[0] - else -> throw IllegalArgumentException("Collection has more than one element.") - } -} - -/** - * Returns the single element, or throws an exception if the array is empty or has more than one element. - */ -public fun DoubleArray.single(): Double { - return when (size) { - 0 -> throw NoSuchElementException("Collection is empty.") - 1 -> this[0] - else -> throw IllegalArgumentException("Collection has more than one element.") - } -} - -/** - * Returns the single element, or throws an exception if the array is empty or has more than one element. - */ -public fun FloatArray.single(): Float { +public fun ShortArray.single(): Short { return when (size) { 0 -> throw NoSuchElementException("Collection is empty.") 1 -> this[0] @@ -2136,7 +2103,40 @@ public fun LongArray.single(): Long { /** * Returns the single element, or throws an exception if the array is empty or has more than one element. */ -public fun ShortArray.single(): Short { +public fun FloatArray.single(): Float { + return when (size) { + 0 -> throw NoSuchElementException("Collection is empty.") + 1 -> this[0] + else -> throw IllegalArgumentException("Collection has more than one element.") + } +} + +/** + * Returns the single element, or throws an exception if the array is empty or has more than one element. + */ +public fun DoubleArray.single(): Double { + return when (size) { + 0 -> throw NoSuchElementException("Collection is empty.") + 1 -> this[0] + else -> throw IllegalArgumentException("Collection has more than one element.") + } +} + +/** + * Returns the single element, or throws an exception if the array is empty or has more than one element. + */ +public fun BooleanArray.single(): Boolean { + return when (size) { + 0 -> throw NoSuchElementException("Collection is empty.") + 1 -> this[0] + else -> throw IllegalArgumentException("Collection has more than one element.") + } +} + +/** + * Returns the single element, or throws an exception if the array is empty or has more than one element. + */ +public fun CharArray.single(): Char { return when (size) { 0 -> throw NoSuchElementException("Collection is empty.") 1 -> this[0] @@ -2161,23 +2161,6 @@ public inline fun Array.single(predicate: (T) -> Boolean): T { return single as T } -/** - * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element. - */ -public inline fun BooleanArray.single(predicate: (Boolean) -> Boolean): Boolean { - var single: Boolean? = null - var found = false - for (element in this) { - if (predicate(element)) { - if (found) throw IllegalArgumentException("Collection contains more than one matching element.") - single = element - found = true - } - } - if (!found) throw NoSuchElementException("Collection doesn't contain any element matching predicate.") - return single as Boolean -} - /** * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element. */ @@ -2198,8 +2181,8 @@ public inline fun ByteArray.single(predicate: (Byte) -> Boolean): Byte { /** * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element. */ -public inline fun CharArray.single(predicate: (Char) -> Boolean): Char { - var single: Char? = null +public inline fun ShortArray.single(predicate: (Short) -> Boolean): Short { + var single: Short? = null var found = false for (element in this) { if (predicate(element)) { @@ -2209,41 +2192,7 @@ public inline fun CharArray.single(predicate: (Char) -> Boolean): Char { } } if (!found) throw NoSuchElementException("Collection doesn't contain any element matching predicate.") - return single as Char -} - -/** - * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element. - */ -public inline fun DoubleArray.single(predicate: (Double) -> Boolean): Double { - var single: Double? = null - var found = false - for (element in this) { - if (predicate(element)) { - if (found) throw IllegalArgumentException("Collection contains more than one matching element.") - single = element - found = true - } - } - if (!found) throw NoSuchElementException("Collection doesn't contain any element matching predicate.") - return single as Double -} - -/** - * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element. - */ -public inline fun FloatArray.single(predicate: (Float) -> Boolean): Float { - var single: Float? = null - var found = false - for (element in this) { - if (predicate(element)) { - if (found) throw IllegalArgumentException("Collection contains more than one matching element.") - single = element - found = true - } - } - if (!found) throw NoSuchElementException("Collection doesn't contain any element matching predicate.") - return single as Float + return single as Short } /** @@ -2283,8 +2232,8 @@ public inline fun LongArray.single(predicate: (Long) -> Boolean): Long { /** * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element. */ -public inline fun ShortArray.single(predicate: (Short) -> Boolean): Short { - var single: Short? = null +public inline fun FloatArray.single(predicate: (Float) -> Boolean): Float { + var single: Float? = null var found = false for (element in this) { if (predicate(element)) { @@ -2294,7 +2243,58 @@ public inline fun ShortArray.single(predicate: (Short) -> Boolean): Short { } } if (!found) throw NoSuchElementException("Collection doesn't contain any element matching predicate.") - return single as Short + return single as Float +} + +/** + * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element. + */ +public inline fun DoubleArray.single(predicate: (Double) -> Boolean): Double { + var single: Double? = null + var found = false + for (element in this) { + if (predicate(element)) { + if (found) throw IllegalArgumentException("Collection contains more than one matching element.") + single = element + found = true + } + } + if (!found) throw NoSuchElementException("Collection doesn't contain any element matching predicate.") + return single as Double +} + +/** + * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element. + */ +public inline fun BooleanArray.single(predicate: (Boolean) -> Boolean): Boolean { + var single: Boolean? = null + var found = false + for (element in this) { + if (predicate(element)) { + if (found) throw IllegalArgumentException("Collection contains more than one matching element.") + single = element + found = true + } + } + if (!found) throw NoSuchElementException("Collection doesn't contain any element matching predicate.") + return single as Boolean +} + +/** + * Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element. + */ +public inline fun CharArray.single(predicate: (Char) -> Boolean): Char { + var single: Char? = null + var found = false + for (element in this) { + if (predicate(element)) { + if (found) throw IllegalArgumentException("Collection contains more than one matching element.") + single = element + found = true + } + } + if (!found) throw NoSuchElementException("Collection doesn't contain any element matching predicate.") + return single as Char } /** @@ -2304,13 +2304,6 @@ public fun Array.singleOrNull(): T? { return if (size == 1) this[0] else null } -/** - * Returns single element, or `null` if the array is empty or has more than one element. - */ -public fun BooleanArray.singleOrNull(): Boolean? { - return if (size == 1) this[0] else null -} - /** * Returns single element, or `null` if the array is empty or has more than one element. */ @@ -2321,21 +2314,7 @@ public fun ByteArray.singleOrNull(): Byte? { /** * Returns single element, or `null` if the array is empty or has more than one element. */ -public fun CharArray.singleOrNull(): Char? { - return if (size == 1) this[0] else null -} - -/** - * Returns single element, or `null` if the array is empty or has more than one element. - */ -public fun DoubleArray.singleOrNull(): Double? { - return if (size == 1) this[0] else null -} - -/** - * Returns single element, or `null` if the array is empty or has more than one element. - */ -public fun FloatArray.singleOrNull(): Float? { +public fun ShortArray.singleOrNull(): Short? { return if (size == 1) this[0] else null } @@ -2356,7 +2335,28 @@ public fun LongArray.singleOrNull(): Long? { /** * Returns single element, or `null` if the array is empty or has more than one element. */ -public fun ShortArray.singleOrNull(): Short? { +public fun FloatArray.singleOrNull(): Float? { + return if (size == 1) this[0] else null +} + +/** + * Returns single element, or `null` if the array is empty or has more than one element. + */ +public fun DoubleArray.singleOrNull(): Double? { + return if (size == 1) this[0] else null +} + +/** + * Returns single element, or `null` if the array is empty or has more than one element. + */ +public fun BooleanArray.singleOrNull(): Boolean? { + return if (size == 1) this[0] else null +} + +/** + * Returns single element, or `null` if the array is empty or has more than one element. + */ +public fun CharArray.singleOrNull(): Char? { return if (size == 1) this[0] else null } @@ -2377,23 +2377,6 @@ public inline fun Array.singleOrNull(predicate: (T) -> Boolean): T? { return single } -/** - * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found. - */ -public inline fun BooleanArray.singleOrNull(predicate: (Boolean) -> Boolean): Boolean? { - var single: Boolean? = null - var found = false - for (element in this) { - if (predicate(element)) { - if (found) return null - single = element - found = true - } - } - if (!found) return null - return single -} - /** * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found. */ @@ -2414,42 +2397,8 @@ public inline fun ByteArray.singleOrNull(predicate: (Byte) -> Boolean): Byte? { /** * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found. */ -public inline fun CharArray.singleOrNull(predicate: (Char) -> Boolean): Char? { - var single: Char? = null - var found = false - for (element in this) { - if (predicate(element)) { - if (found) return null - single = element - found = true - } - } - if (!found) return null - return single -} - -/** - * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found. - */ -public inline fun DoubleArray.singleOrNull(predicate: (Double) -> Boolean): Double? { - var single: Double? = null - var found = false - for (element in this) { - if (predicate(element)) { - if (found) return null - single = element - found = true - } - } - if (!found) return null - return single -} - -/** - * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found. - */ -public inline fun FloatArray.singleOrNull(predicate: (Float) -> Boolean): Float? { - var single: Float? = null +public inline fun ShortArray.singleOrNull(predicate: (Short) -> Boolean): Short? { + var single: Short? = null var found = false for (element in this) { if (predicate(element)) { @@ -2499,8 +2448,59 @@ public inline fun LongArray.singleOrNull(predicate: (Long) -> Boolean): Long? { /** * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found. */ -public inline fun ShortArray.singleOrNull(predicate: (Short) -> Boolean): Short? { - var single: Short? = null +public inline fun FloatArray.singleOrNull(predicate: (Float) -> Boolean): Float? { + var single: Float? = null + var found = false + for (element in this) { + if (predicate(element)) { + if (found) return null + single = element + found = true + } + } + if (!found) return null + return single +} + +/** + * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found. + */ +public inline fun DoubleArray.singleOrNull(predicate: (Double) -> Boolean): Double? { + var single: Double? = null + var found = false + for (element in this) { + if (predicate(element)) { + if (found) return null + single = element + found = true + } + } + if (!found) return null + return single +} + +/** + * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found. + */ +public inline fun BooleanArray.singleOrNull(predicate: (Boolean) -> Boolean): Boolean? { + var single: Boolean? = null + var found = false + for (element in this) { + if (predicate(element)) { + if (found) return null + single = element + found = true + } + } + if (!found) return null + return single +} + +/** + * Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found. + */ +public inline fun CharArray.singleOrNull(predicate: (Char) -> Boolean): Char? { + var single: Char? = null var found = false for (element in this) { if (predicate(element)) { @@ -2529,22 +2529,6 @@ public fun Array.drop(n: Int): List { return list } -/** - * Returns a list containing all elements except first [n] elements. - */ -public fun BooleanArray.drop(n: Int): List { - require(n >= 0, { "Requested element count $n is less than zero." }) - if (n == 0) - return toList() - if (n >= size) - return emptyList() - val list = ArrayList(size - n) - for (index in n..size - 1) { - list.add(this[index]) - } - return list -} - /** * Returns a list containing all elements except first [n] elements. */ @@ -2564,45 +2548,13 @@ public fun ByteArray.drop(n: Int): List { /** * Returns a list containing all elements except first [n] elements. */ -public fun CharArray.drop(n: Int): List { +public fun ShortArray.drop(n: Int): List { require(n >= 0, { "Requested element count $n is less than zero." }) if (n == 0) return toList() if (n >= size) return emptyList() - val list = ArrayList(size - n) - for (index in n..size - 1) { - list.add(this[index]) - } - return list -} - -/** - * Returns a list containing all elements except first [n] elements. - */ -public fun DoubleArray.drop(n: Int): List { - require(n >= 0, { "Requested element count $n is less than zero." }) - if (n == 0) - return toList() - if (n >= size) - return emptyList() - val list = ArrayList(size - n) - for (index in n..size - 1) { - list.add(this[index]) - } - return list -} - -/** - * Returns a list containing all elements except first [n] elements. - */ -public fun FloatArray.drop(n: Int): List { - require(n >= 0, { "Requested element count $n is less than zero." }) - if (n == 0) - return toList() - if (n >= size) - return emptyList() - val list = ArrayList(size - n) + val list = ArrayList(size - n) for (index in n..size - 1) { list.add(this[index]) } @@ -2644,13 +2596,61 @@ public fun LongArray.drop(n: Int): List { /** * Returns a list containing all elements except first [n] elements. */ -public fun ShortArray.drop(n: Int): List { +public fun FloatArray.drop(n: Int): List { require(n >= 0, { "Requested element count $n is less than zero." }) if (n == 0) return toList() if (n >= size) return emptyList() - val list = ArrayList(size - n) + val list = ArrayList(size - n) + for (index in n..size - 1) { + list.add(this[index]) + } + return list +} + +/** + * Returns a list containing all elements except first [n] elements. + */ +public fun DoubleArray.drop(n: Int): List { + require(n >= 0, { "Requested element count $n is less than zero." }) + if (n == 0) + return toList() + if (n >= size) + return emptyList() + val list = ArrayList(size - n) + for (index in n..size - 1) { + list.add(this[index]) + } + return list +} + +/** + * Returns a list containing all elements except first [n] elements. + */ +public fun BooleanArray.drop(n: Int): List { + require(n >= 0, { "Requested element count $n is less than zero." }) + if (n == 0) + return toList() + if (n >= size) + return emptyList() + val list = ArrayList(size - n) + for (index in n..size - 1) { + list.add(this[index]) + } + return list +} + +/** + * Returns a list containing all elements except first [n] elements. + */ +public fun CharArray.drop(n: Int): List { + require(n >= 0, { "Requested element count $n is less than zero." }) + if (n == 0) + return toList() + if (n >= size) + return emptyList() + val list = ArrayList(size - n) for (index in n..size - 1) { list.add(this[index]) } @@ -2665,14 +2665,6 @@ public fun Array.dropLast(n: Int): List { return take((size - n).coerceAtLeast(0)) } -/** - * Returns a list containing all elements except last [n] elements. - */ -public fun BooleanArray.dropLast(n: Int): List { - require(n >= 0, { "Requested element count $n is less than zero." }) - return take((size - n).coerceAtLeast(0)) -} - /** * Returns a list containing all elements except last [n] elements. */ @@ -2684,23 +2676,7 @@ public fun ByteArray.dropLast(n: Int): List { /** * Returns a list containing all elements except last [n] elements. */ -public fun CharArray.dropLast(n: Int): List { - require(n >= 0, { "Requested element count $n is less than zero." }) - return take((size - n).coerceAtLeast(0)) -} - -/** - * Returns a list containing all elements except last [n] elements. - */ -public fun DoubleArray.dropLast(n: Int): List { - require(n >= 0, { "Requested element count $n is less than zero." }) - return take((size - n).coerceAtLeast(0)) -} - -/** - * Returns a list containing all elements except last [n] elements. - */ -public fun FloatArray.dropLast(n: Int): List { +public fun ShortArray.dropLast(n: Int): List { require(n >= 0, { "Requested element count $n is less than zero." }) return take((size - n).coerceAtLeast(0)) } @@ -2724,7 +2700,31 @@ public fun LongArray.dropLast(n: Int): List { /** * Returns a list containing all elements except last [n] elements. */ -public fun ShortArray.dropLast(n: Int): List { +public fun FloatArray.dropLast(n: Int): List { + require(n >= 0, { "Requested element count $n is less than zero." }) + return take((size - n).coerceAtLeast(0)) +} + +/** + * Returns a list containing all elements except last [n] elements. + */ +public fun DoubleArray.dropLast(n: Int): List { + require(n >= 0, { "Requested element count $n is less than zero." }) + return take((size - n).coerceAtLeast(0)) +} + +/** + * Returns a list containing all elements except last [n] elements. + */ +public fun BooleanArray.dropLast(n: Int): List { + require(n >= 0, { "Requested element count $n is less than zero." }) + return take((size - n).coerceAtLeast(0)) +} + +/** + * Returns a list containing all elements except last [n] elements. + */ +public fun CharArray.dropLast(n: Int): List { require(n >= 0, { "Requested element count $n is less than zero." }) return take((size - n).coerceAtLeast(0)) } @@ -2741,18 +2741,6 @@ public inline fun Array.dropLastWhile(predicate: (T) -> Boolean): Lis return emptyList() } -/** - * Returns a list containing all elements except last elements that satisfy the given [predicate]. - */ -public inline fun BooleanArray.dropLastWhile(predicate: (Boolean) -> Boolean): List { - for (index in lastIndex downTo 0) { - if (!predicate(this[index])) { - return take(index + 1) - } - } - return emptyList() -} - /** * Returns a list containing all elements except last elements that satisfy the given [predicate]. */ @@ -2768,31 +2756,7 @@ public inline fun ByteArray.dropLastWhile(predicate: (Byte) -> Boolean): List Boolean): List { - for (index in lastIndex downTo 0) { - if (!predicate(this[index])) { - return take(index + 1) - } - } - return emptyList() -} - -/** - * Returns a list containing all elements except last elements that satisfy the given [predicate]. - */ -public inline fun DoubleArray.dropLastWhile(predicate: (Double) -> Boolean): List { - for (index in lastIndex downTo 0) { - if (!predicate(this[index])) { - return take(index + 1) - } - } - return emptyList() -} - -/** - * Returns a list containing all elements except last elements that satisfy the given [predicate]. - */ -public inline fun FloatArray.dropLastWhile(predicate: (Float) -> Boolean): List { +public inline fun ShortArray.dropLastWhile(predicate: (Short) -> Boolean): List { for (index in lastIndex downTo 0) { if (!predicate(this[index])) { return take(index + 1) @@ -2828,7 +2792,43 @@ public inline fun LongArray.dropLastWhile(predicate: (Long) -> Boolean): List Boolean): List { +public inline fun FloatArray.dropLastWhile(predicate: (Float) -> Boolean): List { + for (index in lastIndex downTo 0) { + if (!predicate(this[index])) { + return take(index + 1) + } + } + return emptyList() +} + +/** + * Returns a list containing all elements except last elements that satisfy the given [predicate]. + */ +public inline fun DoubleArray.dropLastWhile(predicate: (Double) -> Boolean): List { + for (index in lastIndex downTo 0) { + if (!predicate(this[index])) { + return take(index + 1) + } + } + return emptyList() +} + +/** + * Returns a list containing all elements except last elements that satisfy the given [predicate]. + */ +public inline fun BooleanArray.dropLastWhile(predicate: (Boolean) -> Boolean): List { + for (index in lastIndex downTo 0) { + if (!predicate(this[index])) { + return take(index + 1) + } + } + return emptyList() +} + +/** + * Returns a list containing all elements except last elements that satisfy the given [predicate]. + */ +public inline fun CharArray.dropLastWhile(predicate: (Char) -> Boolean): List { for (index in lastIndex downTo 0) { if (!predicate(this[index])) { return take(index + 1) @@ -2853,22 +2853,6 @@ public inline fun Array.dropWhile(predicate: (T) -> Boolean): List return list } -/** - * Returns a list containing all elements except first elements that satisfy the given [predicate]. - */ -public inline fun BooleanArray.dropWhile(predicate: (Boolean) -> Boolean): List { - var yielding = false - val list = ArrayList() - for (item in this) - if (yielding) - list.add(item) - else if (!predicate(item)) { - list.add(item) - yielding = true - } - return list -} - /** * Returns a list containing all elements except first elements that satisfy the given [predicate]. */ @@ -2888,41 +2872,9 @@ public inline fun ByteArray.dropWhile(predicate: (Byte) -> Boolean): List /** * Returns a list containing all elements except first elements that satisfy the given [predicate]. */ -public inline fun CharArray.dropWhile(predicate: (Char) -> Boolean): List { +public inline fun ShortArray.dropWhile(predicate: (Short) -> Boolean): List { var yielding = false - val list = ArrayList() - for (item in this) - if (yielding) - list.add(item) - else if (!predicate(item)) { - list.add(item) - yielding = true - } - return list -} - -/** - * Returns a list containing all elements except first elements that satisfy the given [predicate]. - */ -public inline fun DoubleArray.dropWhile(predicate: (Double) -> Boolean): List { - var yielding = false - val list = ArrayList() - for (item in this) - if (yielding) - list.add(item) - else if (!predicate(item)) { - list.add(item) - yielding = true - } - return list -} - -/** - * Returns a list containing all elements except first elements that satisfy the given [predicate]. - */ -public inline fun FloatArray.dropWhile(predicate: (Float) -> Boolean): List { - var yielding = false - val list = ArrayList() + val list = ArrayList() for (item in this) if (yielding) list.add(item) @@ -2968,9 +2920,57 @@ public inline fun LongArray.dropWhile(predicate: (Long) -> Boolean): List /** * Returns a list containing all elements except first elements that satisfy the given [predicate]. */ -public inline fun ShortArray.dropWhile(predicate: (Short) -> Boolean): List { +public inline fun FloatArray.dropWhile(predicate: (Float) -> Boolean): List { var yielding = false - val list = ArrayList() + val list = ArrayList() + for (item in this) + if (yielding) + list.add(item) + else if (!predicate(item)) { + list.add(item) + yielding = true + } + return list +} + +/** + * Returns a list containing all elements except first elements that satisfy the given [predicate]. + */ +public inline fun DoubleArray.dropWhile(predicate: (Double) -> Boolean): List { + var yielding = false + val list = ArrayList() + for (item in this) + if (yielding) + list.add(item) + else if (!predicate(item)) { + list.add(item) + yielding = true + } + return list +} + +/** + * Returns a list containing all elements except first elements that satisfy the given [predicate]. + */ +public inline fun BooleanArray.dropWhile(predicate: (Boolean) -> Boolean): List { + var yielding = false + val list = ArrayList() + for (item in this) + if (yielding) + list.add(item) + else if (!predicate(item)) { + list.add(item) + yielding = true + } + return list +} + +/** + * Returns a list containing all elements except first elements that satisfy the given [predicate]. + */ +public inline fun CharArray.dropWhile(predicate: (Char) -> Boolean): List { + var yielding = false + val list = ArrayList() for (item in this) if (yielding) list.add(item) @@ -2988,13 +2988,6 @@ public inline fun Array.filter(predicate: (T) -> Boolean): List { return filterTo(ArrayList(), predicate) } -/** - * Returns a list containing only elements matching the given [predicate]. - */ -public inline fun BooleanArray.filter(predicate: (Boolean) -> Boolean): List { - return filterTo(ArrayList(), predicate) -} - /** * Returns a list containing only elements matching the given [predicate]. */ @@ -3005,22 +2998,8 @@ public inline fun ByteArray.filter(predicate: (Byte) -> Boolean): List { /** * Returns a list containing only elements matching the given [predicate]. */ -public inline fun CharArray.filter(predicate: (Char) -> Boolean): List { - return filterTo(ArrayList(), predicate) -} - -/** - * Returns a list containing only elements matching the given [predicate]. - */ -public inline fun DoubleArray.filter(predicate: (Double) -> Boolean): List { - return filterTo(ArrayList(), predicate) -} - -/** - * Returns a list containing only elements matching the given [predicate]. - */ -public inline fun FloatArray.filter(predicate: (Float) -> Boolean): List { - return filterTo(ArrayList(), predicate) +public inline fun ShortArray.filter(predicate: (Short) -> Boolean): List { + return filterTo(ArrayList(), predicate) } /** @@ -3040,8 +3019,29 @@ public inline fun LongArray.filter(predicate: (Long) -> Boolean): List { /** * Returns a list containing only elements matching the given [predicate]. */ -public inline fun ShortArray.filter(predicate: (Short) -> Boolean): List { - return filterTo(ArrayList(), predicate) +public inline fun FloatArray.filter(predicate: (Float) -> Boolean): List { + return filterTo(ArrayList(), predicate) +} + +/** + * Returns a list containing only elements matching the given [predicate]. + */ +public inline fun DoubleArray.filter(predicate: (Double) -> Boolean): List { + return filterTo(ArrayList(), predicate) +} + +/** + * Returns a list containing only elements matching the given [predicate]. + */ +public inline fun BooleanArray.filter(predicate: (Boolean) -> Boolean): List { + return filterTo(ArrayList(), predicate) +} + +/** + * Returns a list containing only elements matching the given [predicate]. + */ +public inline fun CharArray.filter(predicate: (Char) -> Boolean): List { + return filterTo(ArrayList(), predicate) } /** @@ -3051,13 +3051,6 @@ public inline fun Array.filterIndexed(predicate: (Int, T) -> Boolean) return filterIndexedTo(ArrayList(), predicate) } -/** - * Returns a list containing only elements matching the given [predicate]. - */ -public inline fun BooleanArray.filterIndexed(predicate: (Int, Boolean) -> Boolean): List { - return filterIndexedTo(ArrayList(), predicate) -} - /** * Returns a list containing only elements matching the given [predicate]. */ @@ -3068,22 +3061,8 @@ public inline fun ByteArray.filterIndexed(predicate: (Int, Byte) -> Boolean): Li /** * Returns a list containing only elements matching the given [predicate]. */ -public inline fun CharArray.filterIndexed(predicate: (Int, Char) -> Boolean): List { - return filterIndexedTo(ArrayList(), predicate) -} - -/** - * Returns a list containing only elements matching the given [predicate]. - */ -public inline fun DoubleArray.filterIndexed(predicate: (Int, Double) -> Boolean): List { - return filterIndexedTo(ArrayList(), predicate) -} - -/** - * Returns a list containing only elements matching the given [predicate]. - */ -public inline fun FloatArray.filterIndexed(predicate: (Int, Float) -> Boolean): List { - return filterIndexedTo(ArrayList(), predicate) +public inline fun ShortArray.filterIndexed(predicate: (Int, Short) -> Boolean): List { + return filterIndexedTo(ArrayList(), predicate) } /** @@ -3103,8 +3082,29 @@ public inline fun LongArray.filterIndexed(predicate: (Int, Long) -> Boolean): Li /** * Returns a list containing only elements matching the given [predicate]. */ -public inline fun ShortArray.filterIndexed(predicate: (Int, Short) -> Boolean): List { - return filterIndexedTo(ArrayList(), predicate) +public inline fun FloatArray.filterIndexed(predicate: (Int, Float) -> Boolean): List { + return filterIndexedTo(ArrayList(), predicate) +} + +/** + * Returns a list containing only elements matching the given [predicate]. + */ +public inline fun DoubleArray.filterIndexed(predicate: (Int, Double) -> Boolean): List { + return filterIndexedTo(ArrayList(), predicate) +} + +/** + * Returns a list containing only elements matching the given [predicate]. + */ +public inline fun BooleanArray.filterIndexed(predicate: (Int, Boolean) -> Boolean): List { + return filterIndexedTo(ArrayList(), predicate) +} + +/** + * Returns a list containing only elements matching the given [predicate]. + */ +public inline fun CharArray.filterIndexed(predicate: (Int, Char) -> Boolean): List { + return filterIndexedTo(ArrayList(), predicate) } /** @@ -3117,16 +3117,6 @@ public inline fun > Array.filterIndexedTo( return destination } -/** - * Appends all elements matching the given [predicate] to the given [destination]. - */ -public inline fun > BooleanArray.filterIndexedTo(destination: C, predicate: (Int, Boolean) -> Boolean): C { - forEachIndexed { index, element -> - if (predicate(index, element)) destination.add(element) - } - return destination -} - /** * Appends all elements matching the given [predicate] to the given [destination]. */ @@ -3140,27 +3130,7 @@ public inline fun > ByteArray.filterIndexedTo(des /** * Appends all elements matching the given [predicate] to the given [destination]. */ -public inline fun > CharArray.filterIndexedTo(destination: C, predicate: (Int, Char) -> Boolean): C { - forEachIndexed { index, element -> - if (predicate(index, element)) destination.add(element) - } - return destination -} - -/** - * Appends all elements matching the given [predicate] to the given [destination]. - */ -public inline fun > DoubleArray.filterIndexedTo(destination: C, predicate: (Int, Double) -> Boolean): C { - forEachIndexed { index, element -> - if (predicate(index, element)) destination.add(element) - } - return destination -} - -/** - * Appends all elements matching the given [predicate] to the given [destination]. - */ -public inline fun > FloatArray.filterIndexedTo(destination: C, predicate: (Int, Float) -> Boolean): C { +public inline fun > ShortArray.filterIndexedTo(destination: C, predicate: (Int, Short) -> Boolean): C { forEachIndexed { index, element -> if (predicate(index, element)) destination.add(element) } @@ -3190,7 +3160,37 @@ public inline fun > LongArray.filterIndexedTo(des /** * Appends all elements matching the given [predicate] to the given [destination]. */ -public inline fun > ShortArray.filterIndexedTo(destination: C, predicate: (Int, Short) -> Boolean): C { +public inline fun > FloatArray.filterIndexedTo(destination: C, predicate: (Int, Float) -> Boolean): C { + forEachIndexed { index, element -> + if (predicate(index, element)) destination.add(element) + } + return destination +} + +/** + * Appends all elements matching the given [predicate] to the given [destination]. + */ +public inline fun > DoubleArray.filterIndexedTo(destination: C, predicate: (Int, Double) -> Boolean): C { + forEachIndexed { index, element -> + if (predicate(index, element)) destination.add(element) + } + return destination +} + +/** + * Appends all elements matching the given [predicate] to the given [destination]. + */ +public inline fun > BooleanArray.filterIndexedTo(destination: C, predicate: (Int, Boolean) -> Boolean): C { + forEachIndexed { index, element -> + if (predicate(index, element)) destination.add(element) + } + return destination +} + +/** + * Appends all elements matching the given [predicate] to the given [destination]. + */ +public inline fun > CharArray.filterIndexedTo(destination: C, predicate: (Int, Char) -> Boolean): C { forEachIndexed { index, element -> if (predicate(index, element)) destination.add(element) } @@ -3204,13 +3204,6 @@ public inline fun Array.filterNot(predicate: (T) -> Boolean): List return filterNotTo(ArrayList(), predicate) } -/** - * Returns a list containing all elements not matching the given [predicate]. - */ -public inline fun BooleanArray.filterNot(predicate: (Boolean) -> Boolean): List { - return filterNotTo(ArrayList(), predicate) -} - /** * Returns a list containing all elements not matching the given [predicate]. */ @@ -3221,22 +3214,8 @@ public inline fun ByteArray.filterNot(predicate: (Byte) -> Boolean): List /** * Returns a list containing all elements not matching the given [predicate]. */ -public inline fun CharArray.filterNot(predicate: (Char) -> Boolean): List { - return filterNotTo(ArrayList(), predicate) -} - -/** - * Returns a list containing all elements not matching the given [predicate]. - */ -public inline fun DoubleArray.filterNot(predicate: (Double) -> Boolean): List { - return filterNotTo(ArrayList(), predicate) -} - -/** - * Returns a list containing all elements not matching the given [predicate]. - */ -public inline fun FloatArray.filterNot(predicate: (Float) -> Boolean): List { - return filterNotTo(ArrayList(), predicate) +public inline fun ShortArray.filterNot(predicate: (Short) -> Boolean): List { + return filterNotTo(ArrayList(), predicate) } /** @@ -3256,8 +3235,29 @@ public inline fun LongArray.filterNot(predicate: (Long) -> Boolean): List /** * Returns a list containing all elements not matching the given [predicate]. */ -public inline fun ShortArray.filterNot(predicate: (Short) -> Boolean): List { - return filterNotTo(ArrayList(), predicate) +public inline fun FloatArray.filterNot(predicate: (Float) -> Boolean): List { + return filterNotTo(ArrayList(), predicate) +} + +/** + * Returns a list containing all elements not matching the given [predicate]. + */ +public inline fun DoubleArray.filterNot(predicate: (Double) -> Boolean): List { + return filterNotTo(ArrayList(), predicate) +} + +/** + * Returns a list containing all elements not matching the given [predicate]. + */ +public inline fun BooleanArray.filterNot(predicate: (Boolean) -> Boolean): List { + return filterNotTo(ArrayList(), predicate) +} + +/** + * Returns a list containing all elements not matching the given [predicate]. + */ +public inline fun CharArray.filterNot(predicate: (Char) -> Boolean): List { + return filterNotTo(ArrayList(), predicate) } /** @@ -3283,14 +3283,6 @@ public inline fun > Array.filterNotTo(dest return destination } -/** - * Appends all elements not matching the given [predicate] to the given [destination]. - */ -public inline fun > BooleanArray.filterNotTo(destination: C, predicate: (Boolean) -> Boolean): C { - for (element in this) if (!predicate(element)) destination.add(element) - return destination -} - /** * Appends all elements not matching the given [predicate] to the given [destination]. */ @@ -3302,23 +3294,7 @@ public inline fun > ByteArray.filterNotTo(destina /** * Appends all elements not matching the given [predicate] to the given [destination]. */ -public inline fun > CharArray.filterNotTo(destination: C, predicate: (Char) -> Boolean): C { - for (element in this) if (!predicate(element)) destination.add(element) - return destination -} - -/** - * Appends all elements not matching the given [predicate] to the given [destination]. - */ -public inline fun > DoubleArray.filterNotTo(destination: C, predicate: (Double) -> Boolean): C { - for (element in this) if (!predicate(element)) destination.add(element) - return destination -} - -/** - * Appends all elements not matching the given [predicate] to the given [destination]. - */ -public inline fun > FloatArray.filterNotTo(destination: C, predicate: (Float) -> Boolean): C { +public inline fun > ShortArray.filterNotTo(destination: C, predicate: (Short) -> Boolean): C { for (element in this) if (!predicate(element)) destination.add(element) return destination } @@ -3342,7 +3318,31 @@ public inline fun > LongArray.filterNotTo(destina /** * Appends all elements not matching the given [predicate] to the given [destination]. */ -public inline fun > ShortArray.filterNotTo(destination: C, predicate: (Short) -> Boolean): C { +public inline fun > FloatArray.filterNotTo(destination: C, predicate: (Float) -> Boolean): C { + for (element in this) if (!predicate(element)) destination.add(element) + return destination +} + +/** + * Appends all elements not matching the given [predicate] to the given [destination]. + */ +public inline fun > DoubleArray.filterNotTo(destination: C, predicate: (Double) -> Boolean): C { + for (element in this) if (!predicate(element)) destination.add(element) + return destination +} + +/** + * Appends all elements not matching the given [predicate] to the given [destination]. + */ +public inline fun > BooleanArray.filterNotTo(destination: C, predicate: (Boolean) -> Boolean): C { + for (element in this) if (!predicate(element)) destination.add(element) + return destination +} + +/** + * Appends all elements not matching the given [predicate] to the given [destination]. + */ +public inline fun > CharArray.filterNotTo(destination: C, predicate: (Char) -> Boolean): C { for (element in this) if (!predicate(element)) destination.add(element) return destination } @@ -3355,14 +3355,6 @@ public inline fun > Array.filterTo(destina return destination } -/** - * Appends all elements matching the given [predicate] to the given [destination]. - */ -public inline fun > BooleanArray.filterTo(destination: C, predicate: (Boolean) -> Boolean): C { - for (element in this) if (predicate(element)) destination.add(element) - return destination -} - /** * Appends all elements matching the given [predicate] to the given [destination]. */ @@ -3374,23 +3366,7 @@ public inline fun > ByteArray.filterTo(destinatio /** * Appends all elements matching the given [predicate] to the given [destination]. */ -public inline fun > CharArray.filterTo(destination: C, predicate: (Char) -> Boolean): C { - for (element in this) if (predicate(element)) destination.add(element) - return destination -} - -/** - * Appends all elements matching the given [predicate] to the given [destination]. - */ -public inline fun > DoubleArray.filterTo(destination: C, predicate: (Double) -> Boolean): C { - for (element in this) if (predicate(element)) destination.add(element) - return destination -} - -/** - * Appends all elements matching the given [predicate] to the given [destination]. - */ -public inline fun > FloatArray.filterTo(destination: C, predicate: (Float) -> Boolean): C { +public inline fun > ShortArray.filterTo(destination: C, predicate: (Short) -> Boolean): C { for (element in this) if (predicate(element)) destination.add(element) return destination } @@ -3414,7 +3390,31 @@ public inline fun > LongArray.filterTo(destinatio /** * Appends all elements matching the given [predicate] to the given [destination]. */ -public inline fun > ShortArray.filterTo(destination: C, predicate: (Short) -> Boolean): C { +public inline fun > FloatArray.filterTo(destination: C, predicate: (Float) -> Boolean): C { + for (element in this) if (predicate(element)) destination.add(element) + return destination +} + +/** + * Appends all elements matching the given [predicate] to the given [destination]. + */ +public inline fun > DoubleArray.filterTo(destination: C, predicate: (Double) -> Boolean): C { + for (element in this) if (predicate(element)) destination.add(element) + return destination +} + +/** + * Appends all elements matching the given [predicate] to the given [destination]. + */ +public inline fun > BooleanArray.filterTo(destination: C, predicate: (Boolean) -> Boolean): C { + for (element in this) if (predicate(element)) destination.add(element) + return destination +} + +/** + * Appends all elements matching the given [predicate] to the given [destination]. + */ +public inline fun > CharArray.filterTo(destination: C, predicate: (Char) -> Boolean): C { for (element in this) if (predicate(element)) destination.add(element) return destination } @@ -3427,14 +3427,6 @@ public fun Array.slice(indices: IntRange): List { return copyOfRange(indices.start, indices.endInclusive + 1).asList() } -/** - * Returns a list containing elements at indices in the specified [indices] range. - */ -public fun BooleanArray.slice(indices: IntRange): List { - if (indices.isEmpty()) return listOf() - return copyOfRange(indices.start, indices.endInclusive + 1).asList() -} - /** * Returns a list containing elements at indices in the specified [indices] range. */ @@ -3446,23 +3438,7 @@ public fun ByteArray.slice(indices: IntRange): List { /** * Returns a list containing elements at indices in the specified [indices] range. */ -public fun CharArray.slice(indices: IntRange): List { - if (indices.isEmpty()) return listOf() - return copyOfRange(indices.start, indices.endInclusive + 1).asList() -} - -/** - * Returns a list containing elements at indices in the specified [indices] range. - */ -public fun DoubleArray.slice(indices: IntRange): List { - if (indices.isEmpty()) return listOf() - return copyOfRange(indices.start, indices.endInclusive + 1).asList() -} - -/** - * Returns a list containing elements at indices in the specified [indices] range. - */ -public fun FloatArray.slice(indices: IntRange): List { +public fun ShortArray.slice(indices: IntRange): List { if (indices.isEmpty()) return listOf() return copyOfRange(indices.start, indices.endInclusive + 1).asList() } @@ -3486,7 +3462,31 @@ public fun LongArray.slice(indices: IntRange): List { /** * Returns a list containing elements at indices in the specified [indices] range. */ -public fun ShortArray.slice(indices: IntRange): List { +public fun FloatArray.slice(indices: IntRange): List { + if (indices.isEmpty()) return listOf() + return copyOfRange(indices.start, indices.endInclusive + 1).asList() +} + +/** + * Returns a list containing elements at indices in the specified [indices] range. + */ +public fun DoubleArray.slice(indices: IntRange): List { + if (indices.isEmpty()) return listOf() + return copyOfRange(indices.start, indices.endInclusive + 1).asList() +} + +/** + * Returns a list containing elements at indices in the specified [indices] range. + */ +public fun BooleanArray.slice(indices: IntRange): List { + if (indices.isEmpty()) return listOf() + return copyOfRange(indices.start, indices.endInclusive + 1).asList() +} + +/** + * Returns a list containing elements at indices in the specified [indices] range. + */ +public fun CharArray.slice(indices: IntRange): List { if (indices.isEmpty()) return listOf() return copyOfRange(indices.start, indices.endInclusive + 1).asList() } @@ -3504,19 +3504,6 @@ public fun Array.slice(indices: Iterable): List { return list } -/** - * Returns a list containing elements at specified [indices]. - */ -public fun BooleanArray.slice(indices: Iterable): List { - val size = indices.collectionSizeOrDefault(10) - if (size == 0) return listOf() - val list = ArrayList(size) - for (index in indices) { - list.add(get(index)) - } - return list -} - /** * Returns a list containing elements at specified [indices]. */ @@ -3533,36 +3520,10 @@ public fun ByteArray.slice(indices: Iterable): List { /** * Returns a list containing elements at specified [indices]. */ -public fun CharArray.slice(indices: Iterable): List { +public fun ShortArray.slice(indices: Iterable): List { val size = indices.collectionSizeOrDefault(10) if (size == 0) return listOf() - val list = ArrayList(size) - for (index in indices) { - list.add(get(index)) - } - return list -} - -/** - * Returns a list containing elements at specified [indices]. - */ -public fun DoubleArray.slice(indices: Iterable): List { - val size = indices.collectionSizeOrDefault(10) - if (size == 0) return listOf() - val list = ArrayList(size) - for (index in indices) { - list.add(get(index)) - } - return list -} - -/** - * Returns a list containing elements at specified [indices]. - */ -public fun FloatArray.slice(indices: Iterable): List { - val size = indices.collectionSizeOrDefault(10) - if (size == 0) return listOf() - val list = ArrayList(size) + val list = ArrayList(size) for (index in indices) { list.add(get(index)) } @@ -3598,10 +3559,49 @@ public fun LongArray.slice(indices: Iterable): List { /** * Returns a list containing elements at specified [indices]. */ -public fun ShortArray.slice(indices: Iterable): List { +public fun FloatArray.slice(indices: Iterable): List { val size = indices.collectionSizeOrDefault(10) if (size == 0) return listOf() - val list = ArrayList(size) + val list = ArrayList(size) + for (index in indices) { + list.add(get(index)) + } + return list +} + +/** + * Returns a list containing elements at specified [indices]. + */ +public fun DoubleArray.slice(indices: Iterable): List { + val size = indices.collectionSizeOrDefault(10) + if (size == 0) return listOf() + val list = ArrayList(size) + for (index in indices) { + list.add(get(index)) + } + return list +} + +/** + * Returns a list containing elements at specified [indices]. + */ +public fun BooleanArray.slice(indices: Iterable): List { + val size = indices.collectionSizeOrDefault(10) + if (size == 0) return listOf() + val list = ArrayList(size) + for (index in indices) { + list.add(get(index)) + } + return list +} + +/** + * Returns a list containing elements at specified [indices]. + */ +public fun CharArray.slice(indices: Iterable): List { + val size = indices.collectionSizeOrDefault(10) + if (size == 0) return listOf() + val list = ArrayList(size) for (index in indices) { list.add(get(index)) } @@ -3620,18 +3620,6 @@ public fun Array.sliceArray(indices: Collection): Array { return result } -/** - * Returns an array containing elements of this array at specified [indices]. - */ -public fun BooleanArray.sliceArray(indices: Collection): BooleanArray { - val result = BooleanArray(indices.size) - var targetIndex = 0 - for (sourceIndex in indices) { - result[targetIndex++] = this[sourceIndex] - } - return result -} - /** * Returns an array containing elements of this array at specified [indices]. */ @@ -3647,32 +3635,8 @@ public fun ByteArray.sliceArray(indices: Collection): ByteArray { /** * Returns an array containing elements of this array at specified [indices]. */ -public fun CharArray.sliceArray(indices: Collection): CharArray { - val result = CharArray(indices.size) - var targetIndex = 0 - for (sourceIndex in indices) { - result[targetIndex++] = this[sourceIndex] - } - return result -} - -/** - * Returns an array containing elements of this array at specified [indices]. - */ -public fun DoubleArray.sliceArray(indices: Collection): DoubleArray { - val result = DoubleArray(indices.size) - var targetIndex = 0 - for (sourceIndex in indices) { - result[targetIndex++] = this[sourceIndex] - } - return result -} - -/** - * Returns an array containing elements of this array at specified [indices]. - */ -public fun FloatArray.sliceArray(indices: Collection): FloatArray { - val result = FloatArray(indices.size) +public fun ShortArray.sliceArray(indices: Collection): ShortArray { + val result = ShortArray(indices.size) var targetIndex = 0 for (sourceIndex in indices) { result[targetIndex++] = this[sourceIndex] @@ -3707,8 +3671,44 @@ public fun LongArray.sliceArray(indices: Collection): LongArray { /** * Returns an array containing elements of this array at specified [indices]. */ -public fun ShortArray.sliceArray(indices: Collection): ShortArray { - val result = ShortArray(indices.size) +public fun FloatArray.sliceArray(indices: Collection): FloatArray { + val result = FloatArray(indices.size) + var targetIndex = 0 + for (sourceIndex in indices) { + result[targetIndex++] = this[sourceIndex] + } + return result +} + +/** + * Returns an array containing elements of this array at specified [indices]. + */ +public fun DoubleArray.sliceArray(indices: Collection): DoubleArray { + val result = DoubleArray(indices.size) + var targetIndex = 0 + for (sourceIndex in indices) { + result[targetIndex++] = this[sourceIndex] + } + return result +} + +/** + * Returns an array containing elements of this array at specified [indices]. + */ +public fun BooleanArray.sliceArray(indices: Collection): BooleanArray { + val result = BooleanArray(indices.size) + var targetIndex = 0 + for (sourceIndex in indices) { + result[targetIndex++] = this[sourceIndex] + } + return result +} + +/** + * Returns an array containing elements of this array at specified [indices]. + */ +public fun CharArray.sliceArray(indices: Collection): CharArray { + val result = CharArray(indices.size) var targetIndex = 0 for (sourceIndex in indices) { result[targetIndex++] = this[sourceIndex] @@ -3724,14 +3724,6 @@ public fun Array.sliceArray(indices: IntRange): Array { return copyOfRange(indices.start, indices.endInclusive + 1) } -/** - * Returns a list containing elements at indices in the specified [indices] range. - */ -public fun BooleanArray.sliceArray(indices: IntRange): BooleanArray { - if (indices.isEmpty()) return BooleanArray(0) - return copyOfRange(indices.start, indices.endInclusive + 1) -} - /** * Returns a list containing elements at indices in the specified [indices] range. */ @@ -3743,24 +3735,8 @@ public fun ByteArray.sliceArray(indices: IntRange): ByteArray { /** * Returns a list containing elements at indices in the specified [indices] range. */ -public fun CharArray.sliceArray(indices: IntRange): CharArray { - if (indices.isEmpty()) return CharArray(0) - return copyOfRange(indices.start, indices.endInclusive + 1) -} - -/** - * Returns a list containing elements at indices in the specified [indices] range. - */ -public fun DoubleArray.sliceArray(indices: IntRange): DoubleArray { - if (indices.isEmpty()) return DoubleArray(0) - return copyOfRange(indices.start, indices.endInclusive + 1) -} - -/** - * Returns a list containing elements at indices in the specified [indices] range. - */ -public fun FloatArray.sliceArray(indices: IntRange): FloatArray { - if (indices.isEmpty()) return FloatArray(0) +public fun ShortArray.sliceArray(indices: IntRange): ShortArray { + if (indices.isEmpty()) return ShortArray(0) return copyOfRange(indices.start, indices.endInclusive + 1) } @@ -3783,8 +3759,32 @@ public fun LongArray.sliceArray(indices: IntRange): LongArray { /** * Returns a list containing elements at indices in the specified [indices] range. */ -public fun ShortArray.sliceArray(indices: IntRange): ShortArray { - if (indices.isEmpty()) return ShortArray(0) +public fun FloatArray.sliceArray(indices: IntRange): FloatArray { + if (indices.isEmpty()) return FloatArray(0) + return copyOfRange(indices.start, indices.endInclusive + 1) +} + +/** + * Returns a list containing elements at indices in the specified [indices] range. + */ +public fun DoubleArray.sliceArray(indices: IntRange): DoubleArray { + if (indices.isEmpty()) return DoubleArray(0) + return copyOfRange(indices.start, indices.endInclusive + 1) +} + +/** + * Returns a list containing elements at indices in the specified [indices] range. + */ +public fun BooleanArray.sliceArray(indices: IntRange): BooleanArray { + if (indices.isEmpty()) return BooleanArray(0) + return copyOfRange(indices.start, indices.endInclusive + 1) +} + +/** + * Returns a list containing elements at indices in the specified [indices] range. + */ +public fun CharArray.sliceArray(indices: IntRange): CharArray { + if (indices.isEmpty()) return CharArray(0) return copyOfRange(indices.start, indices.endInclusive + 1) } @@ -3805,23 +3805,6 @@ public fun Array.take(n: Int): List { return list } -/** - * Returns a list containing first [n] elements. - */ -public fun BooleanArray.take(n: Int): List { - require(n >= 0) { "Requested element count $n is less than zero." } - if (n == 0) return emptyList() - if (n >= size) return toList() - var count = 0 - val list = ArrayList(n) - for (item in this) { - if (count++ == n) - break; - list.add(item) - } - return list -} - /** * Returns a list containing first [n] elements. */ @@ -3842,46 +3825,12 @@ public fun ByteArray.take(n: Int): List { /** * Returns a list containing first [n] elements. */ -public fun CharArray.take(n: Int): List { +public fun ShortArray.take(n: Int): List { require(n >= 0) { "Requested element count $n is less than zero." } if (n == 0) return emptyList() if (n >= size) return toList() var count = 0 - val list = ArrayList(n) - for (item in this) { - if (count++ == n) - break; - list.add(item) - } - return list -} - -/** - * Returns a list containing first [n] elements. - */ -public fun DoubleArray.take(n: Int): List { - require(n >= 0) { "Requested element count $n is less than zero." } - if (n == 0) return emptyList() - if (n >= size) return toList() - var count = 0 - val list = ArrayList(n) - for (item in this) { - if (count++ == n) - break; - list.add(item) - } - return list -} - -/** - * Returns a list containing first [n] elements. - */ -public fun FloatArray.take(n: Int): List { - require(n >= 0) { "Requested element count $n is less than zero." } - if (n == 0) return emptyList() - if (n >= size) return toList() - var count = 0 - val list = ArrayList(n) + val list = ArrayList(n) for (item in this) { if (count++ == n) break; @@ -3927,12 +3876,63 @@ public fun LongArray.take(n: Int): List { /** * Returns a list containing first [n] elements. */ -public fun ShortArray.take(n: Int): List { +public fun FloatArray.take(n: Int): List { require(n >= 0) { "Requested element count $n is less than zero." } if (n == 0) return emptyList() if (n >= size) return toList() var count = 0 - val list = ArrayList(n) + val list = ArrayList(n) + for (item in this) { + if (count++ == n) + break; + list.add(item) + } + return list +} + +/** + * Returns a list containing first [n] elements. + */ +public fun DoubleArray.take(n: Int): List { + require(n >= 0) { "Requested element count $n is less than zero." } + if (n == 0) return emptyList() + if (n >= size) return toList() + var count = 0 + val list = ArrayList(n) + for (item in this) { + if (count++ == n) + break; + list.add(item) + } + return list +} + +/** + * Returns a list containing first [n] elements. + */ +public fun BooleanArray.take(n: Int): List { + require(n >= 0) { "Requested element count $n is less than zero." } + if (n == 0) return emptyList() + if (n >= size) return toList() + var count = 0 + val list = ArrayList(n) + for (item in this) { + if (count++ == n) + break; + list.add(item) + } + return list +} + +/** + * Returns a list containing first [n] elements. + */ +public fun CharArray.take(n: Int): List { + require(n >= 0) { "Requested element count $n is less than zero." } + if (n == 0) return emptyList() + if (n >= size) return toList() + var count = 0 + val list = ArrayList(n) for (item in this) { if (count++ == n) break; @@ -3955,20 +3955,6 @@ public fun Array.takeLast(n: Int): List { return list } -/** - * Returns a list containing last [n] elements. - */ -public fun BooleanArray.takeLast(n: Int): List { - require(n >= 0, { "Requested element count $n is less than zero." }) - if (n == 0) return emptyList() - val size = size - if (n >= size) return toList() - val list = ArrayList(n) - for (index in size - n .. size - 1) - list.add(this[index]) - return list -} - /** * Returns a list containing last [n] elements. */ @@ -3986,40 +3972,12 @@ public fun ByteArray.takeLast(n: Int): List { /** * Returns a list containing last [n] elements. */ -public fun CharArray.takeLast(n: Int): List { +public fun ShortArray.takeLast(n: Int): List { require(n >= 0, { "Requested element count $n is less than zero." }) if (n == 0) return emptyList() val size = size if (n >= size) return toList() - val list = ArrayList(n) - for (index in size - n .. size - 1) - list.add(this[index]) - return list -} - -/** - * Returns a list containing last [n] elements. - */ -public fun DoubleArray.takeLast(n: Int): List { - require(n >= 0, { "Requested element count $n is less than zero." }) - if (n == 0) return emptyList() - val size = size - if (n >= size) return toList() - val list = ArrayList(n) - for (index in size - n .. size - 1) - list.add(this[index]) - return list -} - -/** - * Returns a list containing last [n] elements. - */ -public fun FloatArray.takeLast(n: Int): List { - require(n >= 0, { "Requested element count $n is less than zero." }) - if (n == 0) return emptyList() - val size = size - if (n >= size) return toList() - val list = ArrayList(n) + val list = ArrayList(n) for (index in size - n .. size - 1) list.add(this[index]) return list @@ -4056,12 +4014,54 @@ public fun LongArray.takeLast(n: Int): List { /** * Returns a list containing last [n] elements. */ -public fun ShortArray.takeLast(n: Int): List { +public fun FloatArray.takeLast(n: Int): List { require(n >= 0, { "Requested element count $n is less than zero." }) if (n == 0) return emptyList() val size = size if (n >= size) return toList() - val list = ArrayList(n) + val list = ArrayList(n) + for (index in size - n .. size - 1) + list.add(this[index]) + return list +} + +/** + * Returns a list containing last [n] elements. + */ +public fun DoubleArray.takeLast(n: Int): List { + require(n >= 0, { "Requested element count $n is less than zero." }) + if (n == 0) return emptyList() + val size = size + if (n >= size) return toList() + val list = ArrayList(n) + for (index in size - n .. size - 1) + list.add(this[index]) + return list +} + +/** + * Returns a list containing last [n] elements. + */ +public fun BooleanArray.takeLast(n: Int): List { + require(n >= 0, { "Requested element count $n is less than zero." }) + if (n == 0) return emptyList() + val size = size + if (n >= size) return toList() + val list = ArrayList(n) + for (index in size - n .. size - 1) + list.add(this[index]) + return list +} + +/** + * Returns a list containing last [n] elements. + */ +public fun CharArray.takeLast(n: Int): List { + require(n >= 0, { "Requested element count $n is less than zero." }) + if (n == 0) return emptyList() + val size = size + if (n >= size) return toList() + val list = ArrayList(n) for (index in size - n .. size - 1) list.add(this[index]) return list @@ -4079,18 +4079,6 @@ public inline fun Array.takeLastWhile(predicate: (T) -> Boolean): Lis return toList() } -/** - * Returns a list containing last elements satisfying the given [predicate]. - */ -public inline fun BooleanArray.takeLastWhile(predicate: (Boolean) -> Boolean): List { - for (index in lastIndex downTo 0) { - if (!predicate(this[index])) { - return drop(index + 1) - } - } - return toList() -} - /** * Returns a list containing last elements satisfying the given [predicate]. */ @@ -4106,31 +4094,7 @@ public inline fun ByteArray.takeLastWhile(predicate: (Byte) -> Boolean): List Boolean): List { - for (index in lastIndex downTo 0) { - if (!predicate(this[index])) { - return drop(index + 1) - } - } - return toList() -} - -/** - * Returns a list containing last elements satisfying the given [predicate]. - */ -public inline fun DoubleArray.takeLastWhile(predicate: (Double) -> Boolean): List { - for (index in lastIndex downTo 0) { - if (!predicate(this[index])) { - return drop(index + 1) - } - } - return toList() -} - -/** - * Returns a list containing last elements satisfying the given [predicate]. - */ -public inline fun FloatArray.takeLastWhile(predicate: (Float) -> Boolean): List { +public inline fun ShortArray.takeLastWhile(predicate: (Short) -> Boolean): List { for (index in lastIndex downTo 0) { if (!predicate(this[index])) { return drop(index + 1) @@ -4166,7 +4130,43 @@ public inline fun LongArray.takeLastWhile(predicate: (Long) -> Boolean): List Boolean): List { +public inline fun FloatArray.takeLastWhile(predicate: (Float) -> Boolean): List { + for (index in lastIndex downTo 0) { + if (!predicate(this[index])) { + return drop(index + 1) + } + } + return toList() +} + +/** + * Returns a list containing last elements satisfying the given [predicate]. + */ +public inline fun DoubleArray.takeLastWhile(predicate: (Double) -> Boolean): List { + for (index in lastIndex downTo 0) { + if (!predicate(this[index])) { + return drop(index + 1) + } + } + return toList() +} + +/** + * Returns a list containing last elements satisfying the given [predicate]. + */ +public inline fun BooleanArray.takeLastWhile(predicate: (Boolean) -> Boolean): List { + for (index in lastIndex downTo 0) { + if (!predicate(this[index])) { + return drop(index + 1) + } + } + return toList() +} + +/** + * Returns a list containing last elements satisfying the given [predicate]. + */ +public inline fun CharArray.takeLastWhile(predicate: (Char) -> Boolean): List { for (index in lastIndex downTo 0) { if (!predicate(this[index])) { return drop(index + 1) @@ -4188,19 +4188,6 @@ public inline fun Array.takeWhile(predicate: (T) -> Boolean): List return list } -/** - * Returns a list containing first elements satisfying the given [predicate]. - */ -public inline fun BooleanArray.takeWhile(predicate: (Boolean) -> Boolean): List { - val list = ArrayList() - for (item in this) { - if (!predicate(item)) - break; - list.add(item) - } - return list -} - /** * Returns a list containing first elements satisfying the given [predicate]. */ @@ -4217,34 +4204,8 @@ public inline fun ByteArray.takeWhile(predicate: (Byte) -> Boolean): List /** * Returns a list containing first elements satisfying the given [predicate]. */ -public inline fun CharArray.takeWhile(predicate: (Char) -> Boolean): List { - val list = ArrayList() - for (item in this) { - if (!predicate(item)) - break; - list.add(item) - } - return list -} - -/** - * Returns a list containing first elements satisfying the given [predicate]. - */ -public inline fun DoubleArray.takeWhile(predicate: (Double) -> Boolean): List { - val list = ArrayList() - for (item in this) { - if (!predicate(item)) - break; - list.add(item) - } - return list -} - -/** - * Returns a list containing first elements satisfying the given [predicate]. - */ -public inline fun FloatArray.takeWhile(predicate: (Float) -> Boolean): List { - val list = ArrayList() +public inline fun ShortArray.takeWhile(predicate: (Short) -> Boolean): List { + val list = ArrayList() for (item in this) { if (!predicate(item)) break; @@ -4282,8 +4243,47 @@ public inline fun LongArray.takeWhile(predicate: (Long) -> Boolean): List /** * Returns a list containing first elements satisfying the given [predicate]. */ -public inline fun ShortArray.takeWhile(predicate: (Short) -> Boolean): List { - val list = ArrayList() +public inline fun FloatArray.takeWhile(predicate: (Float) -> Boolean): List { + val list = ArrayList() + for (item in this) { + if (!predicate(item)) + break; + list.add(item) + } + return list +} + +/** + * Returns a list containing first elements satisfying the given [predicate]. + */ +public inline fun DoubleArray.takeWhile(predicate: (Double) -> Boolean): List { + val list = ArrayList() + for (item in this) { + if (!predicate(item)) + break; + list.add(item) + } + return list +} + +/** + * Returns a list containing first elements satisfying the given [predicate]. + */ +public inline fun BooleanArray.takeWhile(predicate: (Boolean) -> Boolean): List { + val list = ArrayList() + for (item in this) { + if (!predicate(item)) + break; + list.add(item) + } + return list +} + +/** + * Returns a list containing first elements satisfying the given [predicate]. + */ +public inline fun CharArray.takeWhile(predicate: (Char) -> Boolean): List { + val list = ArrayList() for (item in this) { if (!predicate(item)) break; @@ -4307,21 +4307,6 @@ public fun Array.reverse(): Unit { } } -/** - * Reverses elements in the array in-place. - */ -public fun BooleanArray.reverse(): Unit { - val midPoint = (size / 2) - 1 - if (midPoint < 0) return - var reverseIndex = lastIndex - for (index in 0..midPoint) { - val tmp = this[index] - this[index] = this[reverseIndex] - this[reverseIndex] = tmp - reverseIndex-- - } -} - /** * Reverses elements in the array in-place. */ @@ -4340,37 +4325,7 @@ public fun ByteArray.reverse(): Unit { /** * Reverses elements in the array in-place. */ -public fun CharArray.reverse(): Unit { - val midPoint = (size / 2) - 1 - if (midPoint < 0) return - var reverseIndex = lastIndex - for (index in 0..midPoint) { - val tmp = this[index] - this[index] = this[reverseIndex] - this[reverseIndex] = tmp - reverseIndex-- - } -} - -/** - * Reverses elements in the array in-place. - */ -public fun DoubleArray.reverse(): Unit { - val midPoint = (size / 2) - 1 - if (midPoint < 0) return - var reverseIndex = lastIndex - for (index in 0..midPoint) { - val tmp = this[index] - this[index] = this[reverseIndex] - this[reverseIndex] = tmp - reverseIndex-- - } -} - -/** - * Reverses elements in the array in-place. - */ -public fun FloatArray.reverse(): Unit { +public fun ShortArray.reverse(): Unit { val midPoint = (size / 2) - 1 if (midPoint < 0) return var reverseIndex = lastIndex @@ -4415,7 +4370,52 @@ public fun LongArray.reverse(): Unit { /** * Reverses elements in the array in-place. */ -public fun ShortArray.reverse(): Unit { +public fun FloatArray.reverse(): Unit { + val midPoint = (size / 2) - 1 + if (midPoint < 0) return + var reverseIndex = lastIndex + for (index in 0..midPoint) { + val tmp = this[index] + this[index] = this[reverseIndex] + this[reverseIndex] = tmp + reverseIndex-- + } +} + +/** + * Reverses elements in the array in-place. + */ +public fun DoubleArray.reverse(): Unit { + val midPoint = (size / 2) - 1 + if (midPoint < 0) return + var reverseIndex = lastIndex + for (index in 0..midPoint) { + val tmp = this[index] + this[index] = this[reverseIndex] + this[reverseIndex] = tmp + reverseIndex-- + } +} + +/** + * Reverses elements in the array in-place. + */ +public fun BooleanArray.reverse(): Unit { + val midPoint = (size / 2) - 1 + if (midPoint < 0) return + var reverseIndex = lastIndex + for (index in 0..midPoint) { + val tmp = this[index] + this[index] = this[reverseIndex] + this[reverseIndex] = tmp + reverseIndex-- + } +} + +/** + * Reverses elements in the array in-place. + */ +public fun CharArray.reverse(): Unit { val midPoint = (size / 2) - 1 if (midPoint < 0) return var reverseIndex = lastIndex @@ -4437,16 +4437,6 @@ public fun Array.reversed(): List { return list } -/** - * Returns a list with elements in reversed order. - */ -public fun BooleanArray.reversed(): List { - if (isEmpty()) return emptyList() - val list = toMutableList() - Collections.reverse(list) - return list -} - /** * Returns a list with elements in reversed order. */ @@ -4460,27 +4450,7 @@ public fun ByteArray.reversed(): List { /** * Returns a list with elements in reversed order. */ -public fun CharArray.reversed(): List { - if (isEmpty()) return emptyList() - val list = toMutableList() - Collections.reverse(list) - return list -} - -/** - * Returns a list with elements in reversed order. - */ -public fun DoubleArray.reversed(): List { - if (isEmpty()) return emptyList() - val list = toMutableList() - Collections.reverse(list) - return list -} - -/** - * Returns a list with elements in reversed order. - */ -public fun FloatArray.reversed(): List { +public fun ShortArray.reversed(): List { if (isEmpty()) return emptyList() val list = toMutableList() Collections.reverse(list) @@ -4510,7 +4480,37 @@ public fun LongArray.reversed(): List { /** * Returns a list with elements in reversed order. */ -public fun ShortArray.reversed(): List { +public fun FloatArray.reversed(): List { + if (isEmpty()) return emptyList() + val list = toMutableList() + Collections.reverse(list) + return list +} + +/** + * Returns a list with elements in reversed order. + */ +public fun DoubleArray.reversed(): List { + if (isEmpty()) return emptyList() + val list = toMutableList() + Collections.reverse(list) + return list +} + +/** + * Returns a list with elements in reversed order. + */ +public fun BooleanArray.reversed(): List { + if (isEmpty()) return emptyList() + val list = toMutableList() + Collections.reverse(list) + return list +} + +/** + * Returns a list with elements in reversed order. + */ +public fun CharArray.reversed(): List { if (isEmpty()) return emptyList() val list = toMutableList() Collections.reverse(list) @@ -4529,18 +4529,6 @@ public fun Array.reversedArray(): Array { return result } -/** - * Returns an array with elements of this array in reversed order. - */ -public fun BooleanArray.reversedArray(): BooleanArray { - if (isEmpty()) return this - val result = BooleanArray(size) - val lastIndex = lastIndex - for (i in 0..lastIndex) - result[lastIndex - i] = this[i] - return result -} - /** * Returns an array with elements of this array in reversed order. */ @@ -4556,33 +4544,9 @@ public fun ByteArray.reversedArray(): ByteArray { /** * Returns an array with elements of this array in reversed order. */ -public fun CharArray.reversedArray(): CharArray { +public fun ShortArray.reversedArray(): ShortArray { if (isEmpty()) return this - val result = CharArray(size) - val lastIndex = lastIndex - for (i in 0..lastIndex) - result[lastIndex - i] = this[i] - return result -} - -/** - * Returns an array with elements of this array in reversed order. - */ -public fun DoubleArray.reversedArray(): DoubleArray { - if (isEmpty()) return this - val result = DoubleArray(size) - val lastIndex = lastIndex - for (i in 0..lastIndex) - result[lastIndex - i] = this[i] - return result -} - -/** - * Returns an array with elements of this array in reversed order. - */ -public fun FloatArray.reversedArray(): FloatArray { - if (isEmpty()) return this - val result = FloatArray(size) + val result = ShortArray(size) val lastIndex = lastIndex for (i in 0..lastIndex) result[lastIndex - i] = this[i] @@ -4616,9 +4580,45 @@ public fun LongArray.reversedArray(): LongArray { /** * Returns an array with elements of this array in reversed order. */ -public fun ShortArray.reversedArray(): ShortArray { +public fun FloatArray.reversedArray(): FloatArray { if (isEmpty()) return this - val result = ShortArray(size) + val result = FloatArray(size) + val lastIndex = lastIndex + for (i in 0..lastIndex) + result[lastIndex - i] = this[i] + return result +} + +/** + * Returns an array with elements of this array in reversed order. + */ +public fun DoubleArray.reversedArray(): DoubleArray { + if (isEmpty()) return this + val result = DoubleArray(size) + val lastIndex = lastIndex + for (i in 0..lastIndex) + result[lastIndex - i] = this[i] + return result +} + +/** + * Returns an array with elements of this array in reversed order. + */ +public fun BooleanArray.reversedArray(): BooleanArray { + if (isEmpty()) return this + val result = BooleanArray(size) + val lastIndex = lastIndex + for (i in 0..lastIndex) + result[lastIndex - i] = this[i] + return result +} + +/** + * Returns an array with elements of this array in reversed order. + */ +public fun CharArray.reversedArray(): CharArray { + if (isEmpty()) return this + val result = CharArray(size) val lastIndex = lastIndex for (i in 0..lastIndex) result[lastIndex - i] = this[i] @@ -4659,27 +4659,7 @@ public fun ByteArray.sortDescending(): Unit { /** * Sorts elements in the array in-place descending according to their natural sort order. */ -public fun CharArray.sortDescending(): Unit { - if (size > 1) { - sort() - reverse() - } -} - -/** - * Sorts elements in the array in-place descending according to their natural sort order. - */ -public fun DoubleArray.sortDescending(): Unit { - if (size > 1) { - sort() - reverse() - } -} - -/** - * Sorts elements in the array in-place descending according to their natural sort order. - */ -public fun FloatArray.sortDescending(): Unit { +public fun ShortArray.sortDescending(): Unit { if (size > 1) { sort() reverse() @@ -4709,7 +4689,27 @@ public fun LongArray.sortDescending(): Unit { /** * Sorts elements in the array in-place descending according to their natural sort order. */ -public fun ShortArray.sortDescending(): Unit { +public fun FloatArray.sortDescending(): Unit { + if (size > 1) { + sort() + reverse() + } +} + +/** + * Sorts elements in the array in-place descending according to their natural sort order. + */ +public fun DoubleArray.sortDescending(): Unit { + if (size > 1) { + sort() + reverse() + } +} + +/** + * Sorts elements in the array in-place descending according to their natural sort order. + */ +public fun CharArray.sortDescending(): Unit { if (size > 1) { sort() reverse() @@ -4733,21 +4733,7 @@ public fun ByteArray.sorted(): List { /** * Returns a list of all elements sorted according to their natural sort order. */ -public fun CharArray.sorted(): List { - return toTypedArray().apply { sort() }.asList() -} - -/** - * Returns a list of all elements sorted according to their natural sort order. - */ -public fun DoubleArray.sorted(): List { - return toTypedArray().apply { sort() }.asList() -} - -/** - * Returns a list of all elements sorted according to their natural sort order. - */ -public fun FloatArray.sorted(): List { +public fun ShortArray.sorted(): List { return toTypedArray().apply { sort() }.asList() } @@ -4768,7 +4754,21 @@ public fun LongArray.sorted(): List { /** * Returns a list of all elements sorted according to their natural sort order. */ -public fun ShortArray.sorted(): List { +public fun FloatArray.sorted(): List { + return toTypedArray().apply { sort() }.asList() +} + +/** + * Returns a list of all elements sorted according to their natural sort order. + */ +public fun DoubleArray.sorted(): List { + return toTypedArray().apply { sort() }.asList() +} + +/** + * Returns a list of all elements sorted according to their natural sort order. + */ +public fun CharArray.sorted(): List { return toTypedArray().apply { sort() }.asList() } @@ -4791,23 +4791,7 @@ public fun ByteArray.sortedArray(): ByteArray { /** * Returns an array with all elements of this array sorted according to their natural sort order. */ -public fun CharArray.sortedArray(): CharArray { - if (isEmpty()) return this - return this.copyOf().apply { sort() } -} - -/** - * Returns an array with all elements of this array sorted according to their natural sort order. - */ -public fun DoubleArray.sortedArray(): DoubleArray { - if (isEmpty()) return this - return this.copyOf().apply { sort() } -} - -/** - * Returns an array with all elements of this array sorted according to their natural sort order. - */ -public fun FloatArray.sortedArray(): FloatArray { +public fun ShortArray.sortedArray(): ShortArray { if (isEmpty()) return this return this.copyOf().apply { sort() } } @@ -4831,7 +4815,23 @@ public fun LongArray.sortedArray(): LongArray { /** * Returns an array with all elements of this array sorted according to their natural sort order. */ -public fun ShortArray.sortedArray(): ShortArray { +public fun FloatArray.sortedArray(): FloatArray { + if (isEmpty()) return this + return this.copyOf().apply { sort() } +} + +/** + * Returns an array with all elements of this array sorted according to their natural sort order. + */ +public fun DoubleArray.sortedArray(): DoubleArray { + if (isEmpty()) return this + return this.copyOf().apply { sort() } +} + +/** + * Returns an array with all elements of this array sorted according to their natural sort order. + */ +public fun CharArray.sortedArray(): CharArray { if (isEmpty()) return this return this.copyOf().apply { sort() } } @@ -4855,23 +4855,7 @@ public fun ByteArray.sortedArrayDescending(): ByteArray { /** * Returns an array with all elements of this array sorted descending according to their natural sort order. */ -public fun CharArray.sortedArrayDescending(): CharArray { - if (isEmpty()) return this - return this.copyOf().apply { sortDescending() } -} - -/** - * Returns an array with all elements of this array sorted descending according to their natural sort order. - */ -public fun DoubleArray.sortedArrayDescending(): DoubleArray { - if (isEmpty()) return this - return this.copyOf().apply { sortDescending() } -} - -/** - * Returns an array with all elements of this array sorted descending according to their natural sort order. - */ -public fun FloatArray.sortedArrayDescending(): FloatArray { +public fun ShortArray.sortedArrayDescending(): ShortArray { if (isEmpty()) return this return this.copyOf().apply { sortDescending() } } @@ -4895,7 +4879,23 @@ public fun LongArray.sortedArrayDescending(): LongArray { /** * Returns an array with all elements of this array sorted descending according to their natural sort order. */ -public fun ShortArray.sortedArrayDescending(): ShortArray { +public fun FloatArray.sortedArrayDescending(): FloatArray { + if (isEmpty()) return this + return this.copyOf().apply { sortDescending() } +} + +/** + * Returns an array with all elements of this array sorted descending according to their natural sort order. + */ +public fun DoubleArray.sortedArrayDescending(): DoubleArray { + if (isEmpty()) return this + return this.copyOf().apply { sortDescending() } +} + +/** + * Returns an array with all elements of this array sorted descending according to their natural sort order. + */ +public fun CharArray.sortedArrayDescending(): CharArray { if (isEmpty()) return this return this.copyOf().apply { sortDescending() } } @@ -4915,13 +4915,6 @@ public inline fun > Array.sortedBy(crossinline selec return sortedWith(compareBy(selector)) } -/** - * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function. - */ -public inline fun > BooleanArray.sortedBy(crossinline selector: (Boolean) -> R?): List { - return sortedWith(compareBy(selector)) -} - /** * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function. */ @@ -4932,21 +4925,7 @@ public inline fun > ByteArray.sortedBy(crossinline selector: ( /** * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function. */ -public inline fun > CharArray.sortedBy(crossinline selector: (Char) -> R?): List { - return sortedWith(compareBy(selector)) -} - -/** - * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function. - */ -public inline fun > DoubleArray.sortedBy(crossinline selector: (Double) -> R?): List { - return sortedWith(compareBy(selector)) -} - -/** - * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function. - */ -public inline fun > FloatArray.sortedBy(crossinline selector: (Float) -> R?): List { +public inline fun > ShortArray.sortedBy(crossinline selector: (Short) -> R?): List { return sortedWith(compareBy(selector)) } @@ -4967,7 +4946,28 @@ public inline fun > LongArray.sortedBy(crossinline selector: ( /** * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function. */ -public inline fun > ShortArray.sortedBy(crossinline selector: (Short) -> R?): List { +public inline fun > FloatArray.sortedBy(crossinline selector: (Float) -> R?): List { + return sortedWith(compareBy(selector)) +} + +/** + * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function. + */ +public inline fun > DoubleArray.sortedBy(crossinline selector: (Double) -> R?): List { + return sortedWith(compareBy(selector)) +} + +/** + * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function. + */ +public inline fun > BooleanArray.sortedBy(crossinline selector: (Boolean) -> R?): List { + return sortedWith(compareBy(selector)) +} + +/** + * Returns a list of all elements sorted according to natural sort order of the value returned by specified [selector] function. + */ +public inline fun > CharArray.sortedBy(crossinline selector: (Char) -> R?): List { return sortedWith(compareBy(selector)) } @@ -4978,13 +4978,6 @@ public inline fun > Array.sortedByDescending(crossin return sortedWith(compareByDescending(selector)) } -/** - * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function. - */ -public inline fun > BooleanArray.sortedByDescending(crossinline selector: (Boolean) -> R?): List { - return sortedWith(compareByDescending(selector)) -} - /** * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function. */ @@ -4995,21 +4988,7 @@ public inline fun > ByteArray.sortedByDescending(crossinline s /** * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function. */ -public inline fun > CharArray.sortedByDescending(crossinline selector: (Char) -> R?): List { - return sortedWith(compareByDescending(selector)) -} - -/** - * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function. - */ -public inline fun > DoubleArray.sortedByDescending(crossinline selector: (Double) -> R?): List { - return sortedWith(compareByDescending(selector)) -} - -/** - * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function. - */ -public inline fun > FloatArray.sortedByDescending(crossinline selector: (Float) -> R?): List { +public inline fun > ShortArray.sortedByDescending(crossinline selector: (Short) -> R?): List { return sortedWith(compareByDescending(selector)) } @@ -5030,7 +5009,28 @@ public inline fun > LongArray.sortedByDescending(crossinline s /** * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function. */ -public inline fun > ShortArray.sortedByDescending(crossinline selector: (Short) -> R?): List { +public inline fun > FloatArray.sortedByDescending(crossinline selector: (Float) -> R?): List { + return sortedWith(compareByDescending(selector)) +} + +/** + * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function. + */ +public inline fun > DoubleArray.sortedByDescending(crossinline selector: (Double) -> R?): List { + return sortedWith(compareByDescending(selector)) +} + +/** + * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function. + */ +public inline fun > BooleanArray.sortedByDescending(crossinline selector: (Boolean) -> R?): List { + return sortedWith(compareByDescending(selector)) +} + +/** + * Returns a list of all elements sorted descending according to natural sort order of the value returned by specified [selector] function. + */ +public inline fun > CharArray.sortedByDescending(crossinline selector: (Char) -> R?): List { return sortedWith(compareByDescending(selector)) } @@ -5051,21 +5051,7 @@ public fun ByteArray.sortedDescending(): List { /** * Returns a list of all elements sorted descending according to their natural sort order. */ -public fun CharArray.sortedDescending(): List { - return copyOf().apply { sort() }.reversed() -} - -/** - * Returns a list of all elements sorted descending according to their natural sort order. - */ -public fun DoubleArray.sortedDescending(): List { - return copyOf().apply { sort() }.reversed() -} - -/** - * Returns a list of all elements sorted descending according to their natural sort order. - */ -public fun FloatArray.sortedDescending(): List { +public fun ShortArray.sortedDescending(): List { return copyOf().apply { sort() }.reversed() } @@ -5086,7 +5072,21 @@ public fun LongArray.sortedDescending(): List { /** * Returns a list of all elements sorted descending according to their natural sort order. */ -public fun ShortArray.sortedDescending(): List { +public fun FloatArray.sortedDescending(): List { + return copyOf().apply { sort() }.reversed() +} + +/** + * Returns a list of all elements sorted descending according to their natural sort order. + */ +public fun DoubleArray.sortedDescending(): List { + return copyOf().apply { sort() }.reversed() +} + +/** + * Returns a list of all elements sorted descending according to their natural sort order. + */ +public fun CharArray.sortedDescending(): List { return copyOf().apply { sort() }.reversed() } @@ -5097,13 +5097,6 @@ public fun Array.sortedWith(comparator: Comparator): List { return sortedArrayWith(comparator).asList() } -/** - * Returns a list of all elements sorted according to the specified [comparator]. - */ -public fun BooleanArray.sortedWith(comparator: Comparator): List { - return toTypedArray().apply { sortWith(comparator) }.asList() -} - /** * Returns a list of all elements sorted according to the specified [comparator]. */ @@ -5114,21 +5107,7 @@ public fun ByteArray.sortedWith(comparator: Comparator): List { /** * Returns a list of all elements sorted according to the specified [comparator]. */ -public fun CharArray.sortedWith(comparator: Comparator): List { - return toTypedArray().apply { sortWith(comparator) }.asList() -} - -/** - * Returns a list of all elements sorted according to the specified [comparator]. - */ -public fun DoubleArray.sortedWith(comparator: Comparator): List { - return toTypedArray().apply { sortWith(comparator) }.asList() -} - -/** - * Returns a list of all elements sorted according to the specified [comparator]. - */ -public fun FloatArray.sortedWith(comparator: Comparator): List { +public fun ShortArray.sortedWith(comparator: Comparator): List { return toTypedArray().apply { sortWith(comparator) }.asList() } @@ -5149,7 +5128,28 @@ public fun LongArray.sortedWith(comparator: Comparator): List { /** * Returns a list of all elements sorted according to the specified [comparator]. */ -public fun ShortArray.sortedWith(comparator: Comparator): List { +public fun FloatArray.sortedWith(comparator: Comparator): List { + return toTypedArray().apply { sortWith(comparator) }.asList() +} + +/** + * Returns a list of all elements sorted according to the specified [comparator]. + */ +public fun DoubleArray.sortedWith(comparator: Comparator): List { + return toTypedArray().apply { sortWith(comparator) }.asList() +} + +/** + * Returns a list of all elements sorted according to the specified [comparator]. + */ +public fun BooleanArray.sortedWith(comparator: Comparator): List { + return toTypedArray().apply { sortWith(comparator) }.asList() +} + +/** + * Returns a list of all elements sorted according to the specified [comparator]. + */ +public fun CharArray.sortedWith(comparator: Comparator): List { return toTypedArray().apply { sortWith(comparator) }.asList() } @@ -5159,12 +5159,6 @@ public fun ShortArray.sortedWith(comparator: Comparator): List public val Array.indices: IntRange get() = IntRange(0, lastIndex) -/** - * Returns the range of valid indices for the array. - */ -public val BooleanArray.indices: IntRange - get() = IntRange(0, lastIndex) - /** * Returns the range of valid indices for the array. */ @@ -5174,19 +5168,7 @@ public val ByteArray.indices: IntRange /** * Returns the range of valid indices for the array. */ -public val CharArray.indices: IntRange - get() = IntRange(0, lastIndex) - -/** - * Returns the range of valid indices for the array. - */ -public val DoubleArray.indices: IntRange - get() = IntRange(0, lastIndex) - -/** - * Returns the range of valid indices for the array. - */ -public val FloatArray.indices: IntRange +public val ShortArray.indices: IntRange get() = IntRange(0, lastIndex) /** @@ -5204,7 +5186,25 @@ public val LongArray.indices: IntRange /** * Returns the range of valid indices for the array. */ -public val ShortArray.indices: IntRange +public val FloatArray.indices: IntRange + get() = IntRange(0, lastIndex) + +/** + * Returns the range of valid indices for the array. + */ +public val DoubleArray.indices: IntRange + get() = IntRange(0, lastIndex) + +/** + * Returns the range of valid indices for the array. + */ +public val BooleanArray.indices: IntRange + get() = IntRange(0, lastIndex) + +/** + * Returns the range of valid indices for the array. + */ +public val CharArray.indices: IntRange get() = IntRange(0, lastIndex) /** @@ -5215,14 +5215,6 @@ public inline fun Array.isEmpty(): Boolean { return size == 0 } -/** - * Returns `true` if the array is empty. - */ -@kotlin.internal.InlineOnly -public inline fun BooleanArray.isEmpty(): Boolean { - return size == 0 -} - /** * Returns `true` if the array is empty. */ @@ -5235,23 +5227,7 @@ public inline fun ByteArray.isEmpty(): Boolean { * Returns `true` if the array is empty. */ @kotlin.internal.InlineOnly -public inline fun CharArray.isEmpty(): Boolean { - return size == 0 -} - -/** - * Returns `true` if the array is empty. - */ -@kotlin.internal.InlineOnly -public inline fun DoubleArray.isEmpty(): Boolean { - return size == 0 -} - -/** - * Returns `true` if the array is empty. - */ -@kotlin.internal.InlineOnly -public inline fun FloatArray.isEmpty(): Boolean { +public inline fun ShortArray.isEmpty(): Boolean { return size == 0 } @@ -5275,7 +5251,31 @@ public inline fun LongArray.isEmpty(): Boolean { * Returns `true` if the array is empty. */ @kotlin.internal.InlineOnly -public inline fun ShortArray.isEmpty(): Boolean { +public inline fun FloatArray.isEmpty(): Boolean { + return size == 0 +} + +/** + * Returns `true` if the array is empty. + */ +@kotlin.internal.InlineOnly +public inline fun DoubleArray.isEmpty(): Boolean { + return size == 0 +} + +/** + * Returns `true` if the array is empty. + */ +@kotlin.internal.InlineOnly +public inline fun BooleanArray.isEmpty(): Boolean { + return size == 0 +} + +/** + * Returns `true` if the array is empty. + */ +@kotlin.internal.InlineOnly +public inline fun CharArray.isEmpty(): Boolean { return size == 0 } @@ -5287,14 +5287,6 @@ public inline fun Array.isNotEmpty(): Boolean { return !isEmpty() } -/** - * Returns `true` if the array is not empty. - */ -@kotlin.internal.InlineOnly -public inline fun BooleanArray.isNotEmpty(): Boolean { - return !isEmpty() -} - /** * Returns `true` if the array is not empty. */ @@ -5307,23 +5299,7 @@ public inline fun ByteArray.isNotEmpty(): Boolean { * Returns `true` if the array is not empty. */ @kotlin.internal.InlineOnly -public inline fun CharArray.isNotEmpty(): Boolean { - return !isEmpty() -} - -/** - * Returns `true` if the array is not empty. - */ -@kotlin.internal.InlineOnly -public inline fun DoubleArray.isNotEmpty(): Boolean { - return !isEmpty() -} - -/** - * Returns `true` if the array is not empty. - */ -@kotlin.internal.InlineOnly -public inline fun FloatArray.isNotEmpty(): Boolean { +public inline fun ShortArray.isNotEmpty(): Boolean { return !isEmpty() } @@ -5347,7 +5323,31 @@ public inline fun LongArray.isNotEmpty(): Boolean { * Returns `true` if the array is not empty. */ @kotlin.internal.InlineOnly -public inline fun ShortArray.isNotEmpty(): Boolean { +public inline fun FloatArray.isNotEmpty(): Boolean { + return !isEmpty() +} + +/** + * Returns `true` if the array is not empty. + */ +@kotlin.internal.InlineOnly +public inline fun DoubleArray.isNotEmpty(): Boolean { + return !isEmpty() +} + +/** + * Returns `true` if the array is not empty. + */ +@kotlin.internal.InlineOnly +public inline fun BooleanArray.isNotEmpty(): Boolean { + return !isEmpty() +} + +/** + * Returns `true` if the array is not empty. + */ +@kotlin.internal.InlineOnly +public inline fun CharArray.isNotEmpty(): Boolean { return !isEmpty() } @@ -5357,12 +5357,6 @@ public inline fun ShortArray.isNotEmpty(): Boolean { public val Array.lastIndex: Int get() = size - 1 -/** - * Returns the last valid index for the array. - */ -public val BooleanArray.lastIndex: Int - get() = size - 1 - /** * Returns the last valid index for the array. */ @@ -5372,19 +5366,7 @@ public val ByteArray.lastIndex: Int /** * Returns the last valid index for the array. */ -public val CharArray.lastIndex: Int - get() = size - 1 - -/** - * Returns the last valid index for the array. - */ -public val DoubleArray.lastIndex: Int - get() = size - 1 - -/** - * Returns the last valid index for the array. - */ -public val FloatArray.lastIndex: Int +public val ShortArray.lastIndex: Int get() = size - 1 /** @@ -5402,7 +5384,25 @@ public val LongArray.lastIndex: Int /** * Returns the last valid index for the array. */ -public val ShortArray.lastIndex: Int +public val FloatArray.lastIndex: Int + get() = size - 1 + +/** + * Returns the last valid index for the array. + */ +public val DoubleArray.lastIndex: Int + get() = size - 1 + +/** + * Returns the last valid index for the array. + */ +public val BooleanArray.lastIndex: Int + get() = size - 1 + +/** + * Returns the last valid index for the array. + */ +public val CharArray.lastIndex: Int get() = size - 1 /** @@ -5496,17 +5496,6 @@ public inline fun Array.associate(transform: (T) -> Pair) return associateTo(LinkedHashMap(capacity), transform) } -/** - * Returns a [Map] containing key-value pairs provided by [transform] function - * applied to elements of the given array. - * If any of two pairs would have the same key the last one gets added to the map. - */ -public inline fun BooleanArray.associate(transform: (Boolean) -> Pair): Map { - @Suppress("INVISIBLE_MEMBER_FROM_INLINE") - val capacity = mapCapacity(size).coerceAtLeast(16) - return associateTo(LinkedHashMap(capacity), transform) -} - /** * Returns a [Map] containing key-value pairs provided by [transform] function * applied to elements of the given array. @@ -5523,29 +5512,7 @@ public inline fun ByteArray.associate(transform: (Byte) -> Pair): M * applied to elements of the given array. * If any of two pairs would have the same key the last one gets added to the map. */ -public inline fun CharArray.associate(transform: (Char) -> Pair): Map { - @Suppress("INVISIBLE_MEMBER_FROM_INLINE") - val capacity = mapCapacity(size).coerceAtLeast(16) - return associateTo(LinkedHashMap(capacity), transform) -} - -/** - * Returns a [Map] containing key-value pairs provided by [transform] function - * applied to elements of the given array. - * If any of two pairs would have the same key the last one gets added to the map. - */ -public inline fun DoubleArray.associate(transform: (Double) -> Pair): Map { - @Suppress("INVISIBLE_MEMBER_FROM_INLINE") - val capacity = mapCapacity(size).coerceAtLeast(16) - return associateTo(LinkedHashMap(capacity), transform) -} - -/** - * Returns a [Map] containing key-value pairs provided by [transform] function - * applied to elements of the given array. - * If any of two pairs would have the same key the last one gets added to the map. - */ -public inline fun FloatArray.associate(transform: (Float) -> Pair): Map { +public inline fun ShortArray.associate(transform: (Short) -> Pair): Map { @Suppress("INVISIBLE_MEMBER_FROM_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateTo(LinkedHashMap(capacity), transform) @@ -5578,7 +5545,40 @@ public inline fun LongArray.associate(transform: (Long) -> Pair): M * applied to elements of the given array. * If any of two pairs would have the same key the last one gets added to the map. */ -public inline fun ShortArray.associate(transform: (Short) -> Pair): Map { +public inline fun FloatArray.associate(transform: (Float) -> Pair): Map { + @Suppress("INVISIBLE_MEMBER_FROM_INLINE") + val capacity = mapCapacity(size).coerceAtLeast(16) + return associateTo(LinkedHashMap(capacity), transform) +} + +/** + * Returns a [Map] containing key-value pairs provided by [transform] function + * applied to elements of the given array. + * If any of two pairs would have the same key the last one gets added to the map. + */ +public inline fun DoubleArray.associate(transform: (Double) -> Pair): Map { + @Suppress("INVISIBLE_MEMBER_FROM_INLINE") + val capacity = mapCapacity(size).coerceAtLeast(16) + return associateTo(LinkedHashMap(capacity), transform) +} + +/** + * Returns a [Map] containing key-value pairs provided by [transform] function + * applied to elements of the given array. + * If any of two pairs would have the same key the last one gets added to the map. + */ +public inline fun BooleanArray.associate(transform: (Boolean) -> Pair): Map { + @Suppress("INVISIBLE_MEMBER_FROM_INLINE") + val capacity = mapCapacity(size).coerceAtLeast(16) + return associateTo(LinkedHashMap(capacity), transform) +} + +/** + * Returns a [Map] containing key-value pairs provided by [transform] function + * applied to elements of the given array. + * If any of two pairs would have the same key the last one gets added to the map. + */ +public inline fun CharArray.associate(transform: (Char) -> Pair): Map { @Suppress("INVISIBLE_MEMBER_FROM_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateTo(LinkedHashMap(capacity), transform) @@ -5595,17 +5595,6 @@ public inline fun Array.associateBy(keySelector: (T) -> K): Map(capacity), keySelector) } -/** - * Returns a [Map] containing the elements from the given array indexed by the key - * returned from [keySelector] function applied to each element. - * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. - */ -public inline fun BooleanArray.associateBy(keySelector: (Boolean) -> K): Map { - @Suppress("INVISIBLE_MEMBER_FROM_INLINE") - val capacity = mapCapacity(size).coerceAtLeast(16) - return associateByTo(LinkedHashMap(capacity), keySelector) -} - /** * Returns a [Map] containing the elements from the given array indexed by the key * returned from [keySelector] function applied to each element. @@ -5622,32 +5611,10 @@ public inline fun ByteArray.associateBy(keySelector: (Byte) -> K): Map CharArray.associateBy(keySelector: (Char) -> K): Map { +public inline fun ShortArray.associateBy(keySelector: (Short) -> K): Map { @Suppress("INVISIBLE_MEMBER_FROM_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) - return associateByTo(LinkedHashMap(capacity), keySelector) -} - -/** - * Returns a [Map] containing the elements from the given array indexed by the key - * returned from [keySelector] function applied to each element. - * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. - */ -public inline fun DoubleArray.associateBy(keySelector: (Double) -> K): Map { - @Suppress("INVISIBLE_MEMBER_FROM_INLINE") - val capacity = mapCapacity(size).coerceAtLeast(16) - return associateByTo(LinkedHashMap(capacity), keySelector) -} - -/** - * Returns a [Map] containing the elements from the given array indexed by the key - * returned from [keySelector] function applied to each element. - * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. - */ -public inline fun FloatArray.associateBy(keySelector: (Float) -> K): Map { - @Suppress("INVISIBLE_MEMBER_FROM_INLINE") - val capacity = mapCapacity(size).coerceAtLeast(16) - return associateByTo(LinkedHashMap(capacity), keySelector) + return associateByTo(LinkedHashMap(capacity), keySelector) } /** @@ -5677,10 +5644,43 @@ public inline fun LongArray.associateBy(keySelector: (Long) -> K): Map ShortArray.associateBy(keySelector: (Short) -> K): Map { +public inline fun FloatArray.associateBy(keySelector: (Float) -> K): Map { @Suppress("INVISIBLE_MEMBER_FROM_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) - return associateByTo(LinkedHashMap(capacity), keySelector) + return associateByTo(LinkedHashMap(capacity), keySelector) +} + +/** + * Returns a [Map] containing the elements from the given array indexed by the key + * returned from [keySelector] function applied to each element. + * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. + */ +public inline fun DoubleArray.associateBy(keySelector: (Double) -> K): Map { + @Suppress("INVISIBLE_MEMBER_FROM_INLINE") + val capacity = mapCapacity(size).coerceAtLeast(16) + return associateByTo(LinkedHashMap(capacity), keySelector) +} + +/** + * Returns a [Map] containing the elements from the given array indexed by the key + * returned from [keySelector] function applied to each element. + * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. + */ +public inline fun BooleanArray.associateBy(keySelector: (Boolean) -> K): Map { + @Suppress("INVISIBLE_MEMBER_FROM_INLINE") + val capacity = mapCapacity(size).coerceAtLeast(16) + return associateByTo(LinkedHashMap(capacity), keySelector) +} + +/** + * Returns a [Map] containing the elements from the given array indexed by the key + * returned from [keySelector] function applied to each element. + * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. + */ +public inline fun CharArray.associateBy(keySelector: (Char) -> K): Map { + @Suppress("INVISIBLE_MEMBER_FROM_INLINE") + val capacity = mapCapacity(size).coerceAtLeast(16) + return associateByTo(LinkedHashMap(capacity), keySelector) } /** @@ -5693,16 +5693,6 @@ public inline fun Array.associateBy(keySelector: (T) -> K, valu return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) } -/** - * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array. - * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. - */ -public inline fun BooleanArray.associateBy(keySelector: (Boolean) -> K, valueTransform: (Boolean) -> V): Map { - @Suppress("INVISIBLE_MEMBER_FROM_INLINE") - val capacity = mapCapacity(size).coerceAtLeast(16) - return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) -} - /** * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array. * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. @@ -5717,27 +5707,7 @@ public inline fun ByteArray.associateBy(keySelector: (Byte) -> K, valueTr * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array. * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. */ -public inline fun CharArray.associateBy(keySelector: (Char) -> K, valueTransform: (Char) -> V): Map { - @Suppress("INVISIBLE_MEMBER_FROM_INLINE") - val capacity = mapCapacity(size).coerceAtLeast(16) - return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) -} - -/** - * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array. - * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. - */ -public inline fun DoubleArray.associateBy(keySelector: (Double) -> K, valueTransform: (Double) -> V): Map { - @Suppress("INVISIBLE_MEMBER_FROM_INLINE") - val capacity = mapCapacity(size).coerceAtLeast(16) - return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) -} - -/** - * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array. - * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. - */ -public inline fun FloatArray.associateBy(keySelector: (Float) -> K, valueTransform: (Float) -> V): Map { +public inline fun ShortArray.associateBy(keySelector: (Short) -> K, valueTransform: (Short) -> V): Map { @Suppress("INVISIBLE_MEMBER_FROM_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) @@ -5767,7 +5737,37 @@ public inline fun LongArray.associateBy(keySelector: (Long) -> K, valueTr * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array. * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. */ -public inline fun ShortArray.associateBy(keySelector: (Short) -> K, valueTransform: (Short) -> V): Map { +public inline fun FloatArray.associateBy(keySelector: (Float) -> K, valueTransform: (Float) -> V): Map { + @Suppress("INVISIBLE_MEMBER_FROM_INLINE") + val capacity = mapCapacity(size).coerceAtLeast(16) + return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) +} + +/** + * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array. + * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. + */ +public inline fun DoubleArray.associateBy(keySelector: (Double) -> K, valueTransform: (Double) -> V): Map { + @Suppress("INVISIBLE_MEMBER_FROM_INLINE") + val capacity = mapCapacity(size).coerceAtLeast(16) + return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) +} + +/** + * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array. + * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. + */ +public inline fun BooleanArray.associateBy(keySelector: (Boolean) -> K, valueTransform: (Boolean) -> V): Map { + @Suppress("INVISIBLE_MEMBER_FROM_INLINE") + val capacity = mapCapacity(size).coerceAtLeast(16) + return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) +} + +/** + * Returns a [Map] containing the values provided by [valueTransform] and indexed by [keySelector] functions applied to elements of the given array. + * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. + */ +public inline fun CharArray.associateBy(keySelector: (Char) -> K, valueTransform: (Char) -> V): Map { @Suppress("INVISIBLE_MEMBER_FROM_INLINE") val capacity = mapCapacity(size).coerceAtLeast(16) return associateByTo(LinkedHashMap(capacity), keySelector, valueTransform) @@ -5786,19 +5786,6 @@ public inline fun > Array.associateByTo( return destination } -/** - * Populates and returns the [destination] mutable map with key-value pairs, - * where key is provided by the [keySelector] function applied to each element of the given array - * and value is the element itself. - * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. - */ -public inline fun > BooleanArray.associateByTo(destination: M, keySelector: (Boolean) -> K): M { - for (element in this) { - destination.put(keySelector(element), element) - } - return destination -} - /** * Populates and returns the [destination] mutable map with key-value pairs, * where key is provided by the [keySelector] function applied to each element of the given array @@ -5818,33 +5805,7 @@ public inline fun > ByteArray.associateByTo(des * and value is the element itself. * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. */ -public inline fun > CharArray.associateByTo(destination: M, keySelector: (Char) -> K): M { - for (element in this) { - destination.put(keySelector(element), element) - } - return destination -} - -/** - * Populates and returns the [destination] mutable map with key-value pairs, - * where key is provided by the [keySelector] function applied to each element of the given array - * and value is the element itself. - * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. - */ -public inline fun > DoubleArray.associateByTo(destination: M, keySelector: (Double) -> K): M { - for (element in this) { - destination.put(keySelector(element), element) - } - return destination -} - -/** - * Populates and returns the [destination] mutable map with key-value pairs, - * where key is provided by the [keySelector] function applied to each element of the given array - * and value is the element itself. - * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. - */ -public inline fun > FloatArray.associateByTo(destination: M, keySelector: (Float) -> K): M { +public inline fun > ShortArray.associateByTo(destination: M, keySelector: (Short) -> K): M { for (element in this) { destination.put(keySelector(element), element) } @@ -5883,7 +5844,46 @@ public inline fun > LongArray.associateByTo(des * and value is the element itself. * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. */ -public inline fun > ShortArray.associateByTo(destination: M, keySelector: (Short) -> K): M { +public inline fun > FloatArray.associateByTo(destination: M, keySelector: (Float) -> K): M { + for (element in this) { + destination.put(keySelector(element), element) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs, + * where key is provided by the [keySelector] function applied to each element of the given array + * and value is the element itself. + * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. + */ +public inline fun > DoubleArray.associateByTo(destination: M, keySelector: (Double) -> K): M { + for (element in this) { + destination.put(keySelector(element), element) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs, + * where key is provided by the [keySelector] function applied to each element of the given array + * and value is the element itself. + * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. + */ +public inline fun > BooleanArray.associateByTo(destination: M, keySelector: (Boolean) -> K): M { + for (element in this) { + destination.put(keySelector(element), element) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs, + * where key is provided by the [keySelector] function applied to each element of the given array + * and value is the element itself. + * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. + */ +public inline fun > CharArray.associateByTo(destination: M, keySelector: (Char) -> K): M { for (element in this) { destination.put(keySelector(element), element) } @@ -5903,19 +5903,6 @@ public inline fun > Array.associateBy return destination } -/** - * Populates and returns the [destination] mutable map with key-value pairs, - * where key is provided by the [keySelector] function and - * and value is provided by the [valueTransform] function applied to elements of the given array. - * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. - */ -public inline fun > BooleanArray.associateByTo(destination: M, keySelector: (Boolean) -> K, valueTransform: (Boolean) -> V): M { - for (element in this) { - destination.put(keySelector(element), valueTransform(element)) - } - return destination -} - /** * Populates and returns the [destination] mutable map with key-value pairs, * where key is provided by the [keySelector] function and @@ -5935,33 +5922,7 @@ public inline fun > ByteArray.associateByTo(des * and value is provided by the [valueTransform] function applied to elements of the given array. * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. */ -public inline fun > CharArray.associateByTo(destination: M, keySelector: (Char) -> K, valueTransform: (Char) -> V): M { - for (element in this) { - destination.put(keySelector(element), valueTransform(element)) - } - return destination -} - -/** - * Populates and returns the [destination] mutable map with key-value pairs, - * where key is provided by the [keySelector] function and - * and value is provided by the [valueTransform] function applied to elements of the given array. - * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. - */ -public inline fun > DoubleArray.associateByTo(destination: M, keySelector: (Double) -> K, valueTransform: (Double) -> V): M { - for (element in this) { - destination.put(keySelector(element), valueTransform(element)) - } - return destination -} - -/** - * Populates and returns the [destination] mutable map with key-value pairs, - * where key is provided by the [keySelector] function and - * and value is provided by the [valueTransform] function applied to elements of the given array. - * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. - */ -public inline fun > FloatArray.associateByTo(destination: M, keySelector: (Float) -> K, valueTransform: (Float) -> V): M { +public inline fun > ShortArray.associateByTo(destination: M, keySelector: (Short) -> K, valueTransform: (Short) -> V): M { for (element in this) { destination.put(keySelector(element), valueTransform(element)) } @@ -6000,7 +5961,46 @@ public inline fun > LongArray.associateByTo(des * and value is provided by the [valueTransform] function applied to elements of the given array. * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. */ -public inline fun > ShortArray.associateByTo(destination: M, keySelector: (Short) -> K, valueTransform: (Short) -> V): M { +public inline fun > FloatArray.associateByTo(destination: M, keySelector: (Float) -> K, valueTransform: (Float) -> V): M { + for (element in this) { + destination.put(keySelector(element), valueTransform(element)) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs, + * where key is provided by the [keySelector] function and + * and value is provided by the [valueTransform] function applied to elements of the given array. + * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. + */ +public inline fun > DoubleArray.associateByTo(destination: M, keySelector: (Double) -> K, valueTransform: (Double) -> V): M { + for (element in this) { + destination.put(keySelector(element), valueTransform(element)) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs, + * where key is provided by the [keySelector] function and + * and value is provided by the [valueTransform] function applied to elements of the given array. + * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. + */ +public inline fun > BooleanArray.associateByTo(destination: M, keySelector: (Boolean) -> K, valueTransform: (Boolean) -> V): M { + for (element in this) { + destination.put(keySelector(element), valueTransform(element)) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs, + * where key is provided by the [keySelector] function and + * and value is provided by the [valueTransform] function applied to elements of the given array. + * If any two elements would have the same key returned by [keySelector] the last one gets added to the map. + */ +public inline fun > CharArray.associateByTo(destination: M, keySelector: (Char) -> K, valueTransform: (Char) -> V): M { for (element in this) { destination.put(keySelector(element), valueTransform(element)) } @@ -6019,18 +6019,6 @@ public inline fun > Array.associateTo return destination } -/** - * Populates and returns the [destination] mutable map with key-value pairs - * provided by [transform] function applied to each element of the given array. - * If any of two pairs would have the same key the last one gets added to the map. - */ -public inline fun > BooleanArray.associateTo(destination: M, transform: (Boolean) -> Pair): M { - for (element in this) { - destination += transform(element) - } - return destination -} - /** * Populates and returns the [destination] mutable map with key-value pairs * provided by [transform] function applied to each element of the given array. @@ -6048,31 +6036,7 @@ public inline fun > ByteArray.associateTo(desti * provided by [transform] function applied to each element of the given array. * If any of two pairs would have the same key the last one gets added to the map. */ -public inline fun > CharArray.associateTo(destination: M, transform: (Char) -> Pair): M { - for (element in this) { - destination += transform(element) - } - return destination -} - -/** - * Populates and returns the [destination] mutable map with key-value pairs - * provided by [transform] function applied to each element of the given array. - * If any of two pairs would have the same key the last one gets added to the map. - */ -public inline fun > DoubleArray.associateTo(destination: M, transform: (Double) -> Pair): M { - for (element in this) { - destination += transform(element) - } - return destination -} - -/** - * Populates and returns the [destination] mutable map with key-value pairs - * provided by [transform] function applied to each element of the given array. - * If any of two pairs would have the same key the last one gets added to the map. - */ -public inline fun > FloatArray.associateTo(destination: M, transform: (Float) -> Pair): M { +public inline fun > ShortArray.associateTo(destination: M, transform: (Short) -> Pair): M { for (element in this) { destination += transform(element) } @@ -6108,7 +6072,43 @@ public inline fun > LongArray.associateTo(desti * provided by [transform] function applied to each element of the given array. * If any of two pairs would have the same key the last one gets added to the map. */ -public inline fun > ShortArray.associateTo(destination: M, transform: (Short) -> Pair): M { +public inline fun > FloatArray.associateTo(destination: M, transform: (Float) -> Pair): M { + for (element in this) { + destination += transform(element) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs + * provided by [transform] function applied to each element of the given array. + * If any of two pairs would have the same key the last one gets added to the map. + */ +public inline fun > DoubleArray.associateTo(destination: M, transform: (Double) -> Pair): M { + for (element in this) { + destination += transform(element) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs + * provided by [transform] function applied to each element of the given array. + * If any of two pairs would have the same key the last one gets added to the map. + */ +public inline fun > BooleanArray.associateTo(destination: M, transform: (Boolean) -> Pair): M { + for (element in this) { + destination += transform(element) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs + * provided by [transform] function applied to each element of the given array. + * If any of two pairs would have the same key the last one gets added to the map. + */ +public inline fun > CharArray.associateTo(destination: M, transform: (Char) -> Pair): M { for (element in this) { destination += transform(element) } @@ -6123,16 +6123,6 @@ public fun Array.toArrayList(): ArrayList { return ArrayList(this.asCollection()) } -/** - * Returns an [ArrayList] of all elements. - */ -@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) -public fun BooleanArray.toArrayList(): ArrayList { - val list = ArrayList(size) - for (item in this) list.add(item) - return list -} - /** * Returns an [ArrayList] of all elements. */ @@ -6147,28 +6137,8 @@ public fun ByteArray.toArrayList(): ArrayList { * Returns an [ArrayList] of all elements. */ @Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) -public fun CharArray.toArrayList(): ArrayList { - val list = ArrayList(size) - for (item in this) list.add(item) - return list -} - -/** - * Returns an [ArrayList] of all elements. - */ -@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) -public fun DoubleArray.toArrayList(): ArrayList { - val list = ArrayList(size) - for (item in this) list.add(item) - return list -} - -/** - * Returns an [ArrayList] of all elements. - */ -@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) -public fun FloatArray.toArrayList(): ArrayList { - val list = ArrayList(size) +public fun ShortArray.toArrayList(): ArrayList { + val list = ArrayList(size) for (item in this) list.add(item) return list } @@ -6197,8 +6167,38 @@ public fun LongArray.toArrayList(): ArrayList { * Returns an [ArrayList] of all elements. */ @Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) -public fun ShortArray.toArrayList(): ArrayList { - val list = ArrayList(size) +public fun FloatArray.toArrayList(): ArrayList { + val list = ArrayList(size) + for (item in this) list.add(item) + return list +} + +/** + * Returns an [ArrayList] of all elements. + */ +@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) +public fun DoubleArray.toArrayList(): ArrayList { + val list = ArrayList(size) + for (item in this) list.add(item) + return list +} + +/** + * Returns an [ArrayList] of all elements. + */ +@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) +public fun BooleanArray.toArrayList(): ArrayList { + val list = ArrayList(size) + for (item in this) list.add(item) + return list +} + +/** + * Returns an [ArrayList] of all elements. + */ +@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) +public fun CharArray.toArrayList(): ArrayList { + val list = ArrayList(size) for (item in this) list.add(item) return list } @@ -6213,16 +6213,6 @@ public fun > Array.toCollection(destinatio return destination } -/** - * Appends all elements to the given [destination] collection. - */ -public fun > BooleanArray.toCollection(destination: C): C { - for (item in this) { - destination.add(item) - } - return destination -} - /** * Appends all elements to the given [destination] collection. */ @@ -6236,27 +6226,7 @@ public fun > ByteArray.toCollection(destination: /** * Appends all elements to the given [destination] collection. */ -public fun > CharArray.toCollection(destination: C): C { - for (item in this) { - destination.add(item) - } - return destination -} - -/** - * Appends all elements to the given [destination] collection. - */ -public fun > DoubleArray.toCollection(destination: C): C { - for (item in this) { - destination.add(item) - } - return destination -} - -/** - * Appends all elements to the given [destination] collection. - */ -public fun > FloatArray.toCollection(destination: C): C { +public fun > ShortArray.toCollection(destination: C): C { for (item in this) { destination.add(item) } @@ -6286,7 +6256,37 @@ public fun > LongArray.toCollection(destination: /** * Appends all elements to the given [destination] collection. */ -public fun > ShortArray.toCollection(destination: C): C { +public fun > FloatArray.toCollection(destination: C): C { + for (item in this) { + destination.add(item) + } + return destination +} + +/** + * Appends all elements to the given [destination] collection. + */ +public fun > DoubleArray.toCollection(destination: C): C { + for (item in this) { + destination.add(item) + } + return destination +} + +/** + * Appends all elements to the given [destination] collection. + */ +public fun > BooleanArray.toCollection(destination: C): C { + for (item in this) { + destination.add(item) + } + return destination +} + +/** + * Appends all elements to the given [destination] collection. + */ +public fun > CharArray.toCollection(destination: C): C { for (item in this) { destination.add(item) } @@ -6300,13 +6300,6 @@ public fun Array.toHashSet(): HashSet { return toCollection(HashSet(mapCapacity(size))) } -/** - * Returns a [HashSet] of all elements. - */ -public fun BooleanArray.toHashSet(): HashSet { - return toCollection(HashSet(mapCapacity(size))) -} - /** * Returns a [HashSet] of all elements. */ @@ -6317,22 +6310,8 @@ public fun ByteArray.toHashSet(): HashSet { /** * Returns a [HashSet] of all elements. */ -public fun CharArray.toHashSet(): HashSet { - return toCollection(HashSet(mapCapacity(size))) -} - -/** - * Returns a [HashSet] of all elements. - */ -public fun DoubleArray.toHashSet(): HashSet { - return toCollection(HashSet(mapCapacity(size))) -} - -/** - * Returns a [HashSet] of all elements. - */ -public fun FloatArray.toHashSet(): HashSet { - return toCollection(HashSet(mapCapacity(size))) +public fun ShortArray.toHashSet(): HashSet { + return toCollection(HashSet(mapCapacity(size))) } /** @@ -6352,8 +6331,29 @@ public fun LongArray.toHashSet(): HashSet { /** * Returns a [HashSet] of all elements. */ -public fun ShortArray.toHashSet(): HashSet { - return toCollection(HashSet(mapCapacity(size))) +public fun FloatArray.toHashSet(): HashSet { + return toCollection(HashSet(mapCapacity(size))) +} + +/** + * Returns a [HashSet] of all elements. + */ +public fun DoubleArray.toHashSet(): HashSet { + return toCollection(HashSet(mapCapacity(size))) +} + +/** + * Returns a [HashSet] of all elements. + */ +public fun BooleanArray.toHashSet(): HashSet { + return toCollection(HashSet(mapCapacity(size))) +} + +/** + * Returns a [HashSet] of all elements. + */ +public fun CharArray.toHashSet(): HashSet { + return toCollection(HashSet(mapCapacity(size))) } /** @@ -6363,13 +6363,6 @@ public fun Array.toList(): List { return this.toMutableList() } -/** - * Returns a [List] containing all elements. - */ -public fun BooleanArray.toList(): List { - return this.toMutableList() -} - /** * Returns a [List] containing all elements. */ @@ -6380,21 +6373,7 @@ public fun ByteArray.toList(): List { /** * Returns a [List] containing all elements. */ -public fun CharArray.toList(): List { - return this.toMutableList() -} - -/** - * Returns a [List] containing all elements. - */ -public fun DoubleArray.toList(): List { - return this.toMutableList() -} - -/** - * Returns a [List] containing all elements. - */ -public fun FloatArray.toList(): List { +public fun ShortArray.toList(): List { return this.toMutableList() } @@ -6415,7 +6394,28 @@ public fun LongArray.toList(): List { /** * Returns a [List] containing all elements. */ -public fun ShortArray.toList(): List { +public fun FloatArray.toList(): List { + return this.toMutableList() +} + +/** + * Returns a [List] containing all elements. + */ +public fun DoubleArray.toList(): List { + return this.toMutableList() +} + +/** + * Returns a [List] containing all elements. + */ +public fun BooleanArray.toList(): List { + return this.toMutableList() +} + +/** + * Returns a [List] containing all elements. + */ +public fun CharArray.toList(): List { return this.toMutableList() } @@ -6428,15 +6428,6 @@ public inline fun Array.toMap(selector: (T) -> K, transform: (T return associateBy(selector, transform) } -/** - * Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array. - * If any two elements would have the same key returned by [selector] the last one gets added to the map. - */ -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun BooleanArray.toMap(selector: (Boolean) -> K, transform: (Boolean) -> V): Map { - return associateBy(selector, transform) -} - /** * Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array. * If any two elements would have the same key returned by [selector] the last one gets added to the map. @@ -6451,25 +6442,7 @@ public inline fun ByteArray.toMap(selector: (Byte) -> K, transform: (Byte * If any two elements would have the same key returned by [selector] the last one gets added to the map. */ @Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun CharArray.toMap(selector: (Char) -> K, transform: (Char) -> V): Map { - return associateBy(selector, transform) -} - -/** - * Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array. - * If any two elements would have the same key returned by [selector] the last one gets added to the map. - */ -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun DoubleArray.toMap(selector: (Double) -> K, transform: (Double) -> V): Map { - return associateBy(selector, transform) -} - -/** - * Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array. - * If any two elements would have the same key returned by [selector] the last one gets added to the map. - */ -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun FloatArray.toMap(selector: (Float) -> K, transform: (Float) -> V): Map { +public inline fun ShortArray.toMap(selector: (Short) -> K, transform: (Short) -> V): Map { return associateBy(selector, transform) } @@ -6496,7 +6469,34 @@ public inline fun LongArray.toMap(selector: (Long) -> K, transform: (Long * If any two elements would have the same key returned by [selector] the last one gets added to the map. */ @Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun ShortArray.toMap(selector: (Short) -> K, transform: (Short) -> V): Map { +public inline fun FloatArray.toMap(selector: (Float) -> K, transform: (Float) -> V): Map { + return associateBy(selector, transform) +} + +/** + * Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array. + * If any two elements would have the same key returned by [selector] the last one gets added to the map. + */ +@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) +public inline fun DoubleArray.toMap(selector: (Double) -> K, transform: (Double) -> V): Map { + return associateBy(selector, transform) +} + +/** + * Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array. + * If any two elements would have the same key returned by [selector] the last one gets added to the map. + */ +@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) +public inline fun BooleanArray.toMap(selector: (Boolean) -> K, transform: (Boolean) -> V): Map { + return associateBy(selector, transform) +} + +/** + * Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array. + * If any two elements would have the same key returned by [selector] the last one gets added to the map. + */ +@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) +public inline fun CharArray.toMap(selector: (Char) -> K, transform: (Char) -> V): Map { return associateBy(selector, transform) } @@ -6506,12 +6506,6 @@ public inline fun Array.toMap(transform: (T) -> Pair): Ma return associate(transform) } -@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR) -@kotlin.jvm.JvmName("toMapOfPairs") -public inline fun BooleanArray.toMap(transform: (Boolean) -> Pair): Map { - return associate(transform) -} - @Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR) @kotlin.jvm.JvmName("toMapOfPairs") public inline fun ByteArray.toMap(transform: (Byte) -> Pair): Map { @@ -6520,19 +6514,7 @@ public inline fun ByteArray.toMap(transform: (Byte) -> Pair): Map CharArray.toMap(transform: (Char) -> Pair): Map { - return associate(transform) -} - -@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR) -@kotlin.jvm.JvmName("toMapOfPairs") -public inline fun DoubleArray.toMap(transform: (Double) -> Pair): Map { - return associate(transform) -} - -@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR) -@kotlin.jvm.JvmName("toMapOfPairs") -public inline fun FloatArray.toMap(transform: (Float) -> Pair): Map { +public inline fun ShortArray.toMap(transform: (Short) -> Pair): Map { return associate(transform) } @@ -6550,7 +6532,25 @@ public inline fun LongArray.toMap(transform: (Long) -> Pair): Map ShortArray.toMap(transform: (Short) -> Pair): Map { +public inline fun FloatArray.toMap(transform: (Float) -> Pair): Map { + return associate(transform) +} + +@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR) +@kotlin.jvm.JvmName("toMapOfPairs") +public inline fun DoubleArray.toMap(transform: (Double) -> Pair): Map { + return associate(transform) +} + +@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR) +@kotlin.jvm.JvmName("toMapOfPairs") +public inline fun BooleanArray.toMap(transform: (Boolean) -> Pair): Map { + return associate(transform) +} + +@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR) +@kotlin.jvm.JvmName("toMapOfPairs") +public inline fun CharArray.toMap(transform: (Char) -> Pair): Map { return associate(transform) } @@ -6559,28 +6559,13 @@ public inline fun Array.toMapBy(selector: (T) -> K): Map { return associateBy(selector) } -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) -public inline fun BooleanArray.toMapBy(selector: (Boolean) -> K): Map { - return associateBy(selector) -} - @Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) public inline fun ByteArray.toMapBy(selector: (Byte) -> K): Map { return associateBy(selector) } @Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) -public inline fun CharArray.toMapBy(selector: (Char) -> K): Map { - return associateBy(selector) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) -public inline fun DoubleArray.toMapBy(selector: (Double) -> K): Map { - return associateBy(selector) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) -public inline fun FloatArray.toMapBy(selector: (Float) -> K): Map { +public inline fun ShortArray.toMapBy(selector: (Short) -> K): Map { return associateBy(selector) } @@ -6595,7 +6580,22 @@ public inline fun LongArray.toMapBy(selector: (Long) -> K): Map { } @Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) -public inline fun ShortArray.toMapBy(selector: (Short) -> K): Map { +public inline fun FloatArray.toMapBy(selector: (Float) -> K): Map { + return associateBy(selector) +} + +@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) +public inline fun DoubleArray.toMapBy(selector: (Double) -> K): Map { + return associateBy(selector) +} + +@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) +public inline fun BooleanArray.toMapBy(selector: (Boolean) -> K): Map { + return associateBy(selector) +} + +@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) +public inline fun CharArray.toMapBy(selector: (Char) -> K): Map { return associateBy(selector) } @@ -6604,28 +6604,13 @@ public inline fun Array.toMapBy(selector: (T) -> K, transform: return associateBy(selector, transform) } -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun BooleanArray.toMapBy(selector: (Boolean) -> K, transform: (Boolean) -> V): Map { - return associateBy(selector, transform) -} - @Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) public inline fun ByteArray.toMapBy(selector: (Byte) -> K, transform: (Byte) -> V): Map { return associateBy(selector, transform) } @Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun CharArray.toMapBy(selector: (Char) -> K, transform: (Char) -> V): Map { - return associateBy(selector, transform) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun DoubleArray.toMapBy(selector: (Double) -> K, transform: (Double) -> V): Map { - return associateBy(selector, transform) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun FloatArray.toMapBy(selector: (Float) -> K, transform: (Float) -> V): Map { +public inline fun ShortArray.toMapBy(selector: (Short) -> K, transform: (Short) -> V): Map { return associateBy(selector, transform) } @@ -6640,7 +6625,22 @@ public inline fun LongArray.toMapBy(selector: (Long) -> K, transform: (Lo } @Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun ShortArray.toMapBy(selector: (Short) -> K, transform: (Short) -> V): Map { +public inline fun FloatArray.toMapBy(selector: (Float) -> K, transform: (Float) -> V): Map { + return associateBy(selector, transform) +} + +@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) +public inline fun DoubleArray.toMapBy(selector: (Double) -> K, transform: (Double) -> V): Map { + return associateBy(selector, transform) +} + +@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) +public inline fun BooleanArray.toMapBy(selector: (Boolean) -> K, transform: (Boolean) -> V): Map { + return associateBy(selector, transform) +} + +@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) +public inline fun CharArray.toMapBy(selector: (Char) -> K, transform: (Char) -> V): Map { return associateBy(selector, transform) } @@ -6651,15 +6651,6 @@ public fun Array.toMutableList(): MutableList { return ArrayList(this.asCollection()) } -/** - * Returns a [MutableList] filled with all elements of this array. - */ -public fun BooleanArray.toMutableList(): MutableList { - val list = ArrayList(size) - for (item in this) list.add(item) - return list -} - /** * Returns a [MutableList] filled with all elements of this array. */ @@ -6672,26 +6663,8 @@ public fun ByteArray.toMutableList(): MutableList { /** * Returns a [MutableList] filled with all elements of this array. */ -public fun CharArray.toMutableList(): MutableList { - val list = ArrayList(size) - for (item in this) list.add(item) - return list -} - -/** - * Returns a [MutableList] filled with all elements of this array. - */ -public fun DoubleArray.toMutableList(): MutableList { - val list = ArrayList(size) - for (item in this) list.add(item) - return list -} - -/** - * Returns a [MutableList] filled with all elements of this array. - */ -public fun FloatArray.toMutableList(): MutableList { - val list = ArrayList(size) +public fun ShortArray.toMutableList(): MutableList { + val list = ArrayList(size) for (item in this) list.add(item) return list } @@ -6717,8 +6690,35 @@ public fun LongArray.toMutableList(): MutableList { /** * Returns a [MutableList] filled with all elements of this array. */ -public fun ShortArray.toMutableList(): MutableList { - val list = ArrayList(size) +public fun FloatArray.toMutableList(): MutableList { + val list = ArrayList(size) + for (item in this) list.add(item) + return list +} + +/** + * Returns a [MutableList] filled with all elements of this array. + */ +public fun DoubleArray.toMutableList(): MutableList { + val list = ArrayList(size) + for (item in this) list.add(item) + return list +} + +/** + * Returns a [MutableList] filled with all elements of this array. + */ +public fun BooleanArray.toMutableList(): MutableList { + val list = ArrayList(size) + for (item in this) list.add(item) + return list +} + +/** + * Returns a [MutableList] filled with all elements of this array. + */ +public fun CharArray.toMutableList(): MutableList { + val list = ArrayList(size) for (item in this) list.add(item) return list } @@ -6730,13 +6730,6 @@ public fun Array.toSet(): Set { return toCollection(LinkedHashSet(mapCapacity(size))) } -/** - * Returns a [Set] of all elements. - */ -public fun BooleanArray.toSet(): Set { - return toCollection(LinkedHashSet(mapCapacity(size))) -} - /** * Returns a [Set] of all elements. */ @@ -6747,22 +6740,8 @@ public fun ByteArray.toSet(): Set { /** * Returns a [Set] of all elements. */ -public fun CharArray.toSet(): Set { - return toCollection(LinkedHashSet(mapCapacity(size))) -} - -/** - * Returns a [Set] of all elements. - */ -public fun DoubleArray.toSet(): Set { - return toCollection(LinkedHashSet(mapCapacity(size))) -} - -/** - * Returns a [Set] of all elements. - */ -public fun FloatArray.toSet(): Set { - return toCollection(LinkedHashSet(mapCapacity(size))) +public fun ShortArray.toSet(): Set { + return toCollection(LinkedHashSet(mapCapacity(size))) } /** @@ -6782,8 +6761,29 @@ public fun LongArray.toSet(): Set { /** * Returns a [Set] of all elements. */ -public fun ShortArray.toSet(): Set { - return toCollection(LinkedHashSet(mapCapacity(size))) +public fun FloatArray.toSet(): Set { + return toCollection(LinkedHashSet(mapCapacity(size))) +} + +/** + * Returns a [Set] of all elements. + */ +public fun DoubleArray.toSet(): Set { + return toCollection(LinkedHashSet(mapCapacity(size))) +} + +/** + * Returns a [Set] of all elements. + */ +public fun BooleanArray.toSet(): Set { + return toCollection(LinkedHashSet(mapCapacity(size))) +} + +/** + * Returns a [Set] of all elements. + */ +public fun CharArray.toSet(): Set { + return toCollection(LinkedHashSet(mapCapacity(size))) } /** @@ -6793,13 +6793,6 @@ public fun > Array.toSortedSet(): SortedSet { return toCollection(TreeSet()) } -/** - * Returns a [SortedSet] of all elements. - */ -public fun BooleanArray.toSortedSet(): SortedSet { - return toCollection(TreeSet()) -} - /** * Returns a [SortedSet] of all elements. */ @@ -6810,22 +6803,8 @@ public fun ByteArray.toSortedSet(): SortedSet { /** * Returns a [SortedSet] of all elements. */ -public fun CharArray.toSortedSet(): SortedSet { - return toCollection(TreeSet()) -} - -/** - * Returns a [SortedSet] of all elements. - */ -public fun DoubleArray.toSortedSet(): SortedSet { - return toCollection(TreeSet()) -} - -/** - * Returns a [SortedSet] of all elements. - */ -public fun FloatArray.toSortedSet(): SortedSet { - return toCollection(TreeSet()) +public fun ShortArray.toSortedSet(): SortedSet { + return toCollection(TreeSet()) } /** @@ -6845,8 +6824,29 @@ public fun LongArray.toSortedSet(): SortedSet { /** * Returns a [SortedSet] of all elements. */ -public fun ShortArray.toSortedSet(): SortedSet { - return toCollection(TreeSet()) +public fun FloatArray.toSortedSet(): SortedSet { + return toCollection(TreeSet()) +} + +/** + * Returns a [SortedSet] of all elements. + */ +public fun DoubleArray.toSortedSet(): SortedSet { + return toCollection(TreeSet()) +} + +/** + * Returns a [SortedSet] of all elements. + */ +public fun BooleanArray.toSortedSet(): SortedSet { + return toCollection(TreeSet()) +} + +/** + * Returns a [SortedSet] of all elements. + */ +public fun CharArray.toSortedSet(): SortedSet { + return toCollection(TreeSet()) } /** @@ -6865,13 +6865,6 @@ public inline fun Array.flatMap(transform: (T) -> Iterable): Li return flatMapTo(ArrayList(), transform) } -/** - * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array. - */ -public inline fun BooleanArray.flatMap(transform: (Boolean) -> Iterable): List { - return flatMapTo(ArrayList(), transform) -} - /** * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array. */ @@ -6882,21 +6875,7 @@ public inline fun ByteArray.flatMap(transform: (Byte) -> Iterable): List< /** * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array. */ -public inline fun CharArray.flatMap(transform: (Char) -> Iterable): List { - return flatMapTo(ArrayList(), transform) -} - -/** - * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array. - */ -public inline fun DoubleArray.flatMap(transform: (Double) -> Iterable): List { - return flatMapTo(ArrayList(), transform) -} - -/** - * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array. - */ -public inline fun FloatArray.flatMap(transform: (Float) -> Iterable): List { +public inline fun ShortArray.flatMap(transform: (Short) -> Iterable): List { return flatMapTo(ArrayList(), transform) } @@ -6917,7 +6896,28 @@ public inline fun LongArray.flatMap(transform: (Long) -> Iterable): List< /** * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array. */ -public inline fun ShortArray.flatMap(transform: (Short) -> Iterable): List { +public inline fun FloatArray.flatMap(transform: (Float) -> Iterable): List { + return flatMapTo(ArrayList(), transform) +} + +/** + * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array. + */ +public inline fun DoubleArray.flatMap(transform: (Double) -> Iterable): List { + return flatMapTo(ArrayList(), transform) +} + +/** + * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array. + */ +public inline fun BooleanArray.flatMap(transform: (Boolean) -> Iterable): List { + return flatMapTo(ArrayList(), transform) +} + +/** + * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array. + */ +public inline fun CharArray.flatMap(transform: (Char) -> Iterable): List { return flatMapTo(ArrayList(), transform) } @@ -6932,17 +6932,6 @@ public inline fun > Array.flatMapTo(des return destination } -/** - * Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination]. - */ -public inline fun > BooleanArray.flatMapTo(destination: C, transform: (Boolean) -> Iterable): C { - for (element in this) { - val list = transform(element) - destination.addAll(list) - } - return destination -} - /** * Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination]. */ @@ -6957,29 +6946,7 @@ public inline fun > ByteArray.flatMapTo(destinati /** * Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination]. */ -public inline fun > CharArray.flatMapTo(destination: C, transform: (Char) -> Iterable): C { - for (element in this) { - val list = transform(element) - destination.addAll(list) - } - return destination -} - -/** - * Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination]. - */ -public inline fun > DoubleArray.flatMapTo(destination: C, transform: (Double) -> Iterable): C { - for (element in this) { - val list = transform(element) - destination.addAll(list) - } - return destination -} - -/** - * Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination]. - */ -public inline fun > FloatArray.flatMapTo(destination: C, transform: (Float) -> Iterable): C { +public inline fun > ShortArray.flatMapTo(destination: C, transform: (Short) -> Iterable): C { for (element in this) { val list = transform(element) destination.addAll(list) @@ -7012,7 +6979,40 @@ public inline fun > LongArray.flatMapTo(destinati /** * Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination]. */ -public inline fun > ShortArray.flatMapTo(destination: C, transform: (Short) -> Iterable): C { +public inline fun > FloatArray.flatMapTo(destination: C, transform: (Float) -> Iterable): C { + for (element in this) { + val list = transform(element) + destination.addAll(list) + } + return destination +} + +/** + * Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination]. + */ +public inline fun > DoubleArray.flatMapTo(destination: C, transform: (Double) -> Iterable): C { + for (element in this) { + val list = transform(element) + destination.addAll(list) + } + return destination +} + +/** + * Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination]. + */ +public inline fun > BooleanArray.flatMapTo(destination: C, transform: (Boolean) -> Iterable): C { + for (element in this) { + val list = transform(element) + destination.addAll(list) + } + return destination +} + +/** + * Appends all elements yielded from results of [transform] function being invoked on each element of original array, to the given [destination]. + */ +public inline fun > CharArray.flatMapTo(destination: C, transform: (Char) -> Iterable): C { for (element in this) { val list = transform(element) destination.addAll(list) @@ -7029,15 +7029,6 @@ public inline fun Array.groupBy(keySelector: (T) -> K): Map>(), keySelector) } -/** - * Groups elements of the original array by the key returned by the given [keySelector] function - * applied to each element and returns a map where each group key is associated with a list of corresponding elements. - * @sample test.collections.CollectionTest.groupBy - */ -public inline fun BooleanArray.groupBy(keySelector: (Boolean) -> K): Map> { - return groupByTo(LinkedHashMap>(), keySelector) -} - /** * Groups elements of the original array by the key returned by the given [keySelector] function * applied to each element and returns a map where each group key is associated with a list of corresponding elements. @@ -7052,26 +7043,8 @@ public inline fun ByteArray.groupBy(keySelector: (Byte) -> K): Map CharArray.groupBy(keySelector: (Char) -> K): Map> { - return groupByTo(LinkedHashMap>(), keySelector) -} - -/** - * Groups elements of the original array by the key returned by the given [keySelector] function - * applied to each element and returns a map where each group key is associated with a list of corresponding elements. - * @sample test.collections.CollectionTest.groupBy - */ -public inline fun DoubleArray.groupBy(keySelector: (Double) -> K): Map> { - return groupByTo(LinkedHashMap>(), keySelector) -} - -/** - * Groups elements of the original array by the key returned by the given [keySelector] function - * applied to each element and returns a map where each group key is associated with a list of corresponding elements. - * @sample test.collections.CollectionTest.groupBy - */ -public inline fun FloatArray.groupBy(keySelector: (Float) -> K): Map> { - return groupByTo(LinkedHashMap>(), keySelector) +public inline fun ShortArray.groupBy(keySelector: (Short) -> K): Map> { + return groupByTo(LinkedHashMap>(), keySelector) } /** @@ -7097,8 +7070,35 @@ public inline fun LongArray.groupBy(keySelector: (Long) -> K): Map ShortArray.groupBy(keySelector: (Short) -> K): Map> { - return groupByTo(LinkedHashMap>(), keySelector) +public inline fun FloatArray.groupBy(keySelector: (Float) -> K): Map> { + return groupByTo(LinkedHashMap>(), keySelector) +} + +/** + * Groups elements of the original array by the key returned by the given [keySelector] function + * applied to each element and returns a map where each group key is associated with a list of corresponding elements. + * @sample test.collections.CollectionTest.groupBy + */ +public inline fun DoubleArray.groupBy(keySelector: (Double) -> K): Map> { + return groupByTo(LinkedHashMap>(), keySelector) +} + +/** + * Groups elements of the original array by the key returned by the given [keySelector] function + * applied to each element and returns a map where each group key is associated with a list of corresponding elements. + * @sample test.collections.CollectionTest.groupBy + */ +public inline fun BooleanArray.groupBy(keySelector: (Boolean) -> K): Map> { + return groupByTo(LinkedHashMap>(), keySelector) +} + +/** + * Groups elements of the original array by the key returned by the given [keySelector] function + * applied to each element and returns a map where each group key is associated with a list of corresponding elements. + * @sample test.collections.CollectionTest.groupBy + */ +public inline fun CharArray.groupBy(keySelector: (Char) -> K): Map> { + return groupByTo(LinkedHashMap>(), keySelector) } /** @@ -7111,16 +7111,6 @@ public inline fun Array.groupBy(keySelector: (T) -> K, valueTra return groupByTo(LinkedHashMap>(), keySelector, valueTransform) } -/** - * Groups values returned by the [valueTransform] function applied to each element of the original array - * by the key returned by the given [keySelector] function applied to the element - * and returns a map where each group key is associated with a list of corresponding values. - * @sample test.collections.CollectionTest.groupByKeysAndValues - */ -public inline fun BooleanArray.groupBy(keySelector: (Boolean) -> K, valueTransform: (Boolean) -> V): Map> { - return groupByTo(LinkedHashMap>(), keySelector, valueTransform) -} - /** * Groups values returned by the [valueTransform] function applied to each element of the original array * by the key returned by the given [keySelector] function applied to the element @@ -7137,27 +7127,7 @@ public inline fun ByteArray.groupBy(keySelector: (Byte) -> K, valueTransf * and returns a map where each group key is associated with a list of corresponding values. * @sample test.collections.CollectionTest.groupByKeysAndValues */ -public inline fun CharArray.groupBy(keySelector: (Char) -> K, valueTransform: (Char) -> V): Map> { - return groupByTo(LinkedHashMap>(), keySelector, valueTransform) -} - -/** - * Groups values returned by the [valueTransform] function applied to each element of the original array - * by the key returned by the given [keySelector] function applied to the element - * and returns a map where each group key is associated with a list of corresponding values. - * @sample test.collections.CollectionTest.groupByKeysAndValues - */ -public inline fun DoubleArray.groupBy(keySelector: (Double) -> K, valueTransform: (Double) -> V): Map> { - return groupByTo(LinkedHashMap>(), keySelector, valueTransform) -} - -/** - * Groups values returned by the [valueTransform] function applied to each element of the original array - * by the key returned by the given [keySelector] function applied to the element - * and returns a map where each group key is associated with a list of corresponding values. - * @sample test.collections.CollectionTest.groupByKeysAndValues - */ -public inline fun FloatArray.groupBy(keySelector: (Float) -> K, valueTransform: (Float) -> V): Map> { +public inline fun ShortArray.groupBy(keySelector: (Short) -> K, valueTransform: (Short) -> V): Map> { return groupByTo(LinkedHashMap>(), keySelector, valueTransform) } @@ -7187,7 +7157,37 @@ public inline fun LongArray.groupBy(keySelector: (Long) -> K, valueTransf * and returns a map where each group key is associated with a list of corresponding values. * @sample test.collections.CollectionTest.groupByKeysAndValues */ -public inline fun ShortArray.groupBy(keySelector: (Short) -> K, valueTransform: (Short) -> V): Map> { +public inline fun FloatArray.groupBy(keySelector: (Float) -> K, valueTransform: (Float) -> V): Map> { + return groupByTo(LinkedHashMap>(), keySelector, valueTransform) +} + +/** + * Groups values returned by the [valueTransform] function applied to each element of the original array + * by the key returned by the given [keySelector] function applied to the element + * and returns a map where each group key is associated with a list of corresponding values. + * @sample test.collections.CollectionTest.groupByKeysAndValues + */ +public inline fun DoubleArray.groupBy(keySelector: (Double) -> K, valueTransform: (Double) -> V): Map> { + return groupByTo(LinkedHashMap>(), keySelector, valueTransform) +} + +/** + * Groups values returned by the [valueTransform] function applied to each element of the original array + * by the key returned by the given [keySelector] function applied to the element + * and returns a map where each group key is associated with a list of corresponding values. + * @sample test.collections.CollectionTest.groupByKeysAndValues + */ +public inline fun BooleanArray.groupBy(keySelector: (Boolean) -> K, valueTransform: (Boolean) -> V): Map> { + return groupByTo(LinkedHashMap>(), keySelector, valueTransform) +} + +/** + * Groups values returned by the [valueTransform] function applied to each element of the original array + * by the key returned by the given [keySelector] function applied to the element + * and returns a map where each group key is associated with a list of corresponding values. + * @sample test.collections.CollectionTest.groupByKeysAndValues + */ +public inline fun CharArray.groupBy(keySelector: (Char) -> K, valueTransform: (Char) -> V): Map> { return groupByTo(LinkedHashMap>(), keySelector, valueTransform) } @@ -7206,21 +7206,6 @@ public inline fun >> Array.grou return destination } -/** - * Groups elements of the original array by the key returned by the given [keySelector] function - * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements. - * @return The [destination] map. - * @sample test.collections.CollectionTest.groupBy - */ -public inline fun >> BooleanArray.groupByTo(destination: M, keySelector: (Boolean) -> K): M { - for (element in this) { - val key = keySelector(element) - val list = destination.getOrPut(key) { ArrayList() } - list.add(element) - } - return destination -} - /** * Groups elements of the original array by the key returned by the given [keySelector] function * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements. @@ -7242,40 +7227,10 @@ public inline fun >> ByteArray.groupBy * @return The [destination] map. * @sample test.collections.CollectionTest.groupBy */ -public inline fun >> CharArray.groupByTo(destination: M, keySelector: (Char) -> K): M { +public inline fun >> ShortArray.groupByTo(destination: M, keySelector: (Short) -> K): M { for (element in this) { val key = keySelector(element) - val list = destination.getOrPut(key) { ArrayList() } - list.add(element) - } - return destination -} - -/** - * Groups elements of the original array by the key returned by the given [keySelector] function - * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements. - * @return The [destination] map. - * @sample test.collections.CollectionTest.groupBy - */ -public inline fun >> DoubleArray.groupByTo(destination: M, keySelector: (Double) -> K): M { - for (element in this) { - val key = keySelector(element) - val list = destination.getOrPut(key) { ArrayList() } - list.add(element) - } - return destination -} - -/** - * Groups elements of the original array by the key returned by the given [keySelector] function - * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements. - * @return The [destination] map. - * @sample test.collections.CollectionTest.groupBy - */ -public inline fun >> FloatArray.groupByTo(destination: M, keySelector: (Float) -> K): M { - for (element in this) { - val key = keySelector(element) - val list = destination.getOrPut(key) { ArrayList() } + val list = destination.getOrPut(key) { ArrayList() } list.add(element) } return destination @@ -7317,10 +7272,55 @@ public inline fun >> LongArray.groupBy * @return The [destination] map. * @sample test.collections.CollectionTest.groupBy */ -public inline fun >> ShortArray.groupByTo(destination: M, keySelector: (Short) -> K): M { +public inline fun >> FloatArray.groupByTo(destination: M, keySelector: (Float) -> K): M { for (element in this) { val key = keySelector(element) - val list = destination.getOrPut(key) { ArrayList() } + val list = destination.getOrPut(key) { ArrayList() } + list.add(element) + } + return destination +} + +/** + * Groups elements of the original array by the key returned by the given [keySelector] function + * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements. + * @return The [destination] map. + * @sample test.collections.CollectionTest.groupBy + */ +public inline fun >> DoubleArray.groupByTo(destination: M, keySelector: (Double) -> K): M { + for (element in this) { + val key = keySelector(element) + val list = destination.getOrPut(key) { ArrayList() } + list.add(element) + } + return destination +} + +/** + * Groups elements of the original array by the key returned by the given [keySelector] function + * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements. + * @return The [destination] map. + * @sample test.collections.CollectionTest.groupBy + */ +public inline fun >> BooleanArray.groupByTo(destination: M, keySelector: (Boolean) -> K): M { + for (element in this) { + val key = keySelector(element) + val list = destination.getOrPut(key) { ArrayList() } + list.add(element) + } + return destination +} + +/** + * Groups elements of the original array by the key returned by the given [keySelector] function + * applied to each element and puts to the [destination] map each group key associated with a list of corresponding elements. + * @return The [destination] map. + * @sample test.collections.CollectionTest.groupBy + */ +public inline fun >> CharArray.groupByTo(destination: M, keySelector: (Char) -> K): M { + for (element in this) { + val key = keySelector(element) + val list = destination.getOrPut(key) { ArrayList() } list.add(element) } return destination @@ -7342,22 +7342,6 @@ public inline fun >> Array.g return destination } -/** - * Groups values returned by the [valueTransform] function applied to each element of the original array - * by the key returned by the given [keySelector] function applied to the element - * and puts to the [destination] map each group key associated with a list of corresponding values. - * @return The [destination] map. - * @sample test.collections.CollectionTest.groupByKeysAndValues - */ -public inline fun >> BooleanArray.groupByTo(destination: M, keySelector: (Boolean) -> K, valueTransform: (Boolean) -> V): M { - for (element in this) { - val key = keySelector(element) - val list = destination.getOrPut(key) { ArrayList() } - list.add(valueTransform(element)) - } - return destination -} - /** * Groups values returned by the [valueTransform] function applied to each element of the original array * by the key returned by the given [keySelector] function applied to the element @@ -7381,39 +7365,7 @@ public inline fun >> ByteArray.groupBy * @return The [destination] map. * @sample test.collections.CollectionTest.groupByKeysAndValues */ -public inline fun >> CharArray.groupByTo(destination: M, keySelector: (Char) -> K, valueTransform: (Char) -> V): M { - for (element in this) { - val key = keySelector(element) - val list = destination.getOrPut(key) { ArrayList() } - list.add(valueTransform(element)) - } - return destination -} - -/** - * Groups values returned by the [valueTransform] function applied to each element of the original array - * by the key returned by the given [keySelector] function applied to the element - * and puts to the [destination] map each group key associated with a list of corresponding values. - * @return The [destination] map. - * @sample test.collections.CollectionTest.groupByKeysAndValues - */ -public inline fun >> DoubleArray.groupByTo(destination: M, keySelector: (Double) -> K, valueTransform: (Double) -> V): M { - for (element in this) { - val key = keySelector(element) - val list = destination.getOrPut(key) { ArrayList() } - list.add(valueTransform(element)) - } - return destination -} - -/** - * Groups values returned by the [valueTransform] function applied to each element of the original array - * by the key returned by the given [keySelector] function applied to the element - * and puts to the [destination] map each group key associated with a list of corresponding values. - * @return The [destination] map. - * @sample test.collections.CollectionTest.groupByKeysAndValues - */ -public inline fun >> FloatArray.groupByTo(destination: M, keySelector: (Float) -> K, valueTransform: (Float) -> V): M { +public inline fun >> ShortArray.groupByTo(destination: M, keySelector: (Short) -> K, valueTransform: (Short) -> V): M { for (element in this) { val key = keySelector(element) val list = destination.getOrPut(key) { ArrayList() } @@ -7461,7 +7413,55 @@ public inline fun >> LongArray.groupBy * @return The [destination] map. * @sample test.collections.CollectionTest.groupByKeysAndValues */ -public inline fun >> ShortArray.groupByTo(destination: M, keySelector: (Short) -> K, valueTransform: (Short) -> V): M { +public inline fun >> FloatArray.groupByTo(destination: M, keySelector: (Float) -> K, valueTransform: (Float) -> V): M { + for (element in this) { + val key = keySelector(element) + val list = destination.getOrPut(key) { ArrayList() } + list.add(valueTransform(element)) + } + return destination +} + +/** + * Groups values returned by the [valueTransform] function applied to each element of the original array + * by the key returned by the given [keySelector] function applied to the element + * and puts to the [destination] map each group key associated with a list of corresponding values. + * @return The [destination] map. + * @sample test.collections.CollectionTest.groupByKeysAndValues + */ +public inline fun >> DoubleArray.groupByTo(destination: M, keySelector: (Double) -> K, valueTransform: (Double) -> V): M { + for (element in this) { + val key = keySelector(element) + val list = destination.getOrPut(key) { ArrayList() } + list.add(valueTransform(element)) + } + return destination +} + +/** + * Groups values returned by the [valueTransform] function applied to each element of the original array + * by the key returned by the given [keySelector] function applied to the element + * and puts to the [destination] map each group key associated with a list of corresponding values. + * @return The [destination] map. + * @sample test.collections.CollectionTest.groupByKeysAndValues + */ +public inline fun >> BooleanArray.groupByTo(destination: M, keySelector: (Boolean) -> K, valueTransform: (Boolean) -> V): M { + for (element in this) { + val key = keySelector(element) + val list = destination.getOrPut(key) { ArrayList() } + list.add(valueTransform(element)) + } + return destination +} + +/** + * Groups values returned by the [valueTransform] function applied to each element of the original array + * by the key returned by the given [keySelector] function applied to the element + * and puts to the [destination] map each group key associated with a list of corresponding values. + * @return The [destination] map. + * @sample test.collections.CollectionTest.groupByKeysAndValues + */ +public inline fun >> CharArray.groupByTo(destination: M, keySelector: (Char) -> K, valueTransform: (Char) -> V): M { for (element in this) { val key = keySelector(element) val list = destination.getOrPut(key) { ArrayList() } @@ -7478,14 +7478,6 @@ public inline fun Array.map(transform: (T) -> R): List { return mapTo(ArrayList(size), transform) } -/** - * Returns a list containing the results of applying the given [transform] function - * to each element in the original array. - */ -public inline fun BooleanArray.map(transform: (Boolean) -> R): List { - return mapTo(ArrayList(size), transform) -} - /** * Returns a list containing the results of applying the given [transform] function * to each element in the original array. @@ -7498,23 +7490,7 @@ public inline fun ByteArray.map(transform: (Byte) -> R): List { * Returns a list containing the results of applying the given [transform] function * to each element in the original array. */ -public inline fun CharArray.map(transform: (Char) -> R): List { - return mapTo(ArrayList(size), transform) -} - -/** - * Returns a list containing the results of applying the given [transform] function - * to each element in the original array. - */ -public inline fun DoubleArray.map(transform: (Double) -> R): List { - return mapTo(ArrayList(size), transform) -} - -/** - * Returns a list containing the results of applying the given [transform] function - * to each element in the original array. - */ -public inline fun FloatArray.map(transform: (Float) -> R): List { +public inline fun ShortArray.map(transform: (Short) -> R): List { return mapTo(ArrayList(size), transform) } @@ -7538,7 +7514,31 @@ public inline fun LongArray.map(transform: (Long) -> R): List { * Returns a list containing the results of applying the given [transform] function * to each element in the original array. */ -public inline fun ShortArray.map(transform: (Short) -> R): List { +public inline fun FloatArray.map(transform: (Float) -> R): List { + return mapTo(ArrayList(size), transform) +} + +/** + * Returns a list containing the results of applying the given [transform] function + * to each element in the original array. + */ +public inline fun DoubleArray.map(transform: (Double) -> R): List { + return mapTo(ArrayList(size), transform) +} + +/** + * Returns a list containing the results of applying the given [transform] function + * to each element in the original array. + */ +public inline fun BooleanArray.map(transform: (Boolean) -> R): List { + return mapTo(ArrayList(size), transform) +} + +/** + * Returns a list containing the results of applying the given [transform] function + * to each element in the original array. + */ +public inline fun CharArray.map(transform: (Char) -> R): List { return mapTo(ArrayList(size), transform) } @@ -7550,14 +7550,6 @@ public inline fun Array.mapIndexed(transform: (Int, T) -> R): List return mapIndexedTo(ArrayList(size), transform) } -/** - * Returns a list containing the results of applying the given [transform] function - * to each element and its index in the original array. - */ -public inline fun BooleanArray.mapIndexed(transform: (Int, Boolean) -> R): List { - return mapIndexedTo(ArrayList(size), transform) -} - /** * Returns a list containing the results of applying the given [transform] function * to each element and its index in the original array. @@ -7570,23 +7562,7 @@ public inline fun ByteArray.mapIndexed(transform: (Int, Byte) -> R): List * Returns a list containing the results of applying the given [transform] function * to each element and its index in the original array. */ -public inline fun CharArray.mapIndexed(transform: (Int, Char) -> R): List { - return mapIndexedTo(ArrayList(size), transform) -} - -/** - * Returns a list containing the results of applying the given [transform] function - * to each element and its index in the original array. - */ -public inline fun DoubleArray.mapIndexed(transform: (Int, Double) -> R): List { - return mapIndexedTo(ArrayList(size), transform) -} - -/** - * Returns a list containing the results of applying the given [transform] function - * to each element and its index in the original array. - */ -public inline fun FloatArray.mapIndexed(transform: (Int, Float) -> R): List { +public inline fun ShortArray.mapIndexed(transform: (Int, Short) -> R): List { return mapIndexedTo(ArrayList(size), transform) } @@ -7610,7 +7586,31 @@ public inline fun LongArray.mapIndexed(transform: (Int, Long) -> R): List * Returns a list containing the results of applying the given [transform] function * to each element and its index in the original array. */ -public inline fun ShortArray.mapIndexed(transform: (Int, Short) -> R): List { +public inline fun FloatArray.mapIndexed(transform: (Int, Float) -> R): List { + return mapIndexedTo(ArrayList(size), transform) +} + +/** + * Returns a list containing the results of applying the given [transform] function + * to each element and its index in the original array. + */ +public inline fun DoubleArray.mapIndexed(transform: (Int, Double) -> R): List { + return mapIndexedTo(ArrayList(size), transform) +} + +/** + * Returns a list containing the results of applying the given [transform] function + * to each element and its index in the original array. + */ +public inline fun BooleanArray.mapIndexed(transform: (Int, Boolean) -> R): List { + return mapIndexedTo(ArrayList(size), transform) +} + +/** + * Returns a list containing the results of applying the given [transform] function + * to each element and its index in the original array. + */ +public inline fun CharArray.mapIndexed(transform: (Int, Char) -> R): List { return mapIndexedTo(ArrayList(size), transform) } @@ -7642,17 +7642,6 @@ public inline fun > Array.mapIndexedTo( return destination } -/** - * Applies the given [transform] function to each element and its index in the original array - * and appends the results to the given [destination]. - */ -public inline fun > BooleanArray.mapIndexedTo(destination: C, transform: (Int, Boolean) -> R): C { - var index = 0 - for (item in this) - destination.add(transform(index++, item)) - return destination -} - /** * Applies the given [transform] function to each element and its index in the original array * and appends the results to the given [destination]. @@ -7668,29 +7657,7 @@ public inline fun > ByteArray.mapIndexedTo(destin * Applies the given [transform] function to each element and its index in the original array * and appends the results to the given [destination]. */ -public inline fun > CharArray.mapIndexedTo(destination: C, transform: (Int, Char) -> R): C { - var index = 0 - for (item in this) - destination.add(transform(index++, item)) - return destination -} - -/** - * Applies the given [transform] function to each element and its index in the original array - * and appends the results to the given [destination]. - */ -public inline fun > DoubleArray.mapIndexedTo(destination: C, transform: (Int, Double) -> R): C { - var index = 0 - for (item in this) - destination.add(transform(index++, item)) - return destination -} - -/** - * Applies the given [transform] function to each element and its index in the original array - * and appends the results to the given [destination]. - */ -public inline fun > FloatArray.mapIndexedTo(destination: C, transform: (Int, Float) -> R): C { +public inline fun > ShortArray.mapIndexedTo(destination: C, transform: (Int, Short) -> R): C { var index = 0 for (item in this) destination.add(transform(index++, item)) @@ -7723,7 +7690,40 @@ public inline fun > LongArray.mapIndexedTo(destin * Applies the given [transform] function to each element and its index in the original array * and appends the results to the given [destination]. */ -public inline fun > ShortArray.mapIndexedTo(destination: C, transform: (Int, Short) -> R): C { +public inline fun > FloatArray.mapIndexedTo(destination: C, transform: (Int, Float) -> R): C { + var index = 0 + for (item in this) + destination.add(transform(index++, item)) + return destination +} + +/** + * Applies the given [transform] function to each element and its index in the original array + * and appends the results to the given [destination]. + */ +public inline fun > DoubleArray.mapIndexedTo(destination: C, transform: (Int, Double) -> R): C { + var index = 0 + for (item in this) + destination.add(transform(index++, item)) + return destination +} + +/** + * Applies the given [transform] function to each element and its index in the original array + * and appends the results to the given [destination]. + */ +public inline fun > BooleanArray.mapIndexedTo(destination: C, transform: (Int, Boolean) -> R): C { + var index = 0 + for (item in this) + destination.add(transform(index++, item)) + return destination +} + +/** + * Applies the given [transform] function to each element and its index in the original array + * and appends the results to the given [destination]. + */ +public inline fun > CharArray.mapIndexedTo(destination: C, transform: (Int, Char) -> R): C { var index = 0 for (item in this) destination.add(transform(index++, item)) @@ -7757,16 +7757,6 @@ public inline fun > Array.mapTo(destina return destination } -/** - * Applies the given [transform] function to each element of the original array - * and appends the results to the given [destination]. - */ -public inline fun > BooleanArray.mapTo(destination: C, transform: (Boolean) -> R): C { - for (item in this) - destination.add(transform(item)) - return destination -} - /** * Applies the given [transform] function to each element of the original array * and appends the results to the given [destination]. @@ -7781,27 +7771,7 @@ public inline fun > ByteArray.mapTo(destination: * Applies the given [transform] function to each element of the original array * and appends the results to the given [destination]. */ -public inline fun > CharArray.mapTo(destination: C, transform: (Char) -> R): C { - for (item in this) - destination.add(transform(item)) - return destination -} - -/** - * Applies the given [transform] function to each element of the original array - * and appends the results to the given [destination]. - */ -public inline fun > DoubleArray.mapTo(destination: C, transform: (Double) -> R): C { - for (item in this) - destination.add(transform(item)) - return destination -} - -/** - * Applies the given [transform] function to each element of the original array - * and appends the results to the given [destination]. - */ -public inline fun > FloatArray.mapTo(destination: C, transform: (Float) -> R): C { +public inline fun > ShortArray.mapTo(destination: C, transform: (Short) -> R): C { for (item in this) destination.add(transform(item)) return destination @@ -7831,7 +7801,37 @@ public inline fun > LongArray.mapTo(destination: * Applies the given [transform] function to each element of the original array * and appends the results to the given [destination]. */ -public inline fun > ShortArray.mapTo(destination: C, transform: (Short) -> R): C { +public inline fun > FloatArray.mapTo(destination: C, transform: (Float) -> R): C { + for (item in this) + destination.add(transform(item)) + return destination +} + +/** + * Applies the given [transform] function to each element of the original array + * and appends the results to the given [destination]. + */ +public inline fun > DoubleArray.mapTo(destination: C, transform: (Double) -> R): C { + for (item in this) + destination.add(transform(item)) + return destination +} + +/** + * Applies the given [transform] function to each element of the original array + * and appends the results to the given [destination]. + */ +public inline fun > BooleanArray.mapTo(destination: C, transform: (Boolean) -> R): C { + for (item in this) + destination.add(transform(item)) + return destination +} + +/** + * Applies the given [transform] function to each element of the original array + * and appends the results to the given [destination]. + */ +public inline fun > CharArray.mapTo(destination: C, transform: (Char) -> R): C { for (item in this) destination.add(transform(item)) return destination @@ -7844,13 +7844,6 @@ public fun Array.withIndex(): Iterable> { return IndexingIterable { iterator() } } -/** - * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. - */ -public fun BooleanArray.withIndex(): Iterable> { - return IndexingIterable { iterator() } -} - /** * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. */ @@ -7861,21 +7854,7 @@ public fun ByteArray.withIndex(): Iterable> { /** * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. */ -public fun CharArray.withIndex(): Iterable> { - return IndexingIterable { iterator() } -} - -/** - * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. - */ -public fun DoubleArray.withIndex(): Iterable> { - return IndexingIterable { iterator() } -} - -/** - * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. - */ -public fun FloatArray.withIndex(): Iterable> { +public fun ShortArray.withIndex(): Iterable> { return IndexingIterable { iterator() } } @@ -7896,7 +7875,28 @@ public fun LongArray.withIndex(): Iterable> { /** * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. */ -public fun ShortArray.withIndex(): Iterable> { +public fun FloatArray.withIndex(): Iterable> { + return IndexingIterable { iterator() } +} + +/** + * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. + */ +public fun DoubleArray.withIndex(): Iterable> { + return IndexingIterable { iterator() } +} + +/** + * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. + */ +public fun BooleanArray.withIndex(): Iterable> { + return IndexingIterable { iterator() } +} + +/** + * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. + */ +public fun CharArray.withIndex(): Iterable> { return IndexingIterable { iterator() } } @@ -7908,14 +7908,6 @@ public fun Array.distinct(): List { return this.toMutableSet().toList() } -/** - * Returns a list containing only distinct elements from the given array. - * The elements in the resulting list are in the same order as they were in the source array. - */ -public fun BooleanArray.distinct(): List { - return this.toMutableSet().toList() -} - /** * Returns a list containing only distinct elements from the given array. * The elements in the resulting list are in the same order as they were in the source array. @@ -7928,23 +7920,7 @@ public fun ByteArray.distinct(): List { * Returns a list containing only distinct elements from the given array. * The elements in the resulting list are in the same order as they were in the source array. */ -public fun CharArray.distinct(): List { - return this.toMutableSet().toList() -} - -/** - * Returns a list containing only distinct elements from the given array. - * The elements in the resulting list are in the same order as they were in the source array. - */ -public fun DoubleArray.distinct(): List { - return this.toMutableSet().toList() -} - -/** - * Returns a list containing only distinct elements from the given array. - * The elements in the resulting list are in the same order as they were in the source array. - */ -public fun FloatArray.distinct(): List { +public fun ShortArray.distinct(): List { return this.toMutableSet().toList() } @@ -7968,7 +7944,31 @@ public fun LongArray.distinct(): List { * Returns a list containing only distinct elements from the given array. * The elements in the resulting list are in the same order as they were in the source array. */ -public fun ShortArray.distinct(): List { +public fun FloatArray.distinct(): List { + return this.toMutableSet().toList() +} + +/** + * Returns a list containing only distinct elements from the given array. + * The elements in the resulting list are in the same order as they were in the source array. + */ +public fun DoubleArray.distinct(): List { + return this.toMutableSet().toList() +} + +/** + * Returns a list containing only distinct elements from the given array. + * The elements in the resulting list are in the same order as they were in the source array. + */ +public fun BooleanArray.distinct(): List { + return this.toMutableSet().toList() +} + +/** + * Returns a list containing only distinct elements from the given array. + * The elements in the resulting list are in the same order as they were in the source array. + */ +public fun CharArray.distinct(): List { return this.toMutableSet().toList() } @@ -7988,22 +7988,6 @@ public inline fun Array.distinctBy(selector: (T) -> K): List { return list } -/** - * Returns a list containing only elements from the given array - * having distinct keys returned by the given [selector] function. - * The elements in the resulting list are in the same order as they were in the source array. - */ -public inline fun BooleanArray.distinctBy(selector: (Boolean) -> K): List { - val set = HashSet() - val list = ArrayList() - for (e in this) { - val key = selector(e) - if (set.add(key)) - list.add(e) - } - return list -} - /** * Returns a list containing only elements from the given array * having distinct keys returned by the given [selector] function. @@ -8025,41 +8009,9 @@ public inline fun ByteArray.distinctBy(selector: (Byte) -> K): List { * having distinct keys returned by the given [selector] function. * The elements in the resulting list are in the same order as they were in the source array. */ -public inline fun CharArray.distinctBy(selector: (Char) -> K): List { +public inline fun ShortArray.distinctBy(selector: (Short) -> K): List { val set = HashSet() - val list = ArrayList() - for (e in this) { - val key = selector(e) - if (set.add(key)) - list.add(e) - } - return list -} - -/** - * Returns a list containing only elements from the given array - * having distinct keys returned by the given [selector] function. - * The elements in the resulting list are in the same order as they were in the source array. - */ -public inline fun DoubleArray.distinctBy(selector: (Double) -> K): List { - val set = HashSet() - val list = ArrayList() - for (e in this) { - val key = selector(e) - if (set.add(key)) - list.add(e) - } - return list -} - -/** - * Returns a list containing only elements from the given array - * having distinct keys returned by the given [selector] function. - * The elements in the resulting list are in the same order as they were in the source array. - */ -public inline fun FloatArray.distinctBy(selector: (Float) -> K): List { - val set = HashSet() - val list = ArrayList() + val list = ArrayList() for (e in this) { val key = selector(e) if (set.add(key)) @@ -8105,9 +8057,57 @@ public inline fun LongArray.distinctBy(selector: (Long) -> K): List { * having distinct keys returned by the given [selector] function. * The elements in the resulting list are in the same order as they were in the source array. */ -public inline fun ShortArray.distinctBy(selector: (Short) -> K): List { +public inline fun FloatArray.distinctBy(selector: (Float) -> K): List { val set = HashSet() - val list = ArrayList() + val list = ArrayList() + for (e in this) { + val key = selector(e) + if (set.add(key)) + list.add(e) + } + return list +} + +/** + * Returns a list containing only elements from the given array + * having distinct keys returned by the given [selector] function. + * The elements in the resulting list are in the same order as they were in the source array. + */ +public inline fun DoubleArray.distinctBy(selector: (Double) -> K): List { + val set = HashSet() + val list = ArrayList() + for (e in this) { + val key = selector(e) + if (set.add(key)) + list.add(e) + } + return list +} + +/** + * Returns a list containing only elements from the given array + * having distinct keys returned by the given [selector] function. + * The elements in the resulting list are in the same order as they were in the source array. + */ +public inline fun BooleanArray.distinctBy(selector: (Boolean) -> K): List { + val set = HashSet() + val list = ArrayList() + for (e in this) { + val key = selector(e) + if (set.add(key)) + list.add(e) + } + return list +} + +/** + * Returns a list containing only elements from the given array + * having distinct keys returned by the given [selector] function. + * The elements in the resulting list are in the same order as they were in the source array. + */ +public inline fun CharArray.distinctBy(selector: (Char) -> K): List { + val set = HashSet() + val list = ArrayList() for (e in this) { val key = selector(e) if (set.add(key)) @@ -8125,15 +8125,6 @@ public infix fun Array.intersect(other: Iterable): Set { return set } -/** - * Returns a set containing all elements that are contained by both this set and the specified collection. - */ -public infix fun BooleanArray.intersect(other: Iterable): Set { - val set = this.toMutableSet() - set.retainAll(other) - return set -} - /** * Returns a set containing all elements that are contained by both this set and the specified collection. */ @@ -8146,25 +8137,7 @@ public infix fun ByteArray.intersect(other: Iterable): Set { /** * Returns a set containing all elements that are contained by both this set and the specified collection. */ -public infix fun CharArray.intersect(other: Iterable): Set { - val set = this.toMutableSet() - set.retainAll(other) - return set -} - -/** - * Returns a set containing all elements that are contained by both this set and the specified collection. - */ -public infix fun DoubleArray.intersect(other: Iterable): Set { - val set = this.toMutableSet() - set.retainAll(other) - return set -} - -/** - * Returns a set containing all elements that are contained by both this set and the specified collection. - */ -public infix fun FloatArray.intersect(other: Iterable): Set { +public infix fun ShortArray.intersect(other: Iterable): Set { val set = this.toMutableSet() set.retainAll(other) return set @@ -8191,7 +8164,34 @@ public infix fun LongArray.intersect(other: Iterable): Set { /** * Returns a set containing all elements that are contained by both this set and the specified collection. */ -public infix fun ShortArray.intersect(other: Iterable): Set { +public infix fun FloatArray.intersect(other: Iterable): Set { + val set = this.toMutableSet() + set.retainAll(other) + return set +} + +/** + * Returns a set containing all elements that are contained by both this set and the specified collection. + */ +public infix fun DoubleArray.intersect(other: Iterable): Set { + val set = this.toMutableSet() + set.retainAll(other) + return set +} + +/** + * Returns a set containing all elements that are contained by both this set and the specified collection. + */ +public infix fun BooleanArray.intersect(other: Iterable): Set { + val set = this.toMutableSet() + set.retainAll(other) + return set +} + +/** + * Returns a set containing all elements that are contained by both this set and the specified collection. + */ +public infix fun CharArray.intersect(other: Iterable): Set { val set = this.toMutableSet() set.retainAll(other) return set @@ -8206,15 +8206,6 @@ public infix fun Array.subtract(other: Iterable): Set { return set } -/** - * Returns a set containing all elements that are contained by this set and not contained by the specified collection. - */ -public infix fun BooleanArray.subtract(other: Iterable): Set { - val set = this.toMutableSet() - set.removeAll(other) - return set -} - /** * Returns a set containing all elements that are contained by this set and not contained by the specified collection. */ @@ -8227,25 +8218,7 @@ public infix fun ByteArray.subtract(other: Iterable): Set { /** * Returns a set containing all elements that are contained by this set and not contained by the specified collection. */ -public infix fun CharArray.subtract(other: Iterable): Set { - val set = this.toMutableSet() - set.removeAll(other) - return set -} - -/** - * Returns a set containing all elements that are contained by this set and not contained by the specified collection. - */ -public infix fun DoubleArray.subtract(other: Iterable): Set { - val set = this.toMutableSet() - set.removeAll(other) - return set -} - -/** - * Returns a set containing all elements that are contained by this set and not contained by the specified collection. - */ -public infix fun FloatArray.subtract(other: Iterable): Set { +public infix fun ShortArray.subtract(other: Iterable): Set { val set = this.toMutableSet() set.removeAll(other) return set @@ -8272,7 +8245,34 @@ public infix fun LongArray.subtract(other: Iterable): Set { /** * Returns a set containing all elements that are contained by this set and not contained by the specified collection. */ -public infix fun ShortArray.subtract(other: Iterable): Set { +public infix fun FloatArray.subtract(other: Iterable): Set { + val set = this.toMutableSet() + set.removeAll(other) + return set +} + +/** + * Returns a set containing all elements that are contained by this set and not contained by the specified collection. + */ +public infix fun DoubleArray.subtract(other: Iterable): Set { + val set = this.toMutableSet() + set.removeAll(other) + return set +} + +/** + * Returns a set containing all elements that are contained by this set and not contained by the specified collection. + */ +public infix fun BooleanArray.subtract(other: Iterable): Set { + val set = this.toMutableSet() + set.removeAll(other) + return set +} + +/** + * Returns a set containing all elements that are contained by this set and not contained by the specified collection. + */ +public infix fun CharArray.subtract(other: Iterable): Set { val set = this.toMutableSet() set.removeAll(other) return set @@ -8287,15 +8287,6 @@ public fun Array.toMutableSet(): MutableSet { return set } -/** - * Returns a mutable set containing all distinct elements from the given array. - */ -public fun BooleanArray.toMutableSet(): MutableSet { - val set = LinkedHashSet(mapCapacity(size)) - for (item in this) set.add(item) - return set -} - /** * Returns a mutable set containing all distinct elements from the given array. */ @@ -8308,26 +8299,8 @@ public fun ByteArray.toMutableSet(): MutableSet { /** * Returns a mutable set containing all distinct elements from the given array. */ -public fun CharArray.toMutableSet(): MutableSet { - val set = LinkedHashSet(mapCapacity(size)) - for (item in this) set.add(item) - return set -} - -/** - * Returns a mutable set containing all distinct elements from the given array. - */ -public fun DoubleArray.toMutableSet(): MutableSet { - val set = LinkedHashSet(mapCapacity(size)) - for (item in this) set.add(item) - return set -} - -/** - * Returns a mutable set containing all distinct elements from the given array. - */ -public fun FloatArray.toMutableSet(): MutableSet { - val set = LinkedHashSet(mapCapacity(size)) +public fun ShortArray.toMutableSet(): MutableSet { + val set = LinkedHashSet(mapCapacity(size)) for (item in this) set.add(item) return set } @@ -8353,8 +8326,35 @@ public fun LongArray.toMutableSet(): MutableSet { /** * Returns a mutable set containing all distinct elements from the given array. */ -public fun ShortArray.toMutableSet(): MutableSet { - val set = LinkedHashSet(mapCapacity(size)) +public fun FloatArray.toMutableSet(): MutableSet { + val set = LinkedHashSet(mapCapacity(size)) + for (item in this) set.add(item) + return set +} + +/** + * Returns a mutable set containing all distinct elements from the given array. + */ +public fun DoubleArray.toMutableSet(): MutableSet { + val set = LinkedHashSet(mapCapacity(size)) + for (item in this) set.add(item) + return set +} + +/** + * Returns a mutable set containing all distinct elements from the given array. + */ +public fun BooleanArray.toMutableSet(): MutableSet { + val set = LinkedHashSet(mapCapacity(size)) + for (item in this) set.add(item) + return set +} + +/** + * Returns a mutable set containing all distinct elements from the given array. + */ +public fun CharArray.toMutableSet(): MutableSet { + val set = LinkedHashSet(mapCapacity(size)) for (item in this) set.add(item) return set } @@ -8368,15 +8368,6 @@ public infix fun Array.union(other: Iterable): Set { return set } -/** - * Returns a set containing all distinct elements from both collections. - */ -public infix fun BooleanArray.union(other: Iterable): Set { - val set = this.toMutableSet() - set.addAll(other) - return set -} - /** * Returns a set containing all distinct elements from both collections. */ @@ -8389,25 +8380,7 @@ public infix fun ByteArray.union(other: Iterable): Set { /** * Returns a set containing all distinct elements from both collections. */ -public infix fun CharArray.union(other: Iterable): Set { - val set = this.toMutableSet() - set.addAll(other) - return set -} - -/** - * Returns a set containing all distinct elements from both collections. - */ -public infix fun DoubleArray.union(other: Iterable): Set { - val set = this.toMutableSet() - set.addAll(other) - return set -} - -/** - * Returns a set containing all distinct elements from both collections. - */ -public infix fun FloatArray.union(other: Iterable): Set { +public infix fun ShortArray.union(other: Iterable): Set { val set = this.toMutableSet() set.addAll(other) return set @@ -8434,7 +8407,34 @@ public infix fun LongArray.union(other: Iterable): Set { /** * Returns a set containing all distinct elements from both collections. */ -public infix fun ShortArray.union(other: Iterable): Set { +public infix fun FloatArray.union(other: Iterable): Set { + val set = this.toMutableSet() + set.addAll(other) + return set +} + +/** + * Returns a set containing all distinct elements from both collections. + */ +public infix fun DoubleArray.union(other: Iterable): Set { + val set = this.toMutableSet() + set.addAll(other) + return set +} + +/** + * Returns a set containing all distinct elements from both collections. + */ +public infix fun BooleanArray.union(other: Iterable): Set { + val set = this.toMutableSet() + set.addAll(other) + return set +} + +/** + * Returns a set containing all distinct elements from both collections. + */ +public infix fun CharArray.union(other: Iterable): Set { val set = this.toMutableSet() set.addAll(other) return set @@ -8448,14 +8448,6 @@ public inline fun Array.all(predicate: (T) -> Boolean): Boolean { return true } -/** - * Returns `true` if all elements match the given [predicate]. - */ -public inline fun BooleanArray.all(predicate: (Boolean) -> Boolean): Boolean { - for (element in this) if (!predicate(element)) return false - return true -} - /** * Returns `true` if all elements match the given [predicate]. */ @@ -8467,23 +8459,7 @@ public inline fun ByteArray.all(predicate: (Byte) -> Boolean): Boolean { /** * Returns `true` if all elements match the given [predicate]. */ -public inline fun CharArray.all(predicate: (Char) -> Boolean): Boolean { - for (element in this) if (!predicate(element)) return false - return true -} - -/** - * Returns `true` if all elements match the given [predicate]. - */ -public inline fun DoubleArray.all(predicate: (Double) -> Boolean): Boolean { - for (element in this) if (!predicate(element)) return false - return true -} - -/** - * Returns `true` if all elements match the given [predicate]. - */ -public inline fun FloatArray.all(predicate: (Float) -> Boolean): Boolean { +public inline fun ShortArray.all(predicate: (Short) -> Boolean): Boolean { for (element in this) if (!predicate(element)) return false return true } @@ -8507,7 +8483,31 @@ public inline fun LongArray.all(predicate: (Long) -> Boolean): Boolean { /** * Returns `true` if all elements match the given [predicate]. */ -public inline fun ShortArray.all(predicate: (Short) -> Boolean): Boolean { +public inline fun FloatArray.all(predicate: (Float) -> Boolean): Boolean { + for (element in this) if (!predicate(element)) return false + return true +} + +/** + * Returns `true` if all elements match the given [predicate]. + */ +public inline fun DoubleArray.all(predicate: (Double) -> Boolean): Boolean { + for (element in this) if (!predicate(element)) return false + return true +} + +/** + * Returns `true` if all elements match the given [predicate]. + */ +public inline fun BooleanArray.all(predicate: (Boolean) -> Boolean): Boolean { + for (element in this) if (!predicate(element)) return false + return true +} + +/** + * Returns `true` if all elements match the given [predicate]. + */ +public inline fun CharArray.all(predicate: (Char) -> Boolean): Boolean { for (element in this) if (!predicate(element)) return false return true } @@ -8520,14 +8520,6 @@ public fun Array.any(): Boolean { return false } -/** - * Returns `true` if array has at least one element. - */ -public fun BooleanArray.any(): Boolean { - for (element in this) return true - return false -} - /** * Returns `true` if array has at least one element. */ @@ -8539,23 +8531,7 @@ public fun ByteArray.any(): Boolean { /** * Returns `true` if array has at least one element. */ -public fun CharArray.any(): Boolean { - for (element in this) return true - return false -} - -/** - * Returns `true` if array has at least one element. - */ -public fun DoubleArray.any(): Boolean { - for (element in this) return true - return false -} - -/** - * Returns `true` if array has at least one element. - */ -public fun FloatArray.any(): Boolean { +public fun ShortArray.any(): Boolean { for (element in this) return true return false } @@ -8579,7 +8555,31 @@ public fun LongArray.any(): Boolean { /** * Returns `true` if array has at least one element. */ -public fun ShortArray.any(): Boolean { +public fun FloatArray.any(): Boolean { + for (element in this) return true + return false +} + +/** + * Returns `true` if array has at least one element. + */ +public fun DoubleArray.any(): Boolean { + for (element in this) return true + return false +} + +/** + * Returns `true` if array has at least one element. + */ +public fun BooleanArray.any(): Boolean { + for (element in this) return true + return false +} + +/** + * Returns `true` if array has at least one element. + */ +public fun CharArray.any(): Boolean { for (element in this) return true return false } @@ -8592,14 +8592,6 @@ public inline fun Array.any(predicate: (T) -> Boolean): Boolean { return false } -/** - * Returns `true` if at least one element matches the given [predicate]. - */ -public inline fun BooleanArray.any(predicate: (Boolean) -> Boolean): Boolean { - for (element in this) if (predicate(element)) return true - return false -} - /** * Returns `true` if at least one element matches the given [predicate]. */ @@ -8611,23 +8603,7 @@ public inline fun ByteArray.any(predicate: (Byte) -> Boolean): Boolean { /** * Returns `true` if at least one element matches the given [predicate]. */ -public inline fun CharArray.any(predicate: (Char) -> Boolean): Boolean { - for (element in this) if (predicate(element)) return true - return false -} - -/** - * Returns `true` if at least one element matches the given [predicate]. - */ -public inline fun DoubleArray.any(predicate: (Double) -> Boolean): Boolean { - for (element in this) if (predicate(element)) return true - return false -} - -/** - * Returns `true` if at least one element matches the given [predicate]. - */ -public inline fun FloatArray.any(predicate: (Float) -> Boolean): Boolean { +public inline fun ShortArray.any(predicate: (Short) -> Boolean): Boolean { for (element in this) if (predicate(element)) return true return false } @@ -8651,7 +8627,31 @@ public inline fun LongArray.any(predicate: (Long) -> Boolean): Boolean { /** * Returns `true` if at least one element matches the given [predicate]. */ -public inline fun ShortArray.any(predicate: (Short) -> Boolean): Boolean { +public inline fun FloatArray.any(predicate: (Float) -> Boolean): Boolean { + for (element in this) if (predicate(element)) return true + return false +} + +/** + * Returns `true` if at least one element matches the given [predicate]. + */ +public inline fun DoubleArray.any(predicate: (Double) -> Boolean): Boolean { + for (element in this) if (predicate(element)) return true + return false +} + +/** + * Returns `true` if at least one element matches the given [predicate]. + */ +public inline fun BooleanArray.any(predicate: (Boolean) -> Boolean): Boolean { + for (element in this) if (predicate(element)) return true + return false +} + +/** + * Returns `true` if at least one element matches the given [predicate]. + */ +public inline fun CharArray.any(predicate: (Char) -> Boolean): Boolean { for (element in this) if (predicate(element)) return true return false } @@ -8664,14 +8664,6 @@ public inline fun Array.count(): Int { return size } -/** - * Returns the number of elements in this array. - */ -@kotlin.internal.InlineOnly -public inline fun BooleanArray.count(): Int { - return size -} - /** * Returns the number of elements in this array. */ @@ -8684,23 +8676,7 @@ public inline fun ByteArray.count(): Int { * Returns the number of elements in this array. */ @kotlin.internal.InlineOnly -public inline fun CharArray.count(): Int { - return size -} - -/** - * Returns the number of elements in this array. - */ -@kotlin.internal.InlineOnly -public inline fun DoubleArray.count(): Int { - return size -} - -/** - * Returns the number of elements in this array. - */ -@kotlin.internal.InlineOnly -public inline fun FloatArray.count(): Int { +public inline fun ShortArray.count(): Int { return size } @@ -8724,7 +8700,31 @@ public inline fun LongArray.count(): Int { * Returns the number of elements in this array. */ @kotlin.internal.InlineOnly -public inline fun ShortArray.count(): Int { +public inline fun FloatArray.count(): Int { + return size +} + +/** + * Returns the number of elements in this array. + */ +@kotlin.internal.InlineOnly +public inline fun DoubleArray.count(): Int { + return size +} + +/** + * Returns the number of elements in this array. + */ +@kotlin.internal.InlineOnly +public inline fun BooleanArray.count(): Int { + return size +} + +/** + * Returns the number of elements in this array. + */ +@kotlin.internal.InlineOnly +public inline fun CharArray.count(): Int { return size } @@ -8737,15 +8737,6 @@ public inline fun Array.count(predicate: (T) -> Boolean): Int { return count } -/** - * Returns the number of elements matching the given [predicate]. - */ -public inline fun BooleanArray.count(predicate: (Boolean) -> Boolean): Int { - var count = 0 - for (element in this) if (predicate(element)) count++ - return count -} - /** * Returns the number of elements matching the given [predicate]. */ @@ -8758,25 +8749,7 @@ public inline fun ByteArray.count(predicate: (Byte) -> Boolean): Int { /** * Returns the number of elements matching the given [predicate]. */ -public inline fun CharArray.count(predicate: (Char) -> Boolean): Int { - var count = 0 - for (element in this) if (predicate(element)) count++ - return count -} - -/** - * Returns the number of elements matching the given [predicate]. - */ -public inline fun DoubleArray.count(predicate: (Double) -> Boolean): Int { - var count = 0 - for (element in this) if (predicate(element)) count++ - return count -} - -/** - * Returns the number of elements matching the given [predicate]. - */ -public inline fun FloatArray.count(predicate: (Float) -> Boolean): Int { +public inline fun ShortArray.count(predicate: (Short) -> Boolean): Int { var count = 0 for (element in this) if (predicate(element)) count++ return count @@ -8803,7 +8776,34 @@ public inline fun LongArray.count(predicate: (Long) -> Boolean): Int { /** * Returns the number of elements matching the given [predicate]. */ -public inline fun ShortArray.count(predicate: (Short) -> Boolean): Int { +public inline fun FloatArray.count(predicate: (Float) -> Boolean): Int { + var count = 0 + for (element in this) if (predicate(element)) count++ + return count +} + +/** + * Returns the number of elements matching the given [predicate]. + */ +public inline fun DoubleArray.count(predicate: (Double) -> Boolean): Int { + var count = 0 + for (element in this) if (predicate(element)) count++ + return count +} + +/** + * Returns the number of elements matching the given [predicate]. + */ +public inline fun BooleanArray.count(predicate: (Boolean) -> Boolean): Int { + var count = 0 + for (element in this) if (predicate(element)) count++ + return count +} + +/** + * Returns the number of elements matching the given [predicate]. + */ +public inline fun CharArray.count(predicate: (Char) -> Boolean): Int { var count = 0 for (element in this) if (predicate(element)) count++ return count @@ -8818,15 +8818,6 @@ public inline fun Array.fold(initial: R, operation: (R, T) -> R): return accumulator } -/** - * Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element. - */ -public inline fun BooleanArray.fold(initial: R, operation: (R, Boolean) -> R): R { - var accumulator = initial - for (element in this) accumulator = operation(accumulator, element) - return accumulator -} - /** * Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element. */ @@ -8839,25 +8830,7 @@ public inline fun ByteArray.fold(initial: R, operation: (R, Byte) -> R): R { /** * Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element. */ -public inline fun CharArray.fold(initial: R, operation: (R, Char) -> R): R { - var accumulator = initial - for (element in this) accumulator = operation(accumulator, element) - return accumulator -} - -/** - * Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element. - */ -public inline fun DoubleArray.fold(initial: R, operation: (R, Double) -> R): R { - var accumulator = initial - for (element in this) accumulator = operation(accumulator, element) - return accumulator -} - -/** - * Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element. - */ -public inline fun FloatArray.fold(initial: R, operation: (R, Float) -> R): R { +public inline fun ShortArray.fold(initial: R, operation: (R, Short) -> R): R { var accumulator = initial for (element in this) accumulator = operation(accumulator, element) return accumulator @@ -8884,7 +8857,34 @@ public inline fun LongArray.fold(initial: R, operation: (R, Long) -> R): R { /** * Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element. */ -public inline fun ShortArray.fold(initial: R, operation: (R, Short) -> R): R { +public inline fun FloatArray.fold(initial: R, operation: (R, Float) -> R): R { + var accumulator = initial + for (element in this) accumulator = operation(accumulator, element) + return accumulator +} + +/** + * Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element. + */ +public inline fun DoubleArray.fold(initial: R, operation: (R, Double) -> R): R { + var accumulator = initial + for (element in this) accumulator = operation(accumulator, element) + return accumulator +} + +/** + * Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element. + */ +public inline fun BooleanArray.fold(initial: R, operation: (R, Boolean) -> R): R { + var accumulator = initial + for (element in this) accumulator = operation(accumulator, element) + return accumulator +} + +/** + * Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element. + */ +public inline fun CharArray.fold(initial: R, operation: (R, Char) -> R): R { var accumulator = initial for (element in this) accumulator = operation(accumulator, element) return accumulator @@ -8901,17 +8901,6 @@ public inline fun Array.foldIndexed(initial: R, operation: (Int, R return accumulator } -/** - * Accumulates value starting with [initial] value and applying [operation] from left to right - * to current accumulator value and each element with its index in the original array. - */ -public inline fun BooleanArray.foldIndexed(initial: R, operation: (Int, R, Boolean) -> R): R { - var index = 0 - var accumulator = initial - for (element in this) accumulator = operation(index++, accumulator, element) - return accumulator -} - /** * Accumulates value starting with [initial] value and applying [operation] from left to right * to current accumulator value and each element with its index in the original array. @@ -8927,29 +8916,7 @@ public inline fun ByteArray.foldIndexed(initial: R, operation: (Int, R, Byte * Accumulates value starting with [initial] value and applying [operation] from left to right * to current accumulator value and each element with its index in the original array. */ -public inline fun CharArray.foldIndexed(initial: R, operation: (Int, R, Char) -> R): R { - var index = 0 - var accumulator = initial - for (element in this) accumulator = operation(index++, accumulator, element) - return accumulator -} - -/** - * Accumulates value starting with [initial] value and applying [operation] from left to right - * to current accumulator value and each element with its index in the original array. - */ -public inline fun DoubleArray.foldIndexed(initial: R, operation: (Int, R, Double) -> R): R { - var index = 0 - var accumulator = initial - for (element in this) accumulator = operation(index++, accumulator, element) - return accumulator -} - -/** - * Accumulates value starting with [initial] value and applying [operation] from left to right - * to current accumulator value and each element with its index in the original array. - */ -public inline fun FloatArray.foldIndexed(initial: R, operation: (Int, R, Float) -> R): R { +public inline fun ShortArray.foldIndexed(initial: R, operation: (Int, R, Short) -> R): R { var index = 0 var accumulator = initial for (element in this) accumulator = operation(index++, accumulator, element) @@ -8982,7 +8949,40 @@ public inline fun LongArray.foldIndexed(initial: R, operation: (Int, R, Long * Accumulates value starting with [initial] value and applying [operation] from left to right * to current accumulator value and each element with its index in the original array. */ -public inline fun ShortArray.foldIndexed(initial: R, operation: (Int, R, Short) -> R): R { +public inline fun FloatArray.foldIndexed(initial: R, operation: (Int, R, Float) -> R): R { + var index = 0 + var accumulator = initial + for (element in this) accumulator = operation(index++, accumulator, element) + return accumulator +} + +/** + * Accumulates value starting with [initial] value and applying [operation] from left to right + * to current accumulator value and each element with its index in the original array. + */ +public inline fun DoubleArray.foldIndexed(initial: R, operation: (Int, R, Double) -> R): R { + var index = 0 + var accumulator = initial + for (element in this) accumulator = operation(index++, accumulator, element) + return accumulator +} + +/** + * Accumulates value starting with [initial] value and applying [operation] from left to right + * to current accumulator value and each element with its index in the original array. + */ +public inline fun BooleanArray.foldIndexed(initial: R, operation: (Int, R, Boolean) -> R): R { + var index = 0 + var accumulator = initial + for (element in this) accumulator = operation(index++, accumulator, element) + return accumulator +} + +/** + * Accumulates value starting with [initial] value and applying [operation] from left to right + * to current accumulator value and each element with its index in the original array. + */ +public inline fun CharArray.foldIndexed(initial: R, operation: (Int, R, Char) -> R): R { var index = 0 var accumulator = initial for (element in this) accumulator = operation(index++, accumulator, element) @@ -9001,18 +9001,6 @@ public inline fun Array.foldRight(initial: R, operation: (T, R) -> return accumulator } -/** - * Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value. - */ -public inline fun BooleanArray.foldRight(initial: R, operation: (Boolean, R) -> R): R { - var index = lastIndex - var accumulator = initial - while (index >= 0) { - accumulator = operation(get(index--), accumulator) - } - return accumulator -} - /** * Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value. */ @@ -9028,31 +9016,7 @@ public inline fun ByteArray.foldRight(initial: R, operation: (Byte, R) -> R) /** * Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value. */ -public inline fun CharArray.foldRight(initial: R, operation: (Char, R) -> R): R { - var index = lastIndex - var accumulator = initial - while (index >= 0) { - accumulator = operation(get(index--), accumulator) - } - return accumulator -} - -/** - * Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value. - */ -public inline fun DoubleArray.foldRight(initial: R, operation: (Double, R) -> R): R { - var index = lastIndex - var accumulator = initial - while (index >= 0) { - accumulator = operation(get(index--), accumulator) - } - return accumulator -} - -/** - * Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value. - */ -public inline fun FloatArray.foldRight(initial: R, operation: (Float, R) -> R): R { +public inline fun ShortArray.foldRight(initial: R, operation: (Short, R) -> R): R { var index = lastIndex var accumulator = initial while (index >= 0) { @@ -9088,7 +9052,43 @@ public inline fun LongArray.foldRight(initial: R, operation: (Long, R) -> R) /** * Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value. */ -public inline fun ShortArray.foldRight(initial: R, operation: (Short, R) -> R): R { +public inline fun FloatArray.foldRight(initial: R, operation: (Float, R) -> R): R { + var index = lastIndex + var accumulator = initial + while (index >= 0) { + accumulator = operation(get(index--), accumulator) + } + return accumulator +} + +/** + * Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value. + */ +public inline fun DoubleArray.foldRight(initial: R, operation: (Double, R) -> R): R { + var index = lastIndex + var accumulator = initial + while (index >= 0) { + accumulator = operation(get(index--), accumulator) + } + return accumulator +} + +/** + * Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value. + */ +public inline fun BooleanArray.foldRight(initial: R, operation: (Boolean, R) -> R): R { + var index = lastIndex + var accumulator = initial + while (index >= 0) { + accumulator = operation(get(index--), accumulator) + } + return accumulator +} + +/** + * Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value. + */ +public inline fun CharArray.foldRight(initial: R, operation: (Char, R) -> R): R { var index = lastIndex var accumulator = initial while (index >= 0) { @@ -9111,20 +9111,6 @@ public inline fun Array.foldRightIndexed(initial: R, operation: (I return accumulator } -/** - * Accumulates value starting with [initial] value and applying [operation] from right to left - * to each element with its index in the original array and current accumulator value. - */ -public inline fun BooleanArray.foldRightIndexed(initial: R, operation: (Int, Boolean, R) -> R): R { - var index = lastIndex - var accumulator = initial - while (index >= 0) { - accumulator = operation(index, get(index), accumulator) - --index - } - return accumulator -} - /** * Accumulates value starting with [initial] value and applying [operation] from right to left * to each element with its index in the original array and current accumulator value. @@ -9143,35 +9129,7 @@ public inline fun ByteArray.foldRightIndexed(initial: R, operation: (Int, By * Accumulates value starting with [initial] value and applying [operation] from right to left * to each element with its index in the original array and current accumulator value. */ -public inline fun CharArray.foldRightIndexed(initial: R, operation: (Int, Char, R) -> R): R { - var index = lastIndex - var accumulator = initial - while (index >= 0) { - accumulator = operation(index, get(index), accumulator) - --index - } - return accumulator -} - -/** - * Accumulates value starting with [initial] value and applying [operation] from right to left - * to each element with its index in the original array and current accumulator value. - */ -public inline fun DoubleArray.foldRightIndexed(initial: R, operation: (Int, Double, R) -> R): R { - var index = lastIndex - var accumulator = initial - while (index >= 0) { - accumulator = operation(index, get(index), accumulator) - --index - } - return accumulator -} - -/** - * Accumulates value starting with [initial] value and applying [operation] from right to left - * to each element with its index in the original array and current accumulator value. - */ -public inline fun FloatArray.foldRightIndexed(initial: R, operation: (Int, Float, R) -> R): R { +public inline fun ShortArray.foldRightIndexed(initial: R, operation: (Int, Short, R) -> R): R { var index = lastIndex var accumulator = initial while (index >= 0) { @@ -9213,7 +9171,49 @@ public inline fun LongArray.foldRightIndexed(initial: R, operation: (Int, Lo * Accumulates value starting with [initial] value and applying [operation] from right to left * to each element with its index in the original array and current accumulator value. */ -public inline fun ShortArray.foldRightIndexed(initial: R, operation: (Int, Short, R) -> R): R { +public inline fun FloatArray.foldRightIndexed(initial: R, operation: (Int, Float, R) -> R): R { + var index = lastIndex + var accumulator = initial + while (index >= 0) { + accumulator = operation(index, get(index), accumulator) + --index + } + return accumulator +} + +/** + * Accumulates value starting with [initial] value and applying [operation] from right to left + * to each element with its index in the original array and current accumulator value. + */ +public inline fun DoubleArray.foldRightIndexed(initial: R, operation: (Int, Double, R) -> R): R { + var index = lastIndex + var accumulator = initial + while (index >= 0) { + accumulator = operation(index, get(index), accumulator) + --index + } + return accumulator +} + +/** + * Accumulates value starting with [initial] value and applying [operation] from right to left + * to each element with its index in the original array and current accumulator value. + */ +public inline fun BooleanArray.foldRightIndexed(initial: R, operation: (Int, Boolean, R) -> R): R { + var index = lastIndex + var accumulator = initial + while (index >= 0) { + accumulator = operation(index, get(index), accumulator) + --index + } + return accumulator +} + +/** + * Accumulates value starting with [initial] value and applying [operation] from right to left + * to each element with its index in the original array and current accumulator value. + */ +public inline fun CharArray.foldRightIndexed(initial: R, operation: (Int, Char, R) -> R): R { var index = lastIndex var accumulator = initial while (index >= 0) { @@ -9230,13 +9230,6 @@ public inline fun Array.forEach(action: (T) -> Unit): Unit { for (element in this) action(element) } -/** - * Performs the given [action] on each element. - */ -public inline fun BooleanArray.forEach(action: (Boolean) -> Unit): Unit { - for (element in this) action(element) -} - /** * Performs the given [action] on each element. */ @@ -9247,21 +9240,7 @@ public inline fun ByteArray.forEach(action: (Byte) -> Unit): Unit { /** * Performs the given [action] on each element. */ -public inline fun CharArray.forEach(action: (Char) -> Unit): Unit { - for (element in this) action(element) -} - -/** - * Performs the given [action] on each element. - */ -public inline fun DoubleArray.forEach(action: (Double) -> Unit): Unit { - for (element in this) action(element) -} - -/** - * Performs the given [action] on each element. - */ -public inline fun FloatArray.forEach(action: (Float) -> Unit): Unit { +public inline fun ShortArray.forEach(action: (Short) -> Unit): Unit { for (element in this) action(element) } @@ -9282,7 +9261,28 @@ public inline fun LongArray.forEach(action: (Long) -> Unit): Unit { /** * Performs the given [action] on each element. */ -public inline fun ShortArray.forEach(action: (Short) -> Unit): Unit { +public inline fun FloatArray.forEach(action: (Float) -> Unit): Unit { + for (element in this) action(element) +} + +/** + * Performs the given [action] on each element. + */ +public inline fun DoubleArray.forEach(action: (Double) -> Unit): Unit { + for (element in this) action(element) +} + +/** + * Performs the given [action] on each element. + */ +public inline fun BooleanArray.forEach(action: (Boolean) -> Unit): Unit { + for (element in this) action(element) +} + +/** + * Performs the given [action] on each element. + */ +public inline fun CharArray.forEach(action: (Char) -> Unit): Unit { for (element in this) action(element) } @@ -9294,14 +9294,6 @@ public inline fun Array.forEachIndexed(action: (Int, T) -> Unit): Uni for (item in this) action(index++, item) } -/** - * Performs the given [action] on each element, providing sequential index with the element. - */ -public inline fun BooleanArray.forEachIndexed(action: (Int, Boolean) -> Unit): Unit { - var index = 0 - for (item in this) action(index++, item) -} - /** * Performs the given [action] on each element, providing sequential index with the element. */ @@ -9313,23 +9305,7 @@ public inline fun ByteArray.forEachIndexed(action: (Int, Byte) -> Unit): Unit { /** * Performs the given [action] on each element, providing sequential index with the element. */ -public inline fun CharArray.forEachIndexed(action: (Int, Char) -> Unit): Unit { - var index = 0 - for (item in this) action(index++, item) -} - -/** - * Performs the given [action] on each element, providing sequential index with the element. - */ -public inline fun DoubleArray.forEachIndexed(action: (Int, Double) -> Unit): Unit { - var index = 0 - for (item in this) action(index++, item) -} - -/** - * Performs the given [action] on each element, providing sequential index with the element. - */ -public inline fun FloatArray.forEachIndexed(action: (Int, Float) -> Unit): Unit { +public inline fun ShortArray.forEachIndexed(action: (Int, Short) -> Unit): Unit { var index = 0 for (item in this) action(index++, item) } @@ -9353,7 +9329,31 @@ public inline fun LongArray.forEachIndexed(action: (Int, Long) -> Unit): Unit { /** * Performs the given [action] on each element, providing sequential index with the element. */ -public inline fun ShortArray.forEachIndexed(action: (Int, Short) -> Unit): Unit { +public inline fun FloatArray.forEachIndexed(action: (Int, Float) -> Unit): Unit { + var index = 0 + for (item in this) action(index++, item) +} + +/** + * Performs the given [action] on each element, providing sequential index with the element. + */ +public inline fun DoubleArray.forEachIndexed(action: (Int, Double) -> Unit): Unit { + var index = 0 + for (item in this) action(index++, item) +} + +/** + * Performs the given [action] on each element, providing sequential index with the element. + */ +public inline fun BooleanArray.forEachIndexed(action: (Int, Boolean) -> Unit): Unit { + var index = 0 + for (item in this) action(index++, item) +} + +/** + * Performs the given [action] on each element, providing sequential index with the element. + */ +public inline fun CharArray.forEachIndexed(action: (Int, Char) -> Unit): Unit { var index = 0 for (item in this) action(index++, item) } @@ -9387,33 +9387,7 @@ public fun ByteArray.max(): Byte? { /** * Returns the largest element or `null` if there are no elements. */ -public fun CharArray.max(): Char? { - if (isEmpty()) return null - var max = this[0] - for (i in 1..lastIndex) { - val e = this[i] - if (max < e) max = e - } - return max -} - -/** - * Returns the largest element or `null` if there are no elements. - */ -public fun DoubleArray.max(): Double? { - if (isEmpty()) return null - var max = this[0] - for (i in 1..lastIndex) { - val e = this[i] - if (max < e) max = e - } - return max -} - -/** - * Returns the largest element or `null` if there are no elements. - */ -public fun FloatArray.max(): Float? { +public fun ShortArray.max(): Short? { if (isEmpty()) return null var max = this[0] for (i in 1..lastIndex) { @@ -9452,7 +9426,33 @@ public fun LongArray.max(): Long? { /** * Returns the largest element or `null` if there are no elements. */ -public fun ShortArray.max(): Short? { +public fun FloatArray.max(): Float? { + if (isEmpty()) return null + var max = this[0] + for (i in 1..lastIndex) { + val e = this[i] + if (max < e) max = e + } + return max +} + +/** + * Returns the largest element or `null` if there are no elements. + */ +public fun DoubleArray.max(): Double? { + if (isEmpty()) return null + var max = this[0] + for (i in 1..lastIndex) { + val e = this[i] + if (max < e) max = e + } + return max +} + +/** + * Returns the largest element or `null` if there are no elements. + */ +public fun CharArray.max(): Char? { if (isEmpty()) return null var max = this[0] for (i in 1..lastIndex) { @@ -9480,24 +9480,6 @@ public inline fun > Array.maxBy(selector: (T) -> R): return maxElem } -/** - * Returns the first element yielding the largest value of the given function or `null` if there are no elements. - */ -public inline fun > BooleanArray.maxBy(selector: (Boolean) -> R): Boolean? { - if (isEmpty()) return null - var maxElem = this[0] - var maxValue = selector(maxElem) - for (i in 1..lastIndex) { - val e = this[i] - val v = selector(e) - if (maxValue < v) { - maxElem = e - maxValue = v - } - } - return maxElem -} - /** * Returns the first element yielding the largest value of the given function or `null` if there are no elements. */ @@ -9519,43 +9501,7 @@ public inline fun > ByteArray.maxBy(selector: (Byte) -> R): By /** * Returns the first element yielding the largest value of the given function or `null` if there are no elements. */ -public inline fun > CharArray.maxBy(selector: (Char) -> R): Char? { - if (isEmpty()) return null - var maxElem = this[0] - var maxValue = selector(maxElem) - for (i in 1..lastIndex) { - val e = this[i] - val v = selector(e) - if (maxValue < v) { - maxElem = e - maxValue = v - } - } - return maxElem -} - -/** - * Returns the first element yielding the largest value of the given function or `null` if there are no elements. - */ -public inline fun > DoubleArray.maxBy(selector: (Double) -> R): Double? { - if (isEmpty()) return null - var maxElem = this[0] - var maxValue = selector(maxElem) - for (i in 1..lastIndex) { - val e = this[i] - val v = selector(e) - if (maxValue < v) { - maxElem = e - maxValue = v - } - } - return maxElem -} - -/** - * Returns the first element yielding the largest value of the given function or `null` if there are no elements. - */ -public inline fun > FloatArray.maxBy(selector: (Float) -> R): Float? { +public inline fun > ShortArray.maxBy(selector: (Short) -> R): Short? { if (isEmpty()) return null var maxElem = this[0] var maxValue = selector(maxElem) @@ -9609,7 +9555,61 @@ public inline fun > LongArray.maxBy(selector: (Long) -> R): Lo /** * Returns the first element yielding the largest value of the given function or `null` if there are no elements. */ -public inline fun > ShortArray.maxBy(selector: (Short) -> R): Short? { +public inline fun > FloatArray.maxBy(selector: (Float) -> R): Float? { + if (isEmpty()) return null + var maxElem = this[0] + var maxValue = selector(maxElem) + for (i in 1..lastIndex) { + val e = this[i] + val v = selector(e) + if (maxValue < v) { + maxElem = e + maxValue = v + } + } + return maxElem +} + +/** + * Returns the first element yielding the largest value of the given function or `null` if there are no elements. + */ +public inline fun > DoubleArray.maxBy(selector: (Double) -> R): Double? { + if (isEmpty()) return null + var maxElem = this[0] + var maxValue = selector(maxElem) + for (i in 1..lastIndex) { + val e = this[i] + val v = selector(e) + if (maxValue < v) { + maxElem = e + maxValue = v + } + } + return maxElem +} + +/** + * Returns the first element yielding the largest value of the given function or `null` if there are no elements. + */ +public inline fun > BooleanArray.maxBy(selector: (Boolean) -> R): Boolean? { + if (isEmpty()) return null + var maxElem = this[0] + var maxValue = selector(maxElem) + for (i in 1..lastIndex) { + val e = this[i] + val v = selector(e) + if (maxValue < v) { + maxElem = e + maxValue = v + } + } + return maxElem +} + +/** + * Returns the first element yielding the largest value of the given function or `null` if there are no elements. + */ +public inline fun > CharArray.maxBy(selector: (Char) -> R): Char? { if (isEmpty()) return null var maxElem = this[0] var maxValue = selector(maxElem) @@ -9637,19 +9637,6 @@ public fun Array.maxWith(comparator: Comparator): T? { return max } -/** - * Returns the first element having the largest value according to the provided [comparator] or `null` if there are no elements. - */ -public fun BooleanArray.maxWith(comparator: Comparator): Boolean? { - if (isEmpty()) return null - var max = this[0] - for (i in 1..lastIndex) { - val e = this[i] - if (comparator.compare(max, e) < 0) max = e - } - return max -} - /** * Returns the first element having the largest value according to the provided [comparator] or `null` if there are no elements. */ @@ -9666,33 +9653,7 @@ public fun ByteArray.maxWith(comparator: Comparator): Byte? { /** * Returns the first element having the largest value according to the provided [comparator] or `null` if there are no elements. */ -public fun CharArray.maxWith(comparator: Comparator): Char? { - if (isEmpty()) return null - var max = this[0] - for (i in 1..lastIndex) { - val e = this[i] - if (comparator.compare(max, e) < 0) max = e - } - return max -} - -/** - * Returns the first element having the largest value according to the provided [comparator] or `null` if there are no elements. - */ -public fun DoubleArray.maxWith(comparator: Comparator): Double? { - if (isEmpty()) return null - var max = this[0] - for (i in 1..lastIndex) { - val e = this[i] - if (comparator.compare(max, e) < 0) max = e - } - return max -} - -/** - * Returns the first element having the largest value according to the provided [comparator] or `null` if there are no elements. - */ -public fun FloatArray.maxWith(comparator: Comparator): Float? { +public fun ShortArray.maxWith(comparator: Comparator): Short? { if (isEmpty()) return null var max = this[0] for (i in 1..lastIndex) { @@ -9731,7 +9692,46 @@ public fun LongArray.maxWith(comparator: Comparator): Long? { /** * Returns the first element having the largest value according to the provided [comparator] or `null` if there are no elements. */ -public fun ShortArray.maxWith(comparator: Comparator): Short? { +public fun FloatArray.maxWith(comparator: Comparator): Float? { + if (isEmpty()) return null + var max = this[0] + for (i in 1..lastIndex) { + val e = this[i] + if (comparator.compare(max, e) < 0) max = e + } + return max +} + +/** + * Returns the first element having the largest value according to the provided [comparator] or `null` if there are no elements. + */ +public fun DoubleArray.maxWith(comparator: Comparator): Double? { + if (isEmpty()) return null + var max = this[0] + for (i in 1..lastIndex) { + val e = this[i] + if (comparator.compare(max, e) < 0) max = e + } + return max +} + +/** + * Returns the first element having the largest value according to the provided [comparator] or `null` if there are no elements. + */ +public fun BooleanArray.maxWith(comparator: Comparator): Boolean? { + if (isEmpty()) return null + var max = this[0] + for (i in 1..lastIndex) { + val e = this[i] + if (comparator.compare(max, e) < 0) max = e + } + return max +} + +/** + * Returns the first element having the largest value according to the provided [comparator] or `null` if there are no elements. + */ +public fun CharArray.maxWith(comparator: Comparator): Char? { if (isEmpty()) return null var max = this[0] for (i in 1..lastIndex) { @@ -9770,33 +9770,7 @@ public fun ByteArray.min(): Byte? { /** * Returns the smallest element or `null` if there are no elements. */ -public fun CharArray.min(): Char? { - if (isEmpty()) return null - var min = this[0] - for (i in 1..lastIndex) { - val e = this[i] - if (min > e) min = e - } - return min -} - -/** - * Returns the smallest element or `null` if there are no elements. - */ -public fun DoubleArray.min(): Double? { - if (isEmpty()) return null - var min = this[0] - for (i in 1..lastIndex) { - val e = this[i] - if (min > e) min = e - } - return min -} - -/** - * Returns the smallest element or `null` if there are no elements. - */ -public fun FloatArray.min(): Float? { +public fun ShortArray.min(): Short? { if (isEmpty()) return null var min = this[0] for (i in 1..lastIndex) { @@ -9835,7 +9809,33 @@ public fun LongArray.min(): Long? { /** * Returns the smallest element or `null` if there are no elements. */ -public fun ShortArray.min(): Short? { +public fun FloatArray.min(): Float? { + if (isEmpty()) return null + var min = this[0] + for (i in 1..lastIndex) { + val e = this[i] + if (min > e) min = e + } + return min +} + +/** + * Returns the smallest element or `null` if there are no elements. + */ +public fun DoubleArray.min(): Double? { + if (isEmpty()) return null + var min = this[0] + for (i in 1..lastIndex) { + val e = this[i] + if (min > e) min = e + } + return min +} + +/** + * Returns the smallest element or `null` if there are no elements. + */ +public fun CharArray.min(): Char? { if (isEmpty()) return null var min = this[0] for (i in 1..lastIndex) { @@ -9863,24 +9863,6 @@ public inline fun > Array.minBy(selector: (T) -> R): return minElem } -/** - * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. - */ -public inline fun > BooleanArray.minBy(selector: (Boolean) -> R): Boolean? { - if (isEmpty()) return null - var minElem = this[0] - var minValue = selector(minElem) - for (i in 1..lastIndex) { - val e = this[i] - val v = selector(e) - if (minValue > v) { - minElem = e - minValue = v - } - } - return minElem -} - /** * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. */ @@ -9902,43 +9884,7 @@ public inline fun > ByteArray.minBy(selector: (Byte) -> R): By /** * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. */ -public inline fun > CharArray.minBy(selector: (Char) -> R): Char? { - if (isEmpty()) return null - var minElem = this[0] - var minValue = selector(minElem) - for (i in 1..lastIndex) { - val e = this[i] - val v = selector(e) - if (minValue > v) { - minElem = e - minValue = v - } - } - return minElem -} - -/** - * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. - */ -public inline fun > DoubleArray.minBy(selector: (Double) -> R): Double? { - if (isEmpty()) return null - var minElem = this[0] - var minValue = selector(minElem) - for (i in 1..lastIndex) { - val e = this[i] - val v = selector(e) - if (minValue > v) { - minElem = e - minValue = v - } - } - return minElem -} - -/** - * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. - */ -public inline fun > FloatArray.minBy(selector: (Float) -> R): Float? { +public inline fun > ShortArray.minBy(selector: (Short) -> R): Short? { if (isEmpty()) return null var minElem = this[0] var minValue = selector(minElem) @@ -9992,7 +9938,61 @@ public inline fun > LongArray.minBy(selector: (Long) -> R): Lo /** * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. */ -public inline fun > ShortArray.minBy(selector: (Short) -> R): Short? { +public inline fun > FloatArray.minBy(selector: (Float) -> R): Float? { + if (isEmpty()) return null + var minElem = this[0] + var minValue = selector(minElem) + for (i in 1..lastIndex) { + val e = this[i] + val v = selector(e) + if (minValue > v) { + minElem = e + minValue = v + } + } + return minElem +} + +/** + * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. + */ +public inline fun > DoubleArray.minBy(selector: (Double) -> R): Double? { + if (isEmpty()) return null + var minElem = this[0] + var minValue = selector(minElem) + for (i in 1..lastIndex) { + val e = this[i] + val v = selector(e) + if (minValue > v) { + minElem = e + minValue = v + } + } + return minElem +} + +/** + * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. + */ +public inline fun > BooleanArray.minBy(selector: (Boolean) -> R): Boolean? { + if (isEmpty()) return null + var minElem = this[0] + var minValue = selector(minElem) + for (i in 1..lastIndex) { + val e = this[i] + val v = selector(e) + if (minValue > v) { + minElem = e + minValue = v + } + } + return minElem +} + +/** + * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. + */ +public inline fun > CharArray.minBy(selector: (Char) -> R): Char? { if (isEmpty()) return null var minElem = this[0] var minValue = selector(minElem) @@ -10020,19 +10020,6 @@ public fun Array.minWith(comparator: Comparator): T? { return min } -/** - * Returns the first element having the smallest value according to the provided [comparator] or `null` if there are no elements. - */ -public fun BooleanArray.minWith(comparator: Comparator): Boolean? { - if (isEmpty()) return null - var min = this[0] - for (i in 1..lastIndex) { - val e = this[i] - if (comparator.compare(min, e) > 0) min = e - } - return min -} - /** * Returns the first element having the smallest value according to the provided [comparator] or `null` if there are no elements. */ @@ -10049,33 +10036,7 @@ public fun ByteArray.minWith(comparator: Comparator): Byte? { /** * Returns the first element having the smallest value according to the provided [comparator] or `null` if there are no elements. */ -public fun CharArray.minWith(comparator: Comparator): Char? { - if (isEmpty()) return null - var min = this[0] - for (i in 1..lastIndex) { - val e = this[i] - if (comparator.compare(min, e) > 0) min = e - } - return min -} - -/** - * Returns the first element having the smallest value according to the provided [comparator] or `null` if there are no elements. - */ -public fun DoubleArray.minWith(comparator: Comparator): Double? { - if (isEmpty()) return null - var min = this[0] - for (i in 1..lastIndex) { - val e = this[i] - if (comparator.compare(min, e) > 0) min = e - } - return min -} - -/** - * Returns the first element having the smallest value according to the provided [comparator] or `null` if there are no elements. - */ -public fun FloatArray.minWith(comparator: Comparator): Float? { +public fun ShortArray.minWith(comparator: Comparator): Short? { if (isEmpty()) return null var min = this[0] for (i in 1..lastIndex) { @@ -10114,7 +10075,46 @@ public fun LongArray.minWith(comparator: Comparator): Long? { /** * Returns the first element having the smallest value according to the provided [comparator] or `null` if there are no elements. */ -public fun ShortArray.minWith(comparator: Comparator): Short? { +public fun FloatArray.minWith(comparator: Comparator): Float? { + if (isEmpty()) return null + var min = this[0] + for (i in 1..lastIndex) { + val e = this[i] + if (comparator.compare(min, e) > 0) min = e + } + return min +} + +/** + * Returns the first element having the smallest value according to the provided [comparator] or `null` if there are no elements. + */ +public fun DoubleArray.minWith(comparator: Comparator): Double? { + if (isEmpty()) return null + var min = this[0] + for (i in 1..lastIndex) { + val e = this[i] + if (comparator.compare(min, e) > 0) min = e + } + return min +} + +/** + * Returns the first element having the smallest value according to the provided [comparator] or `null` if there are no elements. + */ +public fun BooleanArray.minWith(comparator: Comparator): Boolean? { + if (isEmpty()) return null + var min = this[0] + for (i in 1..lastIndex) { + val e = this[i] + if (comparator.compare(min, e) > 0) min = e + } + return min +} + +/** + * Returns the first element having the smallest value according to the provided [comparator] or `null` if there are no elements. + */ +public fun CharArray.minWith(comparator: Comparator): Char? { if (isEmpty()) return null var min = this[0] for (i in 1..lastIndex) { @@ -10132,14 +10132,6 @@ public fun Array.none(): Boolean { return true } -/** - * Returns `true` if the array has no elements. - */ -public fun BooleanArray.none(): Boolean { - for (element in this) return false - return true -} - /** * Returns `true` if the array has no elements. */ @@ -10151,23 +10143,7 @@ public fun ByteArray.none(): Boolean { /** * Returns `true` if the array has no elements. */ -public fun CharArray.none(): Boolean { - for (element in this) return false - return true -} - -/** - * Returns `true` if the array has no elements. - */ -public fun DoubleArray.none(): Boolean { - for (element in this) return false - return true -} - -/** - * Returns `true` if the array has no elements. - */ -public fun FloatArray.none(): Boolean { +public fun ShortArray.none(): Boolean { for (element in this) return false return true } @@ -10191,7 +10167,31 @@ public fun LongArray.none(): Boolean { /** * Returns `true` if the array has no elements. */ -public fun ShortArray.none(): Boolean { +public fun FloatArray.none(): Boolean { + for (element in this) return false + return true +} + +/** + * Returns `true` if the array has no elements. + */ +public fun DoubleArray.none(): Boolean { + for (element in this) return false + return true +} + +/** + * Returns `true` if the array has no elements. + */ +public fun BooleanArray.none(): Boolean { + for (element in this) return false + return true +} + +/** + * Returns `true` if the array has no elements. + */ +public fun CharArray.none(): Boolean { for (element in this) return false return true } @@ -10204,14 +10204,6 @@ public inline fun Array.none(predicate: (T) -> Boolean): Boolean { return true } -/** - * Returns `true` if no elements match the given [predicate]. - */ -public inline fun BooleanArray.none(predicate: (Boolean) -> Boolean): Boolean { - for (element in this) if (predicate(element)) return false - return true -} - /** * Returns `true` if no elements match the given [predicate]. */ @@ -10223,23 +10215,7 @@ public inline fun ByteArray.none(predicate: (Byte) -> Boolean): Boolean { /** * Returns `true` if no elements match the given [predicate]. */ -public inline fun CharArray.none(predicate: (Char) -> Boolean): Boolean { - for (element in this) if (predicate(element)) return false - return true -} - -/** - * Returns `true` if no elements match the given [predicate]. - */ -public inline fun DoubleArray.none(predicate: (Double) -> Boolean): Boolean { - for (element in this) if (predicate(element)) return false - return true -} - -/** - * Returns `true` if no elements match the given [predicate]. - */ -public inline fun FloatArray.none(predicate: (Float) -> Boolean): Boolean { +public inline fun ShortArray.none(predicate: (Short) -> Boolean): Boolean { for (element in this) if (predicate(element)) return false return true } @@ -10263,7 +10239,31 @@ public inline fun LongArray.none(predicate: (Long) -> Boolean): Boolean { /** * Returns `true` if no elements match the given [predicate]. */ -public inline fun ShortArray.none(predicate: (Short) -> Boolean): Boolean { +public inline fun FloatArray.none(predicate: (Float) -> Boolean): Boolean { + for (element in this) if (predicate(element)) return false + return true +} + +/** + * Returns `true` if no elements match the given [predicate]. + */ +public inline fun DoubleArray.none(predicate: (Double) -> Boolean): Boolean { + for (element in this) if (predicate(element)) return false + return true +} + +/** + * Returns `true` if no elements match the given [predicate]. + */ +public inline fun BooleanArray.none(predicate: (Boolean) -> Boolean): Boolean { + for (element in this) if (predicate(element)) return false + return true +} + +/** + * Returns `true` if no elements match the given [predicate]. + */ +public inline fun CharArray.none(predicate: (Char) -> Boolean): Boolean { for (element in this) if (predicate(element)) return false return true } @@ -10281,19 +10281,6 @@ public inline fun Array.reduce(operation: (S, T) -> S): S { return accumulator } -/** - * Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element. - */ -public inline fun BooleanArray.reduce(operation: (Boolean, Boolean) -> Boolean): Boolean { - val iterator = this.iterator() - if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced.") - var accumulator = iterator.next() - while (iterator.hasNext()) { - accumulator = operation(accumulator, iterator.next()) - } - return accumulator -} - /** * Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element. */ @@ -10310,33 +10297,7 @@ public inline fun ByteArray.reduce(operation: (Byte, Byte) -> Byte): Byte { /** * Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element. */ -public inline fun CharArray.reduce(operation: (Char, Char) -> Char): Char { - val iterator = this.iterator() - if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced.") - var accumulator = iterator.next() - while (iterator.hasNext()) { - accumulator = operation(accumulator, iterator.next()) - } - return accumulator -} - -/** - * Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element. - */ -public inline fun DoubleArray.reduce(operation: (Double, Double) -> Double): Double { - val iterator = this.iterator() - if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced.") - var accumulator = iterator.next() - while (iterator.hasNext()) { - accumulator = operation(accumulator, iterator.next()) - } - return accumulator -} - -/** - * Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element. - */ -public inline fun FloatArray.reduce(operation: (Float, Float) -> Float): Float { +public inline fun ShortArray.reduce(operation: (Short, Short) -> Short): Short { val iterator = this.iterator() if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced.") var accumulator = iterator.next() @@ -10375,7 +10336,46 @@ public inline fun LongArray.reduce(operation: (Long, Long) -> Long): Long { /** * Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element. */ -public inline fun ShortArray.reduce(operation: (Short, Short) -> Short): Short { +public inline fun FloatArray.reduce(operation: (Float, Float) -> Float): Float { + val iterator = this.iterator() + if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced.") + var accumulator = iterator.next() + while (iterator.hasNext()) { + accumulator = operation(accumulator, iterator.next()) + } + return accumulator +} + +/** + * Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element. + */ +public inline fun DoubleArray.reduce(operation: (Double, Double) -> Double): Double { + val iterator = this.iterator() + if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced.") + var accumulator = iterator.next() + while (iterator.hasNext()) { + accumulator = operation(accumulator, iterator.next()) + } + return accumulator +} + +/** + * Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element. + */ +public inline fun BooleanArray.reduce(operation: (Boolean, Boolean) -> Boolean): Boolean { + val iterator = this.iterator() + if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced.") + var accumulator = iterator.next() + while (iterator.hasNext()) { + accumulator = operation(accumulator, iterator.next()) + } + return accumulator +} + +/** + * Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element. + */ +public inline fun CharArray.reduce(operation: (Char, Char) -> Char): Char { val iterator = this.iterator() if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced.") var accumulator = iterator.next() @@ -10400,21 +10400,6 @@ public inline fun Array.reduceIndexed(operation: (Int, S, T) -> return accumulator } -/** - * Accumulates value starting with the first element and applying [operation] from left to right - * to current accumulator value and each element with its index in the original array. - */ -public inline fun BooleanArray.reduceIndexed(operation: (Int, Boolean, Boolean) -> Boolean): Boolean { - val iterator = this.iterator() - if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced.") - var index = 1 - var accumulator = iterator.next() - while (iterator.hasNext()) { - accumulator = operation(index++, accumulator, iterator.next()) - } - return accumulator -} - /** * Accumulates value starting with the first element and applying [operation] from left to right * to current accumulator value and each element with its index in the original array. @@ -10434,37 +10419,7 @@ public inline fun ByteArray.reduceIndexed(operation: (Int, Byte, Byte) -> Byte): * Accumulates value starting with the first element and applying [operation] from left to right * to current accumulator value and each element with its index in the original array. */ -public inline fun CharArray.reduceIndexed(operation: (Int, Char, Char) -> Char): Char { - val iterator = this.iterator() - if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced.") - var index = 1 - var accumulator = iterator.next() - while (iterator.hasNext()) { - accumulator = operation(index++, accumulator, iterator.next()) - } - return accumulator -} - -/** - * Accumulates value starting with the first element and applying [operation] from left to right - * to current accumulator value and each element with its index in the original array. - */ -public inline fun DoubleArray.reduceIndexed(operation: (Int, Double, Double) -> Double): Double { - val iterator = this.iterator() - if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced.") - var index = 1 - var accumulator = iterator.next() - while (iterator.hasNext()) { - accumulator = operation(index++, accumulator, iterator.next()) - } - return accumulator -} - -/** - * Accumulates value starting with the first element and applying [operation] from left to right - * to current accumulator value and each element with its index in the original array. - */ -public inline fun FloatArray.reduceIndexed(operation: (Int, Float, Float) -> Float): Float { +public inline fun ShortArray.reduceIndexed(operation: (Int, Short, Short) -> Short): Short { val iterator = this.iterator() if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced.") var index = 1 @@ -10509,7 +10464,52 @@ public inline fun LongArray.reduceIndexed(operation: (Int, Long, Long) -> Long): * Accumulates value starting with the first element and applying [operation] from left to right * to current accumulator value and each element with its index in the original array. */ -public inline fun ShortArray.reduceIndexed(operation: (Int, Short, Short) -> Short): Short { +public inline fun FloatArray.reduceIndexed(operation: (Int, Float, Float) -> Float): Float { + val iterator = this.iterator() + if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced.") + var index = 1 + var accumulator = iterator.next() + while (iterator.hasNext()) { + accumulator = operation(index++, accumulator, iterator.next()) + } + return accumulator +} + +/** + * Accumulates value starting with the first element and applying [operation] from left to right + * to current accumulator value and each element with its index in the original array. + */ +public inline fun DoubleArray.reduceIndexed(operation: (Int, Double, Double) -> Double): Double { + val iterator = this.iterator() + if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced.") + var index = 1 + var accumulator = iterator.next() + while (iterator.hasNext()) { + accumulator = operation(index++, accumulator, iterator.next()) + } + return accumulator +} + +/** + * Accumulates value starting with the first element and applying [operation] from left to right + * to current accumulator value and each element with its index in the original array. + */ +public inline fun BooleanArray.reduceIndexed(operation: (Int, Boolean, Boolean) -> Boolean): Boolean { + val iterator = this.iterator() + if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced.") + var index = 1 + var accumulator = iterator.next() + while (iterator.hasNext()) { + accumulator = operation(index++, accumulator, iterator.next()) + } + return accumulator +} + +/** + * Accumulates value starting with the first element and applying [operation] from left to right + * to current accumulator value and each element with its index in the original array. + */ +public inline fun CharArray.reduceIndexed(operation: (Int, Char, Char) -> Char): Char { val iterator = this.iterator() if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced.") var index = 1 @@ -10533,19 +10533,6 @@ public inline fun Array.reduceRight(operation: (T, S) -> S): S return accumulator } -/** - * Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value. - */ -public inline fun BooleanArray.reduceRight(operation: (Boolean, Boolean) -> Boolean): Boolean { - var index = lastIndex - if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.") - var accumulator = get(index--) - while (index >= 0) { - accumulator = operation(get(index--), accumulator) - } - return accumulator -} - /** * Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value. */ @@ -10562,33 +10549,7 @@ public inline fun ByteArray.reduceRight(operation: (Byte, Byte) -> Byte): Byte { /** * Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value. */ -public inline fun CharArray.reduceRight(operation: (Char, Char) -> Char): Char { - var index = lastIndex - if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.") - var accumulator = get(index--) - while (index >= 0) { - accumulator = operation(get(index--), accumulator) - } - return accumulator -} - -/** - * Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value. - */ -public inline fun DoubleArray.reduceRight(operation: (Double, Double) -> Double): Double { - var index = lastIndex - if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.") - var accumulator = get(index--) - while (index >= 0) { - accumulator = operation(get(index--), accumulator) - } - return accumulator -} - -/** - * Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value. - */ -public inline fun FloatArray.reduceRight(operation: (Float, Float) -> Float): Float { +public inline fun ShortArray.reduceRight(operation: (Short, Short) -> Short): Short { var index = lastIndex if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.") var accumulator = get(index--) @@ -10627,7 +10588,46 @@ public inline fun LongArray.reduceRight(operation: (Long, Long) -> Long): Long { /** * Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value. */ -public inline fun ShortArray.reduceRight(operation: (Short, Short) -> Short): Short { +public inline fun FloatArray.reduceRight(operation: (Float, Float) -> Float): Float { + var index = lastIndex + if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.") + var accumulator = get(index--) + while (index >= 0) { + accumulator = operation(get(index--), accumulator) + } + return accumulator +} + +/** + * Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value. + */ +public inline fun DoubleArray.reduceRight(operation: (Double, Double) -> Double): Double { + var index = lastIndex + if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.") + var accumulator = get(index--) + while (index >= 0) { + accumulator = operation(get(index--), accumulator) + } + return accumulator +} + +/** + * Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value. + */ +public inline fun BooleanArray.reduceRight(operation: (Boolean, Boolean) -> Boolean): Boolean { + var index = lastIndex + if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.") + var accumulator = get(index--) + while (index >= 0) { + accumulator = operation(get(index--), accumulator) + } + return accumulator +} + +/** + * Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value. + */ +public inline fun CharArray.reduceRight(operation: (Char, Char) -> Char): Char { var index = lastIndex if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.") var accumulator = get(index--) @@ -10652,21 +10652,6 @@ public inline fun Array.reduceRightIndexed(operation: (Int, T, return accumulator } -/** - * Accumulates value starting with last element and applying [operation] from right to left - * to each element with its index in the original array and current accumulator value. - */ -public inline fun BooleanArray.reduceRightIndexed(operation: (Int, Boolean, Boolean) -> Boolean): Boolean { - var index = lastIndex - if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.") - var accumulator = get(index--) - while (index >= 0) { - accumulator = operation(index, get(index), accumulator) - --index - } - return accumulator -} - /** * Accumulates value starting with last element and applying [operation] from right to left * to each element with its index in the original array and current accumulator value. @@ -10686,37 +10671,7 @@ public inline fun ByteArray.reduceRightIndexed(operation: (Int, Byte, Byte) -> B * Accumulates value starting with last element and applying [operation] from right to left * to each element with its index in the original array and current accumulator value. */ -public inline fun CharArray.reduceRightIndexed(operation: (Int, Char, Char) -> Char): Char { - var index = lastIndex - if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.") - var accumulator = get(index--) - while (index >= 0) { - accumulator = operation(index, get(index), accumulator) - --index - } - return accumulator -} - -/** - * Accumulates value starting with last element and applying [operation] from right to left - * to each element with its index in the original array and current accumulator value. - */ -public inline fun DoubleArray.reduceRightIndexed(operation: (Int, Double, Double) -> Double): Double { - var index = lastIndex - if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.") - var accumulator = get(index--) - while (index >= 0) { - accumulator = operation(index, get(index), accumulator) - --index - } - return accumulator -} - -/** - * Accumulates value starting with last element and applying [operation] from right to left - * to each element with its index in the original array and current accumulator value. - */ -public inline fun FloatArray.reduceRightIndexed(operation: (Int, Float, Float) -> Float): Float { +public inline fun ShortArray.reduceRightIndexed(operation: (Int, Short, Short) -> Short): Short { var index = lastIndex if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.") var accumulator = get(index--) @@ -10761,7 +10716,52 @@ public inline fun LongArray.reduceRightIndexed(operation: (Int, Long, Long) -> L * Accumulates value starting with last element and applying [operation] from right to left * to each element with its index in the original array and current accumulator value. */ -public inline fun ShortArray.reduceRightIndexed(operation: (Int, Short, Short) -> Short): Short { +public inline fun FloatArray.reduceRightIndexed(operation: (Int, Float, Float) -> Float): Float { + var index = lastIndex + if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.") + var accumulator = get(index--) + while (index >= 0) { + accumulator = operation(index, get(index), accumulator) + --index + } + return accumulator +} + +/** + * Accumulates value starting with last element and applying [operation] from right to left + * to each element with its index in the original array and current accumulator value. + */ +public inline fun DoubleArray.reduceRightIndexed(operation: (Int, Double, Double) -> Double): Double { + var index = lastIndex + if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.") + var accumulator = get(index--) + while (index >= 0) { + accumulator = operation(index, get(index), accumulator) + --index + } + return accumulator +} + +/** + * Accumulates value starting with last element and applying [operation] from right to left + * to each element with its index in the original array and current accumulator value. + */ +public inline fun BooleanArray.reduceRightIndexed(operation: (Int, Boolean, Boolean) -> Boolean): Boolean { + var index = lastIndex + if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.") + var accumulator = get(index--) + while (index >= 0) { + accumulator = operation(index, get(index), accumulator) + --index + } + return accumulator +} + +/** + * Accumulates value starting with last element and applying [operation] from right to left + * to each element with its index in the original array and current accumulator value. + */ +public inline fun CharArray.reduceRightIndexed(operation: (Int, Char, Char) -> Char): Char { var index = lastIndex if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.") var accumulator = get(index--) @@ -10783,17 +10783,6 @@ public inline fun Array.sumBy(selector: (T) -> Int): Int { return sum } -/** - * Returns the sum of all values produced by [selector] function applied to each element in the array. - */ -public inline fun BooleanArray.sumBy(selector: (Boolean) -> Int): Int { - var sum: Int = 0 - for (element in this) { - sum += selector(element) - } - return sum -} - /** * Returns the sum of all values produced by [selector] function applied to each element in the array. */ @@ -10808,29 +10797,7 @@ public inline fun ByteArray.sumBy(selector: (Byte) -> Int): Int { /** * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun CharArray.sumBy(selector: (Char) -> Int): Int { - var sum: Int = 0 - for (element in this) { - sum += selector(element) - } - return sum -} - -/** - * Returns the sum of all values produced by [selector] function applied to each element in the array. - */ -public inline fun DoubleArray.sumBy(selector: (Double) -> Int): Int { - var sum: Int = 0 - for (element in this) { - sum += selector(element) - } - return sum -} - -/** - * Returns the sum of all values produced by [selector] function applied to each element in the array. - */ -public inline fun FloatArray.sumBy(selector: (Float) -> Int): Int { +public inline fun ShortArray.sumBy(selector: (Short) -> Int): Int { var sum: Int = 0 for (element in this) { sum += selector(element) @@ -10863,7 +10830,40 @@ public inline fun LongArray.sumBy(selector: (Long) -> Int): Int { /** * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun ShortArray.sumBy(selector: (Short) -> Int): Int { +public inline fun FloatArray.sumBy(selector: (Float) -> Int): Int { + var sum: Int = 0 + for (element in this) { + sum += selector(element) + } + return sum +} + +/** + * Returns the sum of all values produced by [selector] function applied to each element in the array. + */ +public inline fun DoubleArray.sumBy(selector: (Double) -> Int): Int { + var sum: Int = 0 + for (element in this) { + sum += selector(element) + } + return sum +} + +/** + * Returns the sum of all values produced by [selector] function applied to each element in the array. + */ +public inline fun BooleanArray.sumBy(selector: (Boolean) -> Int): Int { + var sum: Int = 0 + for (element in this) { + sum += selector(element) + } + return sum +} + +/** + * Returns the sum of all values produced by [selector] function applied to each element in the array. + */ +public inline fun CharArray.sumBy(selector: (Char) -> Int): Int { var sum: Int = 0 for (element in this) { sum += selector(element) @@ -10882,17 +10882,6 @@ public inline fun Array.sumByDouble(selector: (T) -> Double): Double return sum } -/** - * Returns the sum of all values produced by [selector] function applied to each element in the array. - */ -public inline fun BooleanArray.sumByDouble(selector: (Boolean) -> Double): Double { - var sum: Double = 0.0 - for (element in this) { - sum += selector(element) - } - return sum -} - /** * Returns the sum of all values produced by [selector] function applied to each element in the array. */ @@ -10907,29 +10896,7 @@ public inline fun ByteArray.sumByDouble(selector: (Byte) -> Double): Double { /** * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun CharArray.sumByDouble(selector: (Char) -> Double): Double { - var sum: Double = 0.0 - for (element in this) { - sum += selector(element) - } - return sum -} - -/** - * Returns the sum of all values produced by [selector] function applied to each element in the array. - */ -public inline fun DoubleArray.sumByDouble(selector: (Double) -> Double): Double { - var sum: Double = 0.0 - for (element in this) { - sum += selector(element) - } - return sum -} - -/** - * Returns the sum of all values produced by [selector] function applied to each element in the array. - */ -public inline fun FloatArray.sumByDouble(selector: (Float) -> Double): Double { +public inline fun ShortArray.sumByDouble(selector: (Short) -> Double): Double { var sum: Double = 0.0 for (element in this) { sum += selector(element) @@ -10962,7 +10929,40 @@ public inline fun LongArray.sumByDouble(selector: (Long) -> Double): Double { /** * Returns the sum of all values produced by [selector] function applied to each element in the array. */ -public inline fun ShortArray.sumByDouble(selector: (Short) -> Double): Double { +public inline fun FloatArray.sumByDouble(selector: (Float) -> Double): Double { + var sum: Double = 0.0 + for (element in this) { + sum += selector(element) + } + return sum +} + +/** + * Returns the sum of all values produced by [selector] function applied to each element in the array. + */ +public inline fun DoubleArray.sumByDouble(selector: (Double) -> Double): Double { + var sum: Double = 0.0 + for (element in this) { + sum += selector(element) + } + return sum +} + +/** + * Returns the sum of all values produced by [selector] function applied to each element in the array. + */ +public inline fun BooleanArray.sumByDouble(selector: (Boolean) -> Double): Double { + var sum: Double = 0.0 + for (element in this) { + sum += selector(element) + } + return sum +} + +/** + * Returns the sum of all values produced by [selector] function applied to each element in the array. + */ +public inline fun CharArray.sumByDouble(selector: (Char) -> Double): Double { var sum: Double = 0.0 for (element in this) { sum += selector(element) @@ -11000,24 +11000,6 @@ public inline fun Array.partition(predicate: (T) -> Boolean): Pair
  • Boolean): Pair, List> { - val first = ArrayList() - val second = ArrayList() - for (element in this) { - if (predicate(element)) { - first.add(element) - } else { - second.add(element) - } - } - return Pair(first, second) -} - /** * Splits the original array into pair of lists, * where *first* list contains elements for which [predicate] yielded `true`, @@ -11041,45 +11023,9 @@ public inline fun ByteArray.partition(predicate: (Byte) -> Boolean): Pair Boolean): Pair, List> { - val first = ArrayList() - val second = ArrayList() - for (element in this) { - if (predicate(element)) { - first.add(element) - } else { - second.add(element) - } - } - return Pair(first, second) -} - -/** - * Splits the original array into pair of lists, - * where *first* list contains elements for which [predicate] yielded `true`, - * while *second* list contains elements for which [predicate] yielded `false`. - */ -public inline fun DoubleArray.partition(predicate: (Double) -> Boolean): Pair, List> { - val first = ArrayList() - val second = ArrayList() - for (element in this) { - if (predicate(element)) { - first.add(element) - } else { - second.add(element) - } - } - return Pair(first, second) -} - -/** - * Splits the original array into pair of lists, - * where *first* list contains elements for which [predicate] yielded `true`, - * while *second* list contains elements for which [predicate] yielded `false`. - */ -public inline fun FloatArray.partition(predicate: (Float) -> Boolean): Pair, List> { - val first = ArrayList() - val second = ArrayList() +public inline fun ShortArray.partition(predicate: (Short) -> Boolean): Pair, List> { + val first = ArrayList() + val second = ArrayList() for (element in this) { if (predicate(element)) { first.add(element) @@ -11131,9 +11077,63 @@ public inline fun LongArray.partition(predicate: (Long) -> Boolean): Pair Boolean): Pair, List> { - val first = ArrayList() - val second = ArrayList() +public inline fun FloatArray.partition(predicate: (Float) -> Boolean): Pair, List> { + val first = ArrayList() + val second = ArrayList() + for (element in this) { + if (predicate(element)) { + first.add(element) + } else { + second.add(element) + } + } + return Pair(first, second) +} + +/** + * Splits the original array into pair of lists, + * where *first* list contains elements for which [predicate] yielded `true`, + * while *second* list contains elements for which [predicate] yielded `false`. + */ +public inline fun DoubleArray.partition(predicate: (Double) -> Boolean): Pair, List> { + val first = ArrayList() + val second = ArrayList() + for (element in this) { + if (predicate(element)) { + first.add(element) + } else { + second.add(element) + } + } + return Pair(first, second) +} + +/** + * Splits the original array into pair of lists, + * where *first* list contains elements for which [predicate] yielded `true`, + * while *second* list contains elements for which [predicate] yielded `false`. + */ +public inline fun BooleanArray.partition(predicate: (Boolean) -> Boolean): Pair, List> { + val first = ArrayList() + val second = ArrayList() + for (element in this) { + if (predicate(element)) { + first.add(element) + } else { + second.add(element) + } + } + return Pair(first, second) +} + +/** + * Splits the original array into pair of lists, + * where *first* list contains elements for which [predicate] yielded `true`, + * while *second* list contains elements for which [predicate] yielded `false`. + */ +public inline fun CharArray.partition(predicate: (Char) -> Boolean): Pair, List> { + val first = ArrayList() + val second = ArrayList() for (element in this) { if (predicate(element)) { first.add(element) @@ -11151,13 +11151,6 @@ public infix fun Array.zip(other: Array): List> return zip(other) { t1, t2 -> t1 to t2 } } -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public infix fun BooleanArray.zip(other: Array): List> { - return zip(other) { t1, t2 -> t1 to t2 } -} - /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ @@ -11168,21 +11161,7 @@ public infix fun ByteArray.zip(other: Array): List> { /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public infix fun CharArray.zip(other: Array): List> { - return zip(other) { t1, t2 -> t1 to t2 } -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public infix fun DoubleArray.zip(other: Array): List> { - return zip(other) { t1, t2 -> t1 to t2 } -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public infix fun FloatArray.zip(other: Array): List> { +public infix fun ShortArray.zip(other: Array): List> { return zip(other) { t1, t2 -> t1 to t2 } } @@ -11203,7 +11182,28 @@ public infix fun LongArray.zip(other: Array): List> { /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public infix fun ShortArray.zip(other: Array): List> { +public infix fun FloatArray.zip(other: Array): List> { + return zip(other) { t1, t2 -> t1 to t2 } +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public infix fun DoubleArray.zip(other: Array): List> { + return zip(other) { t1, t2 -> t1 to t2 } +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public infix fun BooleanArray.zip(other: Array): List> { + return zip(other) { t1, t2 -> t1 to t2 } +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public infix fun CharArray.zip(other: Array): List> { return zip(other) { t1, t2 -> t1 to t2 } } @@ -11219,18 +11219,6 @@ public inline fun Array.zip(other: Array, transform: (T, return list } -/** - * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. - */ -public inline fun BooleanArray.zip(other: Array, transform: (Boolean, R) -> V): List { - val size = Math.min(size, other.size) - val list = ArrayList(size) - for (i in 0..size-1) { - list.add(transform(this[i], other[i])) - } - return list -} - /** * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ @@ -11246,31 +11234,7 @@ public inline fun ByteArray.zip(other: Array, transform: (Byte, R) /** * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ -public inline fun CharArray.zip(other: Array, transform: (Char, R) -> V): List { - val size = Math.min(size, other.size) - val list = ArrayList(size) - for (i in 0..size-1) { - list.add(transform(this[i], other[i])) - } - return list -} - -/** - * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. - */ -public inline fun DoubleArray.zip(other: Array, transform: (Double, R) -> V): List { - val size = Math.min(size, other.size) - val list = ArrayList(size) - for (i in 0..size-1) { - list.add(transform(this[i], other[i])) - } - return list -} - -/** - * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. - */ -public inline fun FloatArray.zip(other: Array, transform: (Float, R) -> V): List { +public inline fun ShortArray.zip(other: Array, transform: (Short, R) -> V): List { val size = Math.min(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { @@ -11306,7 +11270,43 @@ public inline fun LongArray.zip(other: Array, transform: (Long, R) /** * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ -public inline fun ShortArray.zip(other: Array, transform: (Short, R) -> V): List { +public inline fun FloatArray.zip(other: Array, transform: (Float, R) -> V): List { + val size = Math.min(size, other.size) + val list = ArrayList(size) + for (i in 0..size-1) { + list.add(transform(this[i], other[i])) + } + return list +} + +/** + * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. + */ +public inline fun DoubleArray.zip(other: Array, transform: (Double, R) -> V): List { + val size = Math.min(size, other.size) + val list = ArrayList(size) + for (i in 0..size-1) { + list.add(transform(this[i], other[i])) + } + return list +} + +/** + * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. + */ +public inline fun BooleanArray.zip(other: Array, transform: (Boolean, R) -> V): List { + val size = Math.min(size, other.size) + val list = ArrayList(size) + for (i in 0..size-1) { + list.add(transform(this[i], other[i])) + } + return list +} + +/** + * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. + */ +public inline fun CharArray.zip(other: Array, transform: (Char, R) -> V): List { val size = Math.min(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { @@ -11322,13 +11322,6 @@ public infix fun Array.zip(other: Iterable): List> { return zip(other) { t1, t2 -> t1 to t2 } } -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public infix fun BooleanArray.zip(other: Iterable): List> { - return zip(other) { t1, t2 -> t1 to t2 } -} - /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ @@ -11339,21 +11332,7 @@ public infix fun ByteArray.zip(other: Iterable): List> { /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public infix fun CharArray.zip(other: Iterable): List> { - return zip(other) { t1, t2 -> t1 to t2 } -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public infix fun DoubleArray.zip(other: Iterable): List> { - return zip(other) { t1, t2 -> t1 to t2 } -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public infix fun FloatArray.zip(other: Iterable): List> { +public infix fun ShortArray.zip(other: Iterable): List> { return zip(other) { t1, t2 -> t1 to t2 } } @@ -11374,7 +11353,28 @@ public infix fun LongArray.zip(other: Iterable): List> { /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public infix fun ShortArray.zip(other: Iterable): List> { +public infix fun FloatArray.zip(other: Iterable): List> { + return zip(other) { t1, t2 -> t1 to t2 } +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public infix fun DoubleArray.zip(other: Iterable): List> { + return zip(other) { t1, t2 -> t1 to t2 } +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public infix fun BooleanArray.zip(other: Iterable): List> { + return zip(other) { t1, t2 -> t1 to t2 } +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public infix fun CharArray.zip(other: Iterable): List> { return zip(other) { t1, t2 -> t1 to t2 } } @@ -11393,21 +11393,6 @@ public inline fun Array.zip(other: Iterable, transform: (T, return list } -/** - * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. - */ -public inline fun BooleanArray.zip(other: Iterable, transform: (Boolean, R) -> V): List { - val arraySize = size - @Suppress("INVISIBLE_MEMBER_FROM_INLINE") - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) - var i = 0 - for (element in other) { - if (i >= arraySize) break - list.add(transform(this[i++], element)) - } - return list -} - /** * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ @@ -11426,37 +11411,7 @@ public inline fun ByteArray.zip(other: Iterable, transform: (Byte, R) /** * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ -public inline fun CharArray.zip(other: Iterable, transform: (Char, R) -> V): List { - val arraySize = size - @Suppress("INVISIBLE_MEMBER_FROM_INLINE") - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) - var i = 0 - for (element in other) { - if (i >= arraySize) break - list.add(transform(this[i++], element)) - } - return list -} - -/** - * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. - */ -public inline fun DoubleArray.zip(other: Iterable, transform: (Double, R) -> V): List { - val arraySize = size - @Suppress("INVISIBLE_MEMBER_FROM_INLINE") - val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) - var i = 0 - for (element in other) { - if (i >= arraySize) break - list.add(transform(this[i++], element)) - } - return list -} - -/** - * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. - */ -public inline fun FloatArray.zip(other: Iterable, transform: (Float, R) -> V): List { +public inline fun ShortArray.zip(other: Iterable, transform: (Short, R) -> V): List { val arraySize = size @Suppress("INVISIBLE_MEMBER_FROM_INLINE") val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) @@ -11501,7 +11456,52 @@ public inline fun LongArray.zip(other: Iterable, transform: (Long, R) /** * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ -public inline fun ShortArray.zip(other: Iterable, transform: (Short, R) -> V): List { +public inline fun FloatArray.zip(other: Iterable, transform: (Float, R) -> V): List { + val arraySize = size + @Suppress("INVISIBLE_MEMBER_FROM_INLINE") + val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + var i = 0 + for (element in other) { + if (i >= arraySize) break + list.add(transform(this[i++], element)) + } + return list +} + +/** + * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. + */ +public inline fun DoubleArray.zip(other: Iterable, transform: (Double, R) -> V): List { + val arraySize = size + @Suppress("INVISIBLE_MEMBER_FROM_INLINE") + val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + var i = 0 + for (element in other) { + if (i >= arraySize) break + list.add(transform(this[i++], element)) + } + return list +} + +/** + * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. + */ +public inline fun BooleanArray.zip(other: Iterable, transform: (Boolean, R) -> V): List { + val arraySize = size + @Suppress("INVISIBLE_MEMBER_FROM_INLINE") + val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) + var i = 0 + for (element in other) { + if (i >= arraySize) break + list.add(transform(this[i++], element)) + } + return list +} + +/** + * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. + */ +public inline fun CharArray.zip(other: Iterable, transform: (Char, R) -> V): List { val arraySize = size @Suppress("INVISIBLE_MEMBER_FROM_INLINE") val list = ArrayList(Math.min(other.collectionSizeOrDefault(10), arraySize)) @@ -11513,13 +11513,6 @@ public inline fun ShortArray.zip(other: Iterable, transform: (Short, R return list } -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public infix fun BooleanArray.zip(other: BooleanArray): List> { - return zip(other) { t1, t2 -> t1 to t2 } -} - /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ @@ -11530,21 +11523,7 @@ public infix fun ByteArray.zip(other: ByteArray): List> { /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public infix fun CharArray.zip(other: CharArray): List> { - return zip(other) { t1, t2 -> t1 to t2 } -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public infix fun DoubleArray.zip(other: DoubleArray): List> { - return zip(other) { t1, t2 -> t1 to t2 } -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public infix fun FloatArray.zip(other: FloatArray): List> { +public infix fun ShortArray.zip(other: ShortArray): List> { return zip(other) { t1, t2 -> t1 to t2 } } @@ -11565,20 +11544,29 @@ public infix fun LongArray.zip(other: LongArray): List> { /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public infix fun ShortArray.zip(other: ShortArray): List> { +public infix fun FloatArray.zip(other: FloatArray): List> { return zip(other) { t1, t2 -> t1 to t2 } } /** - * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public inline fun BooleanArray.zip(other: BooleanArray, transform: (Boolean, Boolean) -> V): List { - val size = Math.min(size, other.size) - val list = ArrayList(size) - for (i in 0..size-1) { - list.add(transform(this[i], other[i])) - } - return list +public infix fun DoubleArray.zip(other: DoubleArray): List> { + return zip(other) { t1, t2 -> t1 to t2 } +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public infix fun BooleanArray.zip(other: BooleanArray): List> { + return zip(other) { t1, t2 -> t1 to t2 } +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public infix fun CharArray.zip(other: CharArray): List> { + return zip(other) { t1, t2 -> t1 to t2 } } /** @@ -11596,31 +11584,7 @@ public inline fun ByteArray.zip(other: ByteArray, transform: (Byte, Byte) -> /** * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ -public inline fun CharArray.zip(other: CharArray, transform: (Char, Char) -> V): List { - val size = Math.min(size, other.size) - val list = ArrayList(size) - for (i in 0..size-1) { - list.add(transform(this[i], other[i])) - } - return list -} - -/** - * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. - */ -public inline fun DoubleArray.zip(other: DoubleArray, transform: (Double, Double) -> V): List { - val size = Math.min(size, other.size) - val list = ArrayList(size) - for (i in 0..size-1) { - list.add(transform(this[i], other[i])) - } - return list -} - -/** - * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. - */ -public inline fun FloatArray.zip(other: FloatArray, transform: (Float, Float) -> V): List { +public inline fun ShortArray.zip(other: ShortArray, transform: (Short, Short) -> V): List { val size = Math.min(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { @@ -11656,7 +11620,43 @@ public inline fun LongArray.zip(other: LongArray, transform: (Long, Long) -> /** * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. */ -public inline fun ShortArray.zip(other: ShortArray, transform: (Short, Short) -> V): List { +public inline fun FloatArray.zip(other: FloatArray, transform: (Float, Float) -> V): List { + val size = Math.min(size, other.size) + val list = ArrayList(size) + for (i in 0..size-1) { + list.add(transform(this[i], other[i])) + } + return list +} + +/** + * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. + */ +public inline fun DoubleArray.zip(other: DoubleArray, transform: (Double, Double) -> V): List { + val size = Math.min(size, other.size) + val list = ArrayList(size) + for (i in 0..size-1) { + list.add(transform(this[i], other[i])) + } + return list +} + +/** + * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. + */ +public inline fun BooleanArray.zip(other: BooleanArray, transform: (Boolean, Boolean) -> V): List { + val size = Math.min(size, other.size) + val list = ArrayList(size) + for (i in 0..size-1) { + list.add(transform(this[i], other[i])) + } + return list +} + +/** + * Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection. + */ +public inline fun CharArray.zip(other: CharArray, transform: (Char, Char) -> V): List { val size = Math.min(size, other.size) val list = ArrayList(size) for (i in 0..size-1) { @@ -11687,28 +11687,6 @@ public fun Array.joinTo(buffer: A, separator: CharSeq return buffer } -/** - * Appends the string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied. - * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] - * elements will be appended, followed by the [truncated] string (which defaults to "..."). - */ -public fun BooleanArray.joinTo(buffer: A, separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Boolean) -> CharSequence)? = null): A { - buffer.append(prefix) - var count = 0 - for (element in this) { - if (++count > 1) buffer.append(separator) - if (limit < 0 || count <= limit) { - if (transform != null) - buffer.append(transform(element)) - else - buffer.append(element.toString()) - } else break - } - if (limit >= 0 && count > limit) buffer.append(truncated) - buffer.append(postfix) - return buffer -} - /** * Appends the string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied. * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] @@ -11736,51 +11714,7 @@ public fun ByteArray.joinTo(buffer: A, separator: CharSequence * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). */ -public fun CharArray.joinTo(buffer: A, separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Char) -> CharSequence)? = null): A { - buffer.append(prefix) - var count = 0 - for (element in this) { - if (++count > 1) buffer.append(separator) - if (limit < 0 || count <= limit) { - if (transform != null) - buffer.append(transform(element)) - else - buffer.append(element.toString()) - } else break - } - if (limit >= 0 && count > limit) buffer.append(truncated) - buffer.append(postfix) - return buffer -} - -/** - * Appends the string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied. - * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] - * elements will be appended, followed by the [truncated] string (which defaults to "..."). - */ -public fun DoubleArray.joinTo(buffer: A, separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Double) -> CharSequence)? = null): A { - buffer.append(prefix) - var count = 0 - for (element in this) { - if (++count > 1) buffer.append(separator) - if (limit < 0 || count <= limit) { - if (transform != null) - buffer.append(transform(element)) - else - buffer.append(element.toString()) - } else break - } - if (limit >= 0 && count > limit) buffer.append(truncated) - buffer.append(postfix) - return buffer -} - -/** - * Appends the string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied. - * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] - * elements will be appended, followed by the [truncated] string (which defaults to "..."). - */ -public fun FloatArray.joinTo(buffer: A, separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Float) -> CharSequence)? = null): A { +public fun ShortArray.joinTo(buffer: A, separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Short) -> CharSequence)? = null): A { buffer.append(prefix) var count = 0 for (element in this) { @@ -11846,7 +11780,73 @@ public fun LongArray.joinTo(buffer: A, separator: CharSequence * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). */ -public fun ShortArray.joinTo(buffer: A, separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Short) -> CharSequence)? = null): A { +public fun FloatArray.joinTo(buffer: A, separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Float) -> CharSequence)? = null): A { + buffer.append(prefix) + var count = 0 + for (element in this) { + if (++count > 1) buffer.append(separator) + if (limit < 0 || count <= limit) { + if (transform != null) + buffer.append(transform(element)) + else + buffer.append(element.toString()) + } else break + } + if (limit >= 0 && count > limit) buffer.append(truncated) + buffer.append(postfix) + return buffer +} + +/** + * Appends the string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied. + * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] + * elements will be appended, followed by the [truncated] string (which defaults to "..."). + */ +public fun DoubleArray.joinTo(buffer: A, separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Double) -> CharSequence)? = null): A { + buffer.append(prefix) + var count = 0 + for (element in this) { + if (++count > 1) buffer.append(separator) + if (limit < 0 || count <= limit) { + if (transform != null) + buffer.append(transform(element)) + else + buffer.append(element.toString()) + } else break + } + if (limit >= 0 && count > limit) buffer.append(truncated) + buffer.append(postfix) + return buffer +} + +/** + * Appends the string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied. + * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] + * elements will be appended, followed by the [truncated] string (which defaults to "..."). + */ +public fun BooleanArray.joinTo(buffer: A, separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Boolean) -> CharSequence)? = null): A { + buffer.append(prefix) + var count = 0 + for (element in this) { + if (++count > 1) buffer.append(separator) + if (limit < 0 || count <= limit) { + if (transform != null) + buffer.append(transform(element)) + else + buffer.append(element.toString()) + } else break + } + if (limit >= 0 && count > limit) buffer.append(truncated) + buffer.append(postfix) + return buffer +} + +/** + * Appends the string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied. + * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] + * elements will be appended, followed by the [truncated] string (which defaults to "..."). + */ +public fun CharArray.joinTo(buffer: A, separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Char) -> CharSequence)? = null): A { buffer.append(prefix) var count = 0 for (element in this) { @@ -11872,15 +11872,6 @@ public fun Array.joinToString(separator: CharSequence = ", ", prefix: return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() } -/** - * Creates a string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied. - * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] - * elements will be appended, followed by the [truncated] string (which defaults to "..."). - */ -public fun BooleanArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Boolean) -> CharSequence)? = null): String { - return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() -} - /** * Creates a string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied. * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] @@ -11895,25 +11886,7 @@ public fun ByteArray.joinToString(separator: CharSequence = ", ", prefix: CharSe * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). */ -public fun CharArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Char) -> CharSequence)? = null): String { - return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() -} - -/** - * Creates a string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied. - * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] - * elements will be appended, followed by the [truncated] string (which defaults to "..."). - */ -public fun DoubleArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Double) -> CharSequence)? = null): String { - return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() -} - -/** - * Creates a string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied. - * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] - * elements will be appended, followed by the [truncated] string (which defaults to "..."). - */ -public fun FloatArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Float) -> CharSequence)? = null): String { +public fun ShortArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Short) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() } @@ -11940,7 +11913,34 @@ public fun LongArray.joinToString(separator: CharSequence = ", ", prefix: CharSe * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] * elements will be appended, followed by the [truncated] string (which defaults to "..."). */ -public fun ShortArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Short) -> CharSequence)? = null): String { +public fun FloatArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Float) -> CharSequence)? = null): String { + return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() +} + +/** + * Creates a string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied. + * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] + * elements will be appended, followed by the [truncated] string (which defaults to "..."). + */ +public fun DoubleArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Double) -> CharSequence)? = null): String { + return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() +} + +/** + * Creates a string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied. + * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] + * elements will be appended, followed by the [truncated] string (which defaults to "..."). + */ +public fun BooleanArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Boolean) -> CharSequence)? = null): String { + return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() +} + +/** + * Creates a string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied. + * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] + * elements will be appended, followed by the [truncated] string (which defaults to "..."). + */ +public fun CharArray.joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((Char) -> CharSequence)? = null): String { return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() } @@ -11954,16 +11954,6 @@ public fun Array.asIterable(): Iterable { } } -/** - * Creates an [Iterable] instance that wraps the original array returning its elements when being iterated. - */ -public fun BooleanArray.asIterable(): Iterable { - if (isEmpty()) return emptyList() - return object : Iterable { - override fun iterator(): Iterator = this@asIterable.iterator() - } -} - /** * Creates an [Iterable] instance that wraps the original array returning its elements when being iterated. */ @@ -11977,30 +11967,10 @@ public fun ByteArray.asIterable(): Iterable { /** * Creates an [Iterable] instance that wraps the original array returning its elements when being iterated. */ -public fun CharArray.asIterable(): Iterable { +public fun ShortArray.asIterable(): Iterable { if (isEmpty()) return emptyList() - return object : Iterable { - override fun iterator(): Iterator = this@asIterable.iterator() - } -} - -/** - * Creates an [Iterable] instance that wraps the original array returning its elements when being iterated. - */ -public fun DoubleArray.asIterable(): Iterable { - if (isEmpty()) return emptyList() - return object : Iterable { - override fun iterator(): Iterator = this@asIterable.iterator() - } -} - -/** - * Creates an [Iterable] instance that wraps the original array returning its elements when being iterated. - */ -public fun FloatArray.asIterable(): Iterable { - if (isEmpty()) return emptyList() - return object : Iterable { - override fun iterator(): Iterator = this@asIterable.iterator() + return object : Iterable { + override fun iterator(): Iterator = this@asIterable.iterator() } } @@ -12027,10 +11997,40 @@ public fun LongArray.asIterable(): Iterable { /** * Creates an [Iterable] instance that wraps the original array returning its elements when being iterated. */ -public fun ShortArray.asIterable(): Iterable { +public fun FloatArray.asIterable(): Iterable { if (isEmpty()) return emptyList() - return object : Iterable { - override fun iterator(): Iterator = this@asIterable.iterator() + return object : Iterable { + override fun iterator(): Iterator = this@asIterable.iterator() + } +} + +/** + * Creates an [Iterable] instance that wraps the original array returning its elements when being iterated. + */ +public fun DoubleArray.asIterable(): Iterable { + if (isEmpty()) return emptyList() + return object : Iterable { + override fun iterator(): Iterator = this@asIterable.iterator() + } +} + +/** + * Creates an [Iterable] instance that wraps the original array returning its elements when being iterated. + */ +public fun BooleanArray.asIterable(): Iterable { + if (isEmpty()) return emptyList() + return object : Iterable { + override fun iterator(): Iterator = this@asIterable.iterator() + } +} + +/** + * Creates an [Iterable] instance that wraps the original array returning its elements when being iterated. + */ +public fun CharArray.asIterable(): Iterable { + if (isEmpty()) return emptyList() + return object : Iterable { + override fun iterator(): Iterator = this@asIterable.iterator() } } @@ -12046,18 +12046,6 @@ public fun Array.asSequence(): Sequence { } } -/** - * Creates a [Sequence] instance that wraps the original array returning its elements when being iterated. - */ -public fun BooleanArray.asSequence(): Sequence { - if (isEmpty()) return emptySequence() - return object : Sequence { - override fun iterator(): Iterator { - return this@asSequence.iterator() - } - } -} - /** * Creates a [Sequence] instance that wraps the original array returning its elements when being iterated. */ @@ -12073,34 +12061,10 @@ public fun ByteArray.asSequence(): Sequence { /** * Creates a [Sequence] instance that wraps the original array returning its elements when being iterated. */ -public fun CharArray.asSequence(): Sequence { +public fun ShortArray.asSequence(): Sequence { if (isEmpty()) return emptySequence() - return object : Sequence { - override fun iterator(): Iterator { - return this@asSequence.iterator() - } - } -} - -/** - * Creates a [Sequence] instance that wraps the original array returning its elements when being iterated. - */ -public fun DoubleArray.asSequence(): Sequence { - if (isEmpty()) return emptySequence() - return object : Sequence { - override fun iterator(): Iterator { - return this@asSequence.iterator() - } - } -} - -/** - * Creates a [Sequence] instance that wraps the original array returning its elements when being iterated. - */ -public fun FloatArray.asSequence(): Sequence { - if (isEmpty()) return emptySequence() - return object : Sequence { - override fun iterator(): Iterator { + return object : Sequence { + override fun iterator(): Iterator { return this@asSequence.iterator() } } @@ -12133,10 +12097,46 @@ public fun LongArray.asSequence(): Sequence { /** * Creates a [Sequence] instance that wraps the original array returning its elements when being iterated. */ -public fun ShortArray.asSequence(): Sequence { +public fun FloatArray.asSequence(): Sequence { if (isEmpty()) return emptySequence() - return object : Sequence { - override fun iterator(): Iterator { + return object : Sequence { + override fun iterator(): Iterator { + return this@asSequence.iterator() + } + } +} + +/** + * Creates a [Sequence] instance that wraps the original array returning its elements when being iterated. + */ +public fun DoubleArray.asSequence(): Sequence { + if (isEmpty()) return emptySequence() + return object : Sequence { + override fun iterator(): Iterator { + return this@asSequence.iterator() + } + } +} + +/** + * Creates a [Sequence] instance that wraps the original array returning its elements when being iterated. + */ +public fun BooleanArray.asSequence(): Sequence { + if (isEmpty()) return emptySequence() + return object : Sequence { + override fun iterator(): Iterator { + return this@asSequence.iterator() + } + } +} + +/** + * Creates a [Sequence] instance that wraps the original array returning its elements when being iterated. + */ +public fun CharArray.asSequence(): Sequence { + if (isEmpty()) return emptySequence() + return object : Sequence { + override fun iterator(): Iterator { return this@asSequence.iterator() } } @@ -12150,21 +12150,6 @@ public fun Array.asList(): List { return ArraysUtilJVM.asList(this) } -/** - * Returns a [List] that wraps the original array. - */ -@kotlin.jvm.JvmVersion -public fun BooleanArray.asList(): List { - return object : AbstractList(), RandomAccess { - override val size: Int get() = this@asList.size - override fun isEmpty(): Boolean = this@asList.isEmpty() - override fun contains(element: Boolean): Boolean = this@asList.contains(element) - override fun get(index: Int): Boolean = this@asList[index] - override fun indexOf(element: Boolean): Int = this@asList.indexOf(element) - override fun lastIndexOf(element: Boolean): Int = this@asList.lastIndexOf(element) - } -} - /** * Returns a [List] that wraps the original array. */ @@ -12184,44 +12169,14 @@ public fun ByteArray.asList(): List { * Returns a [List] that wraps the original array. */ @kotlin.jvm.JvmVersion -public fun CharArray.asList(): List { - return object : AbstractList(), RandomAccess { +public fun ShortArray.asList(): List { + return object : AbstractList(), 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 a [List] that wraps the original array. - */ -@kotlin.jvm.JvmVersion -public fun DoubleArray.asList(): List { - return object : AbstractList(), RandomAccess { - override val size: Int get() = this@asList.size - override fun isEmpty(): Boolean = this@asList.isEmpty() - override fun contains(element: Double): Boolean = this@asList.contains(element) - override fun get(index: Int): Double = this@asList[index] - override fun indexOf(element: Double): Int = this@asList.indexOf(element) - override fun lastIndexOf(element: Double): Int = this@asList.lastIndexOf(element) - } -} - -/** - * Returns a [List] that wraps the original array. - */ -@kotlin.jvm.JvmVersion -public fun FloatArray.asList(): List { - return object : AbstractList(), RandomAccess { - override val size: Int get() = this@asList.size - override fun isEmpty(): Boolean = this@asList.isEmpty() - override fun contains(element: Float): Boolean = this@asList.contains(element) - override fun get(index: Int): Float = this@asList[index] - override fun indexOf(element: Float): Int = this@asList.indexOf(element) - override fun lastIndexOf(element: Float): Int = this@asList.lastIndexOf(element) + override fun contains(element: Short): Boolean = this@asList.contains(element) + override fun get(index: Int): Short = this@asList[index] + override fun indexOf(element: Short): Int = this@asList.indexOf(element) + override fun lastIndexOf(element: Short): Int = this@asList.lastIndexOf(element) } } @@ -12259,14 +12214,59 @@ public fun LongArray.asList(): List { * Returns a [List] that wraps the original array. */ @kotlin.jvm.JvmVersion -public fun ShortArray.asList(): List { - return object : AbstractList(), RandomAccess { +public fun FloatArray.asList(): List { + return object : AbstractList(), RandomAccess { override val size: Int get() = this@asList.size override fun isEmpty(): Boolean = this@asList.isEmpty() - override fun contains(element: Short): Boolean = this@asList.contains(element) - override fun get(index: Int): Short = this@asList[index] - override fun indexOf(element: Short): Int = this@asList.indexOf(element) - override fun lastIndexOf(element: Short): Int = this@asList.lastIndexOf(element) + override fun contains(element: Float): Boolean = this@asList.contains(element) + override fun get(index: Int): Float = this@asList[index] + override fun indexOf(element: Float): Int = this@asList.indexOf(element) + override fun lastIndexOf(element: Float): Int = this@asList.lastIndexOf(element) + } +} + +/** + * Returns a [List] that wraps the original array. + */ +@kotlin.jvm.JvmVersion +public fun DoubleArray.asList(): List { + return object : AbstractList(), RandomAccess { + override val size: Int get() = this@asList.size + override fun isEmpty(): Boolean = this@asList.isEmpty() + override fun contains(element: Double): Boolean = this@asList.contains(element) + override fun get(index: Int): Double = this@asList[index] + override fun indexOf(element: Double): Int = this@asList.indexOf(element) + override fun lastIndexOf(element: Double): Int = this@asList.lastIndexOf(element) + } +} + +/** + * Returns a [List] that wraps the original array. + */ +@kotlin.jvm.JvmVersion +public fun BooleanArray.asList(): List { + return object : AbstractList(), RandomAccess { + override val size: Int get() = this@asList.size + override fun isEmpty(): Boolean = this@asList.isEmpty() + override fun contains(element: Boolean): Boolean = this@asList.contains(element) + override fun get(index: Int): Boolean = this@asList[index] + override fun indexOf(element: Boolean): Int = this@asList.indexOf(element) + override fun lastIndexOf(element: Boolean): Int = this@asList.lastIndexOf(element) + } +} + +/** + * Returns a [List] that wraps the original array. + */ +@kotlin.jvm.JvmVersion +public fun CharArray.asList(): List { + return object : AbstractList(), 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) } } @@ -12298,23 +12298,7 @@ public fun ByteArray.binarySearch(element: Byte, fromIndex: Int = 0, toIndex: In * Searches array or range of array for provided element index using binary search algorithm. Array is expected to be sorted. */ @kotlin.jvm.JvmVersion -public fun CharArray.binarySearch(element: Char, fromIndex: Int = 0, toIndex: Int = size): Int { - return Arrays.binarySearch(this, fromIndex, toIndex, element) -} - -/** - * Searches array or range of array for provided element index using binary search algorithm. Array is expected to be sorted. - */ -@kotlin.jvm.JvmVersion -public fun DoubleArray.binarySearch(element: Double, fromIndex: Int = 0, toIndex: Int = size): Int { - return Arrays.binarySearch(this, fromIndex, toIndex, element) -} - -/** - * Searches array or range of array for provided element index using binary search algorithm. Array is expected to be sorted. - */ -@kotlin.jvm.JvmVersion -public fun FloatArray.binarySearch(element: Float, fromIndex: Int = 0, toIndex: Int = size): Int { +public fun ShortArray.binarySearch(element: Short, fromIndex: Int = 0, toIndex: Int = size): Int { return Arrays.binarySearch(this, fromIndex, toIndex, element) } @@ -12338,7 +12322,23 @@ public fun LongArray.binarySearch(element: Long, fromIndex: Int = 0, toIndex: In * Searches array or range of array for provided element index using binary search algorithm. Array is expected to be sorted. */ @kotlin.jvm.JvmVersion -public fun ShortArray.binarySearch(element: Short, fromIndex: Int = 0, toIndex: Int = size): Int { +public fun FloatArray.binarySearch(element: Float, fromIndex: Int = 0, toIndex: Int = size): Int { + return Arrays.binarySearch(this, fromIndex, toIndex, element) +} + +/** + * Searches array or range of array for provided element index using binary search algorithm. Array is expected to be sorted. + */ +@kotlin.jvm.JvmVersion +public fun DoubleArray.binarySearch(element: Double, fromIndex: Int = 0, toIndex: Int = size): Int { + return Arrays.binarySearch(this, fromIndex, toIndex, element) +} + +/** + * Searches array or range of array for provided element index using binary search algorithm. Array is expected to be sorted. + */ +@kotlin.jvm.JvmVersion +public fun CharArray.binarySearch(element: Char, fromIndex: Int = 0, toIndex: Int = size): Int { return Arrays.binarySearch(this, fromIndex, toIndex, element) } @@ -12351,15 +12351,6 @@ public inline fun Array.copyOf(): Array { return Arrays.copyOf(this, size) } -/** - * Returns new array which is a copy of the original array. - */ -@kotlin.jvm.JvmVersion -@kotlin.internal.InlineOnly -public inline fun BooleanArray.copyOf(): BooleanArray { - return Arrays.copyOf(this, size) -} - /** * Returns new array which is a copy of the original array. */ @@ -12374,25 +12365,7 @@ public inline fun ByteArray.copyOf(): ByteArray { */ @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly -public inline fun CharArray.copyOf(): CharArray { - return Arrays.copyOf(this, size) -} - -/** - * Returns new array which is a copy of the original array. - */ -@kotlin.jvm.JvmVersion -@kotlin.internal.InlineOnly -public inline fun DoubleArray.copyOf(): DoubleArray { - return Arrays.copyOf(this, size) -} - -/** - * Returns new array which is a copy of the original array. - */ -@kotlin.jvm.JvmVersion -@kotlin.internal.InlineOnly -public inline fun FloatArray.copyOf(): FloatArray { +public inline fun ShortArray.copyOf(): ShortArray { return Arrays.copyOf(this, size) } @@ -12419,7 +12392,34 @@ public inline fun LongArray.copyOf(): LongArray { */ @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly -public inline fun ShortArray.copyOf(): ShortArray { +public inline fun FloatArray.copyOf(): FloatArray { + return Arrays.copyOf(this, size) +} + +/** + * Returns new array which is a copy of the original array. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun DoubleArray.copyOf(): DoubleArray { + return Arrays.copyOf(this, size) +} + +/** + * Returns new array which is a copy of the original array. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun BooleanArray.copyOf(): BooleanArray { + return Arrays.copyOf(this, size) +} + +/** + * Returns new array which is a copy of the original array. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun CharArray.copyOf(): CharArray { return Arrays.copyOf(this, size) } @@ -12432,15 +12432,6 @@ public inline fun Array.copyOf(newSize: Int): Array { return Arrays.copyOf(this, newSize) } -/** - * Returns new array which is a copy of the original array. - */ -@kotlin.jvm.JvmVersion -@kotlin.internal.InlineOnly -public inline fun BooleanArray.copyOf(newSize: Int): BooleanArray { - return Arrays.copyOf(this, newSize) -} - /** * Returns new array which is a copy of the original array. */ @@ -12455,25 +12446,7 @@ public inline fun ByteArray.copyOf(newSize: Int): ByteArray { */ @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly -public inline fun CharArray.copyOf(newSize: Int): CharArray { - return Arrays.copyOf(this, newSize) -} - -/** - * Returns new array which is a copy of the original array. - */ -@kotlin.jvm.JvmVersion -@kotlin.internal.InlineOnly -public inline fun DoubleArray.copyOf(newSize: Int): DoubleArray { - return Arrays.copyOf(this, newSize) -} - -/** - * Returns new array which is a copy of the original array. - */ -@kotlin.jvm.JvmVersion -@kotlin.internal.InlineOnly -public inline fun FloatArray.copyOf(newSize: Int): FloatArray { +public inline fun ShortArray.copyOf(newSize: Int): ShortArray { return Arrays.copyOf(this, newSize) } @@ -12500,7 +12473,34 @@ public inline fun LongArray.copyOf(newSize: Int): LongArray { */ @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly -public inline fun ShortArray.copyOf(newSize: Int): ShortArray { +public inline fun FloatArray.copyOf(newSize: Int): FloatArray { + return Arrays.copyOf(this, newSize) +} + +/** + * Returns new array which is a copy of the original array. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun DoubleArray.copyOf(newSize: Int): DoubleArray { + return Arrays.copyOf(this, newSize) +} + +/** + * Returns new array which is a copy of the original array. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun BooleanArray.copyOf(newSize: Int): BooleanArray { + return Arrays.copyOf(this, newSize) +} + +/** + * Returns new array which is a copy of the original array. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun CharArray.copyOf(newSize: Int): CharArray { return Arrays.copyOf(this, newSize) } @@ -12513,15 +12513,6 @@ public inline fun Array.copyOfRange(fromIndex: Int, toIndex: Int): Array< return Arrays.copyOfRange(this, fromIndex, toIndex) } -/** - * Returns new array which is a copy of range of original array. - */ -@kotlin.jvm.JvmVersion -@kotlin.internal.InlineOnly -public inline fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int): BooleanArray { - return Arrays.copyOfRange(this, fromIndex, toIndex) -} - /** * Returns new array which is a copy of range of original array. */ @@ -12536,25 +12527,7 @@ public inline fun ByteArray.copyOfRange(fromIndex: Int, toIndex: Int): ByteArray */ @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly -public inline fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray { - return Arrays.copyOfRange(this, fromIndex, toIndex) -} - -/** - * Returns new array which is a copy of range of original array. - */ -@kotlin.jvm.JvmVersion -@kotlin.internal.InlineOnly -public inline fun DoubleArray.copyOfRange(fromIndex: Int, toIndex: Int): DoubleArray { - return Arrays.copyOfRange(this, fromIndex, toIndex) -} - -/** - * Returns new array which is a copy of range of original array. - */ -@kotlin.jvm.JvmVersion -@kotlin.internal.InlineOnly -public inline fun FloatArray.copyOfRange(fromIndex: Int, toIndex: Int): FloatArray { +public inline fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray { return Arrays.copyOfRange(this, fromIndex, toIndex) } @@ -12581,7 +12554,34 @@ public inline fun LongArray.copyOfRange(fromIndex: Int, toIndex: Int): LongArray */ @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly -public inline fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray { +public inline fun FloatArray.copyOfRange(fromIndex: Int, toIndex: Int): FloatArray { + return Arrays.copyOfRange(this, fromIndex, toIndex) +} + +/** + * Returns new array which is a copy of range of original array. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun DoubleArray.copyOfRange(fromIndex: Int, toIndex: Int): DoubleArray { + return Arrays.copyOfRange(this, fromIndex, toIndex) +} + +/** + * Returns new array which is a copy of range of original array. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int): BooleanArray { + return Arrays.copyOfRange(this, fromIndex, toIndex) +} + +/** + * Returns new array which is a copy of range of original array. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray { return Arrays.copyOfRange(this, fromIndex, toIndex) } @@ -12593,14 +12593,6 @@ public fun Array.fill(element: T, fromIndex: Int = 0, toIndex: Int = size Arrays.fill(this, fromIndex, toIndex, element) } -/** - * Fills original array with the provided value. - */ -@kotlin.jvm.JvmVersion -public fun BooleanArray.fill(element: Boolean, fromIndex: Int = 0, toIndex: Int = size): Unit { - Arrays.fill(this, fromIndex, toIndex, element) -} - /** * Fills original array with the provided value. */ @@ -12613,23 +12605,7 @@ public fun ByteArray.fill(element: Byte, fromIndex: Int = 0, toIndex: Int = size * Fills original array with the provided value. */ @kotlin.jvm.JvmVersion -public fun CharArray.fill(element: Char, fromIndex: Int = 0, toIndex: Int = size): Unit { - Arrays.fill(this, fromIndex, toIndex, element) -} - -/** - * Fills original array with the provided value. - */ -@kotlin.jvm.JvmVersion -public fun DoubleArray.fill(element: Double, fromIndex: Int = 0, toIndex: Int = size): Unit { - Arrays.fill(this, fromIndex, toIndex, element) -} - -/** - * Fills original array with the provided value. - */ -@kotlin.jvm.JvmVersion -public fun FloatArray.fill(element: Float, fromIndex: Int = 0, toIndex: Int = size): Unit { +public fun ShortArray.fill(element: Short, fromIndex: Int = 0, toIndex: Int = size): Unit { Arrays.fill(this, fromIndex, toIndex, element) } @@ -12653,7 +12629,31 @@ public fun LongArray.fill(element: Long, fromIndex: Int = 0, toIndex: Int = size * Fills original array with the provided value. */ @kotlin.jvm.JvmVersion -public fun ShortArray.fill(element: Short, fromIndex: Int = 0, toIndex: Int = size): Unit { +public fun FloatArray.fill(element: Float, fromIndex: Int = 0, toIndex: Int = size): Unit { + Arrays.fill(this, fromIndex, toIndex, element) +} + +/** + * Fills original array with the provided value. + */ +@kotlin.jvm.JvmVersion +public fun DoubleArray.fill(element: Double, fromIndex: Int = 0, toIndex: Int = size): Unit { + Arrays.fill(this, fromIndex, toIndex, element) +} + +/** + * Fills original array with the provided value. + */ +@kotlin.jvm.JvmVersion +public fun BooleanArray.fill(element: Boolean, fromIndex: Int = 0, toIndex: Int = size): Unit { + Arrays.fill(this, fromIndex, toIndex, element) +} + +/** + * Fills original array with the provided value. + */ +@kotlin.jvm.JvmVersion +public fun CharArray.fill(element: Char, fromIndex: Int = 0, toIndex: Int = size): Unit { Arrays.fill(this, fromIndex, toIndex, element) } @@ -12702,17 +12702,6 @@ public operator fun Array.plus(element: T): Array { return result } -/** - * Returns an array containing all elements of the original array and then the given [element]. - */ -@kotlin.jvm.JvmVersion -public operator fun BooleanArray.plus(element: Boolean): BooleanArray { - val index = size - val result = 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]. */ @@ -12728,29 +12717,7 @@ public operator fun ByteArray.plus(element: Byte): ByteArray { * Returns an array containing all elements of the original array and then the given [element]. */ @kotlin.jvm.JvmVersion -public operator fun CharArray.plus(element: Char): CharArray { - val index = size - val result = 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]. - */ -@kotlin.jvm.JvmVersion -public operator fun DoubleArray.plus(element: Double): DoubleArray { - val index = size - val result = 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]. - */ -@kotlin.jvm.JvmVersion -public operator fun FloatArray.plus(element: Float): FloatArray { +public operator fun ShortArray.plus(element: Short): ShortArray { val index = size val result = Arrays.copyOf(this, index + 1) result[index] = element @@ -12783,7 +12750,40 @@ public operator fun LongArray.plus(element: Long): LongArray { * Returns an array containing all elements of the original array and then the given [element]. */ @kotlin.jvm.JvmVersion -public operator fun ShortArray.plus(element: Short): ShortArray { +public operator fun FloatArray.plus(element: Float): FloatArray { + val index = size + val result = 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]. + */ +@kotlin.jvm.JvmVersion +public operator fun DoubleArray.plus(element: Double): DoubleArray { + val index = size + val result = 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]. + */ +@kotlin.jvm.JvmVersion +public operator fun BooleanArray.plus(element: Boolean): BooleanArray { + val index = size + val result = 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]. + */ +@kotlin.jvm.JvmVersion +public operator fun CharArray.plus(element: Char): CharArray { val index = size val result = Arrays.copyOf(this, index + 1) result[index] = element @@ -12801,17 +12801,6 @@ public operator fun Array.plus(elements: Collection): Array { return result } -/** - * Returns an array containing all elements of the original array and then all elements of the given [elements] collection. - */ -@kotlin.jvm.JvmVersion -public operator fun BooleanArray.plus(elements: Collection): BooleanArray { - var index = size - val result = 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. */ @@ -12827,29 +12816,7 @@ public operator fun ByteArray.plus(elements: Collection): ByteArray { * Returns an array containing all elements of the original array and then all elements of the given [elements] collection. */ @kotlin.jvm.JvmVersion -public operator fun CharArray.plus(elements: Collection): CharArray { - var index = size - val result = 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. - */ -@kotlin.jvm.JvmVersion -public operator fun DoubleArray.plus(elements: Collection): DoubleArray { - var index = size - val result = 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. - */ -@kotlin.jvm.JvmVersion -public operator fun FloatArray.plus(elements: Collection): FloatArray { +public operator fun ShortArray.plus(elements: Collection): ShortArray { var index = size val result = Arrays.copyOf(this, index + elements.size) for (element in elements) result[index++] = element @@ -12882,7 +12849,40 @@ public operator fun LongArray.plus(elements: Collection): LongArray { * Returns an array containing all elements of the original array and then all elements of the given [elements] collection. */ @kotlin.jvm.JvmVersion -public operator fun ShortArray.plus(elements: Collection): ShortArray { +public operator fun FloatArray.plus(elements: Collection): FloatArray { + var index = size + val result = 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. + */ +@kotlin.jvm.JvmVersion +public operator fun DoubleArray.plus(elements: Collection): DoubleArray { + var index = size + val result = 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. + */ +@kotlin.jvm.JvmVersion +public operator fun BooleanArray.plus(elements: Collection): BooleanArray { + var index = size + val result = 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. + */ +@kotlin.jvm.JvmVersion +public operator fun CharArray.plus(elements: Collection): CharArray { var index = size val result = Arrays.copyOf(this, index + elements.size) for (element in elements) result[index++] = element @@ -12901,18 +12901,6 @@ public operator fun Array.plus(elements: Array): Array { return result } -/** - * Returns an array containing all elements of the original array and then all elements of the given [elements] array. - */ -@kotlin.jvm.JvmVersion -public operator fun BooleanArray.plus(elements: BooleanArray): BooleanArray { - val thisSize = size - val arraySize = elements.size - val result = 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. */ @@ -12929,31 +12917,7 @@ public operator fun ByteArray.plus(elements: ByteArray): ByteArray { * Returns an array containing all elements of the original array and then all elements of the given [elements] array. */ @kotlin.jvm.JvmVersion -public operator fun CharArray.plus(elements: CharArray): CharArray { - val thisSize = size - val arraySize = elements.size - val result = 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. - */ -@kotlin.jvm.JvmVersion -public operator fun DoubleArray.plus(elements: DoubleArray): DoubleArray { - val thisSize = size - val arraySize = elements.size - val result = 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. - */ -@kotlin.jvm.JvmVersion -public operator fun FloatArray.plus(elements: FloatArray): FloatArray { +public operator fun ShortArray.plus(elements: ShortArray): ShortArray { val thisSize = size val arraySize = elements.size val result = Arrays.copyOf(this, thisSize + arraySize) @@ -12989,7 +12953,43 @@ public operator fun LongArray.plus(elements: LongArray): LongArray { * Returns an array containing all elements of the original array and then all elements of the given [elements] array. */ @kotlin.jvm.JvmVersion -public operator fun ShortArray.plus(elements: ShortArray): ShortArray { +public operator fun FloatArray.plus(elements: FloatArray): FloatArray { + val thisSize = size + val arraySize = elements.size + val result = 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. + */ +@kotlin.jvm.JvmVersion +public operator fun DoubleArray.plus(elements: DoubleArray): DoubleArray { + val thisSize = size + val arraySize = elements.size + val result = 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. + */ +@kotlin.jvm.JvmVersion +public operator fun BooleanArray.plus(elements: BooleanArray): BooleanArray { + val thisSize = size + val arraySize = elements.size + val result = 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. + */ +@kotlin.jvm.JvmVersion +public operator fun CharArray.plus(elements: CharArray): CharArray { val thisSize = size val arraySize = elements.size val result = Arrays.copyOf(this, thisSize + arraySize) @@ -13026,23 +13026,7 @@ public fun ByteArray.sort(): Unit { * Sorts the array in-place. */ @kotlin.jvm.JvmVersion -public fun CharArray.sort(): Unit { - if (size > 1) Arrays.sort(this) -} - -/** - * Sorts the array in-place. - */ -@kotlin.jvm.JvmVersion -public fun DoubleArray.sort(): Unit { - if (size > 1) Arrays.sort(this) -} - -/** - * Sorts the array in-place. - */ -@kotlin.jvm.JvmVersion -public fun FloatArray.sort(): Unit { +public fun ShortArray.sort(): Unit { if (size > 1) Arrays.sort(this) } @@ -13066,7 +13050,23 @@ public fun LongArray.sort(): Unit { * Sorts the array in-place. */ @kotlin.jvm.JvmVersion -public fun ShortArray.sort(): Unit { +public fun FloatArray.sort(): Unit { + if (size > 1) Arrays.sort(this) +} + +/** + * Sorts the array in-place. + */ +@kotlin.jvm.JvmVersion +public fun DoubleArray.sort(): Unit { + if (size > 1) Arrays.sort(this) +} + +/** + * Sorts the array in-place. + */ +@kotlin.jvm.JvmVersion +public fun CharArray.sort(): Unit { if (size > 1) Arrays.sort(this) } @@ -13090,23 +13090,7 @@ public fun ByteArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit { * Sorts a range in the array in-place. */ @kotlin.jvm.JvmVersion -public fun CharArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit { - Arrays.sort(this, fromIndex, toIndex) -} - -/** - * Sorts a range in the array in-place. - */ -@kotlin.jvm.JvmVersion -public fun DoubleArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit { - Arrays.sort(this, fromIndex, toIndex) -} - -/** - * Sorts a range in the array in-place. - */ -@kotlin.jvm.JvmVersion -public fun FloatArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit { +public fun ShortArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit { Arrays.sort(this, fromIndex, toIndex) } @@ -13130,7 +13114,23 @@ public fun LongArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit { * Sorts a range in the array in-place. */ @kotlin.jvm.JvmVersion -public fun ShortArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit { +public fun FloatArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit { + Arrays.sort(this, fromIndex, toIndex) +} + +/** + * Sorts a range in the array in-place. + */ +@kotlin.jvm.JvmVersion +public fun DoubleArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit { + Arrays.sort(this, fromIndex, toIndex) +} + +/** + * Sorts a range in the array in-place. + */ +@kotlin.jvm.JvmVersion +public fun CharArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit { Arrays.sort(this, fromIndex, toIndex) } @@ -13150,17 +13150,6 @@ public fun Array.sortWith(comparator: Comparator, fromIndex: In Arrays.sort(this, fromIndex, toIndex, comparator) } -/** - * Returns a *typed* object array containing all of the elements of this primitive array. - */ -@kotlin.jvm.JvmVersion -public fun BooleanArray.toTypedArray(): Array { - val result = arrayOfNulls(size) - for (index in indices) - result[index] = this[index] - return result as Array -} - /** * Returns a *typed* object array containing all of the elements of this primitive array. */ @@ -13176,33 +13165,11 @@ public fun ByteArray.toTypedArray(): Array { * Returns a *typed* object array containing all of the elements of this primitive array. */ @kotlin.jvm.JvmVersion -public fun CharArray.toTypedArray(): Array { - val result = arrayOfNulls(size) +public fun ShortArray.toTypedArray(): Array { + val result = arrayOfNulls(size) for (index in indices) result[index] = this[index] - return result as Array -} - -/** - * Returns a *typed* object array containing all of the elements of this primitive array. - */ -@kotlin.jvm.JvmVersion -public fun DoubleArray.toTypedArray(): Array { - val result = arrayOfNulls(size) - for (index in indices) - result[index] = this[index] - return result as Array -} - -/** - * Returns a *typed* object array containing all of the elements of this primitive array. - */ -@kotlin.jvm.JvmVersion -public fun FloatArray.toTypedArray(): Array { - val result = arrayOfNulls(size) - for (index in indices) - result[index] = this[index] - return result as Array + return result as Array } /** @@ -13231,11 +13198,44 @@ public fun LongArray.toTypedArray(): Array { * Returns a *typed* object array containing all of the elements of this primitive array. */ @kotlin.jvm.JvmVersion -public fun ShortArray.toTypedArray(): Array { - val result = arrayOfNulls(size) +public fun FloatArray.toTypedArray(): Array { + val result = arrayOfNulls(size) for (index in indices) result[index] = this[index] - return result as Array + return result as Array +} + +/** + * Returns a *typed* object array containing all of the elements of this primitive array. + */ +@kotlin.jvm.JvmVersion +public fun DoubleArray.toTypedArray(): Array { + val result = arrayOfNulls(size) + for (index in indices) + result[index] = this[index] + return result as Array +} + +/** + * Returns a *typed* object array containing all of the elements of this primitive array. + */ +@kotlin.jvm.JvmVersion +public fun BooleanArray.toTypedArray(): Array { + val result = arrayOfNulls(size) + for (index in indices) + result[index] = this[index] + return result as Array +} + +/** + * Returns a *typed* object array containing all of the elements of this primitive array. + */ +@kotlin.jvm.JvmVersion +public fun CharArray.toTypedArray(): Array { + val result = arrayOfNulls(size) + for (index in indices) + result[index] = this[index] + return result as Array } /** @@ -13256,23 +13256,8 @@ public fun Array.average(): Double { /** * Returns an average value of elements in the array. */ -@kotlin.jvm.JvmName("averageOfDouble") -public fun Array.average(): Double { - val iterator = iterator() - var sum: Double = 0.0 - var count: Int = 0 - while (iterator.hasNext()) { - sum += iterator.next() - count += 1 - } - return if (count == 0) 0.0 else sum / count -} - -/** - * Returns an average value of elements in the array. - */ -@kotlin.jvm.JvmName("averageOfFloat") -public fun Array.average(): Double { +@kotlin.jvm.JvmName("averageOfShort") +public fun Array.average(): Double { val iterator = iterator() var sum: Double = 0.0 var count: Int = 0 @@ -13316,8 +13301,23 @@ public fun Array.average(): Double { /** * Returns an average value of elements in the array. */ -@kotlin.jvm.JvmName("averageOfShort") -public fun Array.average(): Double { +@kotlin.jvm.JvmName("averageOfFloat") +public fun Array.average(): Double { + val iterator = iterator() + var sum: Double = 0.0 + var count: Int = 0 + while (iterator.hasNext()) { + sum += iterator.next() + count += 1 + } + return if (count == 0) 0.0 else sum / count +} + +/** + * Returns an average value of elements in the array. + */ +@kotlin.jvm.JvmName("averageOfDouble") +public fun Array.average(): Double { val iterator = iterator() var sum: Double = 0.0 var count: Int = 0 @@ -13345,21 +13345,7 @@ public fun ByteArray.average(): Double { /** * Returns an average value of elements in the array. */ -public fun DoubleArray.average(): Double { - val iterator = iterator() - var sum: Double = 0.0 - var count: Int = 0 - while (iterator.hasNext()) { - sum += iterator.next() - count += 1 - } - return if (count == 0) 0.0 else sum / count -} - -/** - * Returns an average value of elements in the array. - */ -public fun FloatArray.average(): Double { +public fun ShortArray.average(): Double { val iterator = iterator() var sum: Double = 0.0 var count: Int = 0 @@ -13401,7 +13387,21 @@ public fun LongArray.average(): Double { /** * Returns an average value of elements in the array. */ -public fun ShortArray.average(): Double { +public fun FloatArray.average(): Double { + val iterator = iterator() + var sum: Double = 0.0 + var count: Int = 0 + while (iterator.hasNext()) { + sum += iterator.next() + count += 1 + } + return if (count == 0) 0.0 else sum / count +} + +/** + * Returns an average value of elements in the array. + */ +public fun DoubleArray.average(): Double { val iterator = iterator() var sum: Double = 0.0 var count: Int = 0 @@ -13428,23 +13428,10 @@ public fun Array.sum(): Int { /** * Returns the sum of all elements in the array. */ -@kotlin.jvm.JvmName("sumOfDouble") -public fun Array.sum(): Double { +@kotlin.jvm.JvmName("sumOfShort") +public fun Array.sum(): Int { val iterator = iterator() - var sum: Double = 0.0 - while (iterator.hasNext()) { - sum += iterator.next() - } - return sum -} - -/** - * Returns the sum of all elements in the array. - */ -@kotlin.jvm.JvmName("sumOfFloat") -public fun Array.sum(): Float { - val iterator = iterator() - var sum: Float = 0.0f + var sum: Int = 0 while (iterator.hasNext()) { sum += iterator.next() } @@ -13480,10 +13467,23 @@ public fun Array.sum(): Long { /** * Returns the sum of all elements in the array. */ -@kotlin.jvm.JvmName("sumOfShort") -public fun Array.sum(): Int { +@kotlin.jvm.JvmName("sumOfFloat") +public fun Array.sum(): Float { val iterator = iterator() - var sum: Int = 0 + var sum: Float = 0.0f + while (iterator.hasNext()) { + sum += iterator.next() + } + return sum +} + +/** + * Returns the sum of all elements in the array. + */ +@kotlin.jvm.JvmName("sumOfDouble") +public fun Array.sum(): Double { + val iterator = iterator() + var sum: Double = 0.0 while (iterator.hasNext()) { sum += iterator.next() } @@ -13505,21 +13505,9 @@ public fun ByteArray.sum(): Int { /** * Returns the sum of all elements in the array. */ -public fun DoubleArray.sum(): Double { +public fun ShortArray.sum(): Int { val iterator = iterator() - var sum: Double = 0.0 - while (iterator.hasNext()) { - sum += iterator.next() - } - return sum -} - -/** - * Returns the sum of all elements in the array. - */ -public fun FloatArray.sum(): Float { - val iterator = iterator() - var sum: Float = 0.0f + var sum: Int = 0 while (iterator.hasNext()) { sum += iterator.next() } @@ -13553,9 +13541,21 @@ public fun LongArray.sum(): Long { /** * Returns the sum of all elements in the array. */ -public fun ShortArray.sum(): Int { +public fun FloatArray.sum(): Float { val iterator = iterator() - var sum: Int = 0 + var sum: Float = 0.0f + while (iterator.hasNext()) { + sum += iterator.next() + } + return sum +} + +/** + * Returns the sum of all elements in the array. + */ +public fun DoubleArray.sum(): Double { + val iterator = iterator() + var sum: Double = 0.0 while (iterator.hasNext()) { sum += iterator.next() } diff --git a/libraries/stdlib/src/generated/_Collections.kt b/libraries/stdlib/src/generated/_Collections.kt index a2371842c49..e6c9fbb6e81 100644 --- a/libraries/stdlib/src/generated/_Collections.kt +++ b/libraries/stdlib/src/generated/_Collections.kt @@ -1943,23 +1943,8 @@ public fun Iterable.average(): Double { /** * Returns an average value of elements in the collection. */ -@kotlin.jvm.JvmName("averageOfDouble") -public fun Iterable.average(): Double { - val iterator = iterator() - var sum: Double = 0.0 - var count: Int = 0 - while (iterator.hasNext()) { - sum += iterator.next() - count += 1 - } - return if (count == 0) 0.0 else sum / count -} - -/** - * Returns an average value of elements in the collection. - */ -@kotlin.jvm.JvmName("averageOfFloat") -public fun Iterable.average(): Double { +@kotlin.jvm.JvmName("averageOfShort") +public fun Iterable.average(): Double { val iterator = iterator() var sum: Double = 0.0 var count: Int = 0 @@ -2003,8 +1988,23 @@ public fun Iterable.average(): Double { /** * Returns an average value of elements in the collection. */ -@kotlin.jvm.JvmName("averageOfShort") -public fun Iterable.average(): Double { +@kotlin.jvm.JvmName("averageOfFloat") +public fun Iterable.average(): Double { + val iterator = iterator() + var sum: Double = 0.0 + var count: Int = 0 + while (iterator.hasNext()) { + sum += iterator.next() + count += 1 + } + return if (count == 0) 0.0 else sum / count +} + +/** + * Returns an average value of elements in the collection. + */ +@kotlin.jvm.JvmName("averageOfDouble") +public fun Iterable.average(): Double { val iterator = iterator() var sum: Double = 0.0 var count: Int = 0 @@ -2031,23 +2031,10 @@ public fun Iterable.sum(): Int { /** * Returns the sum of all elements in the collection. */ -@kotlin.jvm.JvmName("sumOfDouble") -public fun Iterable.sum(): Double { +@kotlin.jvm.JvmName("sumOfShort") +public fun Iterable.sum(): Int { val iterator = iterator() - var sum: Double = 0.0 - while (iterator.hasNext()) { - sum += iterator.next() - } - return sum -} - -/** - * Returns the sum of all elements in the collection. - */ -@kotlin.jvm.JvmName("sumOfFloat") -public fun Iterable.sum(): Float { - val iterator = iterator() - var sum: Float = 0.0f + var sum: Int = 0 while (iterator.hasNext()) { sum += iterator.next() } @@ -2083,10 +2070,23 @@ public fun Iterable.sum(): Long { /** * Returns the sum of all elements in the collection. */ -@kotlin.jvm.JvmName("sumOfShort") -public fun Iterable.sum(): Int { +@kotlin.jvm.JvmName("sumOfFloat") +public fun Iterable.sum(): Float { val iterator = iterator() - var sum: Int = 0 + var sum: Float = 0.0f + while (iterator.hasNext()) { + sum += iterator.next() + } + return sum +} + +/** + * Returns the sum of all elements in the collection. + */ +@kotlin.jvm.JvmName("sumOfDouble") +public fun Iterable.sum(): Double { + val iterator = iterator() + var sum: Double = 0.0 while (iterator.hasNext()) { sum += iterator.next() } diff --git a/libraries/stdlib/src/generated/_Ranges.kt b/libraries/stdlib/src/generated/_Ranges.kt index d2347e1d112..33caf9b2093 100644 --- a/libraries/stdlib/src/generated/_Ranges.kt +++ b/libraries/stdlib/src/generated/_Ranges.kt @@ -389,13 +389,6 @@ public infix fun Short.downTo(to: Short): IntProgression { return IntProgression.fromClosedRange(this.toInt(), to.toInt(), -1) } -/** - * Returns a progression that goes over the same range in the opposite direction with the same step. - */ -public fun CharProgression.reversed(): CharProgression { - return CharProgression.fromClosedRange(last, first, -step) -} - /** * Returns a progression that goes over the same range in the opposite direction with the same step. */ @@ -411,11 +404,10 @@ public fun LongProgression.reversed(): LongProgression { } /** - * Returns a progression that goes over the same range with the given step. + * Returns a progression that goes over the same range in the opposite direction with the same step. */ -public infix fun CharProgression.step(step: Int): CharProgression { - checkStepIsPositive(step > 0, step) - return CharProgression.fromClosedRange(first, last, if (this.step > 0) step else -step) +public fun CharProgression.reversed(): CharProgression { + return CharProgression.fromClosedRange(last, first, -step) } /** @@ -434,6 +426,14 @@ public infix fun LongProgression.step(step: Long): LongProgression { return LongProgression.fromClosedRange(first, last, if (this.step > 0) step else -step) } +/** + * Returns a progression that goes over the same range with the given step. + */ +public infix fun CharProgression.step(step: Int): CharProgression { + checkStepIsPositive(step > 0, step) + return CharProgression.fromClosedRange(first, last, if (this.step > 0) step else -step) +} + /** * Returns a range from this value up to but excluding the specified [to] value. */ @@ -597,15 +597,7 @@ public fun Byte.coerceAtLeast(minimumValue: Byte): Byte { * Ensures that this value is not less than the specified [minimumValue]. * @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise. */ -public fun Double.coerceAtLeast(minimumValue: Double): Double { - return if (this < minimumValue) minimumValue else this -} - -/** - * Ensures that this value is not less than the specified [minimumValue]. - * @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise. - */ -public fun Float.coerceAtLeast(minimumValue: Float): Float { +public fun Short.coerceAtLeast(minimumValue: Short): Short { return if (this < minimumValue) minimumValue else this } @@ -629,7 +621,15 @@ public fun Long.coerceAtLeast(minimumValue: Long): Long { * Ensures that this value is not less than the specified [minimumValue]. * @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise. */ -public fun Short.coerceAtLeast(minimumValue: Short): Short { +public fun Float.coerceAtLeast(minimumValue: Float): Float { + return if (this < minimumValue) minimumValue else this +} + +/** + * Ensures that this value is not less than the specified [minimumValue]. + * @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise. + */ +public fun Double.coerceAtLeast(minimumValue: Double): Double { return if (this < minimumValue) minimumValue else this } @@ -653,15 +653,7 @@ public fun Byte.coerceAtMost(maximumValue: Byte): Byte { * Ensures that this value is not greater than the specified [maximumValue]. * @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise. */ -public fun Double.coerceAtMost(maximumValue: Double): Double { - return if (this > maximumValue) maximumValue else this -} - -/** - * Ensures that this value is not greater than the specified [maximumValue]. - * @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise. - */ -public fun Float.coerceAtMost(maximumValue: Float): Float { +public fun Short.coerceAtMost(maximumValue: Short): Short { return if (this > maximumValue) maximumValue else this } @@ -685,7 +677,15 @@ public fun Long.coerceAtMost(maximumValue: Long): Long { * Ensures that this value is not greater than the specified [maximumValue]. * @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise. */ -public fun Short.coerceAtMost(maximumValue: Short): Short { +public fun Float.coerceAtMost(maximumValue: Float): Float { + return if (this > maximumValue) maximumValue else this +} + +/** + * Ensures that this value is not greater than the specified [maximumValue]. + * @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise. + */ +public fun Double.coerceAtMost(maximumValue: Double): Double { return if (this > maximumValue) maximumValue else this } @@ -721,18 +721,7 @@ public fun Byte.coerceIn(minimumValue: Byte, maximumValue: Byte): Byte { * Ensures that this value lies in the specified range [minimumValue]..[maximumValue]. * @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue]. */ -public fun Double.coerceIn(minimumValue: Double, maximumValue: Double): Double { - if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.") - if (this < minimumValue) return minimumValue - if (this > maximumValue) return maximumValue - return this -} - -/** - * Ensures that this value lies in the specified range [minimumValue]..[maximumValue]. - * @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue]. - */ -public fun Float.coerceIn(minimumValue: Float, maximumValue: Float): Float { +public fun Short.coerceIn(minimumValue: Short, maximumValue: Short): Short { if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.") if (this < minimumValue) return minimumValue if (this > maximumValue) return maximumValue @@ -765,7 +754,18 @@ public fun Long.coerceIn(minimumValue: Long, maximumValue: Long): Long { * Ensures that this value lies in the specified range [minimumValue]..[maximumValue]. * @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue]. */ -public fun Short.coerceIn(minimumValue: Short, maximumValue: Short): Short { +public fun Float.coerceIn(minimumValue: Float, maximumValue: Float): Float { + if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.") + if (this < minimumValue) return minimumValue + if (this > maximumValue) return maximumValue + return this +} + +/** + * Ensures that this value lies in the specified range [minimumValue]..[maximumValue]. + * @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue]. + */ +public fun Double.coerceIn(minimumValue: Double, maximumValue: Double): Double { if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.") if (this < minimumValue) return minimumValue if (this > maximumValue) return maximumValue diff --git a/libraries/stdlib/src/generated/_Sequences.kt b/libraries/stdlib/src/generated/_Sequences.kt index f89ac2af925..2a4c58d6e96 100644 --- a/libraries/stdlib/src/generated/_Sequences.kt +++ b/libraries/stdlib/src/generated/_Sequences.kt @@ -1235,23 +1235,8 @@ public fun Sequence.average(): Double { /** * Returns an average value of elements in the sequence. */ -@kotlin.jvm.JvmName("averageOfDouble") -public fun Sequence.average(): Double { - val iterator = iterator() - var sum: Double = 0.0 - var count: Int = 0 - while (iterator.hasNext()) { - sum += iterator.next() - count += 1 - } - return if (count == 0) 0.0 else sum / count -} - -/** - * Returns an average value of elements in the sequence. - */ -@kotlin.jvm.JvmName("averageOfFloat") -public fun Sequence.average(): Double { +@kotlin.jvm.JvmName("averageOfShort") +public fun Sequence.average(): Double { val iterator = iterator() var sum: Double = 0.0 var count: Int = 0 @@ -1295,8 +1280,23 @@ public fun Sequence.average(): Double { /** * Returns an average value of elements in the sequence. */ -@kotlin.jvm.JvmName("averageOfShort") -public fun Sequence.average(): Double { +@kotlin.jvm.JvmName("averageOfFloat") +public fun Sequence.average(): Double { + val iterator = iterator() + var sum: Double = 0.0 + var count: Int = 0 + while (iterator.hasNext()) { + sum += iterator.next() + count += 1 + } + return if (count == 0) 0.0 else sum / count +} + +/** + * Returns an average value of elements in the sequence. + */ +@kotlin.jvm.JvmName("averageOfDouble") +public fun Sequence.average(): Double { val iterator = iterator() var sum: Double = 0.0 var count: Int = 0 @@ -1323,23 +1323,10 @@ public fun Sequence.sum(): Int { /** * Returns the sum of all elements in the sequence. */ -@kotlin.jvm.JvmName("sumOfDouble") -public fun Sequence.sum(): Double { +@kotlin.jvm.JvmName("sumOfShort") +public fun Sequence.sum(): Int { val iterator = iterator() - var sum: Double = 0.0 - while (iterator.hasNext()) { - sum += iterator.next() - } - return sum -} - -/** - * Returns the sum of all elements in the sequence. - */ -@kotlin.jvm.JvmName("sumOfFloat") -public fun Sequence.sum(): Float { - val iterator = iterator() - var sum: Float = 0.0f + var sum: Int = 0 while (iterator.hasNext()) { sum += iterator.next() } @@ -1375,10 +1362,23 @@ public fun Sequence.sum(): Long { /** * Returns the sum of all elements in the sequence. */ -@kotlin.jvm.JvmName("sumOfShort") -public fun Sequence.sum(): Int { +@kotlin.jvm.JvmName("sumOfFloat") +public fun Sequence.sum(): Float { val iterator = iterator() - var sum: Int = 0 + var sum: Float = 0.0f + while (iterator.hasNext()) { + sum += iterator.next() + } + return sum +} + +/** + * Returns the sum of all elements in the sequence. + */ +@kotlin.jvm.JvmName("sumOfDouble") +public fun Sequence.sum(): Double { + val iterator = iterator() + var sum: Double = 0.0 while (iterator.hasNext()) { sum += iterator.next() } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/engine/Engine.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/engine/Engine.kt index 8a157a3748b..acea556df67 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/engine/Engine.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/engine/Engine.kt @@ -32,14 +32,14 @@ enum class Family { } enum class PrimitiveType { - Boolean, Byte, - Char, Short, Int, Long, Float, - Double; + Double, + Boolean, + Char; companion object { val defaultPrimitives = PrimitiveType.values().toSet() @@ -208,7 +208,7 @@ class GenericFunction(val signature: String, val keyword: String = "fun") { val onlyPrimitives = buildFamilyPrimitives[f] if (f.isPrimitiveSpecialization || onlyPrimitives != null) { - return (onlyPrimitives ?: buildPrimitives).sortedBy { it.name } + return (onlyPrimitives ?: buildPrimitives).sortedBy { it.ordinal } .map { primitive -> ConcreteFunction( { build(it, f, primitive) }, sourceFileFor(f) ) } } else { return listOf(ConcreteFunction( { build(it, f, null) }, sourceFileFor(f) ))