diff --git a/libraries/stdlib/src/generated/_Aggregates.kt b/libraries/stdlib/src/generated/_Aggregates.kt index aedd06d709b..372567d6967 100644 --- a/libraries/stdlib/src/generated/_Aggregates.kt +++ b/libraries/stdlib/src/generated/_Aggregates.kt @@ -10,1391 +10,1253 @@ import java.util.* /** * Returns *true* if all elements match the given *predicate* */ -public inline fun Array.all(predicate: (T) -> Boolean) : Boolean { +public inline fun Array.all(predicate: (T) -> 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 { +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 ByteArray.all(predicate: (Byte) -> Boolean) : Boolean { +public inline fun ByteArray.all(predicate: (Byte) -> 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 { +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 { +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 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 IntArray.all(predicate: (Int) -> Boolean) : Boolean { +public inline fun IntArray.all(predicate: (Int) -> 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 LongArray.all(predicate: (Long) -> Boolean) : Boolean { +public inline fun LongArray.all(predicate: (Long) -> 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 ShortArray.all(predicate: (Short) -> Boolean) : Boolean { +public inline fun ShortArray.all(predicate: (Short) -> 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 Iterable.all(predicate: (T) -> Boolean) : Boolean { +public inline fun Iterable.all(predicate: (T) -> 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 Map.all(predicate: (Map.Entry) -> Boolean) : Boolean { +public inline fun Map.all(predicate: (Map.Entry) -> 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 Stream.all(predicate: (T) -> Boolean) : Boolean { +public inline fun Stream.all(predicate: (T) -> 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 String.all(predicate: (Char) -> Boolean) : Boolean { +public inline fun String.all(predicate: (Char) -> Boolean): Boolean { for (element in this) if (!predicate(element)) return false return true - } /** * Returns *true* if collection has at least one element */ -public fun Array.any() : Boolean { +public fun Array.any(): Boolean { for (element in this) return true return false - } /** * Returns *true* if collection has at least one element */ -public fun BooleanArray.any() : Boolean { +public fun BooleanArray.any(): Boolean { for (element in this) return true return false - } /** * Returns *true* if collection has at least one element */ -public fun ByteArray.any() : Boolean { +public fun ByteArray.any(): Boolean { for (element in this) return true return false - } /** * Returns *true* if collection has at least one element */ -public fun CharArray.any() : Boolean { +public fun CharArray.any(): Boolean { for (element in this) return true return false - } /** * Returns *true* if collection has at least one element */ -public fun DoubleArray.any() : Boolean { +public fun DoubleArray.any(): Boolean { for (element in this) return true return false - } /** * Returns *true* if collection has at least one element */ -public fun FloatArray.any() : Boolean { +public fun FloatArray.any(): Boolean { for (element in this) return true return false - } /** * Returns *true* if collection has at least one element */ -public fun IntArray.any() : Boolean { +public fun IntArray.any(): Boolean { for (element in this) return true return false - } /** * Returns *true* if collection has at least one element */ -public fun LongArray.any() : Boolean { +public fun LongArray.any(): Boolean { for (element in this) return true return false - } /** * Returns *true* if collection has at least one element */ -public fun ShortArray.any() : Boolean { +public fun ShortArray.any(): Boolean { for (element in this) return true return false - } /** * Returns *true* if collection has at least one element */ -public fun Iterable.any() : Boolean { +public fun Iterable.any(): Boolean { for (element in this) return true return false - } /** * Returns *true* if collection has at least one element */ -public fun Map.any() : Boolean { +public fun Map.any(): Boolean { for (element in this) return true return false - } /** * Returns *true* if collection has at least one element */ -public fun Stream.any() : Boolean { +public fun Stream.any(): Boolean { for (element in this) return true return false - } /** * Returns *true* if collection has at least one element */ -public fun String.any() : Boolean { +public fun String.any(): Boolean { for (element in this) return true return false - } /** * Returns *true* if any element matches the given *predicate* */ -public inline fun Array.any(predicate: (T) -> Boolean) : Boolean { +public inline fun Array.any(predicate: (T) -> Boolean): Boolean { for (element in this) if (predicate(element)) return true return false - } /** * Returns *true* if any element matches the given *predicate* */ -public inline fun BooleanArray.any(predicate: (Boolean) -> Boolean) : Boolean { +public inline fun BooleanArray.any(predicate: (Boolean) -> Boolean): Boolean { for (element in this) if (predicate(element)) return true return false - } /** * Returns *true* if any element matches the given *predicate* */ -public inline fun ByteArray.any(predicate: (Byte) -> Boolean) : Boolean { +public inline fun ByteArray.any(predicate: (Byte) -> Boolean): Boolean { for (element in this) if (predicate(element)) return true return false - } /** * Returns *true* if any element matches the given *predicate* */ -public inline fun CharArray.any(predicate: (Char) -> Boolean) : Boolean { +public inline fun CharArray.any(predicate: (Char) -> Boolean): Boolean { for (element in this) if (predicate(element)) return true return false - } /** * Returns *true* if any element matches the given *predicate* */ -public inline fun DoubleArray.any(predicate: (Double) -> Boolean) : Boolean { +public inline fun DoubleArray.any(predicate: (Double) -> Boolean): Boolean { for (element in this) if (predicate(element)) return true return false - } /** * Returns *true* if any element matches the given *predicate* */ -public inline fun FloatArray.any(predicate: (Float) -> 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 any element matches the given *predicate* */ -public inline fun IntArray.any(predicate: (Int) -> Boolean) : Boolean { +public inline fun IntArray.any(predicate: (Int) -> Boolean): Boolean { for (element in this) if (predicate(element)) return true return false - } /** * Returns *true* if any element matches the given *predicate* */ -public inline fun LongArray.any(predicate: (Long) -> Boolean) : Boolean { +public inline fun LongArray.any(predicate: (Long) -> Boolean): Boolean { for (element in this) if (predicate(element)) return true return false - } /** * Returns *true* if any element matches the given *predicate* */ -public inline fun ShortArray.any(predicate: (Short) -> Boolean) : Boolean { +public inline fun ShortArray.any(predicate: (Short) -> Boolean): Boolean { for (element in this) if (predicate(element)) return true return false - } /** * Returns *true* if any element matches the given *predicate* */ -public inline fun Iterable.any(predicate: (T) -> Boolean) : Boolean { +public inline fun Iterable.any(predicate: (T) -> Boolean): Boolean { for (element in this) if (predicate(element)) return true return false - } /** * Returns *true* if any element matches the given *predicate* */ -public inline fun Map.any(predicate: (Map.Entry) -> Boolean) : Boolean { +public inline fun Map.any(predicate: (Map.Entry) -> Boolean): Boolean { for (element in this) if (predicate(element)) return true return false - } /** * Returns *true* if any element matches the given *predicate* */ -public inline fun Stream.any(predicate: (T) -> Boolean) : Boolean { +public inline fun Stream.any(predicate: (T) -> Boolean): Boolean { for (element in this) if (predicate(element)) return true return false - } /** * Returns *true* if any element matches the given *predicate* */ -public inline fun String.any(predicate: (Char) -> Boolean) : Boolean { +public inline fun String.any(predicate: (Char) -> Boolean): Boolean { for (element in this) if (predicate(element)) return true return false - } /** * Returns the number of elements */ -public fun Array.count() : Int { +public fun Array.count(): Int { return size } /** * Returns the number of elements */ -public fun BooleanArray.count() : Int { +public fun BooleanArray.count(): Int { return size } /** * Returns the number of elements */ -public fun ByteArray.count() : Int { +public fun ByteArray.count(): Int { return size } /** * Returns the number of elements */ -public fun CharArray.count() : Int { +public fun CharArray.count(): Int { return size } /** * Returns the number of elements */ -public fun DoubleArray.count() : Int { +public fun DoubleArray.count(): Int { return size } /** * Returns the number of elements */ -public fun FloatArray.count() : Int { +public fun FloatArray.count(): Int { return size } /** * Returns the number of elements */ -public fun IntArray.count() : Int { +public fun IntArray.count(): Int { return size } /** * Returns the number of elements */ -public fun LongArray.count() : Int { +public fun LongArray.count(): Int { return size } /** * Returns the number of elements */ -public fun ShortArray.count() : Int { +public fun ShortArray.count(): Int { return size } /** * Returns the number of elements */ -public fun Collection.count() : Int { +public fun Collection.count(): Int { return size } /** * Returns the number of elements */ -public fun Iterable.count() : Int { +public fun Iterable.count(): Int { var count = 0 for (element in this) count++ return count - } /** * Returns the number of elements */ -public fun Map.count() : Int { +public fun Map.count(): Int { return size } /** * Returns the number of elements */ -public fun Stream.count() : Int { +public fun Stream.count(): Int { var count = 0 for (element in this) count++ return count - } /** * Returns the number of elements */ -public fun String.count() : Int { +public fun String.count(): Int { return size } /** * Returns the number of elements matching the given *predicate* */ -public inline fun Array.count(predicate: (T) -> Boolean) : Int { +public inline fun Array.count(predicate: (T) -> 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 { +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 ByteArray.count(predicate: (Byte) -> Boolean) : Int { +public inline fun ByteArray.count(predicate: (Byte) -> 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 { +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 { +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 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 IntArray.count(predicate: (Int) -> Boolean) : Int { +public inline fun IntArray.count(predicate: (Int) -> 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 LongArray.count(predicate: (Long) -> Boolean) : Int { +public inline fun LongArray.count(predicate: (Long) -> 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 ShortArray.count(predicate: (Short) -> Boolean) : Int { +public inline fun ShortArray.count(predicate: (Short) -> 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 Iterable.count(predicate: (T) -> Boolean) : Int { +public inline fun Iterable.count(predicate: (T) -> 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 Map.count(predicate: (Map.Entry) -> Boolean) : Int { +public inline fun Map.count(predicate: (Map.Entry) -> 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 Stream.count(predicate: (T) -> Boolean) : Int { +public inline fun Stream.count(predicate: (T) -> 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 String.count(predicate: (Char) -> Boolean) : Int { +public inline fun String.count(predicate: (Char) -> Boolean): Int { var count = 0 for (element in this) if (predicate(element)) count++ return count - } /** * Accumulates value starting with *initial* value and applying *operation* from left to right to current accumulator value and each element */ -public inline fun Array.fold(initial: R, operation: (R, T) -> R) : R { +public inline fun Array.fold(initial: R, operation: (R, T) -> 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 { +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 ByteArray.fold(initial: R, operation: (R, Byte) -> R) : R { +public inline fun ByteArray.fold(initial: R, operation: (R, Byte) -> 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 { +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 { +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 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 IntArray.fold(initial: R, operation: (R, Int) -> R) : R { +public inline fun IntArray.fold(initial: R, operation: (R, Int) -> 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 LongArray.fold(initial: R, operation: (R, Long) -> R) : R { +public inline fun LongArray.fold(initial: R, operation: (R, Long) -> 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 ShortArray.fold(initial: R, operation: (R, Short) -> 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 - } /** * Accumulates value starting with *initial* value and applying *operation* from left to right to current accumulator value and each element */ -public inline fun Iterable.fold(initial: R, operation: (R, T) -> R) : R { +public inline fun Iterable.fold(initial: R, operation: (R, T) -> 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 Stream.fold(initial: R, operation: (R, T) -> R) : R { +public inline fun Stream.fold(initial: R, operation: (R, T) -> 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 String.fold(initial: R, operation: (R, Char) -> R) : R { +public inline fun String.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 right to left to each element and current accumulator value */ -public inline fun Array.foldRight(initial: R, operation: (T, R) -> R) : R { +public inline fun Array.foldRight(initial: R, operation: (T, R) -> R): R { var index = size - 1 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 { +public inline fun BooleanArray.foldRight(initial: R, operation: (Boolean, R) -> R): R { var index = size - 1 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 ByteArray.foldRight(initial: R, operation: (Byte, R) -> R) : R { +public inline fun ByteArray.foldRight(initial: R, operation: (Byte, R) -> R): R { var index = size - 1 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 { +public inline fun CharArray.foldRight(initial: R, operation: (Char, R) -> R): R { var index = size - 1 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 { +public inline fun DoubleArray.foldRight(initial: R, operation: (Double, R) -> R): R { var index = size - 1 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 FloatArray.foldRight(initial: R, operation: (Float, R) -> R): R { var index = size - 1 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 IntArray.foldRight(initial: R, operation: (Int, R) -> R) : R { +public inline fun IntArray.foldRight(initial: R, operation: (Int, R) -> R): R { var index = size - 1 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 LongArray.foldRight(initial: R, operation: (Long, R) -> R) : R { +public inline fun LongArray.foldRight(initial: R, operation: (Long, R) -> R): R { var index = size - 1 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 ShortArray.foldRight(initial: R, operation: (Short, R) -> R) : R { +public inline fun ShortArray.foldRight(initial: R, operation: (Short, R) -> R): R { var index = size - 1 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 List.foldRight(initial: R, operation: (T, R) -> R) : R { +public inline fun List.foldRight(initial: R, operation: (T, R) -> R): R { var index = size - 1 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 String.foldRight(initial: R, operation: (Char, R) -> R) : R { +public inline fun String.foldRight(initial: R, operation: (Char, R) -> R): R { var index = size - 1 var accumulator = initial while (index >= 0) { accumulator = operation(get(index--), accumulator) } return accumulator - } /** * Performs the given *operation* on each element */ -public inline fun Array.forEach(operation: (T) -> Unit) : Unit { +public inline fun Array.forEach(operation: (T) -> Unit): Unit { for (element in this) operation(element) - } /** * Performs the given *operation* on each element */ -public inline fun BooleanArray.forEach(operation: (Boolean) -> Unit) : Unit { +public inline fun BooleanArray.forEach(operation: (Boolean) -> Unit): Unit { for (element in this) operation(element) - } /** * Performs the given *operation* on each element */ -public inline fun ByteArray.forEach(operation: (Byte) -> Unit) : Unit { +public inline fun ByteArray.forEach(operation: (Byte) -> Unit): Unit { for (element in this) operation(element) - } /** * Performs the given *operation* on each element */ -public inline fun CharArray.forEach(operation: (Char) -> Unit) : Unit { +public inline fun CharArray.forEach(operation: (Char) -> Unit): Unit { for (element in this) operation(element) - } /** * Performs the given *operation* on each element */ -public inline fun DoubleArray.forEach(operation: (Double) -> Unit) : Unit { +public inline fun DoubleArray.forEach(operation: (Double) -> Unit): Unit { for (element in this) operation(element) - } /** * Performs the given *operation* on each element */ -public inline fun FloatArray.forEach(operation: (Float) -> Unit) : Unit { +public inline fun FloatArray.forEach(operation: (Float) -> Unit): Unit { for (element in this) operation(element) - } /** * Performs the given *operation* on each element */ -public inline fun IntArray.forEach(operation: (Int) -> Unit) : Unit { +public inline fun IntArray.forEach(operation: (Int) -> Unit): Unit { for (element in this) operation(element) - } /** * Performs the given *operation* on each element */ -public inline fun LongArray.forEach(operation: (Long) -> Unit) : Unit { +public inline fun LongArray.forEach(operation: (Long) -> Unit): Unit { for (element in this) operation(element) - } /** * Performs the given *operation* on each element */ -public inline fun ShortArray.forEach(operation: (Short) -> Unit) : Unit { +public inline fun ShortArray.forEach(operation: (Short) -> Unit): Unit { for (element in this) operation(element) - } /** * Performs the given *operation* on each element */ -public inline fun Iterable.forEach(operation: (T) -> Unit) : Unit { +public inline fun Iterable.forEach(operation: (T) -> Unit): Unit { for (element in this) operation(element) - } /** * Performs the given *operation* on each element */ -public inline fun Map.forEach(operation: (Map.Entry) -> Unit) : Unit { +public inline fun Map.forEach(operation: (Map.Entry) -> Unit): Unit { for (element in this) operation(element) - } /** * Performs the given *operation* on each element */ -public inline fun Stream.forEach(operation: (T) -> Unit) : Unit { +public inline fun Stream.forEach(operation: (T) -> Unit): Unit { for (element in this) operation(element) - } /** * Performs the given *operation* on each element */ -public inline fun String.forEach(operation: (Char) -> Unit) : Unit { +public inline fun String.forEach(operation: (Char) -> Unit): Unit { for (element in this) operation(element) - } /** * Returns the largest element or null if there are no elements */ -public fun > Array.max() : T? { +public fun > Array.max(): T? { 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 ByteArray.max() : Byte? { +public fun ByteArray.max(): Byte? { 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? { +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? { +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 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 IntArray.max() : Int? { +public fun IntArray.max(): Int? { 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 LongArray.max() : Long? { +public fun LongArray.max(): Long? { 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 ShortArray.max() : Short? { +public fun ShortArray.max(): Short? { 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 > Iterable.max() : T? { +public fun > Iterable.max(): T? { val iterator = iterator() if (!iterator.hasNext()) return null - var max = iterator.next() while (iterator.hasNext()) { val e = iterator.next() if (max < e) max = e } return max - } /** * Returns the largest element or null if there are no elements */ -public fun > Stream.max() : T? { +public fun > Stream.max(): T? { val iterator = iterator() if (!iterator.hasNext()) return null - var max = iterator.next() while (iterator.hasNext()) { val e = iterator.next() if (max < e) max = e } return max - } /** * Returns the largest element or null if there are no elements */ -public fun String.max() : Char? { +public fun String.max(): Char? { val iterator = iterator() if (!iterator.hasNext()) return null - var max = iterator.next() while (iterator.hasNext()) { val e = iterator.next() if (max < e) max = e } return max - } /** * Returns the first element yielding the largest value of the given function or null if there are no elements */ -public inline fun , T: Any> Array.maxBy(f: (T) -> R) : T? { +public inline fun , T : Any> Array.maxBy(f: (T) -> R): T? { if (isEmpty()) return null - var maxElem = this[0] var maxValue = f(maxElem) for (i in 1..lastIndex) { val e = this[i] val v = f(e) if (maxValue < v) { - maxElem = e - 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(f: (Boolean) -> R) : Boolean? { +public inline fun > BooleanArray.maxBy(f: (Boolean) -> R): Boolean? { if (isEmpty()) return null - var maxElem = this[0] var maxValue = f(maxElem) for (i in 1..lastIndex) { val e = this[i] val v = f(e) if (maxValue < v) { - maxElem = e - 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 > ByteArray.maxBy(f: (Byte) -> R) : Byte? { +public inline fun > ByteArray.maxBy(f: (Byte) -> R): Byte? { if (isEmpty()) return null - var maxElem = this[0] var maxValue = f(maxElem) for (i in 1..lastIndex) { val e = this[i] val v = f(e) if (maxValue < v) { - maxElem = e - 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(f: (Char) -> R) : Char? { +public inline fun > CharArray.maxBy(f: (Char) -> R): Char? { if (isEmpty()) return null - var maxElem = this[0] var maxValue = f(maxElem) for (i in 1..lastIndex) { val e = this[i] val v = f(e) if (maxValue < v) { - maxElem = e - 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(f: (Double) -> R) : Double? { +public inline fun > DoubleArray.maxBy(f: (Double) -> R): Double? { if (isEmpty()) return null - var maxElem = this[0] var maxValue = f(maxElem) for (i in 1..lastIndex) { val e = this[i] val v = f(e) if (maxValue < v) { - maxElem = e - 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(f: (Float) -> R) : Float? { +public inline fun > FloatArray.maxBy(f: (Float) -> R): Float? { if (isEmpty()) return null - var maxElem = this[0] var maxValue = f(maxElem) for (i in 1..lastIndex) { val e = this[i] val v = f(e) if (maxValue < v) { - maxElem = e - 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 > IntArray.maxBy(f: (Int) -> R) : Int? { +public inline fun > IntArray.maxBy(f: (Int) -> R): Int? { if (isEmpty()) return null - var maxElem = this[0] var maxValue = f(maxElem) for (i in 1..lastIndex) { val e = this[i] val v = f(e) if (maxValue < v) { - maxElem = e - 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 > LongArray.maxBy(f: (Long) -> R) : Long? { +public inline fun > LongArray.maxBy(f: (Long) -> R): Long? { if (isEmpty()) return null - var maxElem = this[0] var maxValue = f(maxElem) for (i in 1..lastIndex) { val e = this[i] val v = f(e) if (maxValue < v) { - maxElem = e - 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 > ShortArray.maxBy(f: (Short) -> R) : Short? { +public inline fun > ShortArray.maxBy(f: (Short) -> R): Short? { if (isEmpty()) return null - var maxElem = this[0] var maxValue = f(maxElem) for (i in 1..lastIndex) { val e = this[i] val v = f(e) if (maxValue < v) { - maxElem = e - 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 , T: Any> Iterable.maxBy(f: (T) -> R) : T? { +public inline fun , T : Any> Iterable.maxBy(f: (T) -> R): T? { val iterator = iterator() if (!iterator.hasNext()) return null - var maxElem = iterator.next() var maxValue = f(maxElem) while (iterator.hasNext()) { val e = iterator.next() val v = f(e) if (maxValue < v) { - maxElem = e - 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 , T: Any> Stream.maxBy(f: (T) -> R) : T? { +public inline fun , T : Any> Stream.maxBy(f: (T) -> R): T? { val iterator = iterator() if (!iterator.hasNext()) return null - var maxElem = iterator.next() var maxValue = f(maxElem) while (iterator.hasNext()) { val e = iterator.next() val v = f(e) if (maxValue < v) { - maxElem = e - 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 > String.maxBy(f: (Char) -> R) : Char? { +public inline fun > String.maxBy(f: (Char) -> R): Char? { val iterator = iterator() if (!iterator.hasNext()) return null - var maxElem = iterator.next() var maxValue = f(maxElem) while (iterator.hasNext()) { val e = iterator.next() val v = f(e) if (maxValue < v) { - maxElem = e - 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 > Map.maxBy(f: (Map.Entry) -> R) : Map.Entry? { +public inline fun > Map.maxBy(f: (Map.Entry) -> R): Map.Entry? { val iterator = iterator() if (!iterator.hasNext()) return null - var maxElem = iterator.next() var maxValue = f(maxElem) while (iterator.hasNext()) { val e = iterator.next() val v = f(e) if (maxValue < v) { - maxElem = e - maxValue = v + maxElem = e + maxValue = v } } return maxElem - } /** * Returns the smallest element or null if there are no elements */ -public fun > Array.min() : T? { +public fun > Array.min(): T? { if (isEmpty()) return null var min = this[0] for (i in 1..lastIndex) { @@ -1402,13 +1264,12 @@ public fun > Array.min() : T? { if (min > e) min = e } return min - } /** * Returns the smallest element or null if there are no elements */ -public fun ByteArray.min() : Byte? { +public fun ByteArray.min(): Byte? { if (isEmpty()) return null var min = this[0] for (i in 1..lastIndex) { @@ -1416,13 +1277,12 @@ public fun ByteArray.min() : Byte? { if (min > e) min = e } return min - } /** * Returns the smallest element or null if there are no elements */ -public fun CharArray.min() : Char? { +public fun CharArray.min(): Char? { if (isEmpty()) return null var min = this[0] for (i in 1..lastIndex) { @@ -1430,13 +1290,12 @@ public fun CharArray.min() : Char? { if (min > e) min = e } return min - } /** * Returns the smallest element or null if there are no elements */ -public fun DoubleArray.min() : Double? { +public fun DoubleArray.min(): Double? { if (isEmpty()) return null var min = this[0] for (i in 1..lastIndex) { @@ -1444,13 +1303,12 @@ public fun DoubleArray.min() : Double? { 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 FloatArray.min(): Float? { if (isEmpty()) return null var min = this[0] for (i in 1..lastIndex) { @@ -1458,13 +1316,12 @@ public fun FloatArray.min() : Float? { if (min > e) min = e } return min - } /** * Returns the smallest element or null if there are no elements */ -public fun IntArray.min() : Int? { +public fun IntArray.min(): Int? { if (isEmpty()) return null var min = this[0] for (i in 1..lastIndex) { @@ -1472,13 +1329,12 @@ public fun IntArray.min() : Int? { if (min > e) min = e } return min - } /** * Returns the smallest element or null if there are no elements */ -public fun LongArray.min() : Long? { +public fun LongArray.min(): Long? { if (isEmpty()) return null var min = this[0] for (i in 1..lastIndex) { @@ -1486,13 +1342,12 @@ public fun LongArray.min() : Long? { if (min > e) min = e } return min - } /** * Returns the smallest element or null if there are no elements */ -public fun ShortArray.min() : Short? { +public fun ShortArray.min(): Short? { if (isEmpty()) return null var min = this[0] for (i in 1..lastIndex) { @@ -1500,908 +1355,792 @@ public fun ShortArray.min() : Short? { if (min > e) min = e } return min - } /** * Returns the smallest element or null if there are no elements */ -public fun > Iterable.min() : T? { +public fun > Iterable.min(): T? { val iterator = iterator() if (!iterator.hasNext()) return null - var min = iterator.next() while (iterator.hasNext()) { val e = iterator.next() if (min > e) min = e } return min - } /** * Returns the smallest element or null if there are no elements */ -public fun > Stream.min() : T? { +public fun > Stream.min(): T? { val iterator = iterator() if (!iterator.hasNext()) return null - var min = iterator.next() while (iterator.hasNext()) { val e = iterator.next() if (min > e) min = e } return min - } /** * Returns the smallest element or null if there are no elements */ -public fun String.min() : Char? { +public fun String.min(): Char? { val iterator = iterator() if (!iterator.hasNext()) return null - var min = iterator.next() while (iterator.hasNext()) { val e = iterator.next() if (min > e) min = e } return min - } /** * Returns the first element yielding the smallest value of the given function or null if there are no elements */ -public inline fun , T: Any> Array.minBy(f: (T) -> R) : T? { +public inline fun , T : Any> Array.minBy(f: (T) -> R): T? { if (size == 0) return null - var minElem = this[0] var minValue = f(minElem) for (i in 1..lastIndex) { val e = this[i] val v = f(e) if (minValue > v) { - minElem = e - 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(f: (Boolean) -> R) : Boolean? { +public inline fun > BooleanArray.minBy(f: (Boolean) -> R): Boolean? { if (size == 0) return null - var minElem = this[0] var minValue = f(minElem) for (i in 1..lastIndex) { val e = this[i] val v = f(e) if (minValue > v) { - minElem = e - 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 > ByteArray.minBy(f: (Byte) -> R) : Byte? { +public inline fun > ByteArray.minBy(f: (Byte) -> R): Byte? { if (size == 0) return null - var minElem = this[0] var minValue = f(minElem) for (i in 1..lastIndex) { val e = this[i] val v = f(e) if (minValue > v) { - minElem = e - 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(f: (Char) -> R) : Char? { +public inline fun > CharArray.minBy(f: (Char) -> R): Char? { if (size == 0) return null - var minElem = this[0] var minValue = f(minElem) for (i in 1..lastIndex) { val e = this[i] val v = f(e) if (minValue > v) { - minElem = e - 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(f: (Double) -> R) : Double? { +public inline fun > DoubleArray.minBy(f: (Double) -> R): Double? { if (size == 0) return null - var minElem = this[0] var minValue = f(minElem) for (i in 1..lastIndex) { val e = this[i] val v = f(e) if (minValue > v) { - minElem = e - 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(f: (Float) -> R) : Float? { +public inline fun > FloatArray.minBy(f: (Float) -> R): Float? { if (size == 0) return null - var minElem = this[0] var minValue = f(minElem) for (i in 1..lastIndex) { val e = this[i] val v = f(e) if (minValue > v) { - minElem = e - 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 > IntArray.minBy(f: (Int) -> R) : Int? { +public inline fun > IntArray.minBy(f: (Int) -> R): Int? { if (size == 0) return null - var minElem = this[0] var minValue = f(minElem) for (i in 1..lastIndex) { val e = this[i] val v = f(e) if (minValue > v) { - minElem = e - 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 > LongArray.minBy(f: (Long) -> R) : Long? { +public inline fun > LongArray.minBy(f: (Long) -> R): Long? { if (size == 0) return null - var minElem = this[0] var minValue = f(minElem) for (i in 1..lastIndex) { val e = this[i] val v = f(e) if (minValue > v) { - minElem = e - 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 > ShortArray.minBy(f: (Short) -> R) : Short? { +public inline fun > ShortArray.minBy(f: (Short) -> R): Short? { if (size == 0) return null - var minElem = this[0] var minValue = f(minElem) for (i in 1..lastIndex) { val e = this[i] val v = f(e) if (minValue > v) { - minElem = e - 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 , T: Any> Iterable.minBy(f: (T) -> R) : T? { +public inline fun , T : Any> Iterable.minBy(f: (T) -> R): T? { val iterator = iterator() if (!iterator.hasNext()) return null - var minElem = iterator.next() var minValue = f(minElem) while (iterator.hasNext()) { val e = iterator.next() val v = f(e) if (minValue > v) { - minElem = e - 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 , T: Any> Stream.minBy(f: (T) -> R) : T? { +public inline fun , T : Any> Stream.minBy(f: (T) -> R): T? { val iterator = iterator() if (!iterator.hasNext()) return null - var minElem = iterator.next() var minValue = f(minElem) while (iterator.hasNext()) { val e = iterator.next() val v = f(e) if (minValue > v) { - minElem = e - 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 > String.minBy(f: (Char) -> R) : Char? { +public inline fun > String.minBy(f: (Char) -> R): Char? { val iterator = iterator() if (!iterator.hasNext()) return null - var minElem = iterator.next() var minValue = f(minElem) while (iterator.hasNext()) { val e = iterator.next() val v = f(e) if (minValue > v) { - minElem = e - 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 > Map.minBy(f: (Map.Entry) -> R) : Map.Entry? { +public inline fun > Map.minBy(f: (Map.Entry) -> R): Map.Entry? { val iterator = iterator() if (!iterator.hasNext()) return null - var minElem = iterator.next() var minValue = f(minElem) while (iterator.hasNext()) { val e = iterator.next() val v = f(e) if (minValue > v) { - minElem = e - minValue = v + minElem = e + minValue = v } } return minElem - } /** * Returns *true* if collection has no elements */ -public fun Array.none() : Boolean { +public fun Array.none(): Boolean { for (element in this) return false return true - } /** * Returns *true* if collection has no elements */ -public fun BooleanArray.none() : Boolean { +public fun BooleanArray.none(): Boolean { for (element in this) return false return true - } /** * Returns *true* if collection has no elements */ -public fun ByteArray.none() : Boolean { +public fun ByteArray.none(): Boolean { for (element in this) return false return true - } /** * Returns *true* if collection has no elements */ -public fun CharArray.none() : Boolean { +public fun CharArray.none(): Boolean { for (element in this) return false return true - } /** * Returns *true* if collection has no elements */ -public fun DoubleArray.none() : Boolean { +public fun DoubleArray.none(): Boolean { for (element in this) return false return true - } /** * Returns *true* if collection has no elements */ -public fun FloatArray.none() : Boolean { +public fun FloatArray.none(): Boolean { for (element in this) return false return true - } /** * Returns *true* if collection has no elements */ -public fun IntArray.none() : Boolean { +public fun IntArray.none(): Boolean { for (element in this) return false return true - } /** * Returns *true* if collection has no elements */ -public fun LongArray.none() : Boolean { +public fun LongArray.none(): Boolean { for (element in this) return false return true - } /** * Returns *true* if collection has no elements */ -public fun ShortArray.none() : Boolean { +public fun ShortArray.none(): Boolean { for (element in this) return false return true - } /** * Returns *true* if collection has no elements */ -public fun Iterable.none() : Boolean { +public fun Iterable.none(): Boolean { for (element in this) return false return true - } /** * Returns *true* if collection has no elements */ -public fun Map.none() : Boolean { +public fun Map.none(): Boolean { for (element in this) return false return true - } /** * Returns *true* if collection has no elements */ -public fun Stream.none() : Boolean { +public fun Stream.none(): Boolean { for (element in this) return false return true - } /** * Returns *true* if collection has no elements */ -public fun String.none() : Boolean { +public fun String.none(): Boolean { for (element in this) return false return true - } /** * Returns *true* if no elements match the given *predicate* */ -public inline fun Array.none(predicate: (T) -> Boolean) : Boolean { +public inline fun Array.none(predicate: (T) -> 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 { +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 ByteArray.none(predicate: (Byte) -> Boolean) : Boolean { +public inline fun ByteArray.none(predicate: (Byte) -> 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 { +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 { +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 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 IntArray.none(predicate: (Int) -> Boolean) : Boolean { +public inline fun IntArray.none(predicate: (Int) -> 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 LongArray.none(predicate: (Long) -> Boolean) : Boolean { +public inline fun LongArray.none(predicate: (Long) -> 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 ShortArray.none(predicate: (Short) -> Boolean) : Boolean { +public inline fun ShortArray.none(predicate: (Short) -> 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 Iterable.none(predicate: (T) -> Boolean) : Boolean { +public inline fun Iterable.none(predicate: (T) -> 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 Map.none(predicate: (Map.Entry) -> Boolean) : Boolean { +public inline fun Map.none(predicate: (Map.Entry) -> 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 Stream.none(predicate: (T) -> Boolean) : Boolean { +public inline fun Stream.none(predicate: (T) -> 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 String.none(predicate: (Char) -> Boolean) : Boolean { +public inline fun String.none(predicate: (Char) -> Boolean): Boolean { for (element in this) if (predicate(element)) return false return true - } /** * Accumulates value starting with the first element and applying *operation* from left to right to current accumulator value and each element */ -public inline fun Array.reduce(operation: (T, T) -> T) : T { +public inline fun Array.reduce(operation: (T, T) -> T): T { 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 { +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 ByteArray.reduce(operation: (Byte, Byte) -> Byte) : Byte { +public inline fun ByteArray.reduce(operation: (Byte, Byte) -> Byte): Byte { 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 { +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 { +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 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 IntArray.reduce(operation: (Int, Int) -> Int) : Int { +public inline fun IntArray.reduce(operation: (Int, Int) -> Int): Int { 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 LongArray.reduce(operation: (Long, Long) -> Long) : Long { +public inline fun LongArray.reduce(operation: (Long, Long) -> Long): Long { 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 ShortArray.reduce(operation: (Short, Short) -> Short) : Short { +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() 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 Iterable.reduce(operation: (T, T) -> T) : T { +public inline fun Iterable.reduce(operation: (T, T) -> T): T { 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 Stream.reduce(operation: (T, T) -> T) : T { +public inline fun Stream.reduce(operation: (T, T) -> T): T { 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 String.reduce(operation: (Char, Char) -> Char) : Char { +public inline fun String.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 last element and applying *operation* from right to left to each element and current accumulator value */ -public inline fun Array.reduceRight(operation: (T, T) -> T) : T { +public inline fun Array.reduceRight(operation: (T, T) -> T): T { var index = size - 1 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 { +public inline fun BooleanArray.reduceRight(operation: (Boolean, Boolean) -> Boolean): Boolean { var index = size - 1 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 ByteArray.reduceRight(operation: (Byte, Byte) -> Byte) : Byte { +public inline fun ByteArray.reduceRight(operation: (Byte, Byte) -> Byte): Byte { var index = size - 1 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 { +public inline fun CharArray.reduceRight(operation: (Char, Char) -> Char): Char { var index = size - 1 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 { +public inline fun DoubleArray.reduceRight(operation: (Double, Double) -> Double): Double { var index = size - 1 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 FloatArray.reduceRight(operation: (Float, Float) -> Float): Float { var index = size - 1 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 IntArray.reduceRight(operation: (Int, Int) -> Int) : Int { +public inline fun IntArray.reduceRight(operation: (Int, Int) -> Int): Int { var index = size - 1 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 LongArray.reduceRight(operation: (Long, Long) -> Long) : Long { +public inline fun LongArray.reduceRight(operation: (Long, Long) -> Long): Long { var index = size - 1 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 ShortArray.reduceRight(operation: (Short, Short) -> Short) : Short { +public inline fun ShortArray.reduceRight(operation: (Short, Short) -> Short): Short { var index = size - 1 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 List.reduceRight(operation: (T, T) -> T) : T { +public inline fun List.reduceRight(operation: (T, T) -> T): T { var index = size - 1 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 String.reduceRight(operation: (Char, Char) -> Char) : Char { +public inline fun String.reduceRight(operation: (Char, Char) -> Char): Char { var index = size - 1 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 - } diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index 982face439c..b5681a6658d 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -10,126 +10,126 @@ import java.util.* /** * Returns true if the array is empty */ -public fun Array.isEmpty() : Boolean { +public fun Array.isEmpty(): Boolean { return size == 0 } /** * Returns true if the array is empty */ -public fun BooleanArray.isEmpty() : Boolean { +public fun BooleanArray.isEmpty(): Boolean { return size == 0 } /** * Returns true if the array is empty */ -public fun ByteArray.isEmpty() : Boolean { +public fun ByteArray.isEmpty(): Boolean { return size == 0 } /** * Returns true if the array is empty */ -public fun CharArray.isEmpty() : Boolean { +public fun CharArray.isEmpty(): Boolean { return size == 0 } /** * Returns true if the array is empty */ -public fun DoubleArray.isEmpty() : Boolean { +public fun DoubleArray.isEmpty(): Boolean { return size == 0 } /** * Returns true if the array is empty */ -public fun FloatArray.isEmpty() : Boolean { +public fun FloatArray.isEmpty(): Boolean { return size == 0 } /** * Returns true if the array is empty */ -public fun IntArray.isEmpty() : Boolean { +public fun IntArray.isEmpty(): Boolean { return size == 0 } /** * Returns true if the array is empty */ -public fun LongArray.isEmpty() : Boolean { +public fun LongArray.isEmpty(): Boolean { return size == 0 } /** * Returns true if the array is empty */ -public fun ShortArray.isEmpty() : Boolean { +public fun ShortArray.isEmpty(): Boolean { return size == 0 } /** * Returns true if the array is not empty */ -public fun Array.isNotEmpty() : Boolean { +public fun Array.isNotEmpty(): Boolean { return !isEmpty() } /** * Returns true if the array is not empty */ -public fun BooleanArray.isNotEmpty() : Boolean { +public fun BooleanArray.isNotEmpty(): Boolean { return !isEmpty() } /** * Returns true if the array is not empty */ -public fun ByteArray.isNotEmpty() : Boolean { +public fun ByteArray.isNotEmpty(): Boolean { return !isEmpty() } /** * Returns true if the array is not empty */ -public fun CharArray.isNotEmpty() : Boolean { +public fun CharArray.isNotEmpty(): Boolean { return !isEmpty() } /** * Returns true if the array is not empty */ -public fun DoubleArray.isNotEmpty() : Boolean { +public fun DoubleArray.isNotEmpty(): Boolean { return !isEmpty() } /** * Returns true if the array is not empty */ -public fun FloatArray.isNotEmpty() : Boolean { +public fun FloatArray.isNotEmpty(): Boolean { return !isEmpty() } /** * Returns true if the array is not empty */ -public fun IntArray.isNotEmpty() : Boolean { +public fun IntArray.isNotEmpty(): Boolean { return !isEmpty() } /** * Returns true if the array is not empty */ -public fun LongArray.isNotEmpty() : Boolean { +public fun LongArray.isNotEmpty(): Boolean { return !isEmpty() } /** * Returns true if the array is not empty */ -public fun ShortArray.isNotEmpty() : Boolean { +public fun ShortArray.isNotEmpty(): Boolean { return !isEmpty() } diff --git a/libraries/stdlib/src/generated/_Elements.kt b/libraries/stdlib/src/generated/_Elements.kt index ca2ca13e777..1020537b9a4 100644 --- a/libraries/stdlib/src/generated/_Elements.kt +++ b/libraries/stdlib/src/generated/_Elements.kt @@ -10,171 +10,151 @@ import java.util.* /** * Returns true if *element* is found in the collection */ -public fun Array.contains(element: T) : Boolean { +public fun Array.contains(element: T): Boolean { return indexOf(element) >= 0 - } /** * Returns true if *element* is found in the collection */ -public fun BooleanArray.contains(element: Boolean) : Boolean { +public fun BooleanArray.contains(element: Boolean): Boolean { return indexOf(element) >= 0 - } /** * Returns true if *element* is found in the collection */ -public fun ByteArray.contains(element: Byte) : Boolean { +public fun ByteArray.contains(element: Byte): Boolean { return indexOf(element) >= 0 - } /** * Returns true if *element* is found in the collection */ -public fun CharArray.contains(element: Char) : Boolean { +public fun CharArray.contains(element: Char): Boolean { return indexOf(element) >= 0 - } /** * Returns true if *element* is found in the collection */ -public fun DoubleArray.contains(element: Double) : Boolean { +public fun DoubleArray.contains(element: Double): Boolean { return indexOf(element) >= 0 - } /** * Returns true if *element* is found in the collection */ -public fun FloatArray.contains(element: Float) : Boolean { +public fun FloatArray.contains(element: Float): Boolean { return indexOf(element) >= 0 - } /** * Returns true if *element* is found in the collection */ -public fun IntArray.contains(element: Int) : Boolean { +public fun IntArray.contains(element: Int): Boolean { return indexOf(element) >= 0 - } /** * Returns true if *element* is found in the collection */ -public fun LongArray.contains(element: Long) : Boolean { +public fun LongArray.contains(element: Long): Boolean { return indexOf(element) >= 0 - } /** * Returns true if *element* is found in the collection */ -public fun ShortArray.contains(element: Short) : Boolean { +public fun ShortArray.contains(element: Short): Boolean { return indexOf(element) >= 0 - } /** * Returns true if *element* is found in the collection */ -public fun Iterable.contains(element: T) : Boolean { +public fun Iterable.contains(element: T): Boolean { if (this is Collection<*>) return contains(element) return indexOf(element) >= 0 - } /** * Returns true if *element* is found in the collection */ -public fun Stream.contains(element: T) : Boolean { +public fun Stream.contains(element: T): Boolean { if (this is Collection<*>) return contains(element) return indexOf(element) >= 0 - } /** * Returns element at given *index* */ -public fun Array.elementAt(index : Int) : T { +public fun Array.elementAt(index: Int): T { return get(index) - } /** * Returns element at given *index* */ -public fun BooleanArray.elementAt(index : Int) : Boolean { +public fun BooleanArray.elementAt(index: Int): Boolean { return get(index) - } /** * Returns element at given *index* */ -public fun ByteArray.elementAt(index : Int) : Byte { +public fun ByteArray.elementAt(index: Int): Byte { return get(index) - } /** * Returns element at given *index* */ -public fun CharArray.elementAt(index : Int) : Char { +public fun CharArray.elementAt(index: Int): Char { return get(index) - } /** * Returns element at given *index* */ -public fun DoubleArray.elementAt(index : Int) : Double { +public fun DoubleArray.elementAt(index: Int): Double { return get(index) - } /** * Returns element at given *index* */ -public fun FloatArray.elementAt(index : Int) : Float { +public fun FloatArray.elementAt(index: Int): Float { return get(index) - } /** * Returns element at given *index* */ -public fun IntArray.elementAt(index : Int) : Int { +public fun IntArray.elementAt(index: Int): Int { return get(index) - } /** * Returns element at given *index* */ -public fun LongArray.elementAt(index : Int) : Long { +public fun LongArray.elementAt(index: Int): Long { return get(index) - } /** * Returns element at given *index* */ -public fun ShortArray.elementAt(index : Int) : Short { +public fun ShortArray.elementAt(index: Int): Short { return get(index) - } /** * Returns element at given *index* */ -public fun Iterable.elementAt(index : Int) : T { +public fun Iterable.elementAt(index: Int): T { if (this is List<*>) return get(index) as T val iterator = iterator() @@ -185,21 +165,19 @@ public fun Iterable.elementAt(index : Int) : T { return element } throw IndexOutOfBoundsException("Collection doesn't contain element at index") - } /** * Returns element at given *index* */ -public fun List.elementAt(index : Int) : T { +public fun List.elementAt(index: Int): T { return get(index) - } /** * Returns element at given *index* */ -public fun Stream.elementAt(index : Int) : T { +public fun Stream.elementAt(index: Int): T { val iterator = iterator() var count = 0 while (iterator.hasNext()) { @@ -208,105 +186,94 @@ public fun Stream.elementAt(index : Int) : T { return element } throw IndexOutOfBoundsException("Collection doesn't contain element at index") - } /** * Returns element at given *index* */ -public fun String.elementAt(index : Int) : Char { +public fun String.elementAt(index: Int): Char { return get(index) - } /** * Returns first element */ -public fun Array.first() : T { +public fun Array.first(): T { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[0] - } /** * Returns first element */ -public fun BooleanArray.first() : Boolean { +public fun BooleanArray.first(): Boolean { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[0] - } /** * Returns first element */ -public fun ByteArray.first() : Byte { +public fun ByteArray.first(): Byte { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[0] - } /** * Returns first element */ -public fun CharArray.first() : Char { +public fun CharArray.first(): Char { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[0] - } /** * Returns first element */ -public fun DoubleArray.first() : Double { +public fun DoubleArray.first(): Double { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[0] - } /** * Returns first element */ -public fun FloatArray.first() : Float { +public fun FloatArray.first(): Float { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[0] - } /** * Returns first element */ -public fun IntArray.first() : Int { +public fun IntArray.first(): Int { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[0] - } /** * Returns first element */ -public fun LongArray.first() : Long { +public fun LongArray.first(): Long { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[0] - } /** * Returns first element */ -public fun ShortArray.first() : Short { +public fun ShortArray.first(): Short { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[0] - } /** @@ -332,11 +299,10 @@ public fun Iterable.first(): T { /** * Returns first element */ -public fun List.first() : T { +public fun List.first(): T { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[0] - } /** @@ -362,191 +328,169 @@ public fun Stream.first(): T { /** * Returns first element */ -public fun String.first() : Char { +public fun String.first(): Char { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[0] - } /** * Returns first element matching the given *predicate* */ -public inline fun Array.first(predicate: (T) -> Boolean) : T { +public inline fun Array.first(predicate: (T) -> Boolean): T { for (element in this) if (predicate(element)) return element throw IllegalArgumentException("No element matching predicate was found") - } /** * Returns first element matching the given *predicate* */ -public inline fun BooleanArray.first(predicate: (Boolean) -> Boolean) : Boolean { +public inline fun BooleanArray.first(predicate: (Boolean) -> Boolean): Boolean { for (element in this) if (predicate(element)) return element throw IllegalArgumentException("No element matching predicate was found") - } /** * Returns first element matching the given *predicate* */ -public inline fun ByteArray.first(predicate: (Byte) -> Boolean) : Byte { +public inline fun ByteArray.first(predicate: (Byte) -> Boolean): Byte { for (element in this) if (predicate(element)) return element throw IllegalArgumentException("No element matching predicate was found") - } /** * Returns first element matching the given *predicate* */ -public inline fun CharArray.first(predicate: (Char) -> Boolean) : Char { +public inline fun CharArray.first(predicate: (Char) -> Boolean): Char { for (element in this) if (predicate(element)) return element throw IllegalArgumentException("No element matching predicate was found") - } /** * Returns first element matching the given *predicate* */ -public inline fun DoubleArray.first(predicate: (Double) -> Boolean) : Double { +public inline fun DoubleArray.first(predicate: (Double) -> Boolean): Double { for (element in this) if (predicate(element)) return element throw IllegalArgumentException("No element matching predicate was found") - } /** * Returns first element matching the given *predicate* */ -public inline fun FloatArray.first(predicate: (Float) -> Boolean) : Float { +public inline fun FloatArray.first(predicate: (Float) -> Boolean): Float { for (element in this) if (predicate(element)) return element throw IllegalArgumentException("No element matching predicate was found") - } /** * Returns first element matching the given *predicate* */ -public inline fun IntArray.first(predicate: (Int) -> Boolean) : Int { +public inline fun IntArray.first(predicate: (Int) -> Boolean): Int { for (element in this) if (predicate(element)) return element throw IllegalArgumentException("No element matching predicate was found") - } /** * Returns first element matching the given *predicate* */ -public inline fun LongArray.first(predicate: (Long) -> Boolean) : Long { +public inline fun LongArray.first(predicate: (Long) -> Boolean): Long { for (element in this) if (predicate(element)) return element throw IllegalArgumentException("No element matching predicate was found") - } /** * Returns first element matching the given *predicate* */ -public inline fun ShortArray.first(predicate: (Short) -> Boolean) : Short { +public inline fun ShortArray.first(predicate: (Short) -> Boolean): Short { for (element in this) if (predicate(element)) return element throw IllegalArgumentException("No element matching predicate was found") - } /** * Returns first element matching the given *predicate* */ -public inline fun Iterable.first(predicate: (T) -> Boolean) : T { +public inline fun Iterable.first(predicate: (T) -> Boolean): T { for (element in this) if (predicate(element)) return element throw IllegalArgumentException("No element matching predicate was found") - } /** * Returns first element matching the given *predicate* */ -public inline fun Stream.first(predicate: (T) -> Boolean) : T { +public inline fun Stream.first(predicate: (T) -> Boolean): T { for (element in this) if (predicate(element)) return element throw IllegalArgumentException("No element matching predicate was found") - } /** * Returns first element matching the given *predicate* */ -public inline fun String.first(predicate: (Char) -> Boolean) : Char { +public inline fun String.first(predicate: (Char) -> Boolean): Char { for (element in this) if (predicate(element)) return element throw IllegalArgumentException("No element matching predicate was found") - } /** * Returns first elementm, or null if collection is empty */ -public fun Array.firstOrNull() : T? { +public fun Array.firstOrNull(): T? { return if (size > 0) this[0] else null - } /** * Returns first elementm, or null if collection is empty */ -public fun BooleanArray.firstOrNull() : Boolean? { +public fun BooleanArray.firstOrNull(): Boolean? { return if (size > 0) this[0] else null - } /** * Returns first elementm, or null if collection is empty */ -public fun ByteArray.firstOrNull() : Byte? { +public fun ByteArray.firstOrNull(): Byte? { return if (size > 0) this[0] else null - } /** * Returns first elementm, or null if collection is empty */ -public fun CharArray.firstOrNull() : Char? { +public fun CharArray.firstOrNull(): Char? { return if (size > 0) this[0] else null - } /** * Returns first elementm, or null if collection is empty */ -public fun DoubleArray.firstOrNull() : Double? { +public fun DoubleArray.firstOrNull(): Double? { return if (size > 0) this[0] else null - } /** * Returns first elementm, or null if collection is empty */ -public fun FloatArray.firstOrNull() : Float? { +public fun FloatArray.firstOrNull(): Float? { return if (size > 0) this[0] else null - } /** * Returns first elementm, or null if collection is empty */ -public fun IntArray.firstOrNull() : Int? { +public fun IntArray.firstOrNull(): Int? { return if (size > 0) this[0] else null - } /** * Returns first elementm, or null if collection is empty */ -public fun LongArray.firstOrNull() : Long? { +public fun LongArray.firstOrNull(): Long? { return if (size > 0) this[0] else null - } /** * Returns first elementm, or null if collection is empty */ -public fun ShortArray.firstOrNull() : Short? { +public fun ShortArray.firstOrNull(): Short? { return if (size > 0) this[0] else null - } /** @@ -572,9 +516,8 @@ public fun Iterable.firstOrNull(): T? { /** * Returns first elementm, or null if collection is empty */ -public fun List.firstOrNull() : T? { +public fun List.firstOrNull(): T? { return if (size > 0) this[0] else null - } /** @@ -600,123 +543,110 @@ public fun Stream.firstOrNull(): T? { /** * Returns first elementm, or null if collection is empty */ -public fun String.firstOrNull() : Char? { +public fun String.firstOrNull(): Char? { return if (size > 0) this[0] else null - } /** * Returns first element matching the given *predicate*, or *null* if element was not found */ -public inline fun Array.firstOrNull(predicate: (T) -> Boolean) : T? { +public inline fun Array.firstOrNull(predicate: (T) -> Boolean): T? { for (element in this) if (predicate(element)) return element return null - } /** * Returns first element matching the given *predicate*, or *null* if element was not found */ -public inline fun BooleanArray.firstOrNull(predicate: (Boolean) -> Boolean) : Boolean? { +public inline fun BooleanArray.firstOrNull(predicate: (Boolean) -> Boolean): Boolean? { for (element in this) if (predicate(element)) return element return null - } /** * Returns first element matching the given *predicate*, or *null* if element was not found */ -public inline fun ByteArray.firstOrNull(predicate: (Byte) -> Boolean) : Byte? { +public inline fun ByteArray.firstOrNull(predicate: (Byte) -> Boolean): Byte? { for (element in this) if (predicate(element)) return element return null - } /** * Returns first element matching the given *predicate*, or *null* if element was not found */ -public inline fun CharArray.firstOrNull(predicate: (Char) -> Boolean) : Char? { +public inline fun CharArray.firstOrNull(predicate: (Char) -> Boolean): Char? { for (element in this) if (predicate(element)) return element return null - } /** * Returns first element matching the given *predicate*, or *null* if element was not found */ -public inline fun DoubleArray.firstOrNull(predicate: (Double) -> Boolean) : Double? { +public inline fun DoubleArray.firstOrNull(predicate: (Double) -> Boolean): Double? { for (element in this) if (predicate(element)) return element return null - } /** * Returns 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 FloatArray.firstOrNull(predicate: (Float) -> Boolean): Float? { for (element in this) if (predicate(element)) return element return null - } /** * Returns first element matching the given *predicate*, or *null* if element was not found */ -public inline fun IntArray.firstOrNull(predicate: (Int) -> Boolean) : Int? { +public inline fun IntArray.firstOrNull(predicate: (Int) -> Boolean): Int? { for (element in this) if (predicate(element)) return element return null - } /** * Returns first element matching the given *predicate*, or *null* if element was not found */ -public inline fun LongArray.firstOrNull(predicate: (Long) -> Boolean) : Long? { +public inline fun LongArray.firstOrNull(predicate: (Long) -> Boolean): Long? { for (element in this) if (predicate(element)) return element return null - } /** * Returns 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 ShortArray.firstOrNull(predicate: (Short) -> Boolean): Short? { for (element in this) if (predicate(element)) return element return null - } /** * Returns first element matching the given *predicate*, or *null* if element was not found */ -public inline fun Iterable.firstOrNull(predicate: (T) -> Boolean) : T? { +public inline fun Iterable.firstOrNull(predicate: (T) -> Boolean): T? { for (element in this) if (predicate(element)) return element return null - } /** * Returns first element matching the given *predicate*, or *null* if element was not found */ -public inline fun Stream.firstOrNull(predicate: (T) -> Boolean) : T? { +public inline fun Stream.firstOrNull(predicate: (T) -> Boolean): T? { for (element in this) if (predicate(element)) return element return null - } /** * Returns first element matching the given *predicate*, or *null* if element was not found */ -public inline fun String.firstOrNull(predicate: (Char) -> Boolean) : Char? { +public inline fun String.firstOrNull(predicate: (Char) -> Boolean): Char? { for (element in this) if (predicate(element)) return element return null - } /** * Returns first index of *element*, or -1 if the collection does not contain element */ -public fun Array.indexOf(element: T) : Int { +public fun Array.indexOf(element: T): Int { if (element == null) { for (index in indices) { if (this[index] == null) { @@ -731,117 +661,108 @@ public fun Array.indexOf(element: T) : Int { } } return -1 - } /** * Returns first index of *element*, or -1 if the collection does not contain element */ -public fun BooleanArray.indexOf(element: Boolean) : Int { +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 collection does not contain element */ -public fun ByteArray.indexOf(element: Byte) : Int { +public fun ByteArray.indexOf(element: Byte): Int { for (index in indices) { if (element == this[index]) { return index } } return -1 - } /** * Returns first index of *element*, or -1 if the collection does not contain element */ -public fun CharArray.indexOf(element: Char) : Int { +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 collection does not contain element */ -public fun DoubleArray.indexOf(element: Double) : Int { +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 collection does not contain element */ -public fun FloatArray.indexOf(element: Float) : 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 collection does not contain element */ -public fun IntArray.indexOf(element: Int) : Int { +public fun IntArray.indexOf(element: Int): Int { for (index in indices) { if (element == this[index]) { return index } } return -1 - } /** * Returns first index of *element*, or -1 if the collection does not contain element */ -public fun LongArray.indexOf(element: Long) : Int { +public fun LongArray.indexOf(element: Long): Int { for (index in indices) { if (element == this[index]) { return index } } return -1 - } /** * Returns first index of *element*, or -1 if the collection does not contain element */ -public fun ShortArray.indexOf(element: Short) : Int { +public fun ShortArray.indexOf(element: Short): Int { for (index in indices) { if (element == this[index]) { return index } } return -1 - } /** * Returns first index of *element*, or -1 if the collection does not contain element */ -public fun Iterable.indexOf(element: T) : Int { +public fun Iterable.indexOf(element: T): Int { var index = 0 for (item in this) { if (element == item) @@ -849,13 +770,12 @@ public fun Iterable.indexOf(element: T) : Int { index++ } return -1 - } /** * Returns first index of *element*, or -1 if the collection does not contain element */ -public fun Stream.indexOf(element: T) : Int { +public fun Stream.indexOf(element: T): Int { var index = 0 for (item in this) { if (element == item) @@ -863,108 +783,100 @@ public fun Stream.indexOf(element: T) : Int { index++ } return -1 - } /** * Returns last element */ -public fun Array.last() : T { +public fun Array.last(): T { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[size - 1] - } /** * Returns last element */ -public fun BooleanArray.last() : Boolean { +public fun BooleanArray.last(): Boolean { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[size - 1] - } /** * Returns last element */ -public fun ByteArray.last() : Byte { +public fun ByteArray.last(): Byte { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[size - 1] - } /** * Returns last element */ -public fun CharArray.last() : Char { +public fun CharArray.last(): Char { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[size - 1] - } /** * Returns last element */ -public fun DoubleArray.last() : Double { +public fun DoubleArray.last(): Double { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[size - 1] - } /** * Returns last element */ -public fun FloatArray.last() : Float { +public fun FloatArray.last(): Float { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[size - 1] - } /** * Returns last element */ -public fun IntArray.last() : Int { +public fun IntArray.last(): Int { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[size - 1] - } /** * Returns last element */ -public fun LongArray.last() : Long { +public fun LongArray.last(): Long { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[size - 1] - } /** * Returns last element */ -public fun ShortArray.last() : Short { +public fun ShortArray.last(): Short { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[size - 1] - } /** * Returns last element */ -public fun Iterable.last() : T { +public fun Iterable.last(): T { when (this) { - is List<*> -> if (size == 0) + is List<*> -> { + if (size == 0) throw IllegalArgumentException("Collection is empty") else return this[size - 1] as T + } else -> { val iterator = iterator() if (!iterator.hasNext()) @@ -975,28 +887,28 @@ public fun Iterable.last() : T { return last } } - } /** * Returns last element */ -public fun List.last() : T { +public fun List.last(): T { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[size - 1] - } /** * Returns last element */ -public fun Stream.last() : T { +public fun Stream.last(): T { when (this) { - is List<*> -> if (size == 0) + is List<*> -> { + if (size == 0) throw IllegalArgumentException("Collection is empty") else return this[size - 1] as T + } else -> { val iterator = iterator() if (!iterator.hasNext()) @@ -1007,23 +919,21 @@ public fun Stream.last() : T { return last } } - } /** * Returns last element */ -public fun String.last() : Char { +public fun String.last(): Char { if (size == 0) throw IllegalArgumentException("Collection is empty") return this[size - 1] - } /** * Returns last element matching the given *predicate* */ -public inline fun Array.last(predicate: (T) -> Boolean) : T { +public inline fun Array.last(predicate: (T) -> Boolean): T { var last: T? = null var found = false for (element in this) { @@ -1034,13 +944,12 @@ public inline fun Array.last(predicate: (T) -> Boolean) : T { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return last as T - } /** * Returns last element matching the given *predicate* */ -public inline fun BooleanArray.last(predicate: (Boolean) -> Boolean) : Boolean { +public inline fun BooleanArray.last(predicate: (Boolean) -> Boolean): Boolean { var last: Boolean? = null var found = false for (element in this) { @@ -1051,13 +960,12 @@ public inline fun BooleanArray.last(predicate: (Boolean) -> Boolean) : Boolean { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return last as Boolean - } /** * Returns last element matching the given *predicate* */ -public inline fun ByteArray.last(predicate: (Byte) -> Boolean) : Byte { +public inline fun ByteArray.last(predicate: (Byte) -> Boolean): Byte { var last: Byte? = null var found = false for (element in this) { @@ -1068,13 +976,12 @@ public inline fun ByteArray.last(predicate: (Byte) -> Boolean) : Byte { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return last as Byte - } /** * Returns last element matching the given *predicate* */ -public inline fun CharArray.last(predicate: (Char) -> Boolean) : Char { +public inline fun CharArray.last(predicate: (Char) -> Boolean): Char { var last: Char? = null var found = false for (element in this) { @@ -1085,13 +992,12 @@ public inline fun CharArray.last(predicate: (Char) -> Boolean) : Char { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return last as Char - } /** * Returns last element matching the given *predicate* */ -public inline fun DoubleArray.last(predicate: (Double) -> Boolean) : Double { +public inline fun DoubleArray.last(predicate: (Double) -> Boolean): Double { var last: Double? = null var found = false for (element in this) { @@ -1102,13 +1008,12 @@ public inline fun DoubleArray.last(predicate: (Double) -> Boolean) : Double { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return last as Double - } /** * Returns last element matching the given *predicate* */ -public inline fun FloatArray.last(predicate: (Float) -> Boolean) : Float { +public inline fun FloatArray.last(predicate: (Float) -> Boolean): Float { var last: Float? = null var found = false for (element in this) { @@ -1119,13 +1024,12 @@ public inline fun FloatArray.last(predicate: (Float) -> Boolean) : Float { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return last as Float - } /** * Returns last element matching the given *predicate* */ -public inline fun IntArray.last(predicate: (Int) -> Boolean) : Int { +public inline fun IntArray.last(predicate: (Int) -> Boolean): Int { var last: Int? = null var found = false for (element in this) { @@ -1136,13 +1040,12 @@ public inline fun IntArray.last(predicate: (Int) -> Boolean) : Int { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return last as Int - } /** * Returns last element matching the given *predicate* */ -public inline fun LongArray.last(predicate: (Long) -> Boolean) : Long { +public inline fun LongArray.last(predicate: (Long) -> Boolean): Long { var last: Long? = null var found = false for (element in this) { @@ -1153,13 +1056,12 @@ public inline fun LongArray.last(predicate: (Long) -> Boolean) : Long { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return last as Long - } /** * Returns last element matching the given *predicate* */ -public inline fun ShortArray.last(predicate: (Short) -> Boolean) : Short { +public inline fun ShortArray.last(predicate: (Short) -> Boolean): Short { var last: Short? = null var found = false for (element in this) { @@ -1170,13 +1072,12 @@ public inline fun ShortArray.last(predicate: (Short) -> Boolean) : Short { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return last as Short - } /** * Returns last element matching the given *predicate* */ -public inline fun Iterable.last(predicate: (T) -> Boolean) : T { +public inline fun Iterable.last(predicate: (T) -> Boolean): T { var last: T? = null var found = false for (element in this) { @@ -1187,13 +1088,12 @@ public inline fun Iterable.last(predicate: (T) -> Boolean) : T { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return last as T - } /** * Returns last element matching the given *predicate* */ -public inline fun Stream.last(predicate: (T) -> Boolean) : T { +public inline fun Stream.last(predicate: (T) -> Boolean): T { var last: T? = null var found = false for (element in this) { @@ -1204,13 +1104,12 @@ public inline fun Stream.last(predicate: (T) -> Boolean) : T { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return last as T - } /** * Returns last element matching the given *predicate* */ -public inline fun String.last(predicate: (Char) -> Boolean) : Char { +public inline fun String.last(predicate: (Char) -> Boolean): Char { var last: Char? = null var found = false for (element in this) { @@ -1221,13 +1120,12 @@ public inline fun String.last(predicate: (Char) -> Boolean) : Char { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return last as Char - } /** * Returns last index of *element*, or -1 if the collection does not contain element */ -public fun Array.lastIndexOf(element: T) : Int { +public fun Array.lastIndexOf(element: T): Int { if (element == null) { for (index in indices.reverse()) { if (this[index] == null) { @@ -1242,117 +1140,108 @@ public fun Array.lastIndexOf(element: T) : Int { } } return -1 - } /** * Returns last index of *element*, or -1 if the collection does not contain element */ -public fun BooleanArray.lastIndexOf(element: Boolean) : Int { +public fun BooleanArray.lastIndexOf(element: Boolean): Int { for (index in indices.reverse()) { if (element == this[index]) { return index } } return -1 - } /** * Returns last index of *element*, or -1 if the collection does not contain element */ -public fun ByteArray.lastIndexOf(element: Byte) : Int { +public fun ByteArray.lastIndexOf(element: Byte): Int { for (index in indices.reverse()) { if (element == this[index]) { return index } } return -1 - } /** * Returns last index of *element*, or -1 if the collection does not contain element */ -public fun CharArray.lastIndexOf(element: Char) : Int { +public fun CharArray.lastIndexOf(element: Char): Int { for (index in indices.reverse()) { if (element == this[index]) { return index } } return -1 - } /** * Returns last index of *element*, or -1 if the collection does not contain element */ -public fun DoubleArray.lastIndexOf(element: Double) : Int { +public fun DoubleArray.lastIndexOf(element: Double): Int { for (index in indices.reverse()) { if (element == this[index]) { return index } } return -1 - } /** * Returns last index of *element*, or -1 if the collection does not contain element */ -public fun FloatArray.lastIndexOf(element: Float) : Int { +public fun FloatArray.lastIndexOf(element: Float): Int { for (index in indices.reverse()) { if (element == this[index]) { return index } } return -1 - } /** * Returns last index of *element*, or -1 if the collection does not contain element */ -public fun IntArray.lastIndexOf(element: Int) : Int { +public fun IntArray.lastIndexOf(element: Int): Int { for (index in indices.reverse()) { if (element == this[index]) { return index } } return -1 - } /** * Returns last index of *element*, or -1 if the collection does not contain element */ -public fun LongArray.lastIndexOf(element: Long) : Int { +public fun LongArray.lastIndexOf(element: Long): Int { for (index in indices.reverse()) { if (element == this[index]) { return index } } return -1 - } /** * Returns last index of *element*, or -1 if the collection does not contain element */ -public fun ShortArray.lastIndexOf(element: Short) : Int { +public fun ShortArray.lastIndexOf(element: Short): Int { for (index in indices.reverse()) { if (element == this[index]) { return index } } return -1 - } /** * Returns last index of *element*, or -1 if the collection does not contain element */ -public fun Iterable.lastIndexOf(element: T) : Int { +public fun Iterable.lastIndexOf(element: T): Int { var lastIndex = -1 var index = 0 for (item in this) { @@ -1361,13 +1250,12 @@ public fun Iterable.lastIndexOf(element: T) : Int { index++ } return lastIndex - } /** * Returns last index of *element*, or -1 if the collection does not contain element */ -public fun List.lastIndexOf(element: T) : Int { +public fun List.lastIndexOf(element: T): Int { if (element == null) { for (index in indices.reverse()) { if (this[index] == null) { @@ -1382,13 +1270,12 @@ public fun List.lastIndexOf(element: T) : Int { } } return -1 - } /** * Returns last index of *element*, or -1 if the collection does not contain element */ -public fun Stream.lastIndexOf(element: T) : Int { +public fun Stream.lastIndexOf(element: T): Int { var lastIndex = -1 var index = 0 for (item in this) { @@ -1397,85 +1284,75 @@ public fun Stream.lastIndexOf(element: T) : Int { index++ } return lastIndex - } /** * Returns last element, or null if collection is empty */ -public fun Array.lastOrNull() : T? { +public fun Array.lastOrNull(): T? { return if (size > 0) this[size - 1] else null - } /** * Returns last element, or null if collection is empty */ -public fun BooleanArray.lastOrNull() : Boolean? { +public fun BooleanArray.lastOrNull(): Boolean? { return if (size > 0) this[size - 1] else null - } /** * Returns last element, or null if collection is empty */ -public fun ByteArray.lastOrNull() : Byte? { +public fun ByteArray.lastOrNull(): Byte? { return if (size > 0) this[size - 1] else null - } /** * Returns last element, or null if collection is empty */ -public fun CharArray.lastOrNull() : Char? { +public fun CharArray.lastOrNull(): Char? { return if (size > 0) this[size - 1] else null - } /** * Returns last element, or null if collection is empty */ -public fun DoubleArray.lastOrNull() : Double? { +public fun DoubleArray.lastOrNull(): Double? { return if (size > 0) this[size - 1] else null - } /** * Returns last element, or null if collection is empty */ -public fun FloatArray.lastOrNull() : Float? { +public fun FloatArray.lastOrNull(): Float? { return if (size > 0) this[size - 1] else null - } /** * Returns last element, or null if collection is empty */ -public fun IntArray.lastOrNull() : Int? { +public fun IntArray.lastOrNull(): Int? { return if (size > 0) this[size - 1] else null - } /** * Returns last element, or null if collection is empty */ -public fun LongArray.lastOrNull() : Long? { +public fun LongArray.lastOrNull(): Long? { return if (size > 0) this[size - 1] else null - } /** * Returns last element, or null if collection is empty */ -public fun ShortArray.lastOrNull() : Short? { +public fun ShortArray.lastOrNull(): Short? { return if (size > 0) this[size - 1] else null - } /** * Returns last element, or null if collection is empty */ -public fun Iterable.lastOrNull() : T? { +public fun Iterable.lastOrNull(): T? { when (this) { is List<*> -> return if (size > 0) this[size - 1] as T else null else -> { @@ -1488,21 +1365,19 @@ public fun Iterable.lastOrNull() : T? { return last } } - } /** * Returns last element, or null if collection is empty */ -public fun List.lastOrNull() : T? { +public fun List.lastOrNull(): T? { return if (size > 0) this[size - 1] else null - } /** * Returns last element, or null if collection is empty */ -public fun Stream.lastOrNull() : T? { +public fun Stream.lastOrNull(): T? { when (this) { is List<*> -> return if (size > 0) this[size - 1] as T else null else -> { @@ -1515,21 +1390,19 @@ public fun Stream.lastOrNull() : T? { return last } } - } /** * Returns last element, or null if collection is empty */ -public fun String.lastOrNull() : Char? { +public fun String.lastOrNull(): Char? { return if (size > 0) this[size - 1] else null - } /** * Returns last element matching the given *predicate*, or null if element was not found */ -public inline fun Array.lastOrNull(predicate: (T) -> Boolean) : T? { +public inline fun Array.lastOrNull(predicate: (T) -> Boolean): T? { var last: T? = null for (element in this) { if (predicate(element)) { @@ -1537,13 +1410,12 @@ public inline fun Array.lastOrNull(predicate: (T) -> Boolean) : T? { } } return last - } /** * Returns last element matching the given *predicate*, or null if element was not found */ -public inline fun BooleanArray.lastOrNull(predicate: (Boolean) -> Boolean) : Boolean? { +public inline fun BooleanArray.lastOrNull(predicate: (Boolean) -> Boolean): Boolean? { var last: Boolean? = null for (element in this) { if (predicate(element)) { @@ -1551,13 +1423,12 @@ public inline fun BooleanArray.lastOrNull(predicate: (Boolean) -> Boolean) : Boo } } return last - } /** * Returns last element matching the given *predicate*, or null if element was not found */ -public inline fun ByteArray.lastOrNull(predicate: (Byte) -> Boolean) : Byte? { +public inline fun ByteArray.lastOrNull(predicate: (Byte) -> Boolean): Byte? { var last: Byte? = null for (element in this) { if (predicate(element)) { @@ -1565,13 +1436,12 @@ public inline fun ByteArray.lastOrNull(predicate: (Byte) -> Boolean) : Byte? { } } return last - } /** * Returns last element matching the given *predicate*, or null if element was not found */ -public inline fun CharArray.lastOrNull(predicate: (Char) -> Boolean) : Char? { +public inline fun CharArray.lastOrNull(predicate: (Char) -> Boolean): Char? { var last: Char? = null for (element in this) { if (predicate(element)) { @@ -1579,13 +1449,12 @@ public inline fun CharArray.lastOrNull(predicate: (Char) -> Boolean) : Char? { } } return last - } /** * Returns last element matching the given *predicate*, or null if element was not found */ -public inline fun DoubleArray.lastOrNull(predicate: (Double) -> Boolean) : Double? { +public inline fun DoubleArray.lastOrNull(predicate: (Double) -> Boolean): Double? { var last: Double? = null for (element in this) { if (predicate(element)) { @@ -1593,13 +1462,12 @@ public inline fun DoubleArray.lastOrNull(predicate: (Double) -> Boolean) : Doubl } } return last - } /** * Returns last element matching the given *predicate*, or null if element was not found */ -public inline fun FloatArray.lastOrNull(predicate: (Float) -> Boolean) : Float? { +public inline fun FloatArray.lastOrNull(predicate: (Float) -> Boolean): Float? { var last: Float? = null for (element in this) { if (predicate(element)) { @@ -1607,13 +1475,12 @@ public inline fun FloatArray.lastOrNull(predicate: (Float) -> Boolean) : Float? } } return last - } /** * Returns last element matching the given *predicate*, or null if element was not found */ -public inline fun IntArray.lastOrNull(predicate: (Int) -> Boolean) : Int? { +public inline fun IntArray.lastOrNull(predicate: (Int) -> Boolean): Int? { var last: Int? = null for (element in this) { if (predicate(element)) { @@ -1621,13 +1488,12 @@ public inline fun IntArray.lastOrNull(predicate: (Int) -> Boolean) : Int? { } } return last - } /** * Returns last element matching the given *predicate*, or null if element was not found */ -public inline fun LongArray.lastOrNull(predicate: (Long) -> Boolean) : Long? { +public inline fun LongArray.lastOrNull(predicate: (Long) -> Boolean): Long? { var last: Long? = null for (element in this) { if (predicate(element)) { @@ -1635,13 +1501,12 @@ public inline fun LongArray.lastOrNull(predicate: (Long) -> Boolean) : Long? { } } return last - } /** * Returns last element matching the given *predicate*, or null if element was not found */ -public inline fun ShortArray.lastOrNull(predicate: (Short) -> Boolean) : Short? { +public inline fun ShortArray.lastOrNull(predicate: (Short) -> Boolean): Short? { var last: Short? = null for (element in this) { if (predicate(element)) { @@ -1649,13 +1514,12 @@ public inline fun ShortArray.lastOrNull(predicate: (Short) -> Boolean) : Short? } } return last - } /** * Returns last element matching the given *predicate*, or null if element was not found */ -public inline fun Iterable.lastOrNull(predicate: (T) -> Boolean) : T? { +public inline fun Iterable.lastOrNull(predicate: (T) -> Boolean): T? { var last: T? = null for (element in this) { if (predicate(element)) { @@ -1663,13 +1527,12 @@ public inline fun Iterable.lastOrNull(predicate: (T) -> Boolean) : T? { } } return last - } /** * Returns last element matching the given *predicate*, or null if element was not found */ -public inline fun Stream.lastOrNull(predicate: (T) -> Boolean) : T? { +public inline fun Stream.lastOrNull(predicate: (T) -> Boolean): T? { var last: T? = null for (element in this) { if (predicate(element)) { @@ -1677,13 +1540,12 @@ public inline fun Stream.lastOrNull(predicate: (T) -> Boolean) : T? { } } return last - } /** * Returns last element matching the given *predicate*, or null if element was not found */ -public inline fun String.lastOrNull(predicate: (Char) -> Boolean) : Char? { +public inline fun String.lastOrNull(predicate: (Char) -> Boolean): Char? { var last: Char? = null for (element in this) { if (predicate(element)) { @@ -1691,103 +1553,93 @@ public inline fun String.lastOrNull(predicate: (Char) -> Boolean) : Char? { } } return last - } /** * Returns single element, or throws exception if there is no or more than one element */ -public fun Array.single() : T { +public fun Array.single(): T { if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or throws exception if there is no or more than one element */ -public fun BooleanArray.single() : Boolean { +public fun BooleanArray.single(): Boolean { if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or throws exception if there is no or more than one element */ -public fun ByteArray.single() : Byte { +public fun ByteArray.single(): Byte { if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or throws exception if there is no or more than one element */ -public fun CharArray.single() : Char { +public fun CharArray.single(): Char { if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or throws exception if there is no or more than one element */ -public fun DoubleArray.single() : Double { +public fun DoubleArray.single(): Double { if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or throws exception if there is no or more than one element */ -public fun FloatArray.single() : Float { +public fun FloatArray.single(): Float { if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or throws exception if there is no or more than one element */ -public fun IntArray.single() : Int { +public fun IntArray.single(): Int { if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or throws exception if there is no or more than one element */ -public fun LongArray.single() : Long { +public fun LongArray.single(): Long { if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or throws exception if there is no or more than one element */ -public fun ShortArray.single() : Short { +public fun ShortArray.single(): Short { if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or throws exception if there is no or more than one element */ -public fun Iterable.single() : T { +public fun Iterable.single(): T { when (this) { is List<*> -> return if (size == 1) this[0] as T else throw IllegalArgumentException("Collection has $size elements") else -> { @@ -1800,23 +1652,21 @@ public fun Iterable.single() : T { return single } } - } /** * Returns single element, or throws exception if there is no or more than one element */ -public fun List.single() : T { +public fun List.single(): T { if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or throws exception if there is no or more than one element */ -public fun Stream.single() : T { +public fun Stream.single(): T { when (this) { is List<*> -> return if (size == 1) this[0] as T else throw IllegalArgumentException("Collection has $size elements") else -> { @@ -1829,23 +1679,21 @@ public fun Stream.single() : T { return single } } - } /** * Returns single element, or throws exception if there is no or more than one element */ -public fun String.single() : Char { +public fun String.single(): Char { if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element matching the given *predicate*, or throws exception if there is no or more than one element */ -public inline fun Array.single(predicate: (T) -> Boolean) : T { +public inline fun Array.single(predicate: (T) -> Boolean): T { var single: T? = null var found = false for (element in this) { @@ -1857,13 +1705,12 @@ public inline fun Array.single(predicate: (T) -> Boolean) : T { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return single as T - } /** * Returns single element matching the given *predicate*, or throws exception if there is no or more than one element */ -public inline fun BooleanArray.single(predicate: (Boolean) -> Boolean) : Boolean { +public inline fun BooleanArray.single(predicate: (Boolean) -> Boolean): Boolean { var single: Boolean? = null var found = false for (element in this) { @@ -1875,13 +1722,12 @@ public inline fun BooleanArray.single(predicate: (Boolean) -> Boolean) : Boolean } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return single as Boolean - } /** * Returns single element matching the given *predicate*, or throws exception if there is no or more than one element */ -public inline fun ByteArray.single(predicate: (Byte) -> Boolean) : Byte { +public inline fun ByteArray.single(predicate: (Byte) -> Boolean): Byte { var single: Byte? = null var found = false for (element in this) { @@ -1893,13 +1739,12 @@ public inline fun ByteArray.single(predicate: (Byte) -> Boolean) : Byte { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return single as Byte - } /** * Returns single element matching the given *predicate*, or throws exception if there is no or more than one element */ -public inline fun CharArray.single(predicate: (Char) -> Boolean) : Char { +public inline fun CharArray.single(predicate: (Char) -> Boolean): Char { var single: Char? = null var found = false for (element in this) { @@ -1911,13 +1756,12 @@ public inline fun CharArray.single(predicate: (Char) -> Boolean) : Char { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return single as Char - } /** * Returns single element matching the given *predicate*, or throws exception if there is no or more than one element */ -public inline fun DoubleArray.single(predicate: (Double) -> Boolean) : Double { +public inline fun DoubleArray.single(predicate: (Double) -> Boolean): Double { var single: Double? = null var found = false for (element in this) { @@ -1929,13 +1773,12 @@ public inline fun DoubleArray.single(predicate: (Double) -> Boolean) : Double { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return single as Double - } /** * Returns single element matching the given *predicate*, or throws exception if there is no or more than one element */ -public inline fun FloatArray.single(predicate: (Float) -> Boolean) : Float { +public inline fun FloatArray.single(predicate: (Float) -> Boolean): Float { var single: Float? = null var found = false for (element in this) { @@ -1947,13 +1790,12 @@ public inline fun FloatArray.single(predicate: (Float) -> Boolean) : Float { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return single as Float - } /** * Returns single element matching the given *predicate*, or throws exception if there is no or more than one element */ -public inline fun IntArray.single(predicate: (Int) -> Boolean) : Int { +public inline fun IntArray.single(predicate: (Int) -> Boolean): Int { var single: Int? = null var found = false for (element in this) { @@ -1965,13 +1807,12 @@ public inline fun IntArray.single(predicate: (Int) -> Boolean) : Int { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return single as Int - } /** * Returns single element matching the given *predicate*, or throws exception if there is no or more than one element */ -public inline fun LongArray.single(predicate: (Long) -> Boolean) : Long { +public inline fun LongArray.single(predicate: (Long) -> Boolean): Long { var single: Long? = null var found = false for (element in this) { @@ -1983,13 +1824,12 @@ public inline fun LongArray.single(predicate: (Long) -> Boolean) : Long { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return single as Long - } /** * Returns single element matching the given *predicate*, or throws exception if there is no or more than one element */ -public inline fun ShortArray.single(predicate: (Short) -> Boolean) : Short { +public inline fun ShortArray.single(predicate: (Short) -> Boolean): Short { var single: Short? = null var found = false for (element in this) { @@ -2001,13 +1841,12 @@ public inline fun ShortArray.single(predicate: (Short) -> Boolean) : Short { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return single as Short - } /** * Returns single element matching the given *predicate*, or throws exception if there is no or more than one element */ -public inline fun Iterable.single(predicate: (T) -> Boolean) : T { +public inline fun Iterable.single(predicate: (T) -> Boolean): T { var single: T? = null var found = false for (element in this) { @@ -2019,13 +1858,12 @@ public inline fun Iterable.single(predicate: (T) -> Boolean) : T { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return single as T - } /** * Returns single element matching the given *predicate*, or throws exception if there is no or more than one element */ -public inline fun Stream.single(predicate: (T) -> Boolean) : T { +public inline fun Stream.single(predicate: (T) -> Boolean): T { var single: T? = null var found = false for (element in this) { @@ -2037,13 +1875,12 @@ public inline fun Stream.single(predicate: (T) -> Boolean) : T { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return single as T - } /** * Returns single element matching the given *predicate*, or throws exception if there is no or more than one element */ -public inline fun String.single(predicate: (Char) -> Boolean) : Char { +public inline fun String.single(predicate: (Char) -> Boolean): Char { var single: Char? = null var found = false for (element in this) { @@ -2055,121 +1892,111 @@ public inline fun String.single(predicate: (Char) -> Boolean) : Char { } if (!found) throw IllegalArgumentException("Collection doesn't contain any element matching predicate") return single as Char - } /** * Returns single element, or null if collection is empty, or throws exception if there is more than one element */ -public fun Array.singleOrNull() : T? { +public fun Array.singleOrNull(): T? { if (size == 0) return null if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or null if collection is empty, or throws exception if there is more than one element */ -public fun BooleanArray.singleOrNull() : Boolean? { +public fun BooleanArray.singleOrNull(): Boolean? { if (size == 0) return null if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or null if collection is empty, or throws exception if there is more than one element */ -public fun ByteArray.singleOrNull() : Byte? { +public fun ByteArray.singleOrNull(): Byte? { if (size == 0) return null if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or null if collection is empty, or throws exception if there is more than one element */ -public fun CharArray.singleOrNull() : Char? { +public fun CharArray.singleOrNull(): Char? { if (size == 0) return null if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or null if collection is empty, or throws exception if there is more than one element */ -public fun DoubleArray.singleOrNull() : Double? { +public fun DoubleArray.singleOrNull(): Double? { if (size == 0) return null if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or null if collection is empty, or throws exception if there is more than one element */ -public fun FloatArray.singleOrNull() : Float? { +public fun FloatArray.singleOrNull(): Float? { if (size == 0) return null if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or null if collection is empty, or throws exception if there is more than one element */ -public fun IntArray.singleOrNull() : Int? { +public fun IntArray.singleOrNull(): Int? { if (size == 0) return null if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or null if collection is empty, or throws exception if there is more than one element */ -public fun LongArray.singleOrNull() : Long? { +public fun LongArray.singleOrNull(): Long? { if (size == 0) return null if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or null if collection is empty, or throws exception if there is more than one element */ -public fun ShortArray.singleOrNull() : Short? { +public fun ShortArray.singleOrNull(): Short? { if (size == 0) return null if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or null if collection is empty, or throws exception if there is more than one element */ -public fun Iterable.singleOrNull() : T? { +public fun Iterable.singleOrNull(): T? { when (this) { is List<*> -> return if (size == 1) this[0] as T else if (size == 0) null else throw IllegalArgumentException("Collection has $size elements") else -> { @@ -2182,25 +2009,23 @@ public fun Iterable.singleOrNull() : T? { return single } } - } /** * Returns single element, or null if collection is empty, or throws exception if there is more than one element */ -public fun List.singleOrNull() : T? { +public fun List.singleOrNull(): T? { if (size == 0) return null if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element, or null if collection is empty, or throws exception if there is more than one element */ -public fun Stream.singleOrNull() : T? { +public fun Stream.singleOrNull(): T? { when (this) { is List<*> -> return if (size == 1) this[0] as T else if (size == 0) null else throw IllegalArgumentException("Collection has $size elements") else -> { @@ -2213,25 +2038,23 @@ public fun Stream.singleOrNull() : T? { return single } } - } /** * Returns single element, or null if collection is empty, or throws exception if there is more than one element */ -public fun String.singleOrNull() : Char? { +public fun String.singleOrNull(): Char? { if (size == 0) return null if (size != 1) throw IllegalArgumentException("Collection has $size elements") return this[0] - } /** * Returns single element matching the given *predicate*, or null if element was not found or more than one elements were found */ -public inline fun Array.singleOrNull(predicate: (T) -> Boolean) : T? { +public inline fun Array.singleOrNull(predicate: (T) -> Boolean): T? { var single: T? = null var found = false for (element in this) { @@ -2243,13 +2066,12 @@ public inline fun Array.singleOrNull(predicate: (T) -> Boolean) : T? } if (!found) return null return single - } /** * Returns single element matching the given *predicate*, or null if element was not found or more than one elements were found */ -public inline fun BooleanArray.singleOrNull(predicate: (Boolean) -> Boolean) : Boolean? { +public inline fun BooleanArray.singleOrNull(predicate: (Boolean) -> Boolean): Boolean? { var single: Boolean? = null var found = false for (element in this) { @@ -2261,13 +2083,12 @@ public inline fun BooleanArray.singleOrNull(predicate: (Boolean) -> Boolean) : B } if (!found) return null return single - } /** * Returns single element matching the given *predicate*, or null if element was not found or more than one elements were found */ -public inline fun ByteArray.singleOrNull(predicate: (Byte) -> Boolean) : Byte? { +public inline fun ByteArray.singleOrNull(predicate: (Byte) -> Boolean): Byte? { var single: Byte? = null var found = false for (element in this) { @@ -2279,13 +2100,12 @@ public inline fun ByteArray.singleOrNull(predicate: (Byte) -> Boolean) : Byte? { } if (!found) return null return single - } /** * Returns single element matching the given *predicate*, or null if element was not found or more than one elements were found */ -public inline fun CharArray.singleOrNull(predicate: (Char) -> Boolean) : Char? { +public inline fun CharArray.singleOrNull(predicate: (Char) -> Boolean): Char? { var single: Char? = null var found = false for (element in this) { @@ -2297,13 +2117,12 @@ public inline fun CharArray.singleOrNull(predicate: (Char) -> Boolean) : Char? { } if (!found) return null return single - } /** * Returns single element matching the given *predicate*, or null if element was not found or more than one elements were found */ -public inline fun DoubleArray.singleOrNull(predicate: (Double) -> Boolean) : Double? { +public inline fun DoubleArray.singleOrNull(predicate: (Double) -> Boolean): Double? { var single: Double? = null var found = false for (element in this) { @@ -2315,13 +2134,12 @@ public inline fun DoubleArray.singleOrNull(predicate: (Double) -> Boolean) : Dou } if (!found) return null return single - } /** * Returns single element matching the given *predicate*, or null if element was not found or more than one elements were found */ -public inline fun FloatArray.singleOrNull(predicate: (Float) -> Boolean) : Float? { +public inline fun FloatArray.singleOrNull(predicate: (Float) -> Boolean): Float? { var single: Float? = null var found = false for (element in this) { @@ -2333,13 +2151,12 @@ public inline fun FloatArray.singleOrNull(predicate: (Float) -> Boolean) : Float } if (!found) return null return single - } /** * Returns single element matching the given *predicate*, or null if element was not found or more than one elements were found */ -public inline fun IntArray.singleOrNull(predicate: (Int) -> Boolean) : Int? { +public inline fun IntArray.singleOrNull(predicate: (Int) -> Boolean): Int? { var single: Int? = null var found = false for (element in this) { @@ -2351,13 +2168,12 @@ public inline fun IntArray.singleOrNull(predicate: (Int) -> Boolean) : Int? { } if (!found) return null return single - } /** * Returns single element matching the given *predicate*, or null if element was not found or more than one elements were found */ -public inline fun LongArray.singleOrNull(predicate: (Long) -> Boolean) : Long? { +public inline fun LongArray.singleOrNull(predicate: (Long) -> Boolean): Long? { var single: Long? = null var found = false for (element in this) { @@ -2369,13 +2185,12 @@ public inline fun LongArray.singleOrNull(predicate: (Long) -> Boolean) : Long? { } if (!found) return null return single - } /** * Returns single element matching the given *predicate*, or null if element was not found or more than one elements were found */ -public inline fun ShortArray.singleOrNull(predicate: (Short) -> Boolean) : Short? { +public inline fun ShortArray.singleOrNull(predicate: (Short) -> Boolean): Short? { var single: Short? = null var found = false for (element in this) { @@ -2387,13 +2202,12 @@ public inline fun ShortArray.singleOrNull(predicate: (Short) -> Boolean) : Short } if (!found) return null return single - } /** * Returns single element matching the given *predicate*, or null if element was not found or more than one elements were found */ -public inline fun Iterable.singleOrNull(predicate: (T) -> Boolean) : T? { +public inline fun Iterable.singleOrNull(predicate: (T) -> Boolean): T? { var single: T? = null var found = false for (element in this) { @@ -2405,13 +2219,12 @@ public inline fun Iterable.singleOrNull(predicate: (T) -> Boolean) : T? { } if (!found) return null return single - } /** * Returns single element matching the given *predicate*, or null if element was not found or more than one elements were found */ -public inline fun Stream.singleOrNull(predicate: (T) -> Boolean) : T? { +public inline fun Stream.singleOrNull(predicate: (T) -> Boolean): T? { var single: T? = null var found = false for (element in this) { @@ -2423,13 +2236,12 @@ public inline fun Stream.singleOrNull(predicate: (T) -> Boolean) : T? { } if (!found) return null return single - } /** * Returns single element matching the given *predicate*, or null if element was not found or more than one elements were found */ -public inline fun String.singleOrNull(predicate: (Char) -> Boolean) : Char? { +public inline fun String.singleOrNull(predicate: (Char) -> Boolean): Char? { var single: Char? = null var found = false for (element in this) { @@ -2441,6 +2253,5 @@ public inline fun String.singleOrNull(predicate: (Char) -> Boolean) : Char? { } if (!found) return null return single - } diff --git a/libraries/stdlib/src/generated/_Filtering.kt b/libraries/stdlib/src/generated/_Filtering.kt index 2d0ba33ecd5..80c99b6ba71 100644 --- a/libraries/stdlib/src/generated/_Filtering.kt +++ b/libraries/stdlib/src/generated/_Filtering.kt @@ -10,377 +10,344 @@ import java.util.* /** * Returns a list containing all elements except first *n* elements */ -public fun Array.drop(n: Int) : List { +public fun Array.drop(n: Int): List { if (n >= size) return ArrayList() - var count = 0 val list = ArrayList(size - n) for (item in this) { if (count++ >= n) list.add(item) } return list - } /** * Returns a list containing all elements except first *n* elements */ -public fun BooleanArray.drop(n: Int) : List { +public fun BooleanArray.drop(n: Int): List { if (n >= size) return ArrayList() - var count = 0 val list = ArrayList(size - n) for (item in this) { if (count++ >= n) list.add(item) } return list - } /** * Returns a list containing all elements except first *n* elements */ -public fun ByteArray.drop(n: Int) : List { +public fun ByteArray.drop(n: Int): List { if (n >= size) return ArrayList() - var count = 0 val list = ArrayList(size - n) for (item in this) { if (count++ >= n) list.add(item) } return list - } /** * Returns a list containing all elements except first *n* elements */ -public fun CharArray.drop(n: Int) : List { +public fun CharArray.drop(n: Int): List { if (n >= size) return ArrayList() - var count = 0 val list = ArrayList(size - n) for (item in this) { if (count++ >= n) list.add(item) } return list - } /** * Returns a list containing all elements except first *n* elements */ -public fun DoubleArray.drop(n: Int) : List { +public fun DoubleArray.drop(n: Int): List { if (n >= size) return ArrayList() - var count = 0 val list = ArrayList(size - n) for (item in this) { if (count++ >= n) list.add(item) } return list - } /** * Returns a list containing all elements except first *n* elements */ -public fun FloatArray.drop(n: Int) : List { +public fun FloatArray.drop(n: Int): List { if (n >= size) return ArrayList() - var count = 0 val list = ArrayList(size - n) for (item in this) { if (count++ >= n) list.add(item) } return list - } /** * Returns a list containing all elements except first *n* elements */ -public fun IntArray.drop(n: Int) : List { +public fun IntArray.drop(n: Int): List { if (n >= size) return ArrayList() - var count = 0 val list = ArrayList(size - n) for (item in this) { if (count++ >= n) list.add(item) } return list - } /** * Returns a list containing all elements except first *n* elements */ -public fun LongArray.drop(n: Int) : List { +public fun LongArray.drop(n: Int): List { if (n >= size) return ArrayList() - var count = 0 val list = ArrayList(size - n) for (item in this) { if (count++ >= n) list.add(item) } return list - } /** * Returns a list containing all elements except first *n* elements */ -public fun ShortArray.drop(n: Int) : List { +public fun ShortArray.drop(n: Int): List { if (n >= size) return ArrayList() - var count = 0 val list = ArrayList(size - n) for (item in this) { if (count++ >= n) list.add(item) } return list - } /** * Returns a list containing all elements except first *n* elements */ -public fun Collection.drop(n: Int) : List { +public fun Collection.drop(n: Int): List { if (n >= size) return ArrayList() - var count = 0 val list = ArrayList(size - n) for (item in this) { if (count++ >= n) list.add(item) } return list - } /** * Returns a list containing all elements except first *n* elements */ -public fun Iterable.drop(n: Int) : List { +public fun Iterable.drop(n: Int): List { var count = 0 val list = ArrayList() for (item in this) { if (count++ >= n) list.add(item) } return list - } /** * Returns a stream containing all elements except first *n* elements */ -public fun Stream.drop(n: Int) : Stream { +public fun Stream.drop(n: Int): Stream { var count = 0; return FilteringStream(this) { count++ >= n } - } /** * Returns a list containing all elements except first *n* elements */ -public fun String.drop(n: Int) : String { +public fun String.drop(n: Int): String { return substring(Math.min(n, size)) } /** * Returns a list containing all elements except first elements that satisfy the given *predicate* */ -public inline fun Array.dropWhile(predicate: (T)->Boolean) : List { +public inline fun Array.dropWhile(predicate: (T) -> Boolean): List { var yielding = false val list = ArrayList() for (item in this) if (yielding) list.add(item) - else if(!predicate(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 { +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)) { + 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 ByteArray.dropWhile(predicate: (Byte)->Boolean) : List { +public inline fun ByteArray.dropWhile(predicate: (Byte) -> Boolean): List { var yielding = false val list = ArrayList() for (item in this) if (yielding) list.add(item) - else if(!predicate(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 { +public inline fun CharArray.dropWhile(predicate: (Char) -> Boolean): List { var yielding = false val list = ArrayList() for (item in this) if (yielding) list.add(item) - else if(!predicate(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 { +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)) { + 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 { +public inline fun FloatArray.dropWhile(predicate: (Float) -> Boolean): List { var yielding = false val list = ArrayList() for (item in this) if (yielding) list.add(item) - else if(!predicate(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 IntArray.dropWhile(predicate: (Int)->Boolean) : List { +public inline fun IntArray.dropWhile(predicate: (Int) -> Boolean): List { var yielding = false val list = ArrayList() for (item in this) if (yielding) list.add(item) - else if(!predicate(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 LongArray.dropWhile(predicate: (Long)->Boolean) : List { +public inline fun LongArray.dropWhile(predicate: (Long) -> Boolean): List { var yielding = false val list = ArrayList() for (item in this) if (yielding) list.add(item) - else if(!predicate(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 ShortArray.dropWhile(predicate: (Short)->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)) { + 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 Iterable.dropWhile(predicate: (T)->Boolean) : List { +public inline fun Iterable.dropWhile(predicate: (T) -> Boolean): List { var yielding = false val list = ArrayList() for (item in this) if (yielding) list.add(item) - else if(!predicate(item)) { + else if (!predicate(item)) { list.add(item) yielding = true } return list - } /** * Returns a stream containing all elements except first elements that satisfy the given *predicate* */ -public fun Stream.dropWhile(predicate: (T)->Boolean) : Stream { +public fun Stream.dropWhile(predicate: (T) -> Boolean): Stream { var yielding = false return FilteringStream(this) { - if (yielding) - true - else if (!predicate(it)) { - yielding = true - true - } else - false - } - + if (yielding) + true + else if (!predicate(it)) { + yielding = true + true + } else + false + } } /** @@ -392,491 +359,433 @@ public inline fun String.dropWhile(predicate: (Char) -> Boolean): String { return substring(index) } return "" - } /** * Returns a list containing all elements matching the given *predicate* */ -public inline fun Array.filter(predicate: (T)->Boolean) : List { +public inline fun Array.filter(predicate: (T) -> Boolean): List { return filterTo(ArrayList(), predicate) - } /** * Returns a list containing all elements matching the given *predicate* */ -public inline fun BooleanArray.filter(predicate: (Boolean)->Boolean) : List { +public inline fun BooleanArray.filter(predicate: (Boolean) -> Boolean): List { return filterTo(ArrayList(), predicate) - } /** * Returns a list containing all elements matching the given *predicate* */ -public inline fun ByteArray.filter(predicate: (Byte)->Boolean) : List { +public inline fun ByteArray.filter(predicate: (Byte) -> Boolean): List { return filterTo(ArrayList(), predicate) - } /** * Returns a list containing all elements matching the given *predicate* */ -public inline fun CharArray.filter(predicate: (Char)->Boolean) : List { +public inline fun CharArray.filter(predicate: (Char) -> Boolean): List { return filterTo(ArrayList(), predicate) - } /** * Returns a list containing all elements matching the given *predicate* */ -public inline fun DoubleArray.filter(predicate: (Double)->Boolean) : List { +public inline fun DoubleArray.filter(predicate: (Double) -> Boolean): List { return filterTo(ArrayList(), predicate) - } /** * Returns a list containing all elements matching the given *predicate* */ -public inline fun FloatArray.filter(predicate: (Float)->Boolean) : List { +public inline fun FloatArray.filter(predicate: (Float) -> Boolean): List { return filterTo(ArrayList(), predicate) - } /** * Returns a list containing all elements matching the given *predicate* */ -public inline fun IntArray.filter(predicate: (Int)->Boolean) : List { +public inline fun IntArray.filter(predicate: (Int) -> Boolean): List { return filterTo(ArrayList(), predicate) - } /** * Returns a list containing all elements matching the given *predicate* */ -public inline fun LongArray.filter(predicate: (Long)->Boolean) : List { +public inline fun LongArray.filter(predicate: (Long) -> Boolean): List { return filterTo(ArrayList(), predicate) - } /** * Returns a list containing all elements matching the given *predicate* */ -public inline fun ShortArray.filter(predicate: (Short)->Boolean) : List { +public inline fun ShortArray.filter(predicate: (Short) -> Boolean): List { return filterTo(ArrayList(), predicate) - } /** * Returns a list containing all elements matching the given *predicate* */ -public inline fun Iterable.filter(predicate: (T)->Boolean) : List { +public inline fun Iterable.filter(predicate: (T) -> Boolean): List { return filterTo(ArrayList(), predicate) - } /** * Returns a list containing all elements matching the given *predicate* */ -public inline fun Map.filter(predicate: (Map.Entry)->Boolean) : List> { - return filterTo(ArrayList>(), predicate) - +public inline fun Map.filter(predicate: (Map.Entry) -> Boolean): List> { + return filterTo(ArrayList>(), predicate) } /** * Returns a stream containing all elements matching the given *predicate* */ -public fun Stream.filter(predicate: (T)->Boolean) : Stream { +public fun Stream.filter(predicate: (T) -> Boolean): Stream { return FilteringStream(this, true, predicate) - } /** * Returns a list containing all elements matching the given *predicate* */ -public inline fun String.filter(predicate: (Char)->Boolean) : String { +public inline fun String.filter(predicate: (Char) -> Boolean): String { return filterTo(StringBuilder(), predicate).toString() - } /** * Returns a list containing all elements not matching the given *predicate* */ -public inline fun Array.filterNot(predicate: (T)->Boolean) : List { +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 { +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 ByteArray.filterNot(predicate: (Byte)->Boolean) : List { +public inline fun ByteArray.filterNot(predicate: (Byte) -> 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 { +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 { +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 { +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 IntArray.filterNot(predicate: (Int)->Boolean) : List { +public inline fun IntArray.filterNot(predicate: (Int) -> Boolean): List { return filterNotTo(ArrayList(), predicate) - } /** * Returns a list containing all elements not matching the given *predicate* */ -public inline fun LongArray.filterNot(predicate: (Long)->Boolean) : List { +public inline fun LongArray.filterNot(predicate: (Long) -> Boolean): List { return filterNotTo(ArrayList(), predicate) - } /** * Returns a list containing all elements not matching the given *predicate* */ -public inline fun ShortArray.filterNot(predicate: (Short)->Boolean) : List { +public inline fun ShortArray.filterNot(predicate: (Short) -> Boolean): List { return filterNotTo(ArrayList(), predicate) - } /** * Returns a list containing all elements not matching the given *predicate* */ -public inline fun Iterable.filterNot(predicate: (T)->Boolean) : List { +public inline fun Iterable.filterNot(predicate: (T) -> Boolean): List { return filterNotTo(ArrayList(), predicate) - } /** * Returns a list containing all elements not matching the given *predicate* */ -public inline fun Map.filterNot(predicate: (Map.Entry)->Boolean) : List> { - return filterNotTo(ArrayList>(), predicate) - +public inline fun Map.filterNot(predicate: (Map.Entry) -> Boolean): List> { + return filterNotTo(ArrayList>(), predicate) } /** * Returns a stream containing all elements not matching the given *predicate* */ -public fun Stream.filterNot(predicate: (T)->Boolean) : Stream { +public fun Stream.filterNot(predicate: (T) -> Boolean): Stream { return FilteringStream(this, false, predicate) - } /** * Returns a list containing all elements not matching the given *predicate* */ -public inline fun String.filterNot(predicate: (Char)->Boolean) : String { +public inline fun String.filterNot(predicate: (Char) -> Boolean): String { return filterNotTo(StringBuilder(), predicate).toString() - } /** * Returns a list containing all elements that are not null */ -public fun Array.filterNotNull() : List { +public fun Array.filterNotNull(): List { return filterNotNullTo(ArrayList()) - } /** * Returns a list containing all elements that are not null */ -public fun Iterable.filterNotNull() : List { +public fun Iterable.filterNotNull(): List { return filterNotNullTo(ArrayList()) - } /** * Returns a stream containing all elements that are not null */ -public fun Stream.filterNotNull() : Stream { +public fun Stream.filterNotNull(): Stream { return FilteringStream(this, false, { it != null }) as Stream - } /** * Appends all elements that are not null to the given *collection* */ -public fun , T: Any> Array.filterNotNullTo(collection: C) : C { +public fun , T : Any> Array.filterNotNullTo(collection: C): C { for (element in this) if (element != null) collection.add(element) return collection - } /** * Appends all elements that are not null to the given *collection* */ -public fun , T: Any> Iterable.filterNotNullTo(collection: C) : C { +public fun , T : Any> Iterable.filterNotNullTo(collection: C): C { for (element in this) if (element != null) collection.add(element) return collection - } /** * Appends all elements that are not null to the given *collection* */ -public fun , T: Any> Stream.filterNotNullTo(collection: C) : C { +public fun , T : Any> Stream.filterNotNullTo(collection: C): C { for (element in this) if (element != null) collection.add(element) return collection - } /** * Appends all elements not matching the given *predicate* to the given *collection* */ -public inline fun > Array.filterNotTo(collection: C, predicate: (T) -> Boolean) : C { +public inline fun > Array.filterNotTo(collection: C, predicate: (T) -> Boolean): C { for (element in this) if (!predicate(element)) collection.add(element) return collection - } /** * Appends all elements not matching the given *predicate* to the given *collection* */ -public inline fun > BooleanArray.filterNotTo(collection: C, predicate: (Boolean) -> Boolean) : C { +public inline fun > BooleanArray.filterNotTo(collection: C, predicate: (Boolean) -> Boolean): C { for (element in this) if (!predicate(element)) collection.add(element) return collection - } /** * Appends all elements not matching the given *predicate* to the given *collection* */ -public inline fun > ByteArray.filterNotTo(collection: C, predicate: (Byte) -> Boolean) : C { +public inline fun > ByteArray.filterNotTo(collection: C, predicate: (Byte) -> Boolean): C { for (element in this) if (!predicate(element)) collection.add(element) return collection - } /** * Appends all elements not matching the given *predicate* to the given *collection* */ -public inline fun > CharArray.filterNotTo(collection: C, predicate: (Char) -> Boolean) : C { +public inline fun > CharArray.filterNotTo(collection: C, predicate: (Char) -> Boolean): C { for (element in this) if (!predicate(element)) collection.add(element) return collection - } /** * Appends all elements not matching the given *predicate* to the given *collection* */ -public inline fun > DoubleArray.filterNotTo(collection: C, predicate: (Double) -> Boolean) : C { +public inline fun > DoubleArray.filterNotTo(collection: C, predicate: (Double) -> Boolean): C { for (element in this) if (!predicate(element)) collection.add(element) return collection - } /** * Appends all elements not matching the given *predicate* to the given *collection* */ -public inline fun > FloatArray.filterNotTo(collection: C, predicate: (Float) -> Boolean) : C { +public inline fun > FloatArray.filterNotTo(collection: C, predicate: (Float) -> Boolean): C { for (element in this) if (!predicate(element)) collection.add(element) return collection - } /** * Appends all elements not matching the given *predicate* to the given *collection* */ -public inline fun > IntArray.filterNotTo(collection: C, predicate: (Int) -> Boolean) : C { +public inline fun > IntArray.filterNotTo(collection: C, predicate: (Int) -> Boolean): C { for (element in this) if (!predicate(element)) collection.add(element) return collection - } /** * Appends all elements not matching the given *predicate* to the given *collection* */ -public inline fun > LongArray.filterNotTo(collection: C, predicate: (Long) -> Boolean) : C { +public inline fun > LongArray.filterNotTo(collection: C, predicate: (Long) -> Boolean): C { for (element in this) if (!predicate(element)) collection.add(element) return collection - } /** * Appends all elements not matching the given *predicate* to the given *collection* */ -public inline fun > ShortArray.filterNotTo(collection: C, predicate: (Short) -> Boolean) : C { +public inline fun > ShortArray.filterNotTo(collection: C, predicate: (Short) -> Boolean): C { for (element in this) if (!predicate(element)) collection.add(element) return collection - } /** * Appends all elements not matching the given *predicate* to the given *collection* */ -public inline fun > Iterable.filterNotTo(collection: C, predicate: (T) -> Boolean) : C { +public inline fun > Iterable.filterNotTo(collection: C, predicate: (T) -> Boolean): C { for (element in this) if (!predicate(element)) collection.add(element) return collection - } /** * Appends all elements not matching the given *predicate* to the given *collection* */ -public inline fun >> Map.filterNotTo(collection: C, predicate: (Map.Entry) -> Boolean) : C { +public inline fun >> Map.filterNotTo(collection: C, predicate: (Map.Entry) -> Boolean): C { for (element in this) if (!predicate(element)) collection.add(element) return collection - } /** * Appends all elements not matching the given *predicate* to the given *collection* */ -public inline fun > Stream.filterNotTo(collection: C, predicate: (T) -> Boolean) : C { +public inline fun > Stream.filterNotTo(collection: C, predicate: (T) -> Boolean): C { for (element in this) if (!predicate(element)) collection.add(element) return collection - } /** * Appends all characters not matching the given *predicate* to the given *collection* */ -public inline fun String.filterNotTo(collection: C, predicate: (Char) -> Boolean) : C { +public inline fun String.filterNotTo(collection: C, predicate: (Char) -> Boolean): C { for (element in this) if (!predicate(element)) collection.append(element) return collection - } /** * Appends all elements matching the given *predicate* into the given *collection* */ -public inline fun > Array.filterTo(collection: C, predicate: (T) -> Boolean) : C { +public inline fun > Array.filterTo(collection: C, predicate: (T) -> Boolean): C { for (element in this) if (predicate(element)) collection.add(element) return collection - } /** * Appends all elements matching the given *predicate* into the given *collection* */ -public inline fun > BooleanArray.filterTo(collection: C, predicate: (Boolean) -> Boolean) : C { +public inline fun > BooleanArray.filterTo(collection: C, predicate: (Boolean) -> Boolean): C { for (element in this) if (predicate(element)) collection.add(element) return collection - } /** * Appends all elements matching the given *predicate* into the given *collection* */ -public inline fun > ByteArray.filterTo(collection: C, predicate: (Byte) -> Boolean) : C { +public inline fun > ByteArray.filterTo(collection: C, predicate: (Byte) -> Boolean): C { for (element in this) if (predicate(element)) collection.add(element) return collection - } /** * Appends all elements matching the given *predicate* into the given *collection* */ -public inline fun > CharArray.filterTo(collection: C, predicate: (Char) -> Boolean) : C { +public inline fun > CharArray.filterTo(collection: C, predicate: (Char) -> Boolean): C { for (element in this) if (predicate(element)) collection.add(element) return collection - } /** * Appends all elements matching the given *predicate* into the given *collection* */ -public inline fun > DoubleArray.filterTo(collection: C, predicate: (Double) -> Boolean) : C { +public inline fun > DoubleArray.filterTo(collection: C, predicate: (Double) -> Boolean): C { for (element in this) if (predicate(element)) collection.add(element) return collection - } /** * Appends all elements matching the given *predicate* into the given *collection* */ -public inline fun > FloatArray.filterTo(collection: C, predicate: (Float) -> Boolean) : C { +public inline fun > FloatArray.filterTo(collection: C, predicate: (Float) -> Boolean): C { for (element in this) if (predicate(element)) collection.add(element) return collection - } /** * Appends all elements matching the given *predicate* into the given *collection* */ -public inline fun > IntArray.filterTo(collection: C, predicate: (Int) -> Boolean) : C { +public inline fun > IntArray.filterTo(collection: C, predicate: (Int) -> Boolean): C { for (element in this) if (predicate(element)) collection.add(element) return collection - } /** * Appends all elements matching the given *predicate* into the given *collection* */ -public inline fun > LongArray.filterTo(collection: C, predicate: (Long) -> Boolean) : C { +public inline fun > LongArray.filterTo(collection: C, predicate: (Long) -> Boolean): C { for (element in this) if (predicate(element)) collection.add(element) return collection - } /** * Appends all elements matching the given *predicate* into the given *collection* */ -public inline fun > ShortArray.filterTo(collection: C, predicate: (Short) -> Boolean) : C { +public inline fun > ShortArray.filterTo(collection: C, predicate: (Short) -> Boolean): C { for (element in this) if (predicate(element)) collection.add(element) return collection - } /** * Appends all elements matching the given *predicate* into the given *collection* */ -public inline fun > Iterable.filterTo(collection: C, predicate: (T) -> Boolean) : C { +public inline fun > Iterable.filterTo(collection: C, predicate: (T) -> Boolean): C { for (element in this) if (predicate(element)) collection.add(element) return collection - } /** * Appends all elements matching the given *predicate* into the given *collection* */ -public inline fun >> Map.filterTo(collection: C, predicate: (Map.Entry) -> Boolean) : C { +public inline fun >> Map.filterTo(collection: C, predicate: (Map.Entry) -> Boolean): C { for (element in this) if (predicate(element)) collection.add(element) return collection - } /** * Appends all elements matching the given *predicate* into the given *collection* */ -public inline fun > Stream.filterTo(collection: C, predicate: (T) -> Boolean) : C { +public inline fun > Stream.filterTo(collection: C, predicate: (T) -> Boolean): C { for (element in this) if (predicate(element)) collection.add(element) return collection - } /** @@ -893,139 +802,128 @@ public inline fun String.filterTo(destination: C, predicate: (C /** * Returns a list containing elements at specified positions */ -public fun Array.slice(indices: Iterable) : List { +public fun Array.slice(indices: Iterable): List { val list = ArrayList() for (index in indices) { list.add(get(index)) } return list - } /** * Returns a list containing elements at specified positions */ -public fun BooleanArray.slice(indices: Iterable) : List { +public fun BooleanArray.slice(indices: Iterable): List { val list = ArrayList() for (index in indices) { list.add(get(index)) } return list - } /** * Returns a list containing elements at specified positions */ -public fun ByteArray.slice(indices: Iterable) : List { +public fun ByteArray.slice(indices: Iterable): List { val list = ArrayList() for (index in indices) { list.add(get(index)) } return list - } /** * Returns a list containing elements at specified positions */ -public fun CharArray.slice(indices: Iterable) : List { +public fun CharArray.slice(indices: Iterable): List { val list = ArrayList() for (index in indices) { list.add(get(index)) } return list - } /** * Returns a list containing elements at specified positions */ -public fun DoubleArray.slice(indices: Iterable) : List { +public fun DoubleArray.slice(indices: Iterable): List { val list = ArrayList() for (index in indices) { list.add(get(index)) } return list - } /** * Returns a list containing elements at specified positions */ -public fun FloatArray.slice(indices: Iterable) : List { +public fun FloatArray.slice(indices: Iterable): List { val list = ArrayList() for (index in indices) { list.add(get(index)) } return list - } /** * Returns a list containing elements at specified positions */ -public fun IntArray.slice(indices: Iterable) : List { +public fun IntArray.slice(indices: Iterable): List { val list = ArrayList() for (index in indices) { list.add(get(index)) } return list - } /** * Returns a list containing elements at specified positions */ -public fun LongArray.slice(indices: Iterable) : List { +public fun LongArray.slice(indices: Iterable): List { val list = ArrayList() for (index in indices) { list.add(get(index)) } return list - } /** * Returns a list containing elements at specified positions */ -public fun ShortArray.slice(indices: Iterable) : List { +public fun ShortArray.slice(indices: Iterable): List { val list = ArrayList() for (index in indices) { list.add(get(index)) } return list - } /** * Returns a list containing elements at specified positions */ -public fun List.slice(indices: Iterable) : List { +public fun List.slice(indices: Iterable): List { val list = ArrayList() for (index in indices) { list.add(get(index)) } return list - } /** * Returns a list containing elements at specified positions */ -public fun String.slice(indices: Iterable) : String { +public fun String.slice(indices: Iterable): String { val result = StringBuilder() for (i in indices) { result.append(get(i)) } return result.toString() - } /** * Returns a list containing first *n* elements */ -public fun Array.take(n: Int) : List { +public fun Array.take(n: Int): List { var count = 0 val realN = if (n > size) size else n val list = ArrayList(realN) @@ -1035,13 +933,12 @@ public fun Array.take(n: Int) : List { list.add(item) } return list - } /** * Returns a list containing first *n* elements */ -public fun BooleanArray.take(n: Int) : List { +public fun BooleanArray.take(n: Int): List { var count = 0 val realN = if (n > size) size else n val list = ArrayList(realN) @@ -1051,13 +948,12 @@ public fun BooleanArray.take(n: Int) : List { list.add(item) } return list - } /** * Returns a list containing first *n* elements */ -public fun ByteArray.take(n: Int) : List { +public fun ByteArray.take(n: Int): List { var count = 0 val realN = if (n > size) size else n val list = ArrayList(realN) @@ -1067,13 +963,12 @@ public fun ByteArray.take(n: Int) : List { list.add(item) } return list - } /** * Returns a list containing first *n* elements */ -public fun CharArray.take(n: Int) : List { +public fun CharArray.take(n: Int): List { var count = 0 val realN = if (n > size) size else n val list = ArrayList(realN) @@ -1083,13 +978,12 @@ public fun CharArray.take(n: Int) : List { list.add(item) } return list - } /** * Returns a list containing first *n* elements */ -public fun DoubleArray.take(n: Int) : List { +public fun DoubleArray.take(n: Int): List { var count = 0 val realN = if (n > size) size else n val list = ArrayList(realN) @@ -1099,13 +993,12 @@ public fun DoubleArray.take(n: Int) : List { list.add(item) } return list - } /** * Returns a list containing first *n* elements */ -public fun FloatArray.take(n: Int) : List { +public fun FloatArray.take(n: Int): List { var count = 0 val realN = if (n > size) size else n val list = ArrayList(realN) @@ -1115,13 +1008,12 @@ public fun FloatArray.take(n: Int) : List { list.add(item) } return list - } /** * Returns a list containing first *n* elements */ -public fun IntArray.take(n: Int) : List { +public fun IntArray.take(n: Int): List { var count = 0 val realN = if (n > size) size else n val list = ArrayList(realN) @@ -1131,13 +1023,12 @@ public fun IntArray.take(n: Int) : List { list.add(item) } return list - } /** * Returns a list containing first *n* elements */ -public fun LongArray.take(n: Int) : List { +public fun LongArray.take(n: Int): List { var count = 0 val realN = if (n > size) size else n val list = ArrayList(realN) @@ -1147,13 +1038,12 @@ public fun LongArray.take(n: Int) : List { list.add(item) } return list - } /** * Returns a list containing first *n* elements */ -public fun ShortArray.take(n: Int) : List { +public fun ShortArray.take(n: Int): List { var count = 0 val realN = if (n > size) size else n val list = ArrayList(realN) @@ -1163,13 +1053,12 @@ public fun ShortArray.take(n: Int) : List { list.add(item) } return list - } /** * Returns a list containing first *n* elements */ -public fun Collection.take(n: Int) : List { +public fun Collection.take(n: Int): List { var count = 0 val realN = if (n > size) size else n val list = ArrayList(realN) @@ -1179,13 +1068,12 @@ public fun Collection.take(n: Int) : List { list.add(item) } return list - } /** * Returns a list containing first *n* elements */ -public fun Iterable.take(n: Int) : List { +public fun Iterable.take(n: Int): List { var count = 0 val list = ArrayList(n) for (item in this) { @@ -1194,171 +1082,158 @@ public fun Iterable.take(n: Int) : List { list.add(item) } return list - } /** * Returns a stream containing first *n* elements */ -public fun Stream.take(n: Int) : Stream { +public fun Stream.take(n: Int): Stream { var count = 0 return LimitedStream(this) { count++ == n } - } /** * Returns a list containing first *n* elements */ -public fun String.take(n: Int) : String { +public fun String.take(n: Int): String { return substring(0, Math.min(n, size)) } /** * Returns a list containing first elements satisfying the given *predicate* */ -public inline fun Array.takeWhile(predicate: (T)->Boolean) : List { +public inline fun Array.takeWhile(predicate: (T) -> Boolean): List { val list = ArrayList() for (item in this) { - if(!predicate(item)) + if (!predicate(item)) break; - list.add(item) + list.add(item) } return list - } /** * Returns a list containing first elements satisfying the given *predicate* */ -public inline fun BooleanArray.takeWhile(predicate: (Boolean)->Boolean) : List { +public inline fun BooleanArray.takeWhile(predicate: (Boolean) -> Boolean): List { val list = ArrayList() for (item in this) { - if(!predicate(item)) + if (!predicate(item)) break; - list.add(item) + list.add(item) } return list - } /** * Returns a list containing first elements satisfying the given *predicate* */ -public inline fun ByteArray.takeWhile(predicate: (Byte)->Boolean) : List { +public inline fun ByteArray.takeWhile(predicate: (Byte) -> Boolean): List { val list = ArrayList() for (item in this) { - if(!predicate(item)) + if (!predicate(item)) break; - list.add(item) + list.add(item) } return list - } /** * Returns a list containing first elements satisfying the given *predicate* */ -public inline fun CharArray.takeWhile(predicate: (Char)->Boolean) : List { +public inline fun CharArray.takeWhile(predicate: (Char) -> Boolean): List { val list = ArrayList() for (item in this) { - if(!predicate(item)) + if (!predicate(item)) break; - list.add(item) + list.add(item) } return list - } /** * Returns a list containing first elements satisfying the given *predicate* */ -public inline fun DoubleArray.takeWhile(predicate: (Double)->Boolean) : List { +public inline fun DoubleArray.takeWhile(predicate: (Double) -> Boolean): List { val list = ArrayList() for (item in this) { - if(!predicate(item)) + if (!predicate(item)) break; - list.add(item) + list.add(item) } return list - } /** * Returns a list containing first elements satisfying the given *predicate* */ -public inline fun FloatArray.takeWhile(predicate: (Float)->Boolean) : List { +public inline fun FloatArray.takeWhile(predicate: (Float) -> Boolean): List { val list = ArrayList() for (item in this) { - if(!predicate(item)) + if (!predicate(item)) break; - list.add(item) + list.add(item) } return list - } /** * Returns a list containing first elements satisfying the given *predicate* */ -public inline fun IntArray.takeWhile(predicate: (Int)->Boolean) : List { +public inline fun IntArray.takeWhile(predicate: (Int) -> Boolean): List { val list = ArrayList() for (item in this) { - if(!predicate(item)) + if (!predicate(item)) break; - list.add(item) + list.add(item) } return list - } /** * Returns a list containing first elements satisfying the given *predicate* */ -public inline fun LongArray.takeWhile(predicate: (Long)->Boolean) : List { +public inline fun LongArray.takeWhile(predicate: (Long) -> Boolean): List { val list = ArrayList() for (item in this) { - if(!predicate(item)) + if (!predicate(item)) break; - list.add(item) + list.add(item) } return list - } /** * Returns a list containing first elements satisfying the given *predicate* */ -public inline fun ShortArray.takeWhile(predicate: (Short)->Boolean) : List { +public inline fun ShortArray.takeWhile(predicate: (Short) -> Boolean): List { val list = ArrayList() for (item in this) { - if(!predicate(item)) + if (!predicate(item)) break; - list.add(item) + list.add(item) } return list - } /** * Returns a list containing first elements satisfying the given *predicate* */ -public inline fun Iterable.takeWhile(predicate: (T)->Boolean) : List { +public inline fun Iterable.takeWhile(predicate: (T) -> Boolean): List { val list = ArrayList() for (item in this) { - if(!predicate(item)) + if (!predicate(item)) break; - list.add(item) + list.add(item) } return list - } /** * Returns a stream containing first elements satisfying the given *predicate* */ -public fun Stream.takeWhile(predicate: (T)->Boolean) : Stream { +public fun Stream.takeWhile(predicate: (T) -> Boolean): Stream { return LimitedStream(this, false, predicate) - } /** @@ -1370,6 +1245,5 @@ public inline fun String.takeWhile(predicate: (Char) -> Boolean): String { return substring(0, index) } return "" - } diff --git a/libraries/stdlib/src/generated/_Generators.kt b/libraries/stdlib/src/generated/_Generators.kt index 4d63d414119..5bdebb21b70 100644 --- a/libraries/stdlib/src/generated/_Generators.kt +++ b/libraries/stdlib/src/generated/_Generators.kt @@ -12,7 +12,7 @@ import java.util.* * where *first* collection contains elements for which predicate yielded *true*, * while *second* collection contains elements for which predicate yielded *false* */ -public inline fun Array.partition(predicate: (T) -> Boolean) : Pair, List> { +public inline fun Array.partition(predicate: (T) -> Boolean): Pair, List> { val first = ArrayList() val second = ArrayList() for (element in this) { @@ -23,7 +23,6 @@ public inline fun Array.partition(predicate: (T) -> Boolean) : Pair Array.partition(predicate: (T) -> Boolean) : Pair Boolean) : Pair, List> { +public inline fun BooleanArray.partition(predicate: (Boolean) -> Boolean): Pair, List> { val first = ArrayList() val second = ArrayList() for (element in this) { @@ -42,7 +41,6 @@ public inline fun BooleanArray.partition(predicate: (Boolean) -> Boolean) : Pair } } return Pair(first, second) - } /** @@ -50,7 +48,7 @@ public inline fun BooleanArray.partition(predicate: (Boolean) -> Boolean) : Pair * where *first* collection contains elements for which predicate yielded *true*, * while *second* collection contains elements for which predicate yielded *false* */ -public inline fun ByteArray.partition(predicate: (Byte) -> Boolean) : Pair, List> { +public inline fun ByteArray.partition(predicate: (Byte) -> Boolean): Pair, List> { val first = ArrayList() val second = ArrayList() for (element in this) { @@ -61,7 +59,6 @@ public inline fun ByteArray.partition(predicate: (Byte) -> Boolean) : Pair Boolean) : Pair Boolean) : Pair, List> { +public inline fun CharArray.partition(predicate: (Char) -> Boolean): Pair, List> { val first = ArrayList() val second = ArrayList() for (element in this) { @@ -80,7 +77,6 @@ public inline fun CharArray.partition(predicate: (Char) -> Boolean) : Pair Boolean) : Pair Boolean) : Pair, List> { +public inline fun DoubleArray.partition(predicate: (Double) -> Boolean): Pair, List> { val first = ArrayList() val second = ArrayList() for (element in this) { @@ -99,7 +95,6 @@ public inline fun DoubleArray.partition(predicate: (Double) -> Boolean) : Pair Boolean) : Pair Boolean) : Pair, List> { +public inline fun FloatArray.partition(predicate: (Float) -> Boolean): Pair, List> { val first = ArrayList() val second = ArrayList() for (element in this) { @@ -118,7 +113,6 @@ public inline fun FloatArray.partition(predicate: (Float) -> Boolean) : Pair Boolean) : Pair Boolean) : Pair, List> { +public inline fun IntArray.partition(predicate: (Int) -> Boolean): Pair, List> { val first = ArrayList() val second = ArrayList() for (element in this) { @@ -137,7 +131,6 @@ public inline fun IntArray.partition(predicate: (Int) -> Boolean) : Pair Boolean) : Pair Boolean) : Pair, List> { +public inline fun LongArray.partition(predicate: (Long) -> Boolean): Pair, List> { val first = ArrayList() val second = ArrayList() for (element in this) { @@ -156,7 +149,6 @@ public inline fun LongArray.partition(predicate: (Long) -> Boolean) : Pair Boolean) : Pair Boolean) : Pair, List> { +public inline fun ShortArray.partition(predicate: (Short) -> Boolean): Pair, List> { val first = ArrayList() val second = ArrayList() for (element in this) { @@ -175,7 +167,6 @@ public inline fun ShortArray.partition(predicate: (Short) -> Boolean) : Pair Boolean) : Pair Iterable.partition(predicate: (T) -> Boolean) : Pair, List> { +public inline fun Iterable.partition(predicate: (T) -> Boolean): Pair, List> { val first = ArrayList() val second = ArrayList() for (element in this) { @@ -194,7 +185,6 @@ public inline fun Iterable.partition(predicate: (T) -> Boolean) : Pair
  • Iterable.partition(predicate: (T) -> Boolean) : Pair
  • Stream.partition(predicate: (T) -> Boolean) : Pair, List> { +public inline fun Stream.partition(predicate: (T) -> Boolean): Pair, List> { val first = ArrayList() val second = ArrayList() for (element in this) { @@ -213,7 +203,6 @@ public inline fun Stream.partition(predicate: (T) -> Boolean) : Pair Stream.partition(predicate: (T) -> Boolean) : Pair Boolean) : Pair { +public inline fun String.partition(predicate: (Char) -> Boolean): Pair { val first = StringBuilder() val second = StringBuilder() for (element in this) { @@ -232,660 +221,602 @@ public inline fun String.partition(predicate: (Char) -> Boolean) : Pair Array.plus(array: Array) : List { +public fun Array.plus(array: Array): List { val answer = toArrayList() answer.addAll(array) return answer - } /** * Returns a list containing all elements of original collection and then all elements of the given *collection* */ -public fun BooleanArray.plus(array: Array) : List { +public fun BooleanArray.plus(array: Array): List { val answer = toArrayList() answer.addAll(array) return answer - } /** * Returns a list containing all elements of original collection and then all elements of the given *collection* */ -public fun ByteArray.plus(array: Array) : List { +public fun ByteArray.plus(array: Array): List { val answer = toArrayList() answer.addAll(array) return answer - } /** * Returns a list containing all elements of original collection and then all elements of the given *collection* */ -public fun CharArray.plus(array: Array) : List { +public fun CharArray.plus(array: Array): List { val answer = toArrayList() answer.addAll(array) return answer - } /** * Returns a list containing all elements of original collection and then all elements of the given *collection* */ -public fun DoubleArray.plus(array: Array) : List { +public fun DoubleArray.plus(array: Array): List { val answer = toArrayList() answer.addAll(array) return answer - } /** * Returns a list containing all elements of original collection and then all elements of the given *collection* */ -public fun FloatArray.plus(array: Array) : List { +public fun FloatArray.plus(array: Array): List { val answer = toArrayList() answer.addAll(array) return answer - } /** * Returns a list containing all elements of original collection and then all elements of the given *collection* */ -public fun IntArray.plus(array: Array) : List { +public fun IntArray.plus(array: Array): List { val answer = toArrayList() answer.addAll(array) return answer - } /** * Returns a list containing all elements of original collection and then all elements of the given *collection* */ -public fun LongArray.plus(array: Array) : List { +public fun LongArray.plus(array: Array): List { val answer = toArrayList() answer.addAll(array) return answer - } /** * Returns a list containing all elements of original collection and then all elements of the given *collection* */ -public fun ShortArray.plus(array: Array) : List { +public fun ShortArray.plus(array: Array): List { val answer = toArrayList() answer.addAll(array) return answer - } /** * Returns a list containing all elements of original collection and then all elements of the given *collection* */ -public fun Iterable.plus(array: Array) : List { +public fun Iterable.plus(array: Array): List { val answer = toArrayList() answer.addAll(array) return answer - } /** * Returns a list containing all elements of original collection and then all elements of the given *collection* */ -public fun Array.plus(collection: Iterable) : List { +public fun Array.plus(collection: Iterable): List { val answer = toArrayList() answer.addAll(collection) return answer - } /** * Returns a list containing all elements of original collection and then all elements of the given *collection* */ -public fun BooleanArray.plus(collection: Iterable) : List { +public fun BooleanArray.plus(collection: Iterable): List { val answer = toArrayList() answer.addAll(collection) return answer - } /** * Returns a list containing all elements of original collection and then all elements of the given *collection* */ -public fun ByteArray.plus(collection: Iterable) : List { +public fun ByteArray.plus(collection: Iterable): List { val answer = toArrayList() answer.addAll(collection) return answer - } /** * Returns a list containing all elements of original collection and then all elements of the given *collection* */ -public fun CharArray.plus(collection: Iterable) : List { +public fun CharArray.plus(collection: Iterable): List { val answer = toArrayList() answer.addAll(collection) return answer - } /** * Returns a list containing all elements of original collection and then all elements of the given *collection* */ -public fun DoubleArray.plus(collection: Iterable) : List { +public fun DoubleArray.plus(collection: Iterable): List { val answer = toArrayList() answer.addAll(collection) return answer - } /** * Returns a list containing all elements of original collection and then all elements of the given *collection* */ -public fun FloatArray.plus(collection: Iterable) : List { +public fun FloatArray.plus(collection: Iterable): List { val answer = toArrayList() answer.addAll(collection) return answer - } /** * Returns a list containing all elements of original collection and then all elements of the given *collection* */ -public fun IntArray.plus(collection: Iterable) : List { +public fun IntArray.plus(collection: Iterable): List { val answer = toArrayList() answer.addAll(collection) return answer - } /** * Returns a list containing all elements of original collection and then all elements of the given *collection* */ -public fun LongArray.plus(collection: Iterable) : List { +public fun LongArray.plus(collection: Iterable): List { val answer = toArrayList() answer.addAll(collection) return answer - } /** * Returns a list containing all elements of original collection and then all elements of the given *collection* */ -public fun ShortArray.plus(collection: Iterable) : List { +public fun ShortArray.plus(collection: Iterable): List { val answer = toArrayList() answer.addAll(collection) return answer - } /** * Returns a list containing all elements of original collection and then all elements of the given *collection* */ -public fun Iterable.plus(collection: Iterable) : List { +public fun Iterable.plus(collection: Iterable): List { val answer = toArrayList() answer.addAll(collection) return answer - } /** * Returns a stream containing all elements of original stream and then all elements of the given *collection* */ -public fun Stream.plus(collection: Iterable) : Stream { +public fun Stream.plus(collection: Iterable): Stream { return Multistream(streamOf(this, collection.stream())) - } /** * Returns a list containing all elements of original collection and then the given element */ -public fun Array.plus(element: T) : List { +public fun Array.plus(element: T): List { val answer = toArrayList() answer.add(element) return answer - } /** * Returns a list containing all elements of original collection and then the given element */ -public fun BooleanArray.plus(element: Boolean) : List { +public fun BooleanArray.plus(element: Boolean): List { val answer = toArrayList() answer.add(element) return answer - } /** * Returns a list containing all elements of original collection and then the given element */ -public fun ByteArray.plus(element: Byte) : List { +public fun ByteArray.plus(element: Byte): List { val answer = toArrayList() answer.add(element) return answer - } /** * Returns a list containing all elements of original collection and then the given element */ -public fun CharArray.plus(element: Char) : List { +public fun CharArray.plus(element: Char): List { val answer = toArrayList() answer.add(element) return answer - } /** * Returns a list containing all elements of original collection and then the given element */ -public fun DoubleArray.plus(element: Double) : List { +public fun DoubleArray.plus(element: Double): List { val answer = toArrayList() answer.add(element) return answer - } /** * Returns a list containing all elements of original collection and then the given element */ -public fun FloatArray.plus(element: Float) : List { +public fun FloatArray.plus(element: Float): List { val answer = toArrayList() answer.add(element) return answer - } /** * Returns a list containing all elements of original collection and then the given element */ -public fun IntArray.plus(element: Int) : List { +public fun IntArray.plus(element: Int): List { val answer = toArrayList() answer.add(element) return answer - } /** * Returns a list containing all elements of original collection and then the given element */ -public fun LongArray.plus(element: Long) : List { +public fun LongArray.plus(element: Long): List { val answer = toArrayList() answer.add(element) return answer - } /** * Returns a list containing all elements of original collection and then the given element */ -public fun ShortArray.plus(element: Short) : List { +public fun ShortArray.plus(element: Short): List { val answer = toArrayList() answer.add(element) return answer - } /** * Returns a list containing all elements of original collection and then the given element */ -public fun Iterable.plus(element: T) : List { +public fun Iterable.plus(element: T): List { val answer = toArrayList() answer.add(element) return answer - } /** * Returns a stream containing all elements of original stream and then the given element */ -public fun Stream.plus(element: T) : Stream { +public fun Stream.plus(element: T): Stream { return Multistream(streamOf(this, streamOf(element))) - } /** * Returns a stream containing all elements of original stream and then all elements of the given *stream* */ -public fun Stream.plus(stream: Stream) : Stream { +public fun Stream.plus(stream: Stream): Stream { return Multistream(streamOf(this, stream)) - } /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public fun Array.zip(array: Array) : List> { +public fun Array.zip(array: Array): List> { val first = iterator() val second = array.iterator() - val list = ArrayList>() + val list = ArrayList>() while (first.hasNext() && second.hasNext()) { list.add(first.next() to second.next()) } return list - } /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public fun BooleanArray.zip(array: Array) : List> { +public fun BooleanArray.zip(array: Array): List> { val first = iterator() val second = array.iterator() - val list = ArrayList>() + val list = ArrayList>() while (first.hasNext() && second.hasNext()) { list.add(first.next() to second.next()) } return list - } /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public fun ByteArray.zip(array: Array) : List> { +public fun ByteArray.zip(array: Array): List> { val first = iterator() val second = array.iterator() - val list = ArrayList>() + val list = ArrayList>() while (first.hasNext() && second.hasNext()) { list.add(first.next() to second.next()) } return list - } /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public fun CharArray.zip(array: Array) : List> { +public fun CharArray.zip(array: Array): List> { val first = iterator() val second = array.iterator() - val list = ArrayList>() + val list = ArrayList>() while (first.hasNext() && second.hasNext()) { list.add(first.next() to second.next()) } return list - } /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public fun DoubleArray.zip(array: Array) : List> { +public fun DoubleArray.zip(array: Array): List> { val first = iterator() val second = array.iterator() - val list = ArrayList>() + val list = ArrayList>() while (first.hasNext() && second.hasNext()) { list.add(first.next() to second.next()) } return list - } /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public fun FloatArray.zip(array: Array) : List> { +public fun FloatArray.zip(array: Array): List> { val first = iterator() val second = array.iterator() - val list = ArrayList>() + val list = ArrayList>() while (first.hasNext() && second.hasNext()) { list.add(first.next() to second.next()) } return list - } /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public fun IntArray.zip(array: Array) : List> { +public fun IntArray.zip(array: Array): List> { val first = iterator() val second = array.iterator() - val list = ArrayList>() + val list = ArrayList>() while (first.hasNext() && second.hasNext()) { list.add(first.next() to second.next()) } return list - } /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public fun LongArray.zip(array: Array) : List> { +public fun LongArray.zip(array: Array): List> { val first = iterator() val second = array.iterator() - val list = ArrayList>() + val list = ArrayList>() while (first.hasNext() && second.hasNext()) { list.add(first.next() to second.next()) } return list - } /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public fun ShortArray.zip(array: Array) : List> { +public fun ShortArray.zip(array: Array): List> { val first = iterator() val second = array.iterator() - val list = ArrayList>() + val list = ArrayList>() while (first.hasNext() && second.hasNext()) { list.add(first.next() to second.next()) } return list - } /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public fun Iterable.zip(array: Array) : List> { +public fun Iterable.zip(array: Array): List> { val first = iterator() val second = array.iterator() - val list = ArrayList>() + val list = ArrayList>() while (first.hasNext() && second.hasNext()) { list.add(first.next() to second.next()) } return list - } /** * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public fun String.zip(array: Array) : List> { +public fun String.zip(array: Array): List> { val first = iterator() val second = array.iterator() - val list = ArrayList>() + val list = ArrayList>() + while (first.hasNext() && second.hasNext()) { + list.add(first.next() to second.next()) + } + return list +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public fun Array.zip(other: Iterable): List> { + val first = iterator() + val second = other.iterator() + val list = ArrayList>() + while (first.hasNext() && second.hasNext()) { + list.add(first.next() to second.next()) + } + return list +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public fun BooleanArray.zip(other: Iterable): List> { + val first = iterator() + val second = other.iterator() + val list = ArrayList>() + while (first.hasNext() && second.hasNext()) { + list.add(first.next() to second.next()) + } + return list +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public fun ByteArray.zip(other: Iterable): List> { + val first = iterator() + val second = other.iterator() + val list = ArrayList>() + while (first.hasNext() && second.hasNext()) { + list.add(first.next() to second.next()) + } + return list +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public fun CharArray.zip(other: Iterable): List> { + val first = iterator() + val second = other.iterator() + val list = ArrayList>() + while (first.hasNext() && second.hasNext()) { + list.add(first.next() to second.next()) + } + return list +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public fun DoubleArray.zip(other: Iterable): List> { + val first = iterator() + val second = other.iterator() + val list = ArrayList>() + while (first.hasNext() && second.hasNext()) { + list.add(first.next() to second.next()) + } + return list +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public fun FloatArray.zip(other: Iterable): List> { + val first = iterator() + val second = other.iterator() + val list = ArrayList>() + while (first.hasNext() && second.hasNext()) { + list.add(first.next() to second.next()) + } + return list +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public fun IntArray.zip(other: Iterable): List> { + val first = iterator() + val second = other.iterator() + val list = ArrayList>() + while (first.hasNext() && second.hasNext()) { + list.add(first.next() to second.next()) + } + return list +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public fun LongArray.zip(other: Iterable): List> { + val first = iterator() + val second = other.iterator() + val list = ArrayList>() + while (first.hasNext() && second.hasNext()) { + list.add(first.next() to second.next()) + } + return list +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public fun ShortArray.zip(other: Iterable): List> { + val first = iterator() + val second = other.iterator() + val list = ArrayList>() + while (first.hasNext() && second.hasNext()) { + list.add(first.next() to second.next()) + } + return list +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public fun Iterable.zip(other: Iterable): List> { + val first = iterator() + val second = other.iterator() + val list = ArrayList>() + while (first.hasNext() && second.hasNext()) { + list.add(first.next() to second.next()) + } + return list +} + +/** + * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. + */ +public fun String.zip(other: Iterable): List> { + val first = iterator() + val second = other.iterator() + val list = ArrayList>() while (first.hasNext() && second.hasNext()) { list.add(first.next() to second.next()) } return list - } /** * Returns a list of pairs built from characters of both strings with same indexes. List has length of shortest collection. */ -public fun String.zip(other : String) : List> { +public fun String.zip(other: String): List> { val first = iterator() val second = other.iterator() - val list = ArrayList>() + val list = ArrayList>() while (first.hasNext() && second.hasNext()) { list.add(first.next() to second.next()) } return list - -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public fun Array.zip(other: Iterable) : List> { - val first = iterator() - val second = other.iterator() - val list = ArrayList>() - while (first.hasNext() && second.hasNext()) { - list.add(first.next() to second.next()) - } - return list - -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public fun BooleanArray.zip(other: Iterable) : List> { - val first = iterator() - val second = other.iterator() - val list = ArrayList>() - while (first.hasNext() && second.hasNext()) { - list.add(first.next() to second.next()) - } - return list - -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public fun ByteArray.zip(other: Iterable) : List> { - val first = iterator() - val second = other.iterator() - val list = ArrayList>() - while (first.hasNext() && second.hasNext()) { - list.add(first.next() to second.next()) - } - return list - -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public fun CharArray.zip(other: Iterable) : List> { - val first = iterator() - val second = other.iterator() - val list = ArrayList>() - while (first.hasNext() && second.hasNext()) { - list.add(first.next() to second.next()) - } - return list - -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public fun DoubleArray.zip(other: Iterable) : List> { - val first = iterator() - val second = other.iterator() - val list = ArrayList>() - while (first.hasNext() && second.hasNext()) { - list.add(first.next() to second.next()) - } - return list - -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public fun FloatArray.zip(other: Iterable) : List> { - val first = iterator() - val second = other.iterator() - val list = ArrayList>() - while (first.hasNext() && second.hasNext()) { - list.add(first.next() to second.next()) - } - return list - -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public fun IntArray.zip(other: Iterable) : List> { - val first = iterator() - val second = other.iterator() - val list = ArrayList>() - while (first.hasNext() && second.hasNext()) { - list.add(first.next() to second.next()) - } - return list - -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public fun LongArray.zip(other: Iterable) : List> { - val first = iterator() - val second = other.iterator() - val list = ArrayList>() - while (first.hasNext() && second.hasNext()) { - list.add(first.next() to second.next()) - } - return list - -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public fun ShortArray.zip(other: Iterable) : List> { - val first = iterator() - val second = other.iterator() - val list = ArrayList>() - while (first.hasNext() && second.hasNext()) { - list.add(first.next() to second.next()) - } - return list - -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public fun Iterable.zip(other: Iterable) : List> { - val first = iterator() - val second = other.iterator() - val list = ArrayList>() - while (first.hasNext() && second.hasNext()) { - list.add(first.next() to second.next()) - } - return list - -} - -/** - * Returns a list of pairs built from elements of both collections with same indexes. List has length of shortest collection. - */ -public fun String.zip(other: Iterable) : List> { - val first = iterator() - val second = other.iterator() - val list = ArrayList>() - while (first.hasNext() && second.hasNext()) { - list.add(first.next() to second.next()) - } - return list - } /** * Returns a stream of pairs built from elements of both collections with same indexes. List has length of shortest collection. */ -public fun Stream.zip(stream: Stream) : Stream> { +public fun Stream.zip(stream: Stream): Stream> { return ZippingStream(this, stream) - } diff --git a/libraries/stdlib/src/generated/_Guards.kt b/libraries/stdlib/src/generated/_Guards.kt index b3686bb3958..82d1664be8f 100644 --- a/libraries/stdlib/src/generated/_Guards.kt +++ b/libraries/stdlib/src/generated/_Guards.kt @@ -10,52 +10,48 @@ import java.util.* /** * Returns an original collection containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements */ -public fun Array.requireNoNulls() : Array { +public fun Array.requireNoNulls(): Array { for (element in this) { if (element == null) { throw IllegalArgumentException("null element found in $this") } } return this as Array - } /** * Returns an original collection containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements */ -public fun Iterable.requireNoNulls() : Iterable { +public fun Iterable.requireNoNulls(): Iterable { for (element in this) { if (element == null) { throw IllegalArgumentException("null element found in $this") } } return this as Iterable - } /** * Returns an original collection containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements */ -public fun List.requireNoNulls() : List { +public fun List.requireNoNulls(): List { for (element in this) { if (element == null) { throw IllegalArgumentException("null element found in $this") } } return this as List - } /** * Returns an original collection containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements */ -public fun Stream.requireNoNulls() : Stream { +public fun Stream.requireNoNulls(): Stream { return FilteringStream(this) { if (it == null) { throw IllegalArgumentException("null element found in $this") } true } as Stream - } diff --git a/libraries/stdlib/src/generated/_Mapping.kt b/libraries/stdlib/src/generated/_Mapping.kt index 733f9f9cc82..7e91adfde32 100644 --- a/libraries/stdlib/src/generated/_Mapping.kt +++ b/libraries/stdlib/src/generated/_Mapping.kt @@ -10,915 +10,858 @@ import java.util.* /** * Returns a single list of all elements yielded from results of *transform* function being invoked on each element of original collection */ -public inline fun Array.flatMap(transform: (T)-> Iterable) : List { +public inline fun Array.flatMap(transform: (T) -> 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 collection */ -public inline fun BooleanArray.flatMap(transform: (Boolean)-> Iterable) : List { +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 collection */ -public inline fun ByteArray.flatMap(transform: (Byte)-> Iterable) : List { +public inline fun ByteArray.flatMap(transform: (Byte) -> 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 collection */ -public inline fun CharArray.flatMap(transform: (Char)-> Iterable) : List { +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 collection */ -public inline fun DoubleArray.flatMap(transform: (Double)-> Iterable) : List { +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 collection */ -public inline fun FloatArray.flatMap(transform: (Float)-> 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 collection */ -public inline fun IntArray.flatMap(transform: (Int)-> Iterable) : List { +public inline fun IntArray.flatMap(transform: (Int) -> 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 collection */ -public inline fun LongArray.flatMap(transform: (Long)-> Iterable) : List { +public inline fun LongArray.flatMap(transform: (Long) -> 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 collection */ -public inline fun ShortArray.flatMap(transform: (Short)-> Iterable) : List { +public inline fun ShortArray.flatMap(transform: (Short) -> 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 collection */ -public inline fun Iterable.flatMap(transform: (T)-> Iterable) : List { +public inline fun Iterable.flatMap(transform: (T) -> 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 collection */ -public inline fun Map.flatMap(transform: (Map.Entry)-> Iterable) : List { +public inline fun Map.flatMap(transform: (Map.Entry) -> 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 collection */ -public inline fun String.flatMap(transform: (Char)-> Iterable) : List { +public inline fun String.flatMap(transform: (Char) -> Iterable): List { return flatMapTo(ArrayList(), transform) } /** * Returns a single stream of all elements streamed from results of *transform* function being invoked on each element of original stream */ -public fun Stream.flatMap(transform: (T)-> Stream) : Stream { +public fun Stream.flatMap(transform: (T) -> Stream): Stream { return FlatteningStream(this, transform) } /** * Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection* */ -public inline fun > Array.flatMapTo(collection: C, transform: (T) -> Iterable) : C { +public inline fun > Array.flatMapTo(collection: C, transform: (T) -> Iterable): C { for (element in this) { val list = transform(element) collection.addAll(list) } return collection - } /** * Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection* */ -public inline fun > BooleanArray.flatMapTo(collection: C, transform: (Boolean) -> Iterable) : C { +public inline fun > BooleanArray.flatMapTo(collection: C, transform: (Boolean) -> Iterable): C { for (element in this) { val list = transform(element) collection.addAll(list) } return collection - } /** * Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection* */ -public inline fun > ByteArray.flatMapTo(collection: C, transform: (Byte) -> Iterable) : C { +public inline fun > ByteArray.flatMapTo(collection: C, transform: (Byte) -> Iterable): C { for (element in this) { val list = transform(element) collection.addAll(list) } return collection - } /** * Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection* */ -public inline fun > CharArray.flatMapTo(collection: C, transform: (Char) -> Iterable) : C { +public inline fun > CharArray.flatMapTo(collection: C, transform: (Char) -> Iterable): C { for (element in this) { val list = transform(element) collection.addAll(list) } return collection - } /** * Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection* */ -public inline fun > DoubleArray.flatMapTo(collection: C, transform: (Double) -> Iterable) : C { +public inline fun > DoubleArray.flatMapTo(collection: C, transform: (Double) -> Iterable): C { for (element in this) { val list = transform(element) collection.addAll(list) } return collection - } /** * Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection* */ -public inline fun > FloatArray.flatMapTo(collection: C, transform: (Float) -> Iterable) : C { +public inline fun > FloatArray.flatMapTo(collection: C, transform: (Float) -> Iterable): C { for (element in this) { val list = transform(element) collection.addAll(list) } return collection - } /** * Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection* */ -public inline fun > IntArray.flatMapTo(collection: C, transform: (Int) -> Iterable) : C { +public inline fun > IntArray.flatMapTo(collection: C, transform: (Int) -> Iterable): C { for (element in this) { val list = transform(element) collection.addAll(list) } return collection - } /** * Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection* */ -public inline fun > LongArray.flatMapTo(collection: C, transform: (Long) -> Iterable) : C { +public inline fun > LongArray.flatMapTo(collection: C, transform: (Long) -> Iterable): C { for (element in this) { val list = transform(element) collection.addAll(list) } return collection - } /** * Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection* */ -public inline fun > ShortArray.flatMapTo(collection: C, transform: (Short) -> Iterable) : C { +public inline fun > ShortArray.flatMapTo(collection: C, transform: (Short) -> Iterable): C { for (element in this) { val list = transform(element) collection.addAll(list) } return collection - } /** * Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection* */ -public inline fun > Iterable.flatMapTo(collection: C, transform: (T) -> Iterable) : C { +public inline fun > Iterable.flatMapTo(collection: C, transform: (T) -> Iterable): C { for (element in this) { val list = transform(element) collection.addAll(list) } return collection - } /** * Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection* */ -public inline fun > Map.flatMapTo(collection: C, transform: (Map.Entry) -> Iterable) : C { +public inline fun > Map.flatMapTo(collection: C, transform: (Map.Entry) -> Iterable): C { for (element in this) { val list = transform(element) collection.addAll(list) } return collection - } /** * Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection* */ -public inline fun > String.flatMapTo(collection: C, transform: (Char) -> Iterable) : C { +public inline fun > String.flatMapTo(collection: C, transform: (Char) -> Iterable): C { for (element in this) { val list = transform(element) collection.addAll(list) } return collection - } /** * Appends all elements yielded from results of *transform* function being invoked on each element of original stream, to the given *collection* */ -public inline fun > Stream.flatMapTo(collection: C, transform: (T) -> Stream) : C { +public inline fun > Stream.flatMapTo(collection: C, transform: (T) -> Stream): C { for (element in this) { val list = transform(element) collection.addAll(list) } return collection - } /** * Returns a map of the elements in original collection grouped by the result of given *toKey* function */ -public inline fun Array.groupBy(toKey: (T) -> K) : Map> { +public inline fun Array.groupBy(toKey: (T) -> K): Map> { return groupByTo(HashMap>(), toKey) } /** * Returns a map of the elements in original collection grouped by the result of given *toKey* function */ -public inline fun BooleanArray.groupBy(toKey: (Boolean) -> K) : Map> { +public inline fun BooleanArray.groupBy(toKey: (Boolean) -> K): Map> { return groupByTo(HashMap>(), toKey) } /** * Returns a map of the elements in original collection grouped by the result of given *toKey* function */ -public inline fun ByteArray.groupBy(toKey: (Byte) -> K) : Map> { +public inline fun ByteArray.groupBy(toKey: (Byte) -> K): Map> { return groupByTo(HashMap>(), toKey) } /** * Returns a map of the elements in original collection grouped by the result of given *toKey* function */ -public inline fun CharArray.groupBy(toKey: (Char) -> K) : Map> { +public inline fun CharArray.groupBy(toKey: (Char) -> K): Map> { return groupByTo(HashMap>(), toKey) } /** * Returns a map of the elements in original collection grouped by the result of given *toKey* function */ -public inline fun DoubleArray.groupBy(toKey: (Double) -> K) : Map> { +public inline fun DoubleArray.groupBy(toKey: (Double) -> K): Map> { return groupByTo(HashMap>(), toKey) } /** * Returns a map of the elements in original collection grouped by the result of given *toKey* function */ -public inline fun FloatArray.groupBy(toKey: (Float) -> K) : Map> { +public inline fun FloatArray.groupBy(toKey: (Float) -> K): Map> { return groupByTo(HashMap>(), toKey) } /** * Returns a map of the elements in original collection grouped by the result of given *toKey* function */ -public inline fun IntArray.groupBy(toKey: (Int) -> K) : Map> { +public inline fun IntArray.groupBy(toKey: (Int) -> K): Map> { return groupByTo(HashMap>(), toKey) } /** * Returns a map of the elements in original collection grouped by the result of given *toKey* function */ -public inline fun LongArray.groupBy(toKey: (Long) -> K) : Map> { +public inline fun LongArray.groupBy(toKey: (Long) -> K): Map> { return groupByTo(HashMap>(), toKey) } /** * Returns a map of the elements in original collection grouped by the result of given *toKey* function */ -public inline fun ShortArray.groupBy(toKey: (Short) -> K) : Map> { +public inline fun ShortArray.groupBy(toKey: (Short) -> K): Map> { return groupByTo(HashMap>(), toKey) } /** * Returns a map of the elements in original collection grouped by the result of given *toKey* function */ -public inline fun Iterable.groupBy(toKey: (T) -> K) : Map> { +public inline fun Iterable.groupBy(toKey: (T) -> K): Map> { return groupByTo(HashMap>(), toKey) } /** * Returns a map of the elements in original collection grouped by the result of given *toKey* function */ -public inline fun Map.groupBy(toKey: (Map.Entry) -> K) : Map>> { - return groupByTo(HashMap>>(), toKey) +public inline fun Map.groupBy(toKey: (Map.Entry) -> K): Map>> { + return groupByTo(HashMap>>(), toKey) } /** * Returns a map of the elements in original collection grouped by the result of given *toKey* function */ -public inline fun Stream.groupBy(toKey: (T) -> K) : Map> { +public inline fun Stream.groupBy(toKey: (T) -> K): Map> { return groupByTo(HashMap>(), toKey) } /** * Returns a map of the elements in original collection grouped by the result of given *toKey* function */ -public inline fun String.groupBy(toKey: (Char) -> K) : Map> { +public inline fun String.groupBy(toKey: (Char) -> K): Map> { return groupByTo(HashMap>(), toKey) } /** * Appends elements from original collection grouped by the result of given *toKey* function to the given *map* */ -public inline fun Array.groupByTo(map: MutableMap>, toKey: (T) -> K) : Map> { +public inline fun Array.groupByTo(map: MutableMap>, toKey: (T) -> K): Map> { for (element in this) { val key = toKey(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } return map - } /** * Appends elements from original collection grouped by the result of given *toKey* function to the given *map* */ -public inline fun BooleanArray.groupByTo(map: MutableMap>, toKey: (Boolean) -> K) : Map> { +public inline fun BooleanArray.groupByTo(map: MutableMap>, toKey: (Boolean) -> K): Map> { for (element in this) { val key = toKey(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } return map - } /** * Appends elements from original collection grouped by the result of given *toKey* function to the given *map* */ -public inline fun ByteArray.groupByTo(map: MutableMap>, toKey: (Byte) -> K) : Map> { +public inline fun ByteArray.groupByTo(map: MutableMap>, toKey: (Byte) -> K): Map> { for (element in this) { val key = toKey(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } return map - } /** * Appends elements from original collection grouped by the result of given *toKey* function to the given *map* */ -public inline fun CharArray.groupByTo(map: MutableMap>, toKey: (Char) -> K) : Map> { +public inline fun CharArray.groupByTo(map: MutableMap>, toKey: (Char) -> K): Map> { for (element in this) { val key = toKey(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } return map - } /** * Appends elements from original collection grouped by the result of given *toKey* function to the given *map* */ -public inline fun DoubleArray.groupByTo(map: MutableMap>, toKey: (Double) -> K) : Map> { +public inline fun DoubleArray.groupByTo(map: MutableMap>, toKey: (Double) -> K): Map> { for (element in this) { val key = toKey(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } return map - } /** * Appends elements from original collection grouped by the result of given *toKey* function to the given *map* */ -public inline fun FloatArray.groupByTo(map: MutableMap>, toKey: (Float) -> K) : Map> { +public inline fun FloatArray.groupByTo(map: MutableMap>, toKey: (Float) -> K): Map> { for (element in this) { val key = toKey(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } return map - } /** * Appends elements from original collection grouped by the result of given *toKey* function to the given *map* */ -public inline fun IntArray.groupByTo(map: MutableMap>, toKey: (Int) -> K) : Map> { +public inline fun IntArray.groupByTo(map: MutableMap>, toKey: (Int) -> K): Map> { for (element in this) { val key = toKey(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } return map - } /** * Appends elements from original collection grouped by the result of given *toKey* function to the given *map* */ -public inline fun LongArray.groupByTo(map: MutableMap>, toKey: (Long) -> K) : Map> { +public inline fun LongArray.groupByTo(map: MutableMap>, toKey: (Long) -> K): Map> { for (element in this) { val key = toKey(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } return map - } /** * Appends elements from original collection grouped by the result of given *toKey* function to the given *map* */ -public inline fun ShortArray.groupByTo(map: MutableMap>, toKey: (Short) -> K) : Map> { +public inline fun ShortArray.groupByTo(map: MutableMap>, toKey: (Short) -> K): Map> { for (element in this) { val key = toKey(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } return map - } /** * Appends elements from original collection grouped by the result of given *toKey* function to the given *map* */ -public inline fun Iterable.groupByTo(map: MutableMap>, toKey: (T) -> K) : Map> { +public inline fun Iterable.groupByTo(map: MutableMap>, toKey: (T) -> K): Map> { for (element in this) { val key = toKey(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } return map - } /** * Appends elements from original collection grouped by the result of given *toKey* function to the given *map* */ -public inline fun Map.groupByTo(map: MutableMap>>, toKey: (Map.Entry) -> K) : Map>> { +public inline fun Map.groupByTo(map: MutableMap>>, toKey: (Map.Entry) -> K): Map>> { for (element in this) { val key = toKey(element) - val list = map.getOrPut(key) { ArrayList>() } + val list = map.getOrPut(key) { ArrayList>() } list.add(element) } return map - } /** * Appends elements from original collection grouped by the result of given *toKey* function to the given *map* */ -public inline fun Stream.groupByTo(map: MutableMap>, toKey: (T) -> K) : Map> { +public inline fun Stream.groupByTo(map: MutableMap>, toKey: (T) -> K): Map> { for (element in this) { val key = toKey(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } return map - } /** * Appends elements from original collection grouped by the result of given *toKey* function to the given *map* */ -public inline fun String.groupByTo(map: MutableMap>, toKey: (Char) -> K) : Map> { +public inline fun String.groupByTo(map: MutableMap>, toKey: (Char) -> K): Map> { for (element in this) { val key = toKey(element) val list = map.getOrPut(key) { ArrayList() } list.add(element) } return map - } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ -public inline fun Array.map(transform : (T) -> R) : List { +public inline fun Array.map(transform: (T) -> R): List { return mapTo(ArrayList(), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ -public inline fun BooleanArray.map(transform : (Boolean) -> R) : List { +public inline fun BooleanArray.map(transform: (Boolean) -> R): List { return mapTo(ArrayList(), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ -public inline fun ByteArray.map(transform : (Byte) -> R) : List { +public inline fun ByteArray.map(transform: (Byte) -> R): List { return mapTo(ArrayList(), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ -public inline fun CharArray.map(transform : (Char) -> R) : List { +public inline fun CharArray.map(transform: (Char) -> R): List { return mapTo(ArrayList(), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ -public inline fun DoubleArray.map(transform : (Double) -> R) : List { +public inline fun DoubleArray.map(transform: (Double) -> R): List { return mapTo(ArrayList(), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ -public inline fun FloatArray.map(transform : (Float) -> R) : List { +public inline fun FloatArray.map(transform: (Float) -> R): List { return mapTo(ArrayList(), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ -public inline fun IntArray.map(transform : (Int) -> R) : List { +public inline fun IntArray.map(transform: (Int) -> R): List { return mapTo(ArrayList(), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ -public inline fun LongArray.map(transform : (Long) -> R) : List { +public inline fun LongArray.map(transform: (Long) -> R): List { return mapTo(ArrayList(), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ -public inline fun ShortArray.map(transform : (Short) -> R) : List { +public inline fun ShortArray.map(transform: (Short) -> R): List { return mapTo(ArrayList(), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ -public inline fun Iterable.map(transform : (T) -> R) : List { +public inline fun Iterable.map(transform: (T) -> R): List { return mapTo(ArrayList(), transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ -public inline fun Map.map(transform : (Map.Entry) -> R) : List { +public inline fun Map.map(transform: (Map.Entry) -> R): List { return mapTo(ArrayList(), transform) } /** * Returns a stream containing the results of applying the given *transform* function to each element of the original stream */ -public fun Stream.map(transform : (T) -> R) : Stream { - return TransformingStream(this, transform) +public fun Stream.map(transform: (T) -> R): Stream { + return TransformingStream(this, transform) } /** * Returns a list containing the results of applying the given *transform* function to each element of the original collection */ -public inline fun String.map(transform : (Char) -> R) : List { +public inline fun String.map(transform: (Char) -> R): List { return mapTo(ArrayList(), transform) } /** * Returns a list containing the results of applying the given *transform* function to each non-null element of the original collection */ -public inline fun Array.mapNotNull(transform : (T) -> R) : List { +public inline fun Array.mapNotNull(transform: (T) -> R): List { return mapNotNullTo(ArrayList(), transform) - } /** * Returns a list containing the results of applying the given *transform* function to each non-null element of the original collection */ -public inline fun Iterable.mapNotNull(transform : (T) -> R) : List { +public inline fun Iterable.mapNotNull(transform: (T) -> R): List { return mapNotNullTo(ArrayList(), transform) - } /** * Returns a stream containing the results of applying the given *transform* function to each non-null element of the original stream */ -public fun Stream.mapNotNull(transform : (T) -> R) : Stream { +public fun Stream.mapNotNull(transform: (T) -> R): Stream { return TransformingStream(FilteringStream(this, false, { it != null }) as Stream, transform) - } /** * Appends transformed non-null elements of original collection using the given *transform* function * to the given *collection* */ -public inline fun > Array.mapNotNullTo(collection: C, transform : (T) -> R) : C { +public inline fun > Array.mapNotNullTo(collection: C, transform: (T) -> R): C { for (element in this) { if (element != null) { collection.add(transform(element)) - } + } } return collection - } /** * Appends transformed non-null elements of original collection using the given *transform* function * to the given *collection* */ -public inline fun > Iterable.mapNotNullTo(collection: C, transform : (T) -> R) : C { +public inline fun > Iterable.mapNotNullTo(collection: C, transform: (T) -> R): C { for (element in this) { if (element != null) { collection.add(transform(element)) - } + } } return collection - } /** * Appends transformed non-null elements of original collection using the given *transform* function * to the given *collection* */ -public inline fun > Stream.mapNotNullTo(collection: C, transform : (T) -> R) : C { +public inline fun > Stream.mapNotNullTo(collection: C, transform: (T) -> R): C { for (element in this) { if (element != null) { collection.add(transform(element)) - } + } } return collection - } /** * Appends transformed elements of original collection using the given *transform* function * to the given *collection* */ -public inline fun > Array.mapTo(collection: C, transform : (T) -> R) : C { +public inline fun > Array.mapTo(collection: C, transform: (T) -> R): C { for (item in this) collection.add(transform(item)) return collection - } /** * Appends transformed elements of original collection using the given *transform* function * to the given *collection* */ -public inline fun > BooleanArray.mapTo(collection: C, transform : (Boolean) -> R) : C { +public inline fun > BooleanArray.mapTo(collection: C, transform: (Boolean) -> R): C { for (item in this) collection.add(transform(item)) return collection - } /** * Appends transformed elements of original collection using the given *transform* function * to the given *collection* */ -public inline fun > ByteArray.mapTo(collection: C, transform : (Byte) -> R) : C { +public inline fun > ByteArray.mapTo(collection: C, transform: (Byte) -> R): C { for (item in this) collection.add(transform(item)) return collection - } /** * Appends transformed elements of original collection using the given *transform* function * to the given *collection* */ -public inline fun > CharArray.mapTo(collection: C, transform : (Char) -> R) : C { +public inline fun > CharArray.mapTo(collection: C, transform: (Char) -> R): C { for (item in this) collection.add(transform(item)) return collection - } /** * Appends transformed elements of original collection using the given *transform* function * to the given *collection* */ -public inline fun > DoubleArray.mapTo(collection: C, transform : (Double) -> R) : C { +public inline fun > DoubleArray.mapTo(collection: C, transform: (Double) -> R): C { for (item in this) collection.add(transform(item)) return collection - } /** * Appends transformed elements of original collection using the given *transform* function * to the given *collection* */ -public inline fun > FloatArray.mapTo(collection: C, transform : (Float) -> R) : C { +public inline fun > FloatArray.mapTo(collection: C, transform: (Float) -> R): C { for (item in this) collection.add(transform(item)) return collection - } /** * Appends transformed elements of original collection using the given *transform* function * to the given *collection* */ -public inline fun > IntArray.mapTo(collection: C, transform : (Int) -> R) : C { +public inline fun > IntArray.mapTo(collection: C, transform: (Int) -> R): C { for (item in this) collection.add(transform(item)) return collection - } /** * Appends transformed elements of original collection using the given *transform* function * to the given *collection* */ -public inline fun > LongArray.mapTo(collection: C, transform : (Long) -> R) : C { +public inline fun > LongArray.mapTo(collection: C, transform: (Long) -> R): C { for (item in this) collection.add(transform(item)) return collection - } /** * Appends transformed elements of original collection using the given *transform* function * to the given *collection* */ -public inline fun > ShortArray.mapTo(collection: C, transform : (Short) -> R) : C { +public inline fun > ShortArray.mapTo(collection: C, transform: (Short) -> R): C { for (item in this) collection.add(transform(item)) return collection - } /** * Appends transformed elements of original collection using the given *transform* function * to the given *collection* */ -public inline fun > Iterable.mapTo(collection: C, transform : (T) -> R) : C { +public inline fun > Iterable.mapTo(collection: C, transform: (T) -> R): C { for (item in this) collection.add(transform(item)) return collection - } /** * Appends transformed elements of original collection using the given *transform* function * to the given *collection* */ -public inline fun > Map.mapTo(collection: C, transform : (Map.Entry) -> R) : C { +public inline fun > Map.mapTo(collection: C, transform: (Map.Entry) -> R): C { for (item in this) collection.add(transform(item)) return collection - } /** * Appends transformed elements of original collection using the given *transform* function * to the given *collection* */ -public inline fun > Stream.mapTo(collection: C, transform : (T) -> R) : C { +public inline fun > Stream.mapTo(collection: C, transform: (T) -> R): C { for (item in this) collection.add(transform(item)) return collection - } /** * Appends transformed elements of original collection using the given *transform* function * to the given *collection* */ -public inline fun > String.mapTo(collection: C, transform : (Char) -> R) : C { +public inline fun > String.mapTo(collection: C, transform: (Char) -> R): C { for (item in this) collection.add(transform(item)) return collection - } /** * Returns a list containing pairs of each element of the original collection and their index */ -public fun Array.withIndices() : List> { +public fun Array.withIndices(): List> { var index = 0 return mapTo(ArrayList>(), { index++ to it }) - } /** * Returns a list containing pairs of each element of the original collection and their index */ -public fun BooleanArray.withIndices() : List> { +public fun BooleanArray.withIndices(): List> { var index = 0 return mapTo(ArrayList>(), { index++ to it }) - } /** * Returns a list containing pairs of each element of the original collection and their index */ -public fun ByteArray.withIndices() : List> { +public fun ByteArray.withIndices(): List> { var index = 0 return mapTo(ArrayList>(), { index++ to it }) - } /** * Returns a list containing pairs of each element of the original collection and their index */ -public fun CharArray.withIndices() : List> { +public fun CharArray.withIndices(): List> { var index = 0 return mapTo(ArrayList>(), { index++ to it }) - } /** * Returns a list containing pairs of each element of the original collection and their index */ -public fun DoubleArray.withIndices() : List> { +public fun DoubleArray.withIndices(): List> { var index = 0 return mapTo(ArrayList>(), { index++ to it }) - } /** * Returns a list containing pairs of each element of the original collection and their index */ -public fun FloatArray.withIndices() : List> { +public fun FloatArray.withIndices(): List> { var index = 0 return mapTo(ArrayList>(), { index++ to it }) - } /** * Returns a list containing pairs of each element of the original collection and their index */ -public fun IntArray.withIndices() : List> { +public fun IntArray.withIndices(): List> { var index = 0 return mapTo(ArrayList>(), { index++ to it }) - } /** * Returns a list containing pairs of each element of the original collection and their index */ -public fun LongArray.withIndices() : List> { +public fun LongArray.withIndices(): List> { var index = 0 return mapTo(ArrayList>(), { index++ to it }) - } /** * Returns a list containing pairs of each element of the original collection and their index */ -public fun ShortArray.withIndices() : List> { +public fun ShortArray.withIndices(): List> { var index = 0 return mapTo(ArrayList>(), { index++ to it }) - } /** * Returns a list containing pairs of each element of the original collection and their index */ -public fun Iterable.withIndices() : List> { +public fun Iterable.withIndices(): List> { var index = 0 return mapTo(ArrayList>(), { index++ to it }) - } /** * Returns a stream containing pairs of each element of the original collection and their index */ -public fun Stream.withIndices() : Stream> { +public fun Stream.withIndices(): Stream> { var index = 0 return TransformingStream(this, { index++ to it }) - } /** * Returns a list containing pairs of each element of the original collection and their index */ -public fun String.withIndices() : List> { +public fun String.withIndices(): List> { var index = 0 return mapTo(ArrayList>(), { index++ to it }) - } diff --git a/libraries/stdlib/src/generated/_Numeric.kt b/libraries/stdlib/src/generated/_Numeric.kt index c8d4ede75b0..ceaa2b4826a 100644 --- a/libraries/stdlib/src/generated/_Numeric.kt +++ b/libraries/stdlib/src/generated/_Numeric.kt @@ -10,208 +10,192 @@ import java.util.* /** * Returns the sum of all elements in the collection */ -public fun Iterable.sum() : Int { +public fun Iterable.sum(): Int { val iterator = iterator() - var sum : Int = 0 + var sum: Int = 0 while (iterator.hasNext()) { sum += iterator.next() } return sum - } /** * Returns the sum of all elements in the collection */ -public fun Iterable.sum() : Long { +public fun Iterable.sum(): Long { val iterator = iterator() - var sum : Long = 0 + var sum: Long = 0 while (iterator.hasNext()) { sum += iterator.next() } return sum - } /** * Returns the sum of all elements in the collection */ -public fun Iterable.sum() : Double { +public fun Iterable.sum(): Double { val iterator = iterator() - var sum : Double = 0.0 + var sum: Double = 0.0 while (iterator.hasNext()) { sum += iterator.next() } return sum - } /** * Returns the sum of all elements in the collection */ -public fun Iterable.sum() : Float { +public fun Iterable.sum(): Float { val iterator = iterator() - var sum : Float = 0.0f + var sum: Float = 0.0f while (iterator.hasNext()) { sum += iterator.next() } return sum - } /** * Returns the sum of all elements in the collection */ -public fun Array.sum() : Int { +public fun Array.sum(): Int { val iterator = iterator() - var sum : Int = 0 + var sum: Int = 0 while (iterator.hasNext()) { sum += iterator.next() } return sum - } /** * Returns the sum of all elements in the collection */ -public fun IntArray.sum() : Int { +public fun IntArray.sum(): Int { val iterator = iterator() - var sum : Int = 0 + var sum: Int = 0 while (iterator.hasNext()) { sum += iterator.next() } return sum - } /** * Returns the sum of all elements in the collection */ -public fun Array.sum() : Long { +public fun Array.sum(): Long { val iterator = iterator() - var sum : Long = 0 + var sum: Long = 0 while (iterator.hasNext()) { sum += iterator.next() } return sum - } /** * Returns the sum of all elements in the collection */ -public fun LongArray.sum() : Long { +public fun LongArray.sum(): Long { val iterator = iterator() - var sum : Long = 0 + var sum: Long = 0 while (iterator.hasNext()) { sum += iterator.next() } return sum - } /** * Returns the sum of all elements in the collection */ -public fun Array.sum() : Int { +public fun Array.sum(): Int { val iterator = iterator() - var sum : Int = 0 + var sum: Int = 0 while (iterator.hasNext()) { sum += iterator.next() } return sum - } /** * Returns the sum of all elements in the collection */ -public fun ByteArray.sum() : Int { +public fun ByteArray.sum(): Int { val iterator = iterator() - var sum : Int = 0 + var sum: Int = 0 while (iterator.hasNext()) { sum += iterator.next() } return sum - } /** * Returns the sum of all elements in the collection */ -public fun Array.sum() : Int { +public fun Array.sum(): Int { val iterator = iterator() - var sum : Int = 0 + var sum: Int = 0 while (iterator.hasNext()) { sum += iterator.next() } return sum - } /** * Returns the sum of all elements in the collection */ -public fun ShortArray.sum() : Int { +public fun ShortArray.sum(): Int { val iterator = iterator() - var sum : Int = 0 + var sum: Int = 0 while (iterator.hasNext()) { sum += iterator.next() } return sum - } /** * Returns the sum of all elements in the collection */ -public fun Array.sum() : Double { +public fun Array.sum(): Double { val iterator = iterator() - var sum : Double = 0.0 + var sum: Double = 0.0 while (iterator.hasNext()) { sum += iterator.next() } return sum - } /** * Returns the sum of all elements in the collection */ -public fun DoubleArray.sum() : Double { +public fun DoubleArray.sum(): Double { val iterator = iterator() - var sum : Double = 0.0 + var sum: Double = 0.0 while (iterator.hasNext()) { sum += iterator.next() } return sum - } /** * Returns the sum of all elements in the collection */ -public fun Array.sum() : Float { +public fun Array.sum(): Float { val iterator = iterator() - var sum : Float = 0.0f + var sum: Float = 0.0f while (iterator.hasNext()) { sum += iterator.next() } return sum - } /** * Returns the sum of all elements in the collection */ -public fun FloatArray.sum() : Float { +public fun FloatArray.sum(): Float { val iterator = iterator() - var sum : Float = 0.0f + var sum: Float = 0.0f while (iterator.hasNext()) { sum += iterator.next() } return sum - } diff --git a/libraries/stdlib/src/generated/_Ordering.kt b/libraries/stdlib/src/generated/_Ordering.kt index c6a9d7e3aac..78e1d52c570 100644 --- a/libraries/stdlib/src/generated/_Ordering.kt +++ b/libraries/stdlib/src/generated/_Ordering.kt @@ -10,193 +10,174 @@ import java.util.* /** * Returns a list with elements in reversed order */ -public fun Array.reverse() : List { +public fun Array.reverse(): List { val list = toArrayList() Collections.reverse(list) return list - } /** * Returns a list with elements in reversed order */ -public fun BooleanArray.reverse() : List { +public fun BooleanArray.reverse(): List { val list = toArrayList() Collections.reverse(list) return list - } /** * Returns a list with elements in reversed order */ -public fun ByteArray.reverse() : List { +public fun ByteArray.reverse(): List { val list = toArrayList() Collections.reverse(list) return list - } /** * Returns a list with elements in reversed order */ -public fun CharArray.reverse() : List { +public fun CharArray.reverse(): List { val list = toArrayList() Collections.reverse(list) return list - } /** * Returns a list with elements in reversed order */ -public fun DoubleArray.reverse() : List { +public fun DoubleArray.reverse(): List { val list = toArrayList() Collections.reverse(list) return list - } /** * Returns a list with elements in reversed order */ -public fun FloatArray.reverse() : List { +public fun FloatArray.reverse(): List { val list = toArrayList() Collections.reverse(list) return list - } /** * Returns a list with elements in reversed order */ -public fun IntArray.reverse() : List { +public fun IntArray.reverse(): List { val list = toArrayList() Collections.reverse(list) return list - } /** * Returns a list with elements in reversed order */ -public fun LongArray.reverse() : List { +public fun LongArray.reverse(): List { val list = toArrayList() Collections.reverse(list) return list - } /** * Returns a list with elements in reversed order */ -public fun ShortArray.reverse() : List { +public fun ShortArray.reverse(): List { val list = toArrayList() Collections.reverse(list) return list - } /** * Returns a list with elements in reversed order */ -public fun Iterable.reverse() : List { +public fun Iterable.reverse(): List { val list = toArrayList() Collections.reverse(list) return list - } /** * Returns a string with characters in reversed order */ -public fun String.reverse() : String { +public fun String.reverse(): String { return StringBuilder().append(this).reverse().toString() - } /** * Returns a sorted list of all elements */ -public fun > Iterable.sort() : List { +public fun > Iterable.sort(): List { val sortedList = toArrayList() java.util.Collections.sort(sortedList) return sortedList - } /** * Returns a list of all elements, sorted by the specified *comparator* */ -public fun Array.sortBy(comparator : Comparator) : List { +public fun Array.sortBy(comparator: Comparator): List { val sortedList = toArrayList() java.util.Collections.sort(sortedList, comparator) return sortedList - } /** * Returns a list of all elements, sorted by the specified *comparator* */ -public fun Iterable.sortBy(comparator : Comparator) : List { +public fun Iterable.sortBy(comparator: Comparator): List { val sortedList = toArrayList() java.util.Collections.sort(sortedList, comparator) return sortedList - } /** * Returns a list of all elements, sorted by results of specified *order* function. */ -public inline fun > Array.sortBy(order: (T) -> R) : List { +public inline fun > Array.sortBy(order: (T) -> R): List { val sortedList = toArrayList() - val sortBy: Comparator = comparator {(x: T, y: T) -> order(x).compareTo(order(y))} + val sortBy: Comparator = comparator {(x: T, y: T) -> order(x).compareTo(order(y)) } java.util.Collections.sort(sortedList, sortBy) return sortedList - } /** * Returns a list of all elements, sorted by results of specified *order* function. */ -public inline fun > Iterable.sortBy(order: (T) -> R) : List { +public inline fun > Iterable.sortBy(order: (T) -> R): List { val sortedList = toArrayList() - val sortBy: Comparator = comparator {(x: T, y: T) -> order(x).compareTo(order(y))} + val sortBy: Comparator = comparator {(x: T, y: T) -> order(x).compareTo(order(y)) } java.util.Collections.sort(sortedList, sortBy) return sortedList - } /** * Returns a sorted list of all elements */ -public fun > Iterable.sortDescending() : List { +public fun > Iterable.sortDescending(): List { val sortedList = toArrayList() - val sortBy: Comparator = comparator {(x: T, y: T) -> -x.compareTo(y)} + val sortBy: Comparator = comparator {(x: T, y: T) -> -x.compareTo(y) } java.util.Collections.sort(sortedList, sortBy) return sortedList - } /** * Returns a list of all elements, sorted by results of specified *order* function. */ -public inline fun > Array.sortDescendingBy(order: (T) -> R) : List { +public inline fun > Array.sortDescendingBy(order: (T) -> R): List { val sortedList = toArrayList() - val sortBy: Comparator = comparator {(x: T, y: T) -> -order(x).compareTo(order(y))} + val sortBy: Comparator = comparator {(x: T, y: T) -> -order(x).compareTo(order(y)) } java.util.Collections.sort(sortedList, sortBy) return sortedList - } /** * Returns a list of all elements, sorted by results of specified *order* function. */ -public inline fun > Iterable.sortDescendingBy(order: (T) -> R) : List { +public inline fun > Iterable.sortDescendingBy(order: (T) -> R): List { val sortedList = toArrayList() - val sortBy: Comparator = comparator {(x: T, y: T) -> -order(x).compareTo(order(y))} + val sortBy: Comparator = comparator {(x: T, y: T) -> -order(x).compareTo(order(y)) } java.util.Collections.sort(sortedList, sortBy) return sortedList - } diff --git a/libraries/stdlib/src/generated/_Snapshots.kt b/libraries/stdlib/src/generated/_Snapshots.kt index c384f451e82..e063bd3aa2d 100644 --- a/libraries/stdlib/src/generated/_Snapshots.kt +++ b/libraries/stdlib/src/generated/_Snapshots.kt @@ -10,771 +10,742 @@ import java.util.* /** * Returns an ArrayList of all elements */ -public fun Array.toArrayList() : ArrayList { +public fun Array.toArrayList(): ArrayList { val list = ArrayList(size) for (item in this) list.add(item) return list - } /** * Returns an ArrayList of all elements */ -public fun BooleanArray.toArrayList() : ArrayList { +public fun BooleanArray.toArrayList(): ArrayList { val list = ArrayList(size) for (item in this) list.add(item) return list - } /** * Returns an ArrayList of all elements */ -public fun ByteArray.toArrayList() : ArrayList { +public fun ByteArray.toArrayList(): ArrayList { val list = ArrayList(size) for (item in this) list.add(item) return list - } /** * Returns an ArrayList of all elements */ -public fun CharArray.toArrayList() : ArrayList { +public fun CharArray.toArrayList(): ArrayList { val list = ArrayList(size) for (item in this) list.add(item) return list - } /** * Returns an ArrayList of all elements */ -public fun DoubleArray.toArrayList() : ArrayList { +public fun DoubleArray.toArrayList(): ArrayList { val list = ArrayList(size) for (item in this) list.add(item) return list - } /** * Returns an ArrayList of all elements */ -public fun FloatArray.toArrayList() : ArrayList { +public fun FloatArray.toArrayList(): ArrayList { val list = ArrayList(size) for (item in this) list.add(item) return list - } /** * Returns an ArrayList of all elements */ -public fun IntArray.toArrayList() : ArrayList { +public fun IntArray.toArrayList(): ArrayList { val list = ArrayList(size) for (item in this) list.add(item) return list - } /** * Returns an ArrayList of all elements */ -public fun LongArray.toArrayList() : ArrayList { +public fun LongArray.toArrayList(): ArrayList { val list = ArrayList(size) for (item in this) list.add(item) return list - } /** * Returns an ArrayList of all elements */ -public fun ShortArray.toArrayList() : ArrayList { +public fun ShortArray.toArrayList(): ArrayList { val list = ArrayList(size) for (item in this) list.add(item) return list - } /** * Returns an ArrayList of all elements */ -public fun Iterable.toArrayList() : ArrayList { +public fun Iterable.toArrayList(): ArrayList { return toCollection(ArrayList()) } /** * Returns an ArrayList of all elements */ -public fun Stream.toArrayList() : ArrayList { +public fun Stream.toArrayList(): ArrayList { return toCollection(ArrayList()) } /** * Returns an ArrayList of all elements */ -public fun String.toArrayList() : ArrayList { +public fun String.toArrayList(): ArrayList { return toCollection(ArrayList()) } /** * Appends all elements to the given *collection* */ -public fun > Array.toCollection(collection : C) : C { +public fun > Array.toCollection(collection: C): C { for (item in this) { collection.add(item) } return collection - } /** * Appends all elements to the given *collection* */ -public fun > BooleanArray.toCollection(collection : C) : C { +public fun > BooleanArray.toCollection(collection: C): C { for (item in this) { collection.add(item) } return collection - } /** * Appends all elements to the given *collection* */ -public fun > ByteArray.toCollection(collection : C) : C { +public fun > ByteArray.toCollection(collection: C): C { for (item in this) { collection.add(item) } return collection - } /** * Appends all elements to the given *collection* */ -public fun > CharArray.toCollection(collection : C) : C { +public fun > CharArray.toCollection(collection: C): C { for (item in this) { collection.add(item) } return collection - } /** * Appends all elements to the given *collection* */ -public fun > DoubleArray.toCollection(collection : C) : C { +public fun > DoubleArray.toCollection(collection: C): C { for (item in this) { collection.add(item) } return collection - } /** * Appends all elements to the given *collection* */ -public fun > FloatArray.toCollection(collection : C) : C { +public fun > FloatArray.toCollection(collection: C): C { for (item in this) { collection.add(item) } return collection - } /** * Appends all elements to the given *collection* */ -public fun > IntArray.toCollection(collection : C) : C { +public fun > IntArray.toCollection(collection: C): C { for (item in this) { collection.add(item) } return collection - } /** * Appends all elements to the given *collection* */ -public fun > LongArray.toCollection(collection : C) : C { +public fun > LongArray.toCollection(collection: C): C { for (item in this) { collection.add(item) } return collection - } /** * Appends all elements to the given *collection* */ -public fun > ShortArray.toCollection(collection : C) : C { +public fun > ShortArray.toCollection(collection: C): C { for (item in this) { collection.add(item) } return collection - } /** * Appends all elements to the given *collection* */ -public fun > Iterable.toCollection(collection : C) : C { +public fun > Iterable.toCollection(collection: C): C { for (item in this) { collection.add(item) } return collection - } /** * Appends all elements to the given *collection* */ -public fun > Stream.toCollection(collection : C) : C { +public fun > Stream.toCollection(collection: C): C { for (item in this) { collection.add(item) } return collection - } /** * Appends all elements to the given *collection* */ -public fun > String.toCollection(collection : C) : C { +public fun > String.toCollection(collection: C): C { for (item in this) { collection.add(item) } return collection - } /** * Returns a HashSet of all elements */ -public fun Array.toHashSet() : HashSet { +public fun Array.toHashSet(): HashSet { return toCollection(HashSet()) } /** * Returns a HashSet of all elements */ -public fun BooleanArray.toHashSet() : HashSet { +public fun BooleanArray.toHashSet(): HashSet { return toCollection(HashSet()) } /** * Returns a HashSet of all elements */ -public fun ByteArray.toHashSet() : HashSet { +public fun ByteArray.toHashSet(): HashSet { return toCollection(HashSet()) } /** * Returns a HashSet of all elements */ -public fun CharArray.toHashSet() : HashSet { +public fun CharArray.toHashSet(): HashSet { return toCollection(HashSet()) } /** * Returns a HashSet of all elements */ -public fun DoubleArray.toHashSet() : HashSet { +public fun DoubleArray.toHashSet(): HashSet { return toCollection(HashSet()) } /** * Returns a HashSet of all elements */ -public fun FloatArray.toHashSet() : HashSet { +public fun FloatArray.toHashSet(): HashSet { return toCollection(HashSet()) } /** * Returns a HashSet of all elements */ -public fun IntArray.toHashSet() : HashSet { +public fun IntArray.toHashSet(): HashSet { return toCollection(HashSet()) } /** * Returns a HashSet of all elements */ -public fun LongArray.toHashSet() : HashSet { +public fun LongArray.toHashSet(): HashSet { return toCollection(HashSet()) } /** * Returns a HashSet of all elements */ -public fun ShortArray.toHashSet() : HashSet { +public fun ShortArray.toHashSet(): HashSet { return toCollection(HashSet()) } /** * Returns a HashSet of all elements */ -public fun Iterable.toHashSet() : HashSet { +public fun Iterable.toHashSet(): HashSet { return toCollection(HashSet()) } /** * Returns a HashSet of all elements */ -public fun Stream.toHashSet() : HashSet { +public fun Stream.toHashSet(): HashSet { return toCollection(HashSet()) } /** * Returns a HashSet of all elements */ -public fun String.toHashSet() : HashSet { +public fun String.toHashSet(): HashSet { return toCollection(HashSet()) } /** * Returns a LinkedList containing all elements */ -public fun Array.toLinkedList() : LinkedList { +public fun Array.toLinkedList(): LinkedList { return toCollection(LinkedList()) } /** * Returns a LinkedList containing all elements */ -public fun BooleanArray.toLinkedList() : LinkedList { +public fun BooleanArray.toLinkedList(): LinkedList { return toCollection(LinkedList()) } /** * Returns a LinkedList containing all elements */ -public fun ByteArray.toLinkedList() : LinkedList { +public fun ByteArray.toLinkedList(): LinkedList { return toCollection(LinkedList()) } /** * Returns a LinkedList containing all elements */ -public fun CharArray.toLinkedList() : LinkedList { +public fun CharArray.toLinkedList(): LinkedList { return toCollection(LinkedList()) } /** * Returns a LinkedList containing all elements */ -public fun DoubleArray.toLinkedList() : LinkedList { +public fun DoubleArray.toLinkedList(): LinkedList { return toCollection(LinkedList()) } /** * Returns a LinkedList containing all elements */ -public fun FloatArray.toLinkedList() : LinkedList { +public fun FloatArray.toLinkedList(): LinkedList { return toCollection(LinkedList()) } /** * Returns a LinkedList containing all elements */ -public fun IntArray.toLinkedList() : LinkedList { +public fun IntArray.toLinkedList(): LinkedList { return toCollection(LinkedList()) } /** * Returns a LinkedList containing all elements */ -public fun LongArray.toLinkedList() : LinkedList { +public fun LongArray.toLinkedList(): LinkedList { return toCollection(LinkedList()) } /** * Returns a LinkedList containing all elements */ -public fun ShortArray.toLinkedList() : LinkedList { +public fun ShortArray.toLinkedList(): LinkedList { return toCollection(LinkedList()) } /** * Returns a LinkedList containing all elements */ -public fun Iterable.toLinkedList() : LinkedList { +public fun Iterable.toLinkedList(): LinkedList { return toCollection(LinkedList()) } /** * Returns a LinkedList containing all elements */ -public fun Stream.toLinkedList() : LinkedList { +public fun Stream.toLinkedList(): LinkedList { return toCollection(LinkedList()) } /** * Returns a LinkedList containing all elements */ -public fun String.toLinkedList() : LinkedList { +public fun String.toLinkedList(): LinkedList { return toCollection(LinkedList()) } /** * Returns a List containing all elements */ -public fun Array.toList() : List { +public fun Array.toList(): List { return toCollection(ArrayList()) } /** * Returns a List containing all elements */ -public fun BooleanArray.toList() : List { +public fun BooleanArray.toList(): List { val list = ArrayList(size) for (item in this) list.add(item) return list - } /** * Returns a List containing all elements */ -public fun ByteArray.toList() : List { +public fun ByteArray.toList(): List { val list = ArrayList(size) for (item in this) list.add(item) return list - } /** * Returns a List containing all elements */ -public fun CharArray.toList() : List { +public fun CharArray.toList(): List { val list = ArrayList(size) for (item in this) list.add(item) return list - } /** * Returns a List containing all elements */ -public fun DoubleArray.toList() : List { +public fun DoubleArray.toList(): List { val list = ArrayList(size) for (item in this) list.add(item) return list - } /** * Returns a List containing all elements */ -public fun FloatArray.toList() : List { +public fun FloatArray.toList(): List { val list = ArrayList(size) for (item in this) list.add(item) return list - } /** * Returns a List containing all elements */ -public fun IntArray.toList() : List { +public fun IntArray.toList(): List { val list = ArrayList(size) for (item in this) list.add(item) return list - } /** * Returns a List containing all elements */ -public fun LongArray.toList() : List { +public fun LongArray.toList(): List { val list = ArrayList(size) for (item in this) list.add(item) return list - } /** * Returns a List containing all elements */ -public fun ShortArray.toList() : List { +public fun ShortArray.toList(): List { val list = ArrayList(size) for (item in this) list.add(item) return list - } /** * Returns a List containing all elements */ -public fun Iterable.toList() : List { +public fun Iterable.toList(): List { return toCollection(ArrayList()) } /** * Returns a List containing all elements */ -public fun Stream.toList() : List { +public fun Stream.toList(): List { return toCollection(ArrayList()) } /** * Returns a List containing all elements */ -public fun String.toList() : List { +public fun String.toList(): List { return toCollection(ArrayList()) } /** * Returns a Set of all elements */ -public fun Array.toSet() : Set { +public fun Array.toSet(): Set { return toCollection(LinkedHashSet()) } /** * Returns a Set of all elements */ -public fun BooleanArray.toSet() : Set { +public fun BooleanArray.toSet(): Set { return toCollection(LinkedHashSet()) } /** * Returns a Set of all elements */ -public fun ByteArray.toSet() : Set { +public fun ByteArray.toSet(): Set { return toCollection(LinkedHashSet()) } /** * Returns a Set of all elements */ -public fun CharArray.toSet() : Set { +public fun CharArray.toSet(): Set { return toCollection(LinkedHashSet()) } /** * Returns a Set of all elements */ -public fun DoubleArray.toSet() : Set { +public fun DoubleArray.toSet(): Set { return toCollection(LinkedHashSet()) } /** * Returns a Set of all elements */ -public fun FloatArray.toSet() : Set { +public fun FloatArray.toSet(): Set { return toCollection(LinkedHashSet()) } /** * Returns a Set of all elements */ -public fun IntArray.toSet() : Set { +public fun IntArray.toSet(): Set { return toCollection(LinkedHashSet()) } /** * Returns a Set of all elements */ -public fun LongArray.toSet() : Set { +public fun LongArray.toSet(): Set { return toCollection(LinkedHashSet()) } /** * Returns a Set of all elements */ -public fun ShortArray.toSet() : Set { +public fun ShortArray.toSet(): Set { return toCollection(LinkedHashSet()) } /** * Returns a Set of all elements */ -public fun Iterable.toSet() : Set { +public fun Iterable.toSet(): Set { return toCollection(LinkedHashSet()) } /** * Returns a Set of all elements */ -public fun Stream.toSet() : Set { +public fun Stream.toSet(): Set { return toCollection(LinkedHashSet()) } /** * Returns a Set of all elements */ -public fun String.toSet() : Set { +public fun String.toSet(): Set { return toCollection(LinkedHashSet()) } /** * Returns a sorted list of all elements */ -public fun > Array.toSortedList() : List { +public fun > Array.toSortedList(): List { return toArrayList().sort() } /** * Returns a sorted list of all elements */ -public fun BooleanArray.toSortedList() : List { +public fun BooleanArray.toSortedList(): List { return toArrayList().sort() } /** * Returns a sorted list of all elements */ -public fun ByteArray.toSortedList() : List { +public fun ByteArray.toSortedList(): List { return toArrayList().sort() } /** * Returns a sorted list of all elements */ -public fun CharArray.toSortedList() : List { +public fun CharArray.toSortedList(): List { return toArrayList().sort() } /** * Returns a sorted list of all elements */ -public fun DoubleArray.toSortedList() : List { +public fun DoubleArray.toSortedList(): List { return toArrayList().sort() } /** * Returns a sorted list of all elements */ -public fun FloatArray.toSortedList() : List { +public fun FloatArray.toSortedList(): List { return toArrayList().sort() } /** * Returns a sorted list of all elements */ -public fun IntArray.toSortedList() : List { +public fun IntArray.toSortedList(): List { return toArrayList().sort() } /** * Returns a sorted list of all elements */ -public fun LongArray.toSortedList() : List { +public fun LongArray.toSortedList(): List { return toArrayList().sort() } /** * Returns a sorted list of all elements */ -public fun ShortArray.toSortedList() : List { +public fun ShortArray.toSortedList(): List { return toArrayList().sort() } /** * Returns a sorted list of all elements */ -public fun > Iterable.toSortedList() : List { +public fun > Iterable.toSortedList(): List { return sort() } /** * Returns a sorted list of all elements */ -public fun > Stream.toSortedList() : List { +public fun > Stream.toSortedList(): List { return toArrayList().sort() } /** * Returns a sorted list of all elements */ -public fun String.toSortedList() : List { +public fun String.toSortedList(): List { return toArrayList().sort() } /** * Returns a SortedSet of all elements */ -public fun Array.toSortedSet() : SortedSet { +public fun Array.toSortedSet(): SortedSet { return toCollection(TreeSet()) } /** * Returns a SortedSet of all elements */ -public fun BooleanArray.toSortedSet() : SortedSet { +public fun BooleanArray.toSortedSet(): SortedSet { return toCollection(TreeSet()) } /** * Returns a SortedSet of all elements */ -public fun ByteArray.toSortedSet() : SortedSet { +public fun ByteArray.toSortedSet(): SortedSet { return toCollection(TreeSet()) } /** * Returns a SortedSet of all elements */ -public fun CharArray.toSortedSet() : SortedSet { +public fun CharArray.toSortedSet(): SortedSet { return toCollection(TreeSet()) } /** * Returns a SortedSet of all elements */ -public fun DoubleArray.toSortedSet() : SortedSet { +public fun DoubleArray.toSortedSet(): SortedSet { return toCollection(TreeSet()) } /** * Returns a SortedSet of all elements */ -public fun FloatArray.toSortedSet() : SortedSet { +public fun FloatArray.toSortedSet(): SortedSet { return toCollection(TreeSet()) } /** * Returns a SortedSet of all elements */ -public fun IntArray.toSortedSet() : SortedSet { +public fun IntArray.toSortedSet(): SortedSet { return toCollection(TreeSet()) } /** * Returns a SortedSet of all elements */ -public fun LongArray.toSortedSet() : SortedSet { +public fun LongArray.toSortedSet(): SortedSet { return toCollection(TreeSet()) } /** * Returns a SortedSet of all elements */ -public fun ShortArray.toSortedSet() : SortedSet { +public fun ShortArray.toSortedSet(): SortedSet { return toCollection(TreeSet()) } /** * Returns a SortedSet of all elements */ -public fun Iterable.toSortedSet() : SortedSet { +public fun Iterable.toSortedSet(): SortedSet { return toCollection(TreeSet()) } /** * Returns a SortedSet of all elements */ -public fun Stream.toSortedSet() : SortedSet { +public fun Stream.toSortedSet(): SortedSet { return toCollection(TreeSet()) } /** * Returns a SortedSet of all elements */ -public fun String.toSortedSet() : SortedSet { +public fun String.toSortedSet(): SortedSet { return toCollection(TreeSet()) } diff --git a/libraries/stdlib/src/generated/_SpecialJVM.kt b/libraries/stdlib/src/generated/_SpecialJVM.kt index 2c2e7d5a02b..edefa308e9d 100644 --- a/libraries/stdlib/src/generated/_SpecialJVM.kt +++ b/libraries/stdlib/src/generated/_SpecialJVM.kt @@ -10,450 +10,433 @@ import java.util.* /** * Searches array or range of array for provided element index using binary search algorithm. Array is expected to be sorted. */ -public fun Array.binarySearch(element: T, fromIndex: Int = 0, toIndex: Int = size - 1) : Int { +public fun Array.binarySearch(element: T, fromIndex: Int = 0, toIndex: Int = size - 1): 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. */ -public fun ByteArray.binarySearch(element: Byte, fromIndex: Int = 0, toIndex: Int = size - 1) : Int { +public fun ByteArray.binarySearch(element: Byte, fromIndex: Int = 0, toIndex: Int = size - 1): 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. */ -public fun CharArray.binarySearch(element: Char, fromIndex: Int = 0, toIndex: Int = size - 1) : Int { +public fun CharArray.binarySearch(element: Char, fromIndex: Int = 0, toIndex: Int = size - 1): 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. */ -public fun DoubleArray.binarySearch(element: Double, fromIndex: Int = 0, toIndex: Int = size - 1) : Int { +public fun DoubleArray.binarySearch(element: Double, fromIndex: Int = 0, toIndex: Int = size - 1): 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. */ -public fun FloatArray.binarySearch(element: Float, fromIndex: Int = 0, toIndex: Int = size - 1) : Int { +public fun FloatArray.binarySearch(element: Float, fromIndex: Int = 0, toIndex: Int = size - 1): 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. */ -public fun IntArray.binarySearch(element: Int, fromIndex: Int = 0, toIndex: Int = size - 1) : Int { +public fun IntArray.binarySearch(element: Int, fromIndex: Int = 0, toIndex: Int = size - 1): 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. */ -public fun LongArray.binarySearch(element: Long, fromIndex: Int = 0, toIndex: Int = size - 1) : Int { +public fun LongArray.binarySearch(element: Long, fromIndex: Int = 0, toIndex: Int = size - 1): 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. */ -public fun ShortArray.binarySearch(element: Short, fromIndex: Int = 0, toIndex: Int = size - 1) : Int { +public fun ShortArray.binarySearch(element: Short, fromIndex: Int = 0, toIndex: Int = size - 1): Int { return Arrays.binarySearch(this, fromIndex, toIndex, element) } /** * Returns new array which is a copy of the original array */ -public fun Array.copyOf() : Array { +public fun Array.copyOf(): Array { return Arrays.copyOf(this, size) as Array } /** * Returns new array which is a copy of the original array */ -public fun BooleanArray.copyOf() : BooleanArray { +public fun BooleanArray.copyOf(): BooleanArray { return Arrays.copyOf(this, size) } /** * Returns new array which is a copy of the original array */ -public fun ByteArray.copyOf() : ByteArray { +public fun ByteArray.copyOf(): ByteArray { return Arrays.copyOf(this, size) } /** * Returns new array which is a copy of the original array */ -public fun CharArray.copyOf() : CharArray { +public fun CharArray.copyOf(): CharArray { return Arrays.copyOf(this, size) } /** * Returns new array which is a copy of the original array */ -public fun DoubleArray.copyOf() : DoubleArray { +public fun DoubleArray.copyOf(): DoubleArray { return Arrays.copyOf(this, size) } /** * Returns new array which is a copy of the original array */ -public fun FloatArray.copyOf() : FloatArray { +public fun FloatArray.copyOf(): FloatArray { return Arrays.copyOf(this, size) } /** * Returns new array which is a copy of the original array */ -public fun IntArray.copyOf() : IntArray { +public fun IntArray.copyOf(): IntArray { return Arrays.copyOf(this, size) } /** * Returns new array which is a copy of the original array */ -public fun LongArray.copyOf() : LongArray { +public fun LongArray.copyOf(): LongArray { return Arrays.copyOf(this, size) } /** * Returns new array which is a copy of the original array */ -public fun ShortArray.copyOf() : ShortArray { +public fun ShortArray.copyOf(): ShortArray { return Arrays.copyOf(this, size) } /** * Returns new array which is a copy of the original array */ -public fun Array.copyOf(newSize: Int) : Array { +public fun Array.copyOf(newSize: Int): Array { return Arrays.copyOf(this, newSize) as Array } /** * Returns new array which is a copy of the original array */ -public fun BooleanArray.copyOf(newSize: Int) : BooleanArray { +public fun BooleanArray.copyOf(newSize: Int): BooleanArray { return Arrays.copyOf(this, newSize) } /** * Returns new array which is a copy of the original array */ -public fun ByteArray.copyOf(newSize: Int) : ByteArray { +public fun ByteArray.copyOf(newSize: Int): ByteArray { return Arrays.copyOf(this, newSize) } /** * Returns new array which is a copy of the original array */ -public fun CharArray.copyOf(newSize: Int) : CharArray { +public fun CharArray.copyOf(newSize: Int): CharArray { return Arrays.copyOf(this, newSize) } /** * Returns new array which is a copy of the original array */ -public fun DoubleArray.copyOf(newSize: Int) : DoubleArray { +public fun DoubleArray.copyOf(newSize: Int): DoubleArray { return Arrays.copyOf(this, newSize) } /** * Returns new array which is a copy of the original array */ -public fun FloatArray.copyOf(newSize: Int) : FloatArray { +public fun FloatArray.copyOf(newSize: Int): FloatArray { return Arrays.copyOf(this, newSize) } /** * Returns new array which is a copy of the original array */ -public fun IntArray.copyOf(newSize: Int) : IntArray { +public fun IntArray.copyOf(newSize: Int): IntArray { return Arrays.copyOf(this, newSize) } /** * Returns new array which is a copy of the original array */ -public fun LongArray.copyOf(newSize: Int) : LongArray { +public fun LongArray.copyOf(newSize: Int): LongArray { return Arrays.copyOf(this, newSize) } /** * Returns new array which is a copy of the original array */ -public fun ShortArray.copyOf(newSize: Int) : ShortArray { +public fun ShortArray.copyOf(newSize: Int): ShortArray { return Arrays.copyOf(this, newSize) } /** * Returns new array which is a copy of range of original array */ -public fun Array.copyOfRange(from: Int, to: Int) : Array { +public fun Array.copyOfRange(from: Int, to: Int): Array { return Arrays.copyOfRange(this, from, to) } /** * Returns new array which is a copy of range of original array */ -public fun BooleanArray.copyOfRange(from: Int, to: Int) : BooleanArray { +public fun BooleanArray.copyOfRange(from: Int, to: Int): BooleanArray { return Arrays.copyOfRange(this, from, to) } /** * Returns new array which is a copy of range of original array */ -public fun ByteArray.copyOfRange(from: Int, to: Int) : ByteArray { +public fun ByteArray.copyOfRange(from: Int, to: Int): ByteArray { return Arrays.copyOfRange(this, from, to) } /** * Returns new array which is a copy of range of original array */ -public fun CharArray.copyOfRange(from: Int, to: Int) : CharArray { +public fun CharArray.copyOfRange(from: Int, to: Int): CharArray { return Arrays.copyOfRange(this, from, to) } /** * Returns new array which is a copy of range of original array */ -public fun DoubleArray.copyOfRange(from: Int, to: Int) : DoubleArray { +public fun DoubleArray.copyOfRange(from: Int, to: Int): DoubleArray { return Arrays.copyOfRange(this, from, to) } /** * Returns new array which is a copy of range of original array */ -public fun FloatArray.copyOfRange(from: Int, to: Int) : FloatArray { +public fun FloatArray.copyOfRange(from: Int, to: Int): FloatArray { return Arrays.copyOfRange(this, from, to) } /** * Returns new array which is a copy of range of original array */ -public fun IntArray.copyOfRange(from: Int, to: Int) : IntArray { +public fun IntArray.copyOfRange(from: Int, to: Int): IntArray { return Arrays.copyOfRange(this, from, to) } /** * Returns new array which is a copy of range of original array */ -public fun LongArray.copyOfRange(from: Int, to: Int) : LongArray { +public fun LongArray.copyOfRange(from: Int, to: Int): LongArray { return Arrays.copyOfRange(this, from, to) } /** * Returns new array which is a copy of range of original array */ -public fun ShortArray.copyOfRange(from: Int, to: Int) : ShortArray { +public fun ShortArray.copyOfRange(from: Int, to: Int): ShortArray { return Arrays.copyOfRange(this, from, to) } /** * Fills original array with the provided value */ -public fun Array.fill(element: T) : Array { +public fun Array.fill(element: T): Array { Arrays.fill(this, element) return this - } /** * Fills original array with the provided value */ -public fun BooleanArray.fill(element: Boolean) : BooleanArray { +public fun BooleanArray.fill(element: Boolean): BooleanArray { Arrays.fill(this, element) return this - } /** * Fills original array with the provided value */ -public fun ByteArray.fill(element: Byte) : ByteArray { +public fun ByteArray.fill(element: Byte): ByteArray { Arrays.fill(this, element) return this - } /** * Fills original array with the provided value */ -public fun CharArray.fill(element: Char) : CharArray { +public fun CharArray.fill(element: Char): CharArray { Arrays.fill(this, element) return this - } /** * Fills original array with the provided value */ -public fun DoubleArray.fill(element: Double) : DoubleArray { +public fun DoubleArray.fill(element: Double): DoubleArray { Arrays.fill(this, element) return this - } /** * Fills original array with the provided value */ -public fun FloatArray.fill(element: Float) : FloatArray { +public fun FloatArray.fill(element: Float): FloatArray { Arrays.fill(this, element) return this - } /** * Fills original array with the provided value */ -public fun IntArray.fill(element: Int) : IntArray { +public fun IntArray.fill(element: Int): IntArray { Arrays.fill(this, element) return this - } /** * Fills original array with the provided value */ -public fun LongArray.fill(element: Long) : LongArray { +public fun LongArray.fill(element: Long): LongArray { Arrays.fill(this, element) return this - } /** * Fills original array with the provided value */ -public fun ShortArray.fill(element: Short) : ShortArray { +public fun ShortArray.fill(element: Short): ShortArray { Arrays.fill(this, element) return this - } /** * Returns a list containing all elements that are instances of specified class */ -public fun Array.filterIsInstance(klass: Class) : List { +public fun Array.filterIsInstance(klass: Class): List { return filterIsInstanceTo(ArrayList(), klass) - } /** * Returns a list containing all elements that are instances of specified class */ -public fun Iterable.filterIsInstance(klass: Class) : List { +public fun Iterable.filterIsInstance(klass: Class): List { return filterIsInstanceTo(ArrayList(), klass) - } /** * Returns a stream containing all elements that are instances of specified class */ -public fun Stream.filterIsInstance(klass: Class) : Stream { +public fun Stream.filterIsInstance(klass: Class): Stream { return FilteringStream(this, true, { klass.isInstance(it) }) - } /** * Returns a list containing all elements that are instances of specified class */ -public fun String.filterIsInstance(klass: Class) : List { +public fun String.filterIsInstance(klass: Class): List { return filterIsInstanceTo(ArrayList(), klass) - } /** * Appends all elements that are instances of specified class into the given *collection* */ -public fun , R: T> Array.filterIsInstanceTo(collection: C, klass: Class) : C { +public fun , R : T> Array.filterIsInstanceTo(collection: C, klass: Class): C { for (element in this) if (klass.isInstance(element)) collection.add(element as R) return collection - } /** * Appends all elements that are instances of specified class into the given *collection* */ -public fun , R: T> Iterable.filterIsInstanceTo(collection: C, klass: Class) : C { +public fun , R : T> Iterable.filterIsInstanceTo(collection: C, klass: Class): C { for (element in this) if (klass.isInstance(element)) collection.add(element as R) return collection - } /** * Appends all elements that are instances of specified class into the given *collection* */ -public fun , R: T> Stream.filterIsInstanceTo(collection: C, klass: Class) : C { +public fun , R : T> Stream.filterIsInstanceTo(collection: C, klass: Class): C { for (element in this) if (klass.isInstance(element)) collection.add(element as R) return collection - } /** * Appends all elements that are instances of specified class into the given *collection* */ -public fun , R: Char> String.filterIsInstanceTo(collection: C, klass: Class) : C { +public fun , R : Char> String.filterIsInstanceTo(collection: C, klass: Class): C { for (element in this) if (klass.isInstance(element)) collection.add(element as R) return collection - } /** * Sorts array or range in array inplace */ -public fun Array.sort(fromIndex : Int = 0, toIndex : Int = size - 1) : Unit { +public fun Array.sort(fromIndex: Int = 0, toIndex: Int = size - 1): Unit { Arrays.sort(this, fromIndex, toIndex) } /** * Sorts array or range in array inplace */ -public fun ByteArray.sort(fromIndex : Int = 0, toIndex : Int = size - 1) : Unit { +public fun ByteArray.sort(fromIndex: Int = 0, toIndex: Int = size - 1): Unit { Arrays.sort(this, fromIndex, toIndex) } /** * Sorts array or range in array inplace */ -public fun CharArray.sort(fromIndex : Int = 0, toIndex : Int = size - 1) : Unit { +public fun CharArray.sort(fromIndex: Int = 0, toIndex: Int = size - 1): Unit { Arrays.sort(this, fromIndex, toIndex) } /** * Sorts array or range in array inplace */ -public fun DoubleArray.sort(fromIndex : Int = 0, toIndex : Int = size - 1) : Unit { +public fun DoubleArray.sort(fromIndex: Int = 0, toIndex: Int = size - 1): Unit { Arrays.sort(this, fromIndex, toIndex) } /** * Sorts array or range in array inplace */ -public fun FloatArray.sort(fromIndex : Int = 0, toIndex : Int = size - 1) : Unit { +public fun FloatArray.sort(fromIndex: Int = 0, toIndex: Int = size - 1): Unit { Arrays.sort(this, fromIndex, toIndex) } /** * Sorts array or range in array inplace */ -public fun IntArray.sort(fromIndex : Int = 0, toIndex : Int = size - 1) : Unit { +public fun IntArray.sort(fromIndex: Int = 0, toIndex: Int = size - 1): Unit { Arrays.sort(this, fromIndex, toIndex) } /** * Sorts array or range in array inplace */ -public fun LongArray.sort(fromIndex : Int = 0, toIndex : Int = size - 1) : Unit { +public fun LongArray.sort(fromIndex: Int = 0, toIndex: Int = size - 1): Unit { Arrays.sort(this, fromIndex, toIndex) } /** * Sorts array or range in array inplace */ -public fun ShortArray.sort(fromIndex : Int = 0, toIndex : Int = size - 1) : Unit { +public fun ShortArray.sort(fromIndex: Int = 0, toIndex: Int = size - 1): Unit { Arrays.sort(this, fromIndex, toIndex) } diff --git a/libraries/stdlib/src/generated/_Streams.kt b/libraries/stdlib/src/generated/_Streams.kt index 28b4e1b0866..a34d1126e67 100644 --- a/libraries/stdlib/src/generated/_Streams.kt +++ b/libraries/stdlib/src/generated/_Streams.kt @@ -10,96 +10,128 @@ import java.util.* /** * Returns a stream from the given collection */ -public fun Array.stream() : Stream { - return object : Stream { override fun iterator() : Iterator { return this@stream.iterator() } } - +public fun Array.stream(): Stream { + return object : Stream { + override fun iterator(): Iterator { + return this@stream.iterator() + } + } } /** * Returns a stream from the given collection */ -public fun BooleanArray.stream() : Stream { - return object : Stream { override fun iterator() : Iterator { return this@stream.iterator() } } - +public fun BooleanArray.stream(): Stream { + return object : Stream { + override fun iterator(): Iterator { + return this@stream.iterator() + } + } } /** * Returns a stream from the given collection */ -public fun ByteArray.stream() : Stream { - return object : Stream { override fun iterator() : Iterator { return this@stream.iterator() } } - +public fun ByteArray.stream(): Stream { + return object : Stream { + override fun iterator(): Iterator { + return this@stream.iterator() + } + } } /** * Returns a stream from the given collection */ -public fun CharArray.stream() : Stream { - return object : Stream { override fun iterator() : Iterator { return this@stream.iterator() } } - +public fun CharArray.stream(): Stream { + return object : Stream { + override fun iterator(): Iterator { + return this@stream.iterator() + } + } } /** * Returns a stream from the given collection */ -public fun DoubleArray.stream() : Stream { - return object : Stream { override fun iterator() : Iterator { return this@stream.iterator() } } - +public fun DoubleArray.stream(): Stream { + return object : Stream { + override fun iterator(): Iterator { + return this@stream.iterator() + } + } } /** * Returns a stream from the given collection */ -public fun FloatArray.stream() : Stream { - return object : Stream { override fun iterator() : Iterator { return this@stream.iterator() } } - +public fun FloatArray.stream(): Stream { + return object : Stream { + override fun iterator(): Iterator { + return this@stream.iterator() + } + } } /** * Returns a stream from the given collection */ -public fun IntArray.stream() : Stream { - return object : Stream { override fun iterator() : Iterator { return this@stream.iterator() } } - +public fun IntArray.stream(): Stream { + return object : Stream { + override fun iterator(): Iterator { + return this@stream.iterator() + } + } } /** * Returns a stream from the given collection */ -public fun LongArray.stream() : Stream { - return object : Stream { override fun iterator() : Iterator { return this@stream.iterator() } } - +public fun LongArray.stream(): Stream { + return object : Stream { + override fun iterator(): Iterator { + return this@stream.iterator() + } + } } /** * Returns a stream from the given collection */ -public fun ShortArray.stream() : Stream { - return object : Stream { override fun iterator() : Iterator { return this@stream.iterator() } } - +public fun ShortArray.stream(): Stream { + return object : Stream { + override fun iterator(): Iterator { + return this@stream.iterator() + } + } } /** * Returns a stream from the given collection */ -public fun Iterable.stream() : Stream { - return object : Stream { override fun iterator() : Iterator { return this@stream.iterator() } } - +public fun Iterable.stream(): Stream { + return object : Stream { + override fun iterator(): Iterator { + return this@stream.iterator() + } + } } /** * Returns a stream from the given collection */ -public fun Stream.stream() : Stream { +public fun Stream.stream(): Stream { return this - } /** * Returns a stream from the given collection */ -public fun String.stream() : Stream { - return object : Stream { override fun iterator() : Iterator { return this@stream.iterator() } } - +public fun String.stream(): Stream { + return object : Stream { + override fun iterator(): Iterator { + return this@stream.iterator() + } + } } diff --git a/libraries/stdlib/src/generated/_Strings.kt b/libraries/stdlib/src/generated/_Strings.kt index 8e45c36f041..fdec0449afb 100644 --- a/libraries/stdlib/src/generated/_Strings.kt +++ b/libraries/stdlib/src/generated/_Strings.kt @@ -12,7 +12,7 @@ import java.util.* * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun Array.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit { +public fun Array.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { buffer.append(prefix) var count = 0 for (element in this) { @@ -24,7 +24,6 @@ public fun Array.appendString(buffer: Appendable, separator: String = } if (limit >= 0 && count > limit) buffer.append(truncated) buffer.append(postfix) - } /** @@ -32,7 +31,7 @@ public fun Array.appendString(buffer: Appendable, separator: String = * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun BooleanArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit { +public fun BooleanArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { buffer.append(prefix) var count = 0 for (element in this) { @@ -44,7 +43,6 @@ public fun BooleanArray.appendString(buffer: Appendable, separator: String = ", } if (limit >= 0 && count > limit) buffer.append(truncated) buffer.append(postfix) - } /** @@ -52,7 +50,7 @@ public fun BooleanArray.appendString(buffer: Appendable, separator: String = ", * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun ByteArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit { +public fun ByteArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { buffer.append(prefix) var count = 0 for (element in this) { @@ -64,7 +62,6 @@ public fun ByteArray.appendString(buffer: Appendable, separator: String = ", ", } if (limit >= 0 && count > limit) buffer.append(truncated) buffer.append(postfix) - } /** @@ -72,7 +69,7 @@ public fun ByteArray.appendString(buffer: Appendable, separator: String = ", ", * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun CharArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit { +public fun CharArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { buffer.append(prefix) var count = 0 for (element in this) { @@ -84,7 +81,6 @@ public fun CharArray.appendString(buffer: Appendable, separator: String = ", ", } if (limit >= 0 && count > limit) buffer.append(truncated) buffer.append(postfix) - } /** @@ -92,7 +88,7 @@ public fun CharArray.appendString(buffer: Appendable, separator: String = ", ", * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun DoubleArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit { +public fun DoubleArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { buffer.append(prefix) var count = 0 for (element in this) { @@ -104,7 +100,6 @@ public fun DoubleArray.appendString(buffer: Appendable, separator: String = ", " } if (limit >= 0 && count > limit) buffer.append(truncated) buffer.append(postfix) - } /** @@ -112,7 +107,7 @@ public fun DoubleArray.appendString(buffer: Appendable, separator: String = ", " * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun FloatArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit { +public fun FloatArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { buffer.append(prefix) var count = 0 for (element in this) { @@ -124,7 +119,6 @@ public fun FloatArray.appendString(buffer: Appendable, separator: String = ", ", } if (limit >= 0 && count > limit) buffer.append(truncated) buffer.append(postfix) - } /** @@ -132,7 +126,7 @@ public fun FloatArray.appendString(buffer: Appendable, separator: String = ", ", * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun IntArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit { +public fun IntArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { buffer.append(prefix) var count = 0 for (element in this) { @@ -144,7 +138,6 @@ public fun IntArray.appendString(buffer: Appendable, separator: String = ", ", p } if (limit >= 0 && count > limit) buffer.append(truncated) buffer.append(postfix) - } /** @@ -152,7 +145,7 @@ public fun IntArray.appendString(buffer: Appendable, separator: String = ", ", p * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun LongArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit { +public fun LongArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { buffer.append(prefix) var count = 0 for (element in this) { @@ -164,7 +157,6 @@ public fun LongArray.appendString(buffer: Appendable, separator: String = ", ", } if (limit >= 0 && count > limit) buffer.append(truncated) buffer.append(postfix) - } /** @@ -172,7 +164,7 @@ public fun LongArray.appendString(buffer: Appendable, separator: String = ", ", * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun ShortArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit { +public fun ShortArray.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { buffer.append(prefix) var count = 0 for (element in this) { @@ -184,7 +176,6 @@ public fun ShortArray.appendString(buffer: Appendable, separator: String = ", ", } if (limit >= 0 && count > limit) buffer.append(truncated) buffer.append(postfix) - } /** @@ -192,7 +183,7 @@ public fun ShortArray.appendString(buffer: Appendable, separator: String = ", ", * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun Iterable.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit { +public fun Iterable.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { buffer.append(prefix) var count = 0 for (element in this) { @@ -204,7 +195,6 @@ public fun Iterable.appendString(buffer: Appendable, separator: String = } if (limit >= 0 && count > limit) buffer.append(truncated) buffer.append(postfix) - } /** @@ -212,7 +202,7 @@ public fun Iterable.appendString(buffer: Appendable, separator: String = * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun Stream.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit { +public fun Stream.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { buffer.append(prefix) var count = 0 for (element in this) { @@ -224,7 +214,6 @@ public fun Stream.appendString(buffer: Appendable, separator: String = ", } if (limit >= 0 && count > limit) buffer.append(truncated) buffer.append(postfix) - } /** @@ -232,7 +221,7 @@ public fun Stream.appendString(buffer: Appendable, separator: String = ", * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun String.appendString(buffer: Appendable, separator: String = ", ", prefix: String ="", postfix: String = "", limit: Int = -1, truncated: String = "...") : Unit { +public fun String.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { buffer.append(prefix) var count = 0 for (element in this) { @@ -244,7 +233,6 @@ public fun String.appendString(buffer: Appendable, separator: String = ", ", pre } if (limit >= 0 && count > limit) buffer.append(truncated) buffer.append(postfix) - } /** @@ -252,11 +240,10 @@ public fun String.appendString(buffer: Appendable, separator: String = ", ", pre * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun Array.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String { +public fun Array.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() appendString(buffer, separator, prefix, postfix, limit, truncated) return buffer.toString() - } /** @@ -264,11 +251,10 @@ public fun Array.makeString(separator: String = ", ", prefix: String * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun BooleanArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String { +public fun BooleanArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() appendString(buffer, separator, prefix, postfix, limit, truncated) return buffer.toString() - } /** @@ -276,11 +262,10 @@ public fun BooleanArray.makeString(separator: String = ", ", prefix: String = "" * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun ByteArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String { +public fun ByteArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() appendString(buffer, separator, prefix, postfix, limit, truncated) return buffer.toString() - } /** @@ -288,11 +273,10 @@ public fun ByteArray.makeString(separator: String = ", ", prefix: String = "", p * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun CharArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String { +public fun CharArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() appendString(buffer, separator, prefix, postfix, limit, truncated) return buffer.toString() - } /** @@ -300,11 +284,10 @@ public fun CharArray.makeString(separator: String = ", ", prefix: String = "", p * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun DoubleArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String { +public fun DoubleArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() appendString(buffer, separator, prefix, postfix, limit, truncated) return buffer.toString() - } /** @@ -312,11 +295,10 @@ public fun DoubleArray.makeString(separator: String = ", ", prefix: String = "", * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun FloatArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String { +public fun FloatArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() appendString(buffer, separator, prefix, postfix, limit, truncated) return buffer.toString() - } /** @@ -324,11 +306,10 @@ public fun FloatArray.makeString(separator: String = ", ", prefix: String = "", * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun IntArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String { +public fun IntArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() appendString(buffer, separator, prefix, postfix, limit, truncated) return buffer.toString() - } /** @@ -336,11 +317,10 @@ public fun IntArray.makeString(separator: String = ", ", prefix: String = "", po * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun LongArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String { +public fun LongArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() appendString(buffer, separator, prefix, postfix, limit, truncated) return buffer.toString() - } /** @@ -348,11 +328,10 @@ public fun LongArray.makeString(separator: String = ", ", prefix: String = "", p * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun ShortArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String { +public fun ShortArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() appendString(buffer, separator, prefix, postfix, limit, truncated) return buffer.toString() - } /** @@ -360,11 +339,10 @@ public fun ShortArray.makeString(separator: String = ", ", prefix: String = "", * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun Iterable.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String { +public fun Iterable.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() appendString(buffer, separator, prefix, postfix, limit, truncated) return buffer.toString() - } /** @@ -372,11 +350,10 @@ public fun Iterable.makeString(separator: String = ", ", prefix: String = * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun Stream.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String { +public fun Stream.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() appendString(buffer, separator, prefix, postfix, limit, truncated) return buffer.toString() - } /** @@ -384,10 +361,9 @@ public fun Stream.makeString(separator: String = ", ", prefix: String = " * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will * a special *truncated* separator (which defaults to "..." */ -public fun String.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...") : String { +public fun String.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() appendString(buffer, separator, prefix, postfix, limit, truncated) return buffer.toString() - } diff --git a/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateCollections.kt b/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateCollections.kt index c76b1cbb71a..2e43193bbd4 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateCollections.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateCollections.kt @@ -5,12 +5,12 @@ import templates.Family.* import templates.* import templates.PrimitiveType.* -fun generateCollectionsAPI(outDir : File) { +fun generateCollectionsAPI(outDir: File) { elements().writeTo(File(outDir, "_Elements.kt")) { build() } filtering().writeTo(File(outDir, "_Filtering.kt")) { build() } ordering().writeTo(File(outDir, "_Ordering.kt")) { build() } arrays().writeTo(File(outDir, "_Arrays.kt")) { build() } - snapshots().writeTo(File(outDir, "_Snapshots.kt")) { build() } + snapshots().writeTo(File(outDir, "_Snapshots.kt")) { build() } mapping().writeTo(File(outDir, "_Mapping.kt")) { build() } aggregates().writeTo(File(outDir, "_Aggregates.kt")) { build() } guards().writeTo(File(outDir, "_Guards.kt")) { build() } @@ -22,11 +22,11 @@ fun generateCollectionsAPI(outDir : File) { numeric().writeTo(File(outDir, "_Numeric.kt")) { val builder = StringBuilder() // TODO: decide if sum for byte and short is needed and how to make it work - for(numeric in listOf(Int, Long, /*Byte, Short, */ Double, Float)) { + for (numeric in listOf(Int, Long, /*Byte, Short, */ Double, Float)) { build(builder, Iterables, numeric) } - for(numeric in listOf(Int, Long, Byte, Short, Double, Float)) { + for (numeric in listOf(Int, Long, Byte, Short, Double, Float)) { build(builder, ArraysOfObjects, numeric) build(builder, ArraysOfPrimitives, numeric) } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt index a9df46dace4..208cde44757 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt @@ -104,7 +104,7 @@ fun aggregates(): List { doc { "Returns the smallest element or null if there are no elements" } returns("T?") exclude(PrimitiveType.Boolean) - typeParam("T: Comparable") + typeParam("T : Comparable") body { """ val iterator = iterator() @@ -135,8 +135,8 @@ fun aggregates(): List { inline(true) doc { "Returns the first element yielding the smallest value of the given function or null if there are no elements" } - typeParam("R: Comparable") - typeParam("T: Any") + typeParam("R : Comparable") + typeParam("T : Any") returns("T?") body { """ @@ -149,8 +149,8 @@ fun aggregates(): List { val e = iterator.next() val v = f(e) if (minValue > v) { - minElem = e - minValue = v + minElem = e + minValue = v } } return minElem @@ -166,8 +166,8 @@ fun aggregates(): List { val e = this[i] val v = f(e) if (minValue > v) { - minElem = e - minValue = v + minElem = e + minValue = v } } return minElem @@ -180,7 +180,7 @@ fun aggregates(): List { only(Maps) doc { "Returns the first element yielding the smallest value of the given function or null if there are no elements" } - typeParam("R: Comparable") + typeParam("R : Comparable") returns("T?") body { """ @@ -193,8 +193,8 @@ fun aggregates(): List { val e = iterator.next() val v = f(e) if (minValue > v) { - minElem = e - minValue = v + minElem = e + minValue = v } } return minElem @@ -206,7 +206,7 @@ fun aggregates(): List { doc { "Returns the largest element or null if there are no elements" } returns("T?") exclude(PrimitiveType.Boolean) - typeParam("T: Comparable") + typeParam("T : Comparable") body { """ val iterator = iterator() @@ -239,8 +239,8 @@ fun aggregates(): List { inline(true) doc { "Returns the first element yielding the largest value of the given function or null if there are no elements" } - typeParam("R: Comparable") - typeParam("T: Any") + typeParam("R : Comparable") + typeParam("T : Any") returns("T?") body { """ @@ -253,8 +253,8 @@ fun aggregates(): List { val e = iterator.next() val v = f(e) if (maxValue < v) { - maxElem = e - maxValue = v + maxElem = e + maxValue = v } } return maxElem @@ -270,8 +270,8 @@ fun aggregates(): List { val e = this[i] val v = f(e) if (maxValue < v) { - maxElem = e - maxValue = v + maxElem = e + maxValue = v } } return maxElem @@ -284,7 +284,7 @@ fun aggregates(): List { only(Maps) doc { "Returns the first element yielding the largest value of the given function or null if there are no elements" } - typeParam("R: Comparable") + typeParam("R : Comparable") returns("T?") body { """ @@ -297,8 +297,8 @@ fun aggregates(): List { val e = iterator.next() val v = f(e) if (maxValue < v) { - maxElem = e - maxValue = v + maxElem = e + maxValue = v } } return maxElem diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt index f77a9a8a23f..58245648a62 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt @@ -116,7 +116,7 @@ fun elements(): List { } } - templates add f("elementAt(index : Int)") { + templates add f("elementAt(index: Int)") { doc { "Returns element at given *index*" } returns("T") body { @@ -241,10 +241,12 @@ fun elements(): List { body { """ when (this) { - is List<*> -> if (size == 0) + is List<*> -> { + if (size == 0) throw IllegalArgumentException("Collection is empty") else return this[size - 1] as T + } else -> { val iterator = iterator() if (!iterator.hasNext()) diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt index deb83614e12..ef1fb5b59be 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt @@ -91,7 +91,7 @@ class GenericFunction(val signature: String) : Comparable { typeParams.add(t) } - fun inline(value : Boolean, vararg families: Family) { + fun inline(value: Boolean, vararg families: Family) { if (families.isEmpty()) defaultInline = value else @@ -148,7 +148,7 @@ class GenericFunction(val signature: String) : Comparable { Iterables -> "Iterable" Collections -> "Collection" Lists -> "List" - Maps -> "Map" + Maps -> "Map" Streams -> "Stream" ArraysOfObjects -> "Array" Strings -> "String" @@ -186,7 +186,7 @@ class GenericFunction(val signature: String) : Comparable { "T" -> { when (f) { Strings -> "Char" - Maps -> "Map.Entry" + Maps -> "Map.Entry" else -> primitive?.name() ?: token } } @@ -200,7 +200,7 @@ class GenericFunction(val signature: String) : Comparable { fun effectiveTypeParams(): List { val types = ArrayList(typeParams) if (primitive == null && f != Strings) { - val implicitTypeParameters = receiver.dropWhile { it != '<' }.drop(1).takeWhile { it != '>' }.split(",") + val implicitTypeParameters = receiver.dropWhile { it != '<' }.drop(1).filterNot { it == ' ' }.takeWhile { it != '>' }.split(",") for (implicit in implicitTypeParameters.reverse()) { if (!types.any { it.startsWith(implicit) }) { types.add(0, implicit) @@ -249,18 +249,21 @@ class GenericFunction(val signature: String) : Comparable { builder.append(receiverType) - builder.append(".${signature.renderType()} : ${returnType.renderType()} {") + builder.append(".${signature.renderType()}: ${returnType.renderType()} {") val body = (bodies[f] ?: defaultBody).trim("\n") - val prefix: Int = body.takeWhile { it == ' ' }.length + val indent: Int = body.takeWhile { it == ' ' }.length + builder.append('\n') StringReader(body).forEachLine { - builder.append('\n') - var count = prefix - builder.append(" ").append(it.dropWhile { count-- > 0 && it == ' ' } .renderType()) + var count = indent + val line = it.dropWhile { count-- > 0 && it == ' ' } .renderType() + if (line.isNotEmpty()) { + builder.append(" ").append(line) + builder.append("\n") + } } - - builder.append("\n}\n\n") + builder.append("}\n\n") } public override fun compareTo(other: GenericFunction): Int = this.signature.compareTo(other.signature) diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt index f08090f38cc..a3dc1fcefc7 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt @@ -29,7 +29,7 @@ fun filtering(): List { } body(Strings) { "return substring(Math.min(n, size))" } - returns(Strings) { "String"} + returns(Strings) { "String" } body(Collections, ArraysOfObjects, ArraysOfPrimitives) { """ @@ -63,7 +63,7 @@ fun filtering(): List { } body(Strings) { "return substring(0, Math.min(n, size))" } - returns(Strings) { "String"} + returns(Strings) { "String" } doc(Streams) { "Returns a stream containing first *n* elements" } returns(Streams) { "Stream" } @@ -90,7 +90,7 @@ fun filtering(): List { } } - templates add f("dropWhile(predicate: (T)->Boolean)") { + templates add f("dropWhile(predicate: (T) -> Boolean)") { inline(true) doc { "Returns a list containing all elements except first elements that satisfy the given *predicate*" } @@ -102,7 +102,7 @@ fun filtering(): List { for (item in this) if (yielding) list.add(item) - else if(!predicate(item)) { + else if (!predicate(item)) { list.add(item) yielding = true } @@ -110,7 +110,7 @@ fun filtering(): List { """ } - returns(Strings) { "String"} + returns(Strings) { "String" } body(Strings) { """ for (index in 0..length) @@ -128,20 +128,20 @@ fun filtering(): List { """ var yielding = false return FilteringStream(this) { - if (yielding) - true - else if (!predicate(it)) { - yielding = true - true - } else - false - } + if (yielding) + true + else if (!predicate(it)) { + yielding = true + true + } else + false + } """ } } - templates add f("takeWhile(predicate: (T)->Boolean)") { + templates add f("takeWhile(predicate: (T) -> Boolean)") { inline(true) doc { "Returns a list containing first elements satisfying the given *predicate*" } @@ -150,15 +150,15 @@ fun filtering(): List { """ val list = ArrayList() for (item in this) { - if(!predicate(item)) + if (!predicate(item)) break; - list.add(item) + list.add(item) } return list """ } - returns(Strings) { "String"} + returns(Strings) { "String" } body(Strings) { """ for (index in 0..length) @@ -179,7 +179,7 @@ fun filtering(): List { } } - templates add f("filter(predicate: (T)->Boolean)") { + templates add f("filter(predicate: (T) -> Boolean)") { inline(true) doc { "Returns a list containing all elements matching the given *predicate*" } @@ -190,7 +190,7 @@ fun filtering(): List { """ } - returns(Strings) { "String"} + returns(Strings) { "String" } body(Strings) { """ return filterTo(StringBuilder(), predicate).toString() @@ -212,7 +212,7 @@ fun filtering(): List { inline(true) doc { "Appends all elements matching the given *predicate* into the given *collection*" } - typeParam("C: TCollection") + typeParam("C : TCollection") returns("C") body { @@ -236,7 +236,7 @@ fun filtering(): List { include(Maps) } - templates add f("filterNot(predicate: (T)->Boolean)") { + templates add f("filterNot(predicate: (T) -> Boolean)") { inline(true) doc { "Returns a list containing all elements not matching the given *predicate*" } @@ -247,7 +247,7 @@ fun filtering(): List { """ } - returns(Strings) { "String"} + returns(Strings) { "String" } body(Strings) { """ return filterNotTo(StringBuilder(), predicate).toString() @@ -269,7 +269,7 @@ fun filtering(): List { inline(true) doc { "Appends all elements not matching the given *predicate* to the given *collection*" } - typeParam("C: TCollection") + typeParam("C : TCollection") returns("C") body { @@ -292,7 +292,7 @@ fun filtering(): List { templates add f("filterNotNull()") { exclude(ArraysOfPrimitives, Strings) doc { "Returns a list containing all elements that are not null" } - typeParam("T: Any") + typeParam("T : Any") returns("List") toNullableT = true body { @@ -314,8 +314,8 @@ fun filtering(): List { exclude(ArraysOfPrimitives, Strings) doc { "Appends all elements that are not null to the given *collection*" } returns("C") - typeParam("C: TCollection") - typeParam("T: Any") + typeParam("C : TCollection") + typeParam("T : Any") toNullableT = true body { """ diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt index 89221626d1c..3d1cb6599c6 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt @@ -11,9 +11,9 @@ fun generators(): List { returns("List") body { """ - val answer = toArrayList() - answer.add(element) - return answer + val answer = toArrayList() + answer.add(element) + return answer """ } @@ -32,9 +32,9 @@ fun generators(): List { returns("List") body { """ - val answer = toArrayList() - answer.addAll(collection) - return answer + val answer = toArrayList() + answer.addAll(collection) + return answer """ } } @@ -45,9 +45,9 @@ fun generators(): List { returns("List") body { """ - val answer = toArrayList() - answer.addAll(array) - return answer + val answer = toArrayList() + answer.addAll(array) + return answer """ } } @@ -88,32 +88,32 @@ fun generators(): List { returns("Pair, List>") body { """ - val first = ArrayList() - val second = ArrayList() - for (element in this) { - if (predicate(element)) { - first.add(element) - } else { - second.add(element) - } + val first = ArrayList() + val second = ArrayList() + for (element in this) { + if (predicate(element)) { + first.add(element) + } else { + second.add(element) } - return Pair(first, second) + } + return Pair(first, second) """ } returns(Strings) { "Pair" } body(Strings) { """ - val first = StringBuilder() - val second = StringBuilder() - for (element in this) { - if (predicate(element)) { - first.append(element) - } else { - second.append(element) - } + val first = StringBuilder() + val second = StringBuilder() + for (element in this) { + if (predicate(element)) { + first.append(element) + } else { + second.append(element) } - return Pair(first.toString(), second.toString()) + } + return Pair(first.toString(), second.toString()) """ } } @@ -126,37 +126,37 @@ fun generators(): List { """ } typeParam("R") - returns("List>") + returns("List>") body { """ - val first = iterator() - val second = other.iterator() - val list = ArrayList>() - while (first.hasNext() && second.hasNext()) { - list.add(first.next() to second.next()) - } - return list + val first = iterator() + val second = other.iterator() + val list = ArrayList>() + while (first.hasNext() && second.hasNext()) { + list.add(first.next() to second.next()) + } + return list """ } } - templates add f("zip(other : String)") { + templates add f("zip(other: String)") { only(Strings) doc { """ Returns a list of pairs built from characters of both strings with same indexes. List has length of shortest collection. """ } - returns("List>") + returns("List>") body { """ - val first = iterator() - val second = other.iterator() - val list = ArrayList>() - while (first.hasNext() && second.hasNext()) { - list.add(first.next() to second.next()) - } - return list + val first = iterator() + val second = other.iterator() + val list = ArrayList>() + while (first.hasNext() && second.hasNext()) { + list.add(first.next() to second.next()) + } + return list """ } } @@ -169,16 +169,16 @@ fun generators(): List { """ } typeParam("R") - returns("List>") + returns("List>") body { """ - val first = iterator() - val second = array.iterator() - val list = ArrayList>() - while (first.hasNext() && second.hasNext()) { - list.add(first.next() to second.next()) - } - return list + val first = iterator() + val second = array.iterator() + val list = ArrayList>() + while (first.hasNext() && second.hasNext()) { + list.add(first.next() to second.next()) + } + return list """ } } @@ -191,10 +191,10 @@ fun generators(): List { """ } typeParam("R") - returns("Stream>") + returns("Stream>") body { """ - return ZippingStream(this, stream) + return ZippingStream(this, stream) """ } } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Guards.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Guards.kt index 1fa4fac5914..66c8cf3acf0 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Guards.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Guards.kt @@ -12,7 +12,7 @@ fun guards(): List { include(Lists) exclude(Strings, ArraysOfPrimitives) doc { "Returns an original collection containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements" } - typeParam("T:Any") + typeParam("T : Any") toNullableT = true returns("SELF") body { diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt index ebaa41ff4cc..48689019e73 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt @@ -25,7 +25,7 @@ fun mapping(): List { } } - templates add f("map(transform : (T) -> R)") { + templates add f("map(transform: (T) -> R)") { inline(true) doc { "Returns a list containing the results of applying the given *transform* function to each element of the original collection" } @@ -39,16 +39,16 @@ fun mapping(): List { returns(Streams) { "Stream" } doc(Streams) { "Returns a stream containing the results of applying the given *transform* function to each element of the original stream" } body(Streams) { - "return TransformingStream(this, transform) " + "return TransformingStream(this, transform)" } include(Maps) } - templates add f("mapNotNull(transform : (T) -> R)") { + templates add f("mapNotNull(transform: (T) -> R)") { inline(true) exclude(Strings, ArraysOfPrimitives) doc { "Returns a list containing the results of applying the given *transform* function to each non-null element of the original collection" } - typeParam("T: Any") + typeParam("T : Any") typeParam("R") returns("List") toNullableT = true @@ -68,7 +68,7 @@ fun mapping(): List { } } - templates add f("mapTo(collection: C, transform : (T) -> R)") { + templates add f("mapTo(collection: C, transform: (T) -> R)") { inline(true) doc { @@ -78,7 +78,7 @@ fun mapping(): List { """ } typeParam("R") - typeParam("C: MutableCollection") + typeParam("C : MutableCollection") returns("C") body { @@ -91,7 +91,7 @@ fun mapping(): List { include(Maps) } - templates add f("mapNotNullTo(collection: C, transform : (T) -> R)") { + templates add f("mapNotNullTo(collection: C, transform: (T) -> R)") { inline(true) exclude(Strings, ArraysOfPrimitives) doc { @@ -100,9 +100,9 @@ fun mapping(): List { to the given *collection* """ } - typeParam("T: Any") + typeParam("T : Any") typeParam("R") - typeParam("C: MutableCollection") + typeParam("C : MutableCollection") returns("C") toNullableT = true body { @@ -110,14 +110,14 @@ fun mapping(): List { for (element in this) { if (element != null) { collection.add(transform(element)) - } + } } return collection """ } } - templates add f("flatMap(transform: (T)-> Iterable)") { + templates add f("flatMap(transform: (T) -> Iterable)") { inline(true) exclude(Streams) @@ -130,7 +130,7 @@ fun mapping(): List { include(Maps) } - templates add f("flatMap(transform: (T)-> Stream)") { + templates add f("flatMap(transform: (T) -> Stream)") { only(Streams) doc { "Returns a single stream of all elements streamed from results of *transform* function being invoked on each element of original stream" } typeParam("R") @@ -145,7 +145,7 @@ fun mapping(): List { exclude(Streams) doc { "Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection*" } typeParam("R") - typeParam("C: MutableCollection") + typeParam("C : MutableCollection") returns("C") body { """ @@ -165,7 +165,7 @@ fun mapping(): List { only(Streams) doc { "Appends all elements yielded from results of *transform* function being invoked on each element of original stream, to the given *collection*" } typeParam("R") - typeParam("C: MutableCollection") + typeParam("C : MutableCollection") returns("C") body { """ diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Numeric.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Numeric.kt index affce76a241..bf5d5b9e36d 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Numeric.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Numeric.kt @@ -10,12 +10,12 @@ fun numeric(): List { returns("SUM") body { """ - val iterator = iterator() - var sum : SUM = ZERO - while (iterator.hasNext()) { - sum += iterator.next() - } - return sum + val iterator = iterator() + var sum: SUM = ZERO + while (iterator.hasNext()) { + sum += iterator.next() + } + return sum """ } } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Ordering.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Ordering.kt index a688623d73d..6d431a0380b 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Ordering.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Ordering.kt @@ -17,7 +17,7 @@ fun ordering(): List { } doc(Strings) { "Returns a string with characters in reversed order" } - returns(Strings) { "String"} + returns(Strings) { "String" } body(Strings) { // TODO: Replace with StringBuilder(this) when JS can handle it """ @@ -35,7 +35,7 @@ fun ordering(): List { """ } returns("List") - typeParam("T: Comparable") + typeParam("T : Comparable") body { """ val sortedList = toArrayList() @@ -57,11 +57,11 @@ fun ordering(): List { """ } returns("List") - typeParam("T: Comparable") + typeParam("T : Comparable") body { """ val sortedList = toArrayList() - val sortBy: Comparator = comparator {(x: T, y: T) -> -x.compareTo(y)} + val sortBy: Comparator = comparator {(x: T, y: T) -> -x.compareTo(y) } java.util.Collections.sort(sortedList, sortBy) return sortedList """ @@ -82,11 +82,11 @@ fun ordering(): List { """ } returns("List") - typeParam("R: Comparable") + typeParam("R : Comparable") body { """ val sortedList = toArrayList() - val sortBy: Comparator = comparator {(x: T, y: T) -> order(x).compareTo(order(y))} + val sortBy: Comparator = comparator {(x: T, y: T) -> order(x).compareTo(order(y)) } java.util.Collections.sort(sortedList, sortBy) return sortedList """ @@ -106,11 +106,11 @@ fun ordering(): List { """ } returns("List") - typeParam("R: Comparable") + typeParam("R : Comparable") body { """ val sortedList = toArrayList() - val sortBy: Comparator = comparator {(x: T, y: T) -> -order(x).compareTo(order(y))} + val sortBy: Comparator = comparator {(x: T, y: T) -> -order(x).compareTo(order(y)) } java.util.Collections.sort(sortedList, sortBy) return sortedList """ @@ -121,7 +121,7 @@ fun ordering(): List { exclude(Strings) } - templates add f("sortBy(comparator : Comparator)") { + templates add f("sortBy(comparator: Comparator)") { doc { """ Returns a list of all elements, sorted by the specified *comparator* diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt index d000bb45d32..2ab5f9fceda 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt @@ -5,7 +5,7 @@ import templates.Family.* fun snapshots(): List { val templates = arrayListOf() - templates add f("toCollection(collection : C)") { + templates add f("toCollection(collection: C)") { doc { "Appends all elements to the given *collection*" } returns("C") typeParam("C : MutableCollection") @@ -94,7 +94,7 @@ fun snapshots(): List { templates add f("toSortedList()") { doc { "Returns a sorted list of all elements" } - typeParam("T: Comparable") + typeParam("T : Comparable") returns("List") body { "return toArrayList().sort()" } body(Iterables) { "return sort()" } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt index 38ae49d9ec2..77df201fbd4 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt @@ -63,7 +63,7 @@ fun specialJVM(): List { } } - templates add f("sort(fromIndex : Int = 0, toIndex : Int = size - 1)") { + templates add f("sort(fromIndex: Int = 0, toIndex: Int = size - 1)") { only(ArraysOfObjects, ArraysOfPrimitives) exclude(PrimitiveType.Boolean) doc { "Sorts array or range in array inplace" } @@ -75,8 +75,8 @@ fun specialJVM(): List { templates add f("filterIsInstanceTo(collection: C, klass: Class)") { doc { "Appends all elements that are instances of specified class into the given *collection*" } - typeParam("C: MutableCollection") - typeParam("R: T") + typeParam("C : MutableCollection") + typeParam("R : T") returns("C") exclude(ArraysOfPrimitives) body { @@ -89,7 +89,7 @@ fun specialJVM(): List { templates add f("filterIsInstance(klass: Class)") { doc { "Returns a list containing all elements that are instances of specified class" } - typeParam("R: T") + typeParam("R : T") returns("List") body { """ diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Stream.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Stream.kt index a6dc7cc6e68..77ff1e3e1d7 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Stream.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Stream.kt @@ -10,7 +10,11 @@ fun streams(): List { returns("Stream") body { """ - return object : Stream { override fun iterator() : Iterator { return this@stream.iterator() } } + return object : Stream { + override fun iterator(): Iterator { + return this@stream.iterator() + } + } """ } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Strings.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Strings.kt index dbc699aa8a5..e05c7dff092 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Strings.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Strings.kt @@ -5,7 +5,7 @@ import templates.Family.* fun strings(): List { val templates = arrayListOf() - templates add f("appendString(buffer: Appendable, separator: String = \", \", prefix: String =\"\", postfix: String = \"\", limit: Int = -1, truncated: String = \"...\")") { + templates add f("appendString(buffer: Appendable, separator: String = \", \", prefix: String = \"\", postfix: String = \"\", limit: Int = -1, truncated: String = \"...\")") { doc { """ Appends the string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied