From 0043454a0641cff382f1e27374f42b5775136843 Mon Sep 17 00:00:00 2001 From: Alexander Zolotov Date: Sat, 16 Jun 2012 00:46:20 +0400 Subject: [PATCH] Implement reduce and reduceRight functions --- .../src/generated/ArraysFromJLangIterables.kt | 30 ++++++++++++++++++ .../BooleanArraysFromJLangIterables.kt | 30 ++++++++++++++++++ .../generated/ByteArraysFromJLangIterables.kt | 30 ++++++++++++++++++ .../generated/CharArraysFromJLangIterables.kt | 30 ++++++++++++++++++ .../DoubleArraysFromJLangIterables.kt | 30 ++++++++++++++++++ .../FloatArraysFromJLangIterables.kt | 30 ++++++++++++++++++ .../generated/IntArraysFromJLangIterables.kt | 30 ++++++++++++++++++ .../JUtilIteratorsFromJLangIterables.kt | 30 ++++++++++++++++++ .../generated/LongArraysFromJLangIterables.kt | 30 ++++++++++++++++++ .../ShortArraysFromJLangIterables.kt | 30 ++++++++++++++++++ .../generated/StandardFromJLangIterables.kt | 30 ++++++++++++++++++ libraries/stdlib/src/kotlin/JLangIterables.kt | 30 ++++++++++++++++++ libraries/stdlib/test/CollectionTest.kt | 31 +++++++++++++++++++ .../kotlin/tools/GenerateStandardLib.kt | 10 ++++-- 14 files changed, 398 insertions(+), 3 deletions(-) diff --git a/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt index b28c5b56f15..cdcd498c19c 100644 --- a/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt @@ -147,6 +147,36 @@ public inline fun Array.fold(initial: T, operation: (T, T) -> T): T { */ public inline fun Array.foldRight(initial: T, operation: (T, T) -> T): T = reverse().fold(initial, {x, y -> operation(y, x)}) + +/** + * Applies binary operation to all elements of iterable, going from left to right. + * Similar to fold function, but uses the first element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduce + */ +public inline fun Array.reduce(operation: (T, T) -> T): T { + val iterator = this.iterator().sure() + if (!iterator.hasNext) { + throw UnsupportedOperationException("Empty iterable can't be reduced") + } + + var result: T = iterator.next() //compiler doesn't understand that result will initialized anyway + while (iterator.hasNext) { + result = operation(result, iterator.next()) + } + + return result +} + +/** + * Applies binary operation to all elements of iterable, going from right to left. + * Similar to foldRight function, but uses the last element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduceRight + */ +public inline fun Array.reduceRight(operation: (T, T) -> T): T = reverse().reduce { x, y -> operation(y, x) } + + /** * Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by * diff --git a/libraries/stdlib/src/generated/BooleanArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/BooleanArraysFromJLangIterables.kt index b1138a60b41..f292457ba9a 100644 --- a/libraries/stdlib/src/generated/BooleanArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/BooleanArraysFromJLangIterables.kt @@ -147,6 +147,36 @@ public inline fun BooleanArray.fold(initial: Boolean, operation: (Boolean, Boole */ public inline fun BooleanArray.foldRight(initial: Boolean, operation: (Boolean, Boolean) -> Boolean): Boolean = reverse().fold(initial, {x, y -> operation(y, x)}) + +/** + * Applies binary operation to all elements of iterable, going from left to right. + * Similar to fold function, but uses the first element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduce + */ +public inline fun BooleanArray.reduce(operation: (Boolean, Boolean) -> Boolean): Boolean { + val iterator = this.iterator().sure() + if (!iterator.hasNext) { + throw UnsupportedOperationException("Empty iterable can't be reduced") + } + + var result: Boolean = iterator.next() //compiler doesn't understand that result will initialized anyway + while (iterator.hasNext) { + result = operation(result, iterator.next()) + } + + return result +} + +/** + * Applies binary operation to all elements of iterable, going from right to left. + * Similar to foldRight function, but uses the last element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduceRight + */ +public inline fun BooleanArray.reduceRight(operation: (Boolean, Boolean) -> Boolean): Boolean = reverse().reduce { x, y -> operation(y, x) } + + /** * Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by * diff --git a/libraries/stdlib/src/generated/ByteArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/ByteArraysFromJLangIterables.kt index b1c71885dd3..7967d0763ef 100644 --- a/libraries/stdlib/src/generated/ByteArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/ByteArraysFromJLangIterables.kt @@ -147,6 +147,36 @@ public inline fun ByteArray.fold(initial: Byte, operation: (Byte, Byte) -> Byte) */ public inline fun ByteArray.foldRight(initial: Byte, operation: (Byte, Byte) -> Byte): Byte = reverse().fold(initial, {x, y -> operation(y, x)}) + +/** + * Applies binary operation to all elements of iterable, going from left to right. + * Similar to fold function, but uses the first element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduce + */ +public inline fun ByteArray.reduce(operation: (Byte, Byte) -> Byte): Byte { + val iterator = this.iterator().sure() + if (!iterator.hasNext) { + throw UnsupportedOperationException("Empty iterable can't be reduced") + } + + var result: Byte = iterator.next() //compiler doesn't understand that result will initialized anyway + while (iterator.hasNext) { + result = operation(result, iterator.next()) + } + + return result +} + +/** + * Applies binary operation to all elements of iterable, going from right to left. + * Similar to foldRight function, but uses the last element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduceRight + */ +public inline fun ByteArray.reduceRight(operation: (Byte, Byte) -> Byte): Byte = reverse().reduce { x, y -> operation(y, x) } + + /** * Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by * diff --git a/libraries/stdlib/src/generated/CharArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/CharArraysFromJLangIterables.kt index 0749372ec7b..a41ece2b3dc 100644 --- a/libraries/stdlib/src/generated/CharArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/CharArraysFromJLangIterables.kt @@ -147,6 +147,36 @@ public inline fun CharArray.fold(initial: Char, operation: (Char, Char) -> Char) */ public inline fun CharArray.foldRight(initial: Char, operation: (Char, Char) -> Char): Char = reverse().fold(initial, {x, y -> operation(y, x)}) + +/** + * Applies binary operation to all elements of iterable, going from left to right. + * Similar to fold function, but uses the first element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduce + */ +public inline fun CharArray.reduce(operation: (Char, Char) -> Char): Char { + val iterator = this.iterator().sure() + if (!iterator.hasNext) { + throw UnsupportedOperationException("Empty iterable can't be reduced") + } + + var result: Char = iterator.next() //compiler doesn't understand that result will initialized anyway + while (iterator.hasNext) { + result = operation(result, iterator.next()) + } + + return result +} + +/** + * Applies binary operation to all elements of iterable, going from right to left. + * Similar to foldRight function, but uses the last element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduceRight + */ +public inline fun CharArray.reduceRight(operation: (Char, Char) -> Char): Char = reverse().reduce { x, y -> operation(y, x) } + + /** * Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by * diff --git a/libraries/stdlib/src/generated/DoubleArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/DoubleArraysFromJLangIterables.kt index 4f6cdad514b..9cd7d285d7f 100644 --- a/libraries/stdlib/src/generated/DoubleArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/DoubleArraysFromJLangIterables.kt @@ -147,6 +147,36 @@ public inline fun DoubleArray.fold(initial: Double, operation: (Double, Double) */ public inline fun DoubleArray.foldRight(initial: Double, operation: (Double, Double) -> Double): Double = reverse().fold(initial, {x, y -> operation(y, x)}) + +/** + * Applies binary operation to all elements of iterable, going from left to right. + * Similar to fold function, but uses the first element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduce + */ +public inline fun DoubleArray.reduce(operation: (Double, Double) -> Double): Double { + val iterator = this.iterator().sure() + if (!iterator.hasNext) { + throw UnsupportedOperationException("Empty iterable can't be reduced") + } + + var result: Double = iterator.next() //compiler doesn't understand that result will initialized anyway + while (iterator.hasNext) { + result = operation(result, iterator.next()) + } + + return result +} + +/** + * Applies binary operation to all elements of iterable, going from right to left. + * Similar to foldRight function, but uses the last element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduceRight + */ +public inline fun DoubleArray.reduceRight(operation: (Double, Double) -> Double): Double = reverse().reduce { x, y -> operation(y, x) } + + /** * Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by * diff --git a/libraries/stdlib/src/generated/FloatArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/FloatArraysFromJLangIterables.kt index c19e57a0bfd..4682062829f 100644 --- a/libraries/stdlib/src/generated/FloatArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/FloatArraysFromJLangIterables.kt @@ -147,6 +147,36 @@ public inline fun FloatArray.fold(initial: Float, operation: (Float, Float) -> F */ public inline fun FloatArray.foldRight(initial: Float, operation: (Float, Float) -> Float): Float = reverse().fold(initial, {x, y -> operation(y, x)}) + +/** + * Applies binary operation to all elements of iterable, going from left to right. + * Similar to fold function, but uses the first element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduce + */ +public inline fun FloatArray.reduce(operation: (Float, Float) -> Float): Float { + val iterator = this.iterator().sure() + if (!iterator.hasNext) { + throw UnsupportedOperationException("Empty iterable can't be reduced") + } + + var result: Float = iterator.next() //compiler doesn't understand that result will initialized anyway + while (iterator.hasNext) { + result = operation(result, iterator.next()) + } + + return result +} + +/** + * Applies binary operation to all elements of iterable, going from right to left. + * Similar to foldRight function, but uses the last element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduceRight + */ +public inline fun FloatArray.reduceRight(operation: (Float, Float) -> Float): Float = reverse().reduce { x, y -> operation(y, x) } + + /** * Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by * diff --git a/libraries/stdlib/src/generated/IntArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/IntArraysFromJLangIterables.kt index 4a6b9cd3dd2..1958da8c110 100644 --- a/libraries/stdlib/src/generated/IntArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/IntArraysFromJLangIterables.kt @@ -147,6 +147,36 @@ public inline fun IntArray.fold(initial: Int, operation: (Int, Int) -> Int): Int */ public inline fun IntArray.foldRight(initial: Int, operation: (Int, Int) -> Int): Int = reverse().fold(initial, {x, y -> operation(y, x)}) + +/** + * Applies binary operation to all elements of iterable, going from left to right. + * Similar to fold function, but uses the first element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduce + */ +public inline fun IntArray.reduce(operation: (Int, Int) -> Int): Int { + val iterator = this.iterator().sure() + if (!iterator.hasNext) { + throw UnsupportedOperationException("Empty iterable can't be reduced") + } + + var result: Int = iterator.next() //compiler doesn't understand that result will initialized anyway + while (iterator.hasNext) { + result = operation(result, iterator.next()) + } + + return result +} + +/** + * Applies binary operation to all elements of iterable, going from right to left. + * Similar to foldRight function, but uses the last element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduceRight + */ +public inline fun IntArray.reduceRight(operation: (Int, Int) -> Int): Int = reverse().reduce { x, y -> operation(y, x) } + + /** * Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by * diff --git a/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt b/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt index 8d100a05aeb..575b828ed9f 100644 --- a/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt @@ -145,6 +145,36 @@ public inline fun java.util.Iterator.fold(initial: T, operation: (T, T) - */ public inline fun java.util.Iterator.foldRight(initial: T, operation: (T, T) -> T): T = reverse().fold(initial, {x, y -> operation(y, x)}) + +/** + * Applies binary operation to all elements of iterable, going from left to right. + * Similar to fold function, but uses the first element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduce + */ +public inline fun java.util.Iterator.reduce(operation: (T, T) -> T): T { + val iterator = this.iterator().sure() + if (!iterator.hasNext()) { + throw UnsupportedOperationException("Empty iterable can't be reduced") + } + + var result: T = iterator.next() //compiler doesn't understand that result will initialized anyway + while (iterator.hasNext()) { + result = operation(result, iterator.next()) + } + + return result +} + +/** + * Applies binary operation to all elements of iterable, going from right to left. + * Similar to foldRight function, but uses the last element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduceRight + */ +public inline fun java.util.Iterator.reduceRight(operation: (T, T) -> T): T = reverse().reduce { x, y -> operation(y, x) } + + /** * Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by * diff --git a/libraries/stdlib/src/generated/LongArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/LongArraysFromJLangIterables.kt index 80f144b0fef..9611b341340 100644 --- a/libraries/stdlib/src/generated/LongArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/LongArraysFromJLangIterables.kt @@ -147,6 +147,36 @@ public inline fun LongArray.fold(initial: Long, operation: (Long, Long) -> Long) */ public inline fun LongArray.foldRight(initial: Long, operation: (Long, Long) -> Long): Long = reverse().fold(initial, {x, y -> operation(y, x)}) + +/** + * Applies binary operation to all elements of iterable, going from left to right. + * Similar to fold function, but uses the first element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduce + */ +public inline fun LongArray.reduce(operation: (Long, Long) -> Long): Long { + val iterator = this.iterator().sure() + if (!iterator.hasNext) { + throw UnsupportedOperationException("Empty iterable can't be reduced") + } + + var result: Long = iterator.next() //compiler doesn't understand that result will initialized anyway + while (iterator.hasNext) { + result = operation(result, iterator.next()) + } + + return result +} + +/** + * Applies binary operation to all elements of iterable, going from right to left. + * Similar to foldRight function, but uses the last element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduceRight + */ +public inline fun LongArray.reduceRight(operation: (Long, Long) -> Long): Long = reverse().reduce { x, y -> operation(y, x) } + + /** * Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by * diff --git a/libraries/stdlib/src/generated/ShortArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/ShortArraysFromJLangIterables.kt index fb658f1ba0e..6de8195cbd2 100644 --- a/libraries/stdlib/src/generated/ShortArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/ShortArraysFromJLangIterables.kt @@ -147,6 +147,36 @@ public inline fun ShortArray.fold(initial: Short, operation: (Short, Short) -> S */ public inline fun ShortArray.foldRight(initial: Short, operation: (Short, Short) -> Short): Short = reverse().fold(initial, {x, y -> operation(y, x)}) + +/** + * Applies binary operation to all elements of iterable, going from left to right. + * Similar to fold function, but uses the first element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduce + */ +public inline fun ShortArray.reduce(operation: (Short, Short) -> Short): Short { + val iterator = this.iterator().sure() + if (!iterator.hasNext) { + throw UnsupportedOperationException("Empty iterable can't be reduced") + } + + var result: Short = iterator.next() //compiler doesn't understand that result will initialized anyway + while (iterator.hasNext) { + result = operation(result, iterator.next()) + } + + return result +} + +/** + * Applies binary operation to all elements of iterable, going from right to left. + * Similar to foldRight function, but uses the last element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduceRight + */ +public inline fun ShortArray.reduceRight(operation: (Short, Short) -> Short): Short = reverse().reduce { x, y -> operation(y, x) } + + /** * Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by * diff --git a/libraries/stdlib/src/generated/StandardFromJLangIterables.kt b/libraries/stdlib/src/generated/StandardFromJLangIterables.kt index 01c00e1df80..c626ff7f513 100644 --- a/libraries/stdlib/src/generated/StandardFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/StandardFromJLangIterables.kt @@ -147,6 +147,36 @@ public inline fun Iterable.fold(initial: T, operation: (T, T) -> T): T { */ public inline fun Iterable.foldRight(initial: T, operation: (T, T) -> T): T = reverse().fold(initial, {x, y -> operation(y, x)}) + +/** + * Applies binary operation to all elements of iterable, going from left to right. + * Similar to fold function, but uses the first element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduce + */ +public inline fun Iterable.reduce(operation: (T, T) -> T): T { + val iterator = this.iterator().sure() + if (!iterator.hasNext) { + throw UnsupportedOperationException("Empty iterable can't be reduced") + } + + var result: T = iterator.next() //compiler doesn't understand that result will initialized anyway + while (iterator.hasNext) { + result = operation(result, iterator.next()) + } + + return result +} + +/** + * Applies binary operation to all elements of iterable, going from right to left. + * Similar to foldRight function, but uses the last element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduceRight + */ +public inline fun Iterable.reduceRight(operation: (T, T) -> T): T = reverse().reduce { x, y -> operation(y, x) } + + /** * Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by * diff --git a/libraries/stdlib/src/kotlin/JLangIterables.kt b/libraries/stdlib/src/kotlin/JLangIterables.kt index 24d8c8e7f2e..13cff107023 100644 --- a/libraries/stdlib/src/kotlin/JLangIterables.kt +++ b/libraries/stdlib/src/kotlin/JLangIterables.kt @@ -137,6 +137,36 @@ public inline fun java.lang.Iterable.fold(initial: T, operation: (T, T) - */ public inline fun java.lang.Iterable.foldRight(initial: T, operation: (T, T) -> T): T = reverse().fold(initial, {x, y -> operation(y, x)}) + +/** + * Applies binary operation to all elements of iterable, going from left to right. + * Similar to fold function, but uses the first element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduce + */ +public inline fun java.lang.Iterable.reduce(operation: (T, T) -> T): T { + val iterator = this.iterator().sure() + if (!iterator.hasNext()) { + throw UnsupportedOperationException("Empty iterable can't be reduced") + } + + var result: T = iterator.next() //compiler doesn't understand that result will initialized anyway + while (iterator.hasNext()) { + result = operation(result, iterator.next()) + } + + return result +} + +/** + * Applies binary operation to all elements of iterable, going from right to left. + * Similar to foldRight function, but uses the last element as initial value + * + * @includeFunctionBody ../../test/CollectionTest.kt reduceRight + */ +public inline fun java.lang.Iterable.reduceRight(operation: (T, T) -> T): T = reverse().reduce { x, y -> operation(y, x) } + + /** * Groups the elements in the collection into a new [[Map]] using the supplied *toKey* function to calculate the key to group the elements by * diff --git a/libraries/stdlib/test/CollectionTest.kt b/libraries/stdlib/test/CollectionTest.kt index d6024a2560a..5db684f4574 100644 --- a/libraries/stdlib/test/CollectionTest.kt +++ b/libraries/stdlib/test/CollectionTest.kt @@ -216,6 +216,37 @@ class CollectionTest { } } + test fun reduce() { + expect("1234") { + val list = arrayList("1", "2", "3", "4") + list.reduce { a, b -> a + b } + } + + expect(-4) { + val array = array(1, 2, 3) + array.reduce { a, b -> a - b } + } + + failsWith { + arrayList().reduce { a, b -> a + b} + } + } + + test fun reduceRight() { + expect("1234") { + val list = arrayList("1", "2", "3", "4") + list.reduceRight { a, b -> a + b } + } + expect(2) { + val array = array(1, 2, 3) + array.reduceRight { a, b -> a - b } + } + + failsWith { + arrayList().reduceRight { a, b -> a + b} + } + } + test fun groupBy() { val words = arrayList("a", "ab", "abc", "def", "abcd") val byLength = words.groupBy{ it.length } diff --git a/libraries/stdlib/test/org/jetbrains/kotlin/tools/GenerateStandardLib.kt b/libraries/stdlib/test/org/jetbrains/kotlin/tools/GenerateStandardLib.kt index 6a21cfd9b82..af1eb23df92 100644 --- a/libraries/stdlib/test/org/jetbrains/kotlin/tools/GenerateStandardLib.kt +++ b/libraries/stdlib/test/org/jetbrains/kotlin/tools/GenerateStandardLib.kt @@ -63,7 +63,9 @@ fun main(args: Array) { // JLangIterables - Generic iterable stuff generateFile(File(outDir, "ArraysFromJLangIterables.kt"), "package kotlin\n\nimport kotlin.util.*", File(srcDir, "JLangIterables.kt")) { - it.replaceAll("java.lang.Iterable) { replaceGenerics(arrayName, it.replaceAll(" java.lang.Iterable", "${arrayName}Array"). replaceAll(" java.lang.Iterable", "${arrayName}Array"). replaceAll("java.lang.Iterable", "${arrayName}Array"). - replaceAll("java.lang.Iterable", "${arrayName}Array")) + replaceAll("java.lang.Iterable", "${arrayName}Array")). + replaceAll("iterator.hasNext\\(\\)", "iterator.hasNext") } generateFile(File(outDir, "${arrayName}ArraysFromJLangIterables.kt"), "package kotlin\n\nimport kotlin.util.*", File(srcDir, "JLangIterables.kt")) { @@ -85,7 +88,8 @@ fun main(args: Array) { } generateFile(File(outDir, "StandardFromJLangIterables.kt"), "package kotlin\n\nimport kotlin.util.*", File(srcDir, "JLangIterables.kt")) { - it.replaceAll("java.lang.Iterable