Review and correct exception messages.
This commit is contained in:
@@ -802,7 +802,7 @@ public inline fun CharArray.findLast(predicate: (Char) -> Boolean): Char? {
|
||||
*/
|
||||
public fun <T> Array<out T>.first(): T {
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty.")
|
||||
throw NoSuchElementException("Array is empty.")
|
||||
return this[0]
|
||||
}
|
||||
|
||||
@@ -812,7 +812,7 @@ public fun <T> Array<out T>.first(): T {
|
||||
*/
|
||||
public fun ByteArray.first(): Byte {
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty.")
|
||||
throw NoSuchElementException("Array is empty.")
|
||||
return this[0]
|
||||
}
|
||||
|
||||
@@ -822,7 +822,7 @@ public fun ByteArray.first(): Byte {
|
||||
*/
|
||||
public fun ShortArray.first(): Short {
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty.")
|
||||
throw NoSuchElementException("Array is empty.")
|
||||
return this[0]
|
||||
}
|
||||
|
||||
@@ -832,7 +832,7 @@ public fun ShortArray.first(): Short {
|
||||
*/
|
||||
public fun IntArray.first(): Int {
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty.")
|
||||
throw NoSuchElementException("Array is empty.")
|
||||
return this[0]
|
||||
}
|
||||
|
||||
@@ -842,7 +842,7 @@ public fun IntArray.first(): Int {
|
||||
*/
|
||||
public fun LongArray.first(): Long {
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty.")
|
||||
throw NoSuchElementException("Array is empty.")
|
||||
return this[0]
|
||||
}
|
||||
|
||||
@@ -852,7 +852,7 @@ public fun LongArray.first(): Long {
|
||||
*/
|
||||
public fun FloatArray.first(): Float {
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty.")
|
||||
throw NoSuchElementException("Array is empty.")
|
||||
return this[0]
|
||||
}
|
||||
|
||||
@@ -862,7 +862,7 @@ public fun FloatArray.first(): Float {
|
||||
*/
|
||||
public fun DoubleArray.first(): Double {
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty.")
|
||||
throw NoSuchElementException("Array is empty.")
|
||||
return this[0]
|
||||
}
|
||||
|
||||
@@ -872,7 +872,7 @@ public fun DoubleArray.first(): Double {
|
||||
*/
|
||||
public fun BooleanArray.first(): Boolean {
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty.")
|
||||
throw NoSuchElementException("Array is empty.")
|
||||
return this[0]
|
||||
}
|
||||
|
||||
@@ -882,7 +882,7 @@ public fun BooleanArray.first(): Boolean {
|
||||
*/
|
||||
public fun CharArray.first(): Char {
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty.")
|
||||
throw NoSuchElementException("Array is empty.")
|
||||
return this[0]
|
||||
}
|
||||
|
||||
@@ -892,7 +892,7 @@ public fun CharArray.first(): Char {
|
||||
*/
|
||||
public inline fun <T> Array<out T>.first(predicate: (T) -> Boolean): T {
|
||||
for (element in this) if (predicate(element)) return element
|
||||
throw NoSuchElementException("No element matching predicate was found.")
|
||||
throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -901,7 +901,7 @@ public inline fun <T> Array<out T>.first(predicate: (T) -> Boolean): T {
|
||||
*/
|
||||
public inline fun ByteArray.first(predicate: (Byte) -> Boolean): Byte {
|
||||
for (element in this) if (predicate(element)) return element
|
||||
throw NoSuchElementException("No element matching predicate was found.")
|
||||
throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -910,7 +910,7 @@ public inline fun ByteArray.first(predicate: (Byte) -> Boolean): Byte {
|
||||
*/
|
||||
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.")
|
||||
throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -919,7 +919,7 @@ public inline fun ShortArray.first(predicate: (Short) -> Boolean): Short {
|
||||
*/
|
||||
public inline fun IntArray.first(predicate: (Int) -> Boolean): Int {
|
||||
for (element in this) if (predicate(element)) return element
|
||||
throw NoSuchElementException("No element matching predicate was found.")
|
||||
throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -928,7 +928,7 @@ public inline fun IntArray.first(predicate: (Int) -> Boolean): Int {
|
||||
*/
|
||||
public inline fun LongArray.first(predicate: (Long) -> Boolean): Long {
|
||||
for (element in this) if (predicate(element)) return element
|
||||
throw NoSuchElementException("No element matching predicate was found.")
|
||||
throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -937,7 +937,7 @@ public inline fun LongArray.first(predicate: (Long) -> Boolean): Long {
|
||||
*/
|
||||
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.")
|
||||
throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -946,7 +946,7 @@ public inline fun FloatArray.first(predicate: (Float) -> Boolean): Float {
|
||||
*/
|
||||
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.")
|
||||
throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -955,7 +955,7 @@ public inline fun DoubleArray.first(predicate: (Double) -> Boolean): Double {
|
||||
*/
|
||||
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.")
|
||||
throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -964,7 +964,7 @@ public inline fun BooleanArray.first(predicate: (Boolean) -> Boolean): Boolean {
|
||||
*/
|
||||
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.")
|
||||
throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1575,7 +1575,7 @@ public inline fun CharArray.indexOfLast(predicate: (Char) -> Boolean): Int {
|
||||
*/
|
||||
public fun <T> Array<out T>.last(): T {
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty.")
|
||||
throw NoSuchElementException("Array is empty.")
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
@@ -1585,7 +1585,7 @@ public fun <T> Array<out T>.last(): T {
|
||||
*/
|
||||
public fun ByteArray.last(): Byte {
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty.")
|
||||
throw NoSuchElementException("Array is empty.")
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
@@ -1595,7 +1595,7 @@ public fun ByteArray.last(): Byte {
|
||||
*/
|
||||
public fun ShortArray.last(): Short {
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty.")
|
||||
throw NoSuchElementException("Array is empty.")
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
@@ -1605,7 +1605,7 @@ public fun ShortArray.last(): Short {
|
||||
*/
|
||||
public fun IntArray.last(): Int {
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty.")
|
||||
throw NoSuchElementException("Array is empty.")
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
@@ -1615,7 +1615,7 @@ public fun IntArray.last(): Int {
|
||||
*/
|
||||
public fun LongArray.last(): Long {
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty.")
|
||||
throw NoSuchElementException("Array is empty.")
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
@@ -1625,7 +1625,7 @@ public fun LongArray.last(): Long {
|
||||
*/
|
||||
public fun FloatArray.last(): Float {
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty.")
|
||||
throw NoSuchElementException("Array is empty.")
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
@@ -1635,7 +1635,7 @@ public fun FloatArray.last(): Float {
|
||||
*/
|
||||
public fun DoubleArray.last(): Double {
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty.")
|
||||
throw NoSuchElementException("Array is empty.")
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
@@ -1645,7 +1645,7 @@ public fun DoubleArray.last(): Double {
|
||||
*/
|
||||
public fun BooleanArray.last(): Boolean {
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty.")
|
||||
throw NoSuchElementException("Array is empty.")
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
@@ -1655,7 +1655,7 @@ public fun BooleanArray.last(): Boolean {
|
||||
*/
|
||||
public fun CharArray.last(): Char {
|
||||
if (isEmpty())
|
||||
throw NoSuchElementException("Collection is empty.")
|
||||
throw NoSuchElementException("Array is empty.")
|
||||
return this[lastIndex]
|
||||
}
|
||||
|
||||
@@ -1668,7 +1668,7 @@ public inline fun <T> Array<out T>.last(predicate: (T) -> Boolean): T {
|
||||
val element = this[index]
|
||||
if (predicate(element)) return element
|
||||
}
|
||||
throw NoSuchElementException("Collection doesn't contain any element matching the predicate.")
|
||||
throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1680,7 +1680,7 @@ public inline fun ByteArray.last(predicate: (Byte) -> Boolean): Byte {
|
||||
val element = this[index]
|
||||
if (predicate(element)) return element
|
||||
}
|
||||
throw NoSuchElementException("Collection doesn't contain any element matching the predicate.")
|
||||
throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1692,7 +1692,7 @@ public inline fun ShortArray.last(predicate: (Short) -> Boolean): Short {
|
||||
val element = this[index]
|
||||
if (predicate(element)) return element
|
||||
}
|
||||
throw NoSuchElementException("Collection doesn't contain any element matching the predicate.")
|
||||
throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1704,7 +1704,7 @@ public inline fun IntArray.last(predicate: (Int) -> Boolean): Int {
|
||||
val element = this[index]
|
||||
if (predicate(element)) return element
|
||||
}
|
||||
throw NoSuchElementException("Collection doesn't contain any element matching the predicate.")
|
||||
throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1716,7 +1716,7 @@ public inline fun LongArray.last(predicate: (Long) -> Boolean): Long {
|
||||
val element = this[index]
|
||||
if (predicate(element)) return element
|
||||
}
|
||||
throw NoSuchElementException("Collection doesn't contain any element matching the predicate.")
|
||||
throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1728,7 +1728,7 @@ public inline fun FloatArray.last(predicate: (Float) -> Boolean): Float {
|
||||
val element = this[index]
|
||||
if (predicate(element)) return element
|
||||
}
|
||||
throw NoSuchElementException("Collection doesn't contain any element matching the predicate.")
|
||||
throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1740,7 +1740,7 @@ public inline fun DoubleArray.last(predicate: (Double) -> Boolean): Double {
|
||||
val element = this[index]
|
||||
if (predicate(element)) return element
|
||||
}
|
||||
throw NoSuchElementException("Collection doesn't contain any element matching the predicate.")
|
||||
throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1752,7 +1752,7 @@ public inline fun BooleanArray.last(predicate: (Boolean) -> Boolean): Boolean {
|
||||
val element = this[index]
|
||||
if (predicate(element)) return element
|
||||
}
|
||||
throw NoSuchElementException("Collection doesn't contain any element matching the predicate.")
|
||||
throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1764,7 +1764,7 @@ public inline fun CharArray.last(predicate: (Char) -> Boolean): Char {
|
||||
val element = this[index]
|
||||
if (predicate(element)) return element
|
||||
}
|
||||
throw NoSuchElementException("Collection doesn't contain any element matching the predicate.")
|
||||
throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2050,9 +2050,9 @@ public inline fun CharArray.lastOrNull(predicate: (Char) -> Boolean): Char? {
|
||||
*/
|
||||
public fun <T> Array<out T>.single(): T {
|
||||
return when (size) {
|
||||
0 -> throw NoSuchElementException("Collection is empty.")
|
||||
0 -> throw NoSuchElementException("Array is empty.")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element.")
|
||||
else -> throw IllegalArgumentException("Array has more than one element.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2061,9 +2061,9 @@ public fun <T> Array<out T>.single(): T {
|
||||
*/
|
||||
public fun ByteArray.single(): Byte {
|
||||
return when (size) {
|
||||
0 -> throw NoSuchElementException("Collection is empty.")
|
||||
0 -> throw NoSuchElementException("Array is empty.")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element.")
|
||||
else -> throw IllegalArgumentException("Array has more than one element.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2072,9 +2072,9 @@ public fun ByteArray.single(): Byte {
|
||||
*/
|
||||
public fun ShortArray.single(): Short {
|
||||
return when (size) {
|
||||
0 -> throw NoSuchElementException("Collection is empty.")
|
||||
0 -> throw NoSuchElementException("Array is empty.")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element.")
|
||||
else -> throw IllegalArgumentException("Array has more than one element.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2083,9 +2083,9 @@ public fun ShortArray.single(): Short {
|
||||
*/
|
||||
public fun IntArray.single(): Int {
|
||||
return when (size) {
|
||||
0 -> throw NoSuchElementException("Collection is empty.")
|
||||
0 -> throw NoSuchElementException("Array is empty.")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element.")
|
||||
else -> throw IllegalArgumentException("Array has more than one element.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2094,9 +2094,9 @@ public fun IntArray.single(): Int {
|
||||
*/
|
||||
public fun LongArray.single(): Long {
|
||||
return when (size) {
|
||||
0 -> throw NoSuchElementException("Collection is empty.")
|
||||
0 -> throw NoSuchElementException("Array is empty.")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element.")
|
||||
else -> throw IllegalArgumentException("Array has more than one element.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2105,9 +2105,9 @@ public fun LongArray.single(): Long {
|
||||
*/
|
||||
public fun FloatArray.single(): Float {
|
||||
return when (size) {
|
||||
0 -> throw NoSuchElementException("Collection is empty.")
|
||||
0 -> throw NoSuchElementException("Array is empty.")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element.")
|
||||
else -> throw IllegalArgumentException("Array has more than one element.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2116,9 +2116,9 @@ public fun FloatArray.single(): Float {
|
||||
*/
|
||||
public fun DoubleArray.single(): Double {
|
||||
return when (size) {
|
||||
0 -> throw NoSuchElementException("Collection is empty.")
|
||||
0 -> throw NoSuchElementException("Array is empty.")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element.")
|
||||
else -> throw IllegalArgumentException("Array has more than one element.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2127,9 +2127,9 @@ public fun DoubleArray.single(): Double {
|
||||
*/
|
||||
public fun BooleanArray.single(): Boolean {
|
||||
return when (size) {
|
||||
0 -> throw NoSuchElementException("Collection is empty.")
|
||||
0 -> throw NoSuchElementException("Array is empty.")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element.")
|
||||
else -> throw IllegalArgumentException("Array has more than one element.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2138,9 +2138,9 @@ public fun BooleanArray.single(): Boolean {
|
||||
*/
|
||||
public fun CharArray.single(): Char {
|
||||
return when (size) {
|
||||
0 -> throw NoSuchElementException("Collection is empty.")
|
||||
0 -> throw NoSuchElementException("Array is empty.")
|
||||
1 -> this[0]
|
||||
else -> throw IllegalArgumentException("Collection has more than one element.")
|
||||
else -> throw IllegalArgumentException("Array has more than one element.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2152,12 +2152,12 @@ public inline fun <T> Array<out T>.single(predicate: (T) -> Boolean): T {
|
||||
var found = false
|
||||
for (element in this) {
|
||||
if (predicate(element)) {
|
||||
if (found) throw IllegalArgumentException("Collection contains more than one matching element.")
|
||||
if (found) throw IllegalArgumentException("Array contains more than one matching element.")
|
||||
single = element
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if (!found) throw NoSuchElementException("Collection doesn't contain any element matching predicate.")
|
||||
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
return single as T
|
||||
}
|
||||
|
||||
@@ -2169,12 +2169,12 @@ public inline fun ByteArray.single(predicate: (Byte) -> Boolean): Byte {
|
||||
var found = false
|
||||
for (element in this) {
|
||||
if (predicate(element)) {
|
||||
if (found) throw IllegalArgumentException("Collection contains more than one matching element.")
|
||||
if (found) throw IllegalArgumentException("Array contains more than one matching element.")
|
||||
single = element
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if (!found) throw NoSuchElementException("Collection doesn't contain any element matching predicate.")
|
||||
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
return single as Byte
|
||||
}
|
||||
|
||||
@@ -2186,12 +2186,12 @@ public inline fun ShortArray.single(predicate: (Short) -> Boolean): Short {
|
||||
var found = false
|
||||
for (element in this) {
|
||||
if (predicate(element)) {
|
||||
if (found) throw IllegalArgumentException("Collection contains more than one matching element.")
|
||||
if (found) throw IllegalArgumentException("Array contains more than one matching element.")
|
||||
single = element
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if (!found) throw NoSuchElementException("Collection doesn't contain any element matching predicate.")
|
||||
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
return single as Short
|
||||
}
|
||||
|
||||
@@ -2203,12 +2203,12 @@ public inline fun IntArray.single(predicate: (Int) -> Boolean): Int {
|
||||
var found = false
|
||||
for (element in this) {
|
||||
if (predicate(element)) {
|
||||
if (found) throw IllegalArgumentException("Collection contains more than one matching element.")
|
||||
if (found) throw IllegalArgumentException("Array contains more than one matching element.")
|
||||
single = element
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if (!found) throw NoSuchElementException("Collection doesn't contain any element matching predicate.")
|
||||
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
return single as Int
|
||||
}
|
||||
|
||||
@@ -2220,12 +2220,12 @@ public inline fun LongArray.single(predicate: (Long) -> Boolean): Long {
|
||||
var found = false
|
||||
for (element in this) {
|
||||
if (predicate(element)) {
|
||||
if (found) throw IllegalArgumentException("Collection contains more than one matching element.")
|
||||
if (found) throw IllegalArgumentException("Array contains more than one matching element.")
|
||||
single = element
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if (!found) throw NoSuchElementException("Collection doesn't contain any element matching predicate.")
|
||||
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
return single as Long
|
||||
}
|
||||
|
||||
@@ -2237,12 +2237,12 @@ public inline fun FloatArray.single(predicate: (Float) -> Boolean): Float {
|
||||
var found = false
|
||||
for (element in this) {
|
||||
if (predicate(element)) {
|
||||
if (found) throw IllegalArgumentException("Collection contains more than one matching element.")
|
||||
if (found) throw IllegalArgumentException("Array contains more than one matching element.")
|
||||
single = element
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if (!found) throw NoSuchElementException("Collection doesn't contain any element matching predicate.")
|
||||
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
return single as Float
|
||||
}
|
||||
|
||||
@@ -2254,12 +2254,12 @@ public inline fun DoubleArray.single(predicate: (Double) -> Boolean): Double {
|
||||
var found = false
|
||||
for (element in this) {
|
||||
if (predicate(element)) {
|
||||
if (found) throw IllegalArgumentException("Collection contains more than one matching element.")
|
||||
if (found) throw IllegalArgumentException("Array contains more than one matching element.")
|
||||
single = element
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if (!found) throw NoSuchElementException("Collection doesn't contain any element matching predicate.")
|
||||
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
return single as Double
|
||||
}
|
||||
|
||||
@@ -2271,12 +2271,12 @@ public inline fun BooleanArray.single(predicate: (Boolean) -> Boolean): Boolean
|
||||
var found = false
|
||||
for (element in this) {
|
||||
if (predicate(element)) {
|
||||
if (found) throw IllegalArgumentException("Collection contains more than one matching element.")
|
||||
if (found) throw IllegalArgumentException("Array contains more than one matching element.")
|
||||
single = element
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if (!found) throw NoSuchElementException("Collection doesn't contain any element matching predicate.")
|
||||
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
return single as Boolean
|
||||
}
|
||||
|
||||
@@ -2288,12 +2288,12 @@ public inline fun CharArray.single(predicate: (Char) -> Boolean): Char {
|
||||
var found = false
|
||||
for (element in this) {
|
||||
if (predicate(element)) {
|
||||
if (found) throw IllegalArgumentException("Collection contains more than one matching element.")
|
||||
if (found) throw IllegalArgumentException("Array contains more than one matching element.")
|
||||
single = element
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if (!found) throw NoSuchElementException("Collection doesn't contain any element matching predicate.")
|
||||
if (!found) throw NoSuchElementException("Array contains no element matching the predicate.")
|
||||
return single as Char
|
||||
}
|
||||
|
||||
@@ -2517,7 +2517,7 @@ public inline fun CharArray.singleOrNull(predicate: (Char) -> Boolean): Char? {
|
||||
* Returns a list containing all elements except first [n] elements.
|
||||
*/
|
||||
public fun <T> Array<out T>.drop(n: Int): List<T> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
if (n == 0)
|
||||
return toList()
|
||||
if (n >= size)
|
||||
@@ -2533,7 +2533,7 @@ public fun <T> Array<out T>.drop(n: Int): List<T> {
|
||||
* Returns a list containing all elements except first [n] elements.
|
||||
*/
|
||||
public fun ByteArray.drop(n: Int): List<Byte> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
if (n == 0)
|
||||
return toList()
|
||||
if (n >= size)
|
||||
@@ -2549,7 +2549,7 @@ public fun ByteArray.drop(n: Int): List<Byte> {
|
||||
* Returns a list containing all elements except first [n] elements.
|
||||
*/
|
||||
public fun ShortArray.drop(n: Int): List<Short> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
if (n == 0)
|
||||
return toList()
|
||||
if (n >= size)
|
||||
@@ -2565,7 +2565,7 @@ public fun ShortArray.drop(n: Int): List<Short> {
|
||||
* Returns a list containing all elements except first [n] elements.
|
||||
*/
|
||||
public fun IntArray.drop(n: Int): List<Int> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
if (n == 0)
|
||||
return toList()
|
||||
if (n >= size)
|
||||
@@ -2581,7 +2581,7 @@ public fun IntArray.drop(n: Int): List<Int> {
|
||||
* Returns a list containing all elements except first [n] elements.
|
||||
*/
|
||||
public fun LongArray.drop(n: Int): List<Long> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
if (n == 0)
|
||||
return toList()
|
||||
if (n >= size)
|
||||
@@ -2597,7 +2597,7 @@ public fun LongArray.drop(n: Int): List<Long> {
|
||||
* Returns a list containing all elements except first [n] elements.
|
||||
*/
|
||||
public fun FloatArray.drop(n: Int): List<Float> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
if (n == 0)
|
||||
return toList()
|
||||
if (n >= size)
|
||||
@@ -2613,7 +2613,7 @@ public fun FloatArray.drop(n: Int): List<Float> {
|
||||
* Returns a list containing all elements except first [n] elements.
|
||||
*/
|
||||
public fun DoubleArray.drop(n: Int): List<Double> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
if (n == 0)
|
||||
return toList()
|
||||
if (n >= size)
|
||||
@@ -2629,7 +2629,7 @@ public fun DoubleArray.drop(n: Int): List<Double> {
|
||||
* Returns a list containing all elements except first [n] elements.
|
||||
*/
|
||||
public fun BooleanArray.drop(n: Int): List<Boolean> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
if (n == 0)
|
||||
return toList()
|
||||
if (n >= size)
|
||||
@@ -2645,7 +2645,7 @@ public fun BooleanArray.drop(n: Int): List<Boolean> {
|
||||
* Returns a list containing all elements except first [n] elements.
|
||||
*/
|
||||
public fun CharArray.drop(n: Int): List<Char> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
if (n == 0)
|
||||
return toList()
|
||||
if (n >= size)
|
||||
@@ -2661,7 +2661,7 @@ public fun CharArray.drop(n: Int): List<Char> {
|
||||
* Returns a list containing all elements except last [n] elements.
|
||||
*/
|
||||
public fun <T> Array<out T>.dropLast(n: Int): List<T> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
return take((size - n).coerceAtLeast(0))
|
||||
}
|
||||
|
||||
@@ -2669,7 +2669,7 @@ public fun <T> Array<out T>.dropLast(n: Int): List<T> {
|
||||
* Returns a list containing all elements except last [n] elements.
|
||||
*/
|
||||
public fun ByteArray.dropLast(n: Int): List<Byte> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
return take((size - n).coerceAtLeast(0))
|
||||
}
|
||||
|
||||
@@ -2677,7 +2677,7 @@ public fun ByteArray.dropLast(n: Int): List<Byte> {
|
||||
* Returns a list containing all elements except last [n] elements.
|
||||
*/
|
||||
public fun ShortArray.dropLast(n: Int): List<Short> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
return take((size - n).coerceAtLeast(0))
|
||||
}
|
||||
|
||||
@@ -2685,7 +2685,7 @@ public fun ShortArray.dropLast(n: Int): List<Short> {
|
||||
* Returns a list containing all elements except last [n] elements.
|
||||
*/
|
||||
public fun IntArray.dropLast(n: Int): List<Int> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
return take((size - n).coerceAtLeast(0))
|
||||
}
|
||||
|
||||
@@ -2693,7 +2693,7 @@ public fun IntArray.dropLast(n: Int): List<Int> {
|
||||
* Returns a list containing all elements except last [n] elements.
|
||||
*/
|
||||
public fun LongArray.dropLast(n: Int): List<Long> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
return take((size - n).coerceAtLeast(0))
|
||||
}
|
||||
|
||||
@@ -2701,7 +2701,7 @@ public fun LongArray.dropLast(n: Int): List<Long> {
|
||||
* Returns a list containing all elements except last [n] elements.
|
||||
*/
|
||||
public fun FloatArray.dropLast(n: Int): List<Float> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
return take((size - n).coerceAtLeast(0))
|
||||
}
|
||||
|
||||
@@ -2709,7 +2709,7 @@ public fun FloatArray.dropLast(n: Int): List<Float> {
|
||||
* Returns a list containing all elements except last [n] elements.
|
||||
*/
|
||||
public fun DoubleArray.dropLast(n: Int): List<Double> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
return take((size - n).coerceAtLeast(0))
|
||||
}
|
||||
|
||||
@@ -2717,7 +2717,7 @@ public fun DoubleArray.dropLast(n: Int): List<Double> {
|
||||
* Returns a list containing all elements except last [n] elements.
|
||||
*/
|
||||
public fun BooleanArray.dropLast(n: Int): List<Boolean> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
return take((size - n).coerceAtLeast(0))
|
||||
}
|
||||
|
||||
@@ -2725,7 +2725,7 @@ public fun BooleanArray.dropLast(n: Int): List<Boolean> {
|
||||
* Returns a list containing all elements except last [n] elements.
|
||||
*/
|
||||
public fun CharArray.dropLast(n: Int): List<Char> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
return take((size - n).coerceAtLeast(0))
|
||||
}
|
||||
|
||||
@@ -3981,7 +3981,7 @@ public fun CharArray.take(n: Int): List<Char> {
|
||||
* Returns a list containing last [n] elements.
|
||||
*/
|
||||
public fun <T> Array<out T>.takeLast(n: Int): List<T> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
if (n == 0) return emptyList()
|
||||
val size = size
|
||||
if (n >= size) return toList()
|
||||
@@ -3995,7 +3995,7 @@ public fun <T> Array<out T>.takeLast(n: Int): List<T> {
|
||||
* Returns a list containing last [n] elements.
|
||||
*/
|
||||
public fun ByteArray.takeLast(n: Int): List<Byte> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
if (n == 0) return emptyList()
|
||||
val size = size
|
||||
if (n >= size) return toList()
|
||||
@@ -4009,7 +4009,7 @@ public fun ByteArray.takeLast(n: Int): List<Byte> {
|
||||
* Returns a list containing last [n] elements.
|
||||
*/
|
||||
public fun ShortArray.takeLast(n: Int): List<Short> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
if (n == 0) return emptyList()
|
||||
val size = size
|
||||
if (n >= size) return toList()
|
||||
@@ -4023,7 +4023,7 @@ public fun ShortArray.takeLast(n: Int): List<Short> {
|
||||
* Returns a list containing last [n] elements.
|
||||
*/
|
||||
public fun IntArray.takeLast(n: Int): List<Int> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
if (n == 0) return emptyList()
|
||||
val size = size
|
||||
if (n >= size) return toList()
|
||||
@@ -4037,7 +4037,7 @@ public fun IntArray.takeLast(n: Int): List<Int> {
|
||||
* Returns a list containing last [n] elements.
|
||||
*/
|
||||
public fun LongArray.takeLast(n: Int): List<Long> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
if (n == 0) return emptyList()
|
||||
val size = size
|
||||
if (n >= size) return toList()
|
||||
@@ -4051,7 +4051,7 @@ public fun LongArray.takeLast(n: Int): List<Long> {
|
||||
* Returns a list containing last [n] elements.
|
||||
*/
|
||||
public fun FloatArray.takeLast(n: Int): List<Float> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
if (n == 0) return emptyList()
|
||||
val size = size
|
||||
if (n >= size) return toList()
|
||||
@@ -4065,7 +4065,7 @@ public fun FloatArray.takeLast(n: Int): List<Float> {
|
||||
* Returns a list containing last [n] elements.
|
||||
*/
|
||||
public fun DoubleArray.takeLast(n: Int): List<Double> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
if (n == 0) return emptyList()
|
||||
val size = size
|
||||
if (n >= size) return toList()
|
||||
@@ -4079,7 +4079,7 @@ public fun DoubleArray.takeLast(n: Int): List<Double> {
|
||||
* Returns a list containing last [n] elements.
|
||||
*/
|
||||
public fun BooleanArray.takeLast(n: Int): List<Boolean> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
if (n == 0) return emptyList()
|
||||
val size = size
|
||||
if (n >= size) return toList()
|
||||
@@ -4093,7 +4093,7 @@ public fun BooleanArray.takeLast(n: Int): List<Boolean> {
|
||||
* Returns a list containing last [n] elements.
|
||||
*/
|
||||
public fun CharArray.takeLast(n: Int): List<Char> {
|
||||
require(n >= 0, { "Requested element count $n is less than zero." })
|
||||
require(n >= 0) { "Requested element count $n is less than zero." }
|
||||
if (n == 0) return emptyList()
|
||||
val size = size
|
||||
if (n >= size) return toList()
|
||||
@@ -10351,7 +10351,7 @@ public inline fun CharArray.reduceIndexed(operation: (Int, Char, Char) -> Char):
|
||||
*/
|
||||
public inline fun <S, T: S> Array<out T>.reduceRight(operation: (T, S) -> S): S {
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.")
|
||||
if (index < 0) throw UnsupportedOperationException("Empty array can't be reduced.")
|
||||
var accumulator: S = get(index--)
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
@@ -10364,7 +10364,7 @@ public inline fun <S, T: S> Array<out T>.reduceRight(operation: (T, S) -> S): S
|
||||
*/
|
||||
public inline fun ByteArray.reduceRight(operation: (Byte, Byte) -> Byte): Byte {
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.")
|
||||
if (index < 0) throw UnsupportedOperationException("Empty array can't be reduced.")
|
||||
var accumulator = get(index--)
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
@@ -10377,7 +10377,7 @@ public inline fun ByteArray.reduceRight(operation: (Byte, Byte) -> Byte): Byte {
|
||||
*/
|
||||
public inline fun ShortArray.reduceRight(operation: (Short, Short) -> Short): Short {
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.")
|
||||
if (index < 0) throw UnsupportedOperationException("Empty array can't be reduced.")
|
||||
var accumulator = get(index--)
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
@@ -10390,7 +10390,7 @@ public inline fun ShortArray.reduceRight(operation: (Short, Short) -> Short): Sh
|
||||
*/
|
||||
public inline fun IntArray.reduceRight(operation: (Int, Int) -> Int): Int {
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.")
|
||||
if (index < 0) throw UnsupportedOperationException("Empty array can't be reduced.")
|
||||
var accumulator = get(index--)
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
@@ -10403,7 +10403,7 @@ public inline fun IntArray.reduceRight(operation: (Int, Int) -> Int): Int {
|
||||
*/
|
||||
public inline fun LongArray.reduceRight(operation: (Long, Long) -> Long): Long {
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.")
|
||||
if (index < 0) throw UnsupportedOperationException("Empty array can't be reduced.")
|
||||
var accumulator = get(index--)
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
@@ -10416,7 +10416,7 @@ public inline fun LongArray.reduceRight(operation: (Long, Long) -> Long): Long {
|
||||
*/
|
||||
public inline fun FloatArray.reduceRight(operation: (Float, Float) -> Float): Float {
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.")
|
||||
if (index < 0) throw UnsupportedOperationException("Empty array can't be reduced.")
|
||||
var accumulator = get(index--)
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
@@ -10429,7 +10429,7 @@ public inline fun FloatArray.reduceRight(operation: (Float, Float) -> Float): Fl
|
||||
*/
|
||||
public inline fun DoubleArray.reduceRight(operation: (Double, Double) -> Double): Double {
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.")
|
||||
if (index < 0) throw UnsupportedOperationException("Empty array can't be reduced.")
|
||||
var accumulator = get(index--)
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
@@ -10442,7 +10442,7 @@ public inline fun DoubleArray.reduceRight(operation: (Double, Double) -> Double)
|
||||
*/
|
||||
public inline fun BooleanArray.reduceRight(operation: (Boolean, Boolean) -> Boolean): Boolean {
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.")
|
||||
if (index < 0) throw UnsupportedOperationException("Empty array can't be reduced.")
|
||||
var accumulator = get(index--)
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
@@ -10455,7 +10455,7 @@ public inline fun BooleanArray.reduceRight(operation: (Boolean, Boolean) -> Bool
|
||||
*/
|
||||
public inline fun CharArray.reduceRight(operation: (Char, Char) -> Char): Char {
|
||||
var index = lastIndex
|
||||
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.")
|
||||
if (index < 0) throw UnsupportedOperationException("Empty array can't be reduced.")
|
||||
var accumulator = get(index--)
|
||||
while (index >= 0) {
|
||||
accumulator = operation(get(index--), accumulator)
|
||||
|
||||
Reference in New Issue
Block a user