diff --git a/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt index 119144eba7f..91ef67657e6 100644 --- a/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt @@ -257,6 +257,9 @@ public inline fun Array.toList() : List = toCollection(ArrayList /** Copies all elements into a [[List] */ public inline fun Array.toCollection() : Collection = toCollection(ArrayList()) +/** Copies all elements into a [[Set]] */ +public inline fun Array.toSet() : Set = toCollection(HashSet()) + /** TODO figure out necessary variance/generics ninja stuff... :) public inline fun Array.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List { @@ -276,9 +279,6 @@ public inline fun Array.toSortedList(transform: fun(T) : java.lang.Com import java.util.* -/** Copies all elements into a [[Set]] */ -public inline fun Array.toSet() : Set = toCollection(HashSet()) - /** Copies all elements into a [[SortedSet]] */ public inline fun Array.toSortedSet() : SortedSet = toCollection(TreeSet()) diff --git a/libraries/stdlib/src/generated/ArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/ArraysFromJLangIterablesLazy.kt index 0283e602155..929ba6fd8c9 100644 --- a/libraries/stdlib/src/generated/ArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/ArraysFromJLangIterablesLazy.kt @@ -95,10 +95,6 @@ public inline fun Array?.requireNoNulls() : List { * @includeFunctionBody ../../test/CollectionTest.kt drop */ public inline fun Array.drop(n: Int): List { - fun countTo(n: Int): (T) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return dropWhile(countTo(n)) } @@ -115,10 +111,6 @@ public inline fun Array.dropWhile(predicate: (T) -> Boolean): List = d * @includeFunctionBody ../../test/CollectionTest.kt take */ public inline fun Array.take(n: Int): List { - fun countTo(n: Int): (T) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return takeWhile(countTo(n)) } diff --git a/libraries/stdlib/src/generated/BooleanArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/BooleanArraysFromJLangIterables.kt index 90267714087..62ab715c1dc 100644 --- a/libraries/stdlib/src/generated/BooleanArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/BooleanArraysFromJLangIterables.kt @@ -257,6 +257,9 @@ public inline fun BooleanArray.toList() : List = toCollection(ArrayLis /** Copies all elements into a [[List] */ public inline fun BooleanArray.toCollection() : Collection = toCollection(ArrayList()) +/** Copies all elements into a [[Set]] */ +public inline fun BooleanArray.toSet() : Set = toCollection(HashSet()) + /** TODO figure out necessary variance/generics ninja stuff... :) public inline fun BooleanArray.toSortedList(transform: fun(Boolean) : java.lang.Comparable<*>) : List { @@ -276,9 +279,6 @@ public inline fun BooleanArray.toSortedList(transform: fun(Boolean) : java.lang import java.util.* -/** Copies all elements into a [[Set]] */ -public inline fun BooleanArray.toSet() : Set = toCollection(HashSet()) - /** Copies all elements into a [[SortedSet]] */ public inline fun BooleanArray.toSortedSet() : SortedSet = toCollection(TreeSet()) diff --git a/libraries/stdlib/src/generated/BooleanArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/BooleanArraysFromJLangIterablesLazy.kt index 1cc25372d29..1bcc2248e51 100644 --- a/libraries/stdlib/src/generated/BooleanArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/BooleanArraysFromJLangIterablesLazy.kt @@ -95,10 +95,6 @@ public inline fun BooleanArray?.requireNoNulls() : List { * @includeFunctionBody ../../test/CollectionTest.kt drop */ public inline fun BooleanArray.drop(n: Int): List { - fun countTo(n: Int): (Boolean) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return dropWhile(countTo(n)) } @@ -115,10 +111,6 @@ public inline fun BooleanArray.dropWhile(predicate: (Boolean) -> Boolean): List< * @includeFunctionBody ../../test/CollectionTest.kt take */ public inline fun BooleanArray.take(n: Int): List { - fun countTo(n: Int): (Boolean) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return takeWhile(countTo(n)) } diff --git a/libraries/stdlib/src/generated/ByteArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/ByteArraysFromJLangIterables.kt index c9e7e87ee31..1892bb7c346 100644 --- a/libraries/stdlib/src/generated/ByteArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/ByteArraysFromJLangIterables.kt @@ -257,6 +257,9 @@ public inline fun ByteArray.toList() : List = toCollection(ArrayList = toCollection(ArrayList()) +/** Copies all elements into a [[Set]] */ +public inline fun ByteArray.toSet() : Set = toCollection(HashSet()) + /** TODO figure out necessary variance/generics ninja stuff... :) public inline fun ByteArray.toSortedList(transform: fun(Byte) : java.lang.Comparable<*>) : List { @@ -276,9 +279,6 @@ public inline fun ByteArray.toSortedList(transform: fun(Byte) : java.lang.Compa import java.util.* -/** Copies all elements into a [[Set]] */ -public inline fun ByteArray.toSet() : Set = toCollection(HashSet()) - /** Copies all elements into a [[SortedSet]] */ public inline fun ByteArray.toSortedSet() : SortedSet = toCollection(TreeSet()) diff --git a/libraries/stdlib/src/generated/ByteArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/ByteArraysFromJLangIterablesLazy.kt index 62fad694c76..4b83b3afd16 100644 --- a/libraries/stdlib/src/generated/ByteArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/ByteArraysFromJLangIterablesLazy.kt @@ -95,10 +95,6 @@ public inline fun ByteArray?.requireNoNulls() : List { * @includeFunctionBody ../../test/CollectionTest.kt drop */ public inline fun ByteArray.drop(n: Int): List { - fun countTo(n: Int): (Byte) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return dropWhile(countTo(n)) } @@ -115,10 +111,6 @@ public inline fun ByteArray.dropWhile(predicate: (Byte) -> Boolean): List * @includeFunctionBody ../../test/CollectionTest.kt take */ public inline fun ByteArray.take(n: Int): List { - fun countTo(n: Int): (Byte) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return takeWhile(countTo(n)) } diff --git a/libraries/stdlib/src/generated/CharArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/CharArraysFromJLangIterables.kt index d82f20af2c3..da2d49bbb83 100644 --- a/libraries/stdlib/src/generated/CharArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/CharArraysFromJLangIterables.kt @@ -257,6 +257,9 @@ public inline fun CharArray.toList() : List = toCollection(ArrayList = toCollection(ArrayList()) +/** Copies all elements into a [[Set]] */ +public inline fun CharArray.toSet() : Set = toCollection(HashSet()) + /** TODO figure out necessary variance/generics ninja stuff... :) public inline fun CharArray.toSortedList(transform: fun(Char) : java.lang.Comparable<*>) : List { @@ -276,9 +279,6 @@ public inline fun CharArray.toSortedList(transform: fun(Char) : java.lang.Compa import java.util.* -/** Copies all elements into a [[Set]] */ -public inline fun CharArray.toSet() : Set = toCollection(HashSet()) - /** Copies all elements into a [[SortedSet]] */ public inline fun CharArray.toSortedSet() : SortedSet = toCollection(TreeSet()) diff --git a/libraries/stdlib/src/generated/CharArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/CharArraysFromJLangIterablesLazy.kt index 89e83a26999..fecc6acaca2 100644 --- a/libraries/stdlib/src/generated/CharArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/CharArraysFromJLangIterablesLazy.kt @@ -95,10 +95,6 @@ public inline fun CharArray?.requireNoNulls() : List { * @includeFunctionBody ../../test/CollectionTest.kt drop */ public inline fun CharArray.drop(n: Int): List { - fun countTo(n: Int): (Char) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return dropWhile(countTo(n)) } @@ -115,10 +111,6 @@ public inline fun CharArray.dropWhile(predicate: (Char) -> Boolean): List * @includeFunctionBody ../../test/CollectionTest.kt take */ public inline fun CharArray.take(n: Int): List { - fun countTo(n: Int): (Char) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return takeWhile(countTo(n)) } diff --git a/libraries/stdlib/src/generated/DoubleArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/DoubleArraysFromJLangIterables.kt index 255028138b7..c5589d9d81d 100644 --- a/libraries/stdlib/src/generated/DoubleArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/DoubleArraysFromJLangIterables.kt @@ -257,6 +257,9 @@ public inline fun DoubleArray.toList() : List = toCollection(ArrayList< /** Copies all elements into a [[List] */ public inline fun DoubleArray.toCollection() : Collection = toCollection(ArrayList()) +/** Copies all elements into a [[Set]] */ +public inline fun DoubleArray.toSet() : Set = toCollection(HashSet()) + /** TODO figure out necessary variance/generics ninja stuff... :) public inline fun DoubleArray.toSortedList(transform: fun(Double) : java.lang.Comparable<*>) : List { @@ -276,9 +279,6 @@ public inline fun DoubleArray.toSortedList(transform: fun(Double) : java.lang.C import java.util.* -/** Copies all elements into a [[Set]] */ -public inline fun DoubleArray.toSet() : Set = toCollection(HashSet()) - /** Copies all elements into a [[SortedSet]] */ public inline fun DoubleArray.toSortedSet() : SortedSet = toCollection(TreeSet()) diff --git a/libraries/stdlib/src/generated/DoubleArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/DoubleArraysFromJLangIterablesLazy.kt index 96d4d993b99..b13e669e0d7 100644 --- a/libraries/stdlib/src/generated/DoubleArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/DoubleArraysFromJLangIterablesLazy.kt @@ -95,10 +95,6 @@ public inline fun DoubleArray?.requireNoNulls() : List { * @includeFunctionBody ../../test/CollectionTest.kt drop */ public inline fun DoubleArray.drop(n: Int): List { - fun countTo(n: Int): (Double) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return dropWhile(countTo(n)) } @@ -115,10 +111,6 @@ public inline fun DoubleArray.dropWhile(predicate: (Double) -> Boolean): List { - fun countTo(n: Int): (Double) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return takeWhile(countTo(n)) } diff --git a/libraries/stdlib/src/generated/FloatArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/FloatArraysFromJLangIterables.kt index 2e2244b2479..8a45fec0264 100644 --- a/libraries/stdlib/src/generated/FloatArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/FloatArraysFromJLangIterables.kt @@ -257,6 +257,9 @@ public inline fun FloatArray.toList() : List = toCollection(ArrayList = toCollection(ArrayList()) +/** Copies all elements into a [[Set]] */ +public inline fun FloatArray.toSet() : Set = toCollection(HashSet()) + /** TODO figure out necessary variance/generics ninja stuff... :) public inline fun FloatArray.toSortedList(transform: fun(Float) : java.lang.Comparable<*>) : List { @@ -276,9 +279,6 @@ public inline fun FloatArray.toSortedList(transform: fun(Float) : java.lang.Com import java.util.* -/** Copies all elements into a [[Set]] */ -public inline fun FloatArray.toSet() : Set = toCollection(HashSet()) - /** Copies all elements into a [[SortedSet]] */ public inline fun FloatArray.toSortedSet() : SortedSet = toCollection(TreeSet()) diff --git a/libraries/stdlib/src/generated/FloatArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/FloatArraysFromJLangIterablesLazy.kt index bbd7452767b..e9370209a08 100644 --- a/libraries/stdlib/src/generated/FloatArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/FloatArraysFromJLangIterablesLazy.kt @@ -95,10 +95,6 @@ public inline fun FloatArray?.requireNoNulls() : List { * @includeFunctionBody ../../test/CollectionTest.kt drop */ public inline fun FloatArray.drop(n: Int): List { - fun countTo(n: Int): (Float) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return dropWhile(countTo(n)) } @@ -115,10 +111,6 @@ public inline fun FloatArray.dropWhile(predicate: (Float) -> Boolean): List { - fun countTo(n: Int): (Float) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return takeWhile(countTo(n)) } diff --git a/libraries/stdlib/src/generated/IntArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/IntArraysFromJLangIterables.kt index 1cceeded2fe..db2d6656aa8 100644 --- a/libraries/stdlib/src/generated/IntArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/IntArraysFromJLangIterables.kt @@ -257,6 +257,9 @@ public inline fun IntArray.toList() : List = toCollection(ArrayList() /** Copies all elements into a [[List] */ public inline fun IntArray.toCollection() : Collection = toCollection(ArrayList()) +/** Copies all elements into a [[Set]] */ +public inline fun IntArray.toSet() : Set = toCollection(HashSet()) + /** TODO figure out necessary variance/generics ninja stuff... :) public inline fun IntArray.toSortedList(transform: fun(Int) : java.lang.Comparable<*>) : List { @@ -276,9 +279,6 @@ public inline fun IntArray.toSortedList(transform: fun(Int) : java.lang.Compara import java.util.* -/** Copies all elements into a [[Set]] */ -public inline fun IntArray.toSet() : Set = toCollection(HashSet()) - /** Copies all elements into a [[SortedSet]] */ public inline fun IntArray.toSortedSet() : SortedSet = toCollection(TreeSet()) diff --git a/libraries/stdlib/src/generated/IntArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/IntArraysFromJLangIterablesLazy.kt index 822c84a041f..40f1c986017 100644 --- a/libraries/stdlib/src/generated/IntArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/IntArraysFromJLangIterablesLazy.kt @@ -95,10 +95,6 @@ public inline fun IntArray?.requireNoNulls() : List { * @includeFunctionBody ../../test/CollectionTest.kt drop */ public inline fun IntArray.drop(n: Int): List { - fun countTo(n: Int): (Int) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return dropWhile(countTo(n)) } @@ -115,10 +111,6 @@ public inline fun IntArray.dropWhile(predicate: (Int) -> Boolean): List = d * @includeFunctionBody ../../test/CollectionTest.kt take */ public inline fun IntArray.take(n: Int): List { - fun countTo(n: Int): (Int) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return takeWhile(countTo(n)) } diff --git a/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt b/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt index 7b6470913f7..c02c56c285a 100644 --- a/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt @@ -255,6 +255,9 @@ public inline fun java.util.Iterator.toList() : List = toCollection /** Copies all elements into a [[List] */ public inline fun java.util.Iterator.toCollection() : Collection = toCollection(ArrayList()) +/** Copies all elements into a [[Set]] */ +public inline fun java.util.Iterator.toSet() : Set = toCollection(HashSet()) + /** TODO figure out necessary variance/generics ninja stuff... :) public inline fun java.util.Iterator.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List { @@ -274,9 +277,6 @@ public inline fun java.util.Iterator.toSortedList(transform: fun(T) : import java.util.* -/** Copies all elements into a [[Set]] */ -public inline fun java.util.Iterator.toSet() : Set = toCollection(HashSet()) - /** Copies all elements into a [[SortedSet]] */ public inline fun java.util.Iterator.toSortedSet() : SortedSet = toCollection(TreeSet()) diff --git a/libraries/stdlib/src/generated/LongArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/LongArraysFromJLangIterables.kt index dcb5693d07f..c45a6e1ba4d 100644 --- a/libraries/stdlib/src/generated/LongArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/LongArraysFromJLangIterables.kt @@ -257,6 +257,9 @@ public inline fun LongArray.toList() : List = toCollection(ArrayList = toCollection(ArrayList()) +/** Copies all elements into a [[Set]] */ +public inline fun LongArray.toSet() : Set = toCollection(HashSet()) + /** TODO figure out necessary variance/generics ninja stuff... :) public inline fun LongArray.toSortedList(transform: fun(Long) : java.lang.Comparable<*>) : List { @@ -276,9 +279,6 @@ public inline fun LongArray.toSortedList(transform: fun(Long) : java.lang.Compa import java.util.* -/** Copies all elements into a [[Set]] */ -public inline fun LongArray.toSet() : Set = toCollection(HashSet()) - /** Copies all elements into a [[SortedSet]] */ public inline fun LongArray.toSortedSet() : SortedSet = toCollection(TreeSet()) diff --git a/libraries/stdlib/src/generated/LongArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/LongArraysFromJLangIterablesLazy.kt index 993e253ffc5..f3d0a74ea95 100644 --- a/libraries/stdlib/src/generated/LongArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/LongArraysFromJLangIterablesLazy.kt @@ -95,10 +95,6 @@ public inline fun LongArray?.requireNoNulls() : List { * @includeFunctionBody ../../test/CollectionTest.kt drop */ public inline fun LongArray.drop(n: Int): List { - fun countTo(n: Int): (Long) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return dropWhile(countTo(n)) } @@ -115,10 +111,6 @@ public inline fun LongArray.dropWhile(predicate: (Long) -> Boolean): List * @includeFunctionBody ../../test/CollectionTest.kt take */ public inline fun LongArray.take(n: Int): List { - fun countTo(n: Int): (Long) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return takeWhile(countTo(n)) } diff --git a/libraries/stdlib/src/generated/ShortArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/ShortArraysFromJLangIterables.kt index c017562d7ee..7637d2ce156 100644 --- a/libraries/stdlib/src/generated/ShortArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/ShortArraysFromJLangIterables.kt @@ -257,6 +257,9 @@ public inline fun ShortArray.toList() : List = toCollection(ArrayList = toCollection(ArrayList()) +/** Copies all elements into a [[Set]] */ +public inline fun ShortArray.toSet() : Set = toCollection(HashSet()) + /** TODO figure out necessary variance/generics ninja stuff... :) public inline fun ShortArray.toSortedList(transform: fun(Short) : java.lang.Comparable<*>) : List { @@ -276,9 +279,6 @@ public inline fun ShortArray.toSortedList(transform: fun(Short) : java.lang.Com import java.util.* -/** Copies all elements into a [[Set]] */ -public inline fun ShortArray.toSet() : Set = toCollection(HashSet()) - /** Copies all elements into a [[SortedSet]] */ public inline fun ShortArray.toSortedSet() : SortedSet = toCollection(TreeSet()) diff --git a/libraries/stdlib/src/generated/ShortArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/ShortArraysFromJLangIterablesLazy.kt index c974b448b78..c0ef03623ff 100644 --- a/libraries/stdlib/src/generated/ShortArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/ShortArraysFromJLangIterablesLazy.kt @@ -95,10 +95,6 @@ public inline fun ShortArray?.requireNoNulls() : List { * @includeFunctionBody ../../test/CollectionTest.kt drop */ public inline fun ShortArray.drop(n: Int): List { - fun countTo(n: Int): (Short) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return dropWhile(countTo(n)) } @@ -115,10 +111,6 @@ public inline fun ShortArray.dropWhile(predicate: (Short) -> Boolean): List { - fun countTo(n: Int): (Short) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return takeWhile(countTo(n)) } diff --git a/libraries/stdlib/src/generated/StandardFromJLangIterables.kt b/libraries/stdlib/src/generated/StandardFromJLangIterables.kt index 7fcd57a9e13..67b9b37d080 100644 --- a/libraries/stdlib/src/generated/StandardFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/StandardFromJLangIterables.kt @@ -257,6 +257,9 @@ public inline fun Iterable.toList() : List = toCollection(ArrayList /** Copies all elements into a [[List] */ public inline fun Iterable.toCollection() : Collection = toCollection(ArrayList()) +/** Copies all elements into a [[Set]] */ +public inline fun Iterable.toSet() : Set = toCollection(HashSet()) + /** TODO figure out necessary variance/generics ninja stuff... :) public inline fun Iterable.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List { @@ -276,9 +279,6 @@ public inline fun Iterable.toSortedList(transform: fun(T) : java.lang. import java.util.* -/** Copies all elements into a [[Set]] */ -public inline fun Iterable.toSet() : Set = toCollection(HashSet()) - /** Copies all elements into a [[SortedSet]] */ public inline fun Iterable.toSortedSet() : SortedSet = toCollection(TreeSet()) diff --git a/libraries/stdlib/src/generated/StandardFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/StandardFromJLangIterablesLazy.kt index c37e08dcf93..5fc38a116f0 100644 --- a/libraries/stdlib/src/generated/StandardFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/StandardFromJLangIterablesLazy.kt @@ -95,10 +95,6 @@ public inline fun Iterable?.requireNoNulls() : List { * @includeFunctionBody ../../test/CollectionTest.kt drop */ public inline fun Iterable.drop(n: Int): List { - fun countTo(n: Int): (T) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return dropWhile(countTo(n)) } @@ -115,10 +111,6 @@ public inline fun Iterable.dropWhile(predicate: (T) -> Boolean): List * @includeFunctionBody ../../test/CollectionTest.kt take */ public inline fun Iterable.take(n: Int): List { - fun countTo(n: Int): (T) -> Boolean { - var count = 0 - return { ++count; count <= n } - } return takeWhile(countTo(n)) } diff --git a/libraries/stdlib/src/kotlin/JLangIterables.kt b/libraries/stdlib/src/kotlin/JLangIterables.kt index 7ff0c93f501..b18c739f0ca 100644 --- a/libraries/stdlib/src/kotlin/JLangIterables.kt +++ b/libraries/stdlib/src/kotlin/JLangIterables.kt @@ -247,6 +247,9 @@ public inline fun java.lang.Iterable.toList() : List = toCollection /** Copies all elements into a [[List] */ public inline fun java.lang.Iterable.toCollection() : Collection = toCollection(ArrayList()) +/** Copies all elements into a [[Set]] */ +public inline fun java.lang.Iterable.toSet() : Set = toCollection(HashSet()) + /** TODO figure out necessary variance/generics ninja stuff... :) public inline fun java.lang.Iterable.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List { diff --git a/libraries/stdlib/src/kotlin/JLangIterablesJVM.kt b/libraries/stdlib/src/kotlin/JLangIterablesJVM.kt index 673adc01b52..690a90530fb 100644 --- a/libraries/stdlib/src/kotlin/JLangIterablesJVM.kt +++ b/libraries/stdlib/src/kotlin/JLangIterablesJVM.kt @@ -2,9 +2,6 @@ package kotlin import java.util.* -/** Copies all elements into a [[Set]] */ -public inline fun java.lang.Iterable.toSet() : Set = toCollection(HashSet()) - /** Copies all elements into a [[SortedSet]] */ public inline fun java.lang.Iterable.toSortedSet() : SortedSet = toCollection(TreeSet()) diff --git a/libraries/stdlib/src/kotlin/JLangIterablesLazy.kt b/libraries/stdlib/src/kotlin/JLangIterablesLazy.kt index 18a3b0a19bf..4bc0e3c72cc 100644 --- a/libraries/stdlib/src/kotlin/JLangIterablesLazy.kt +++ b/libraries/stdlib/src/kotlin/JLangIterablesLazy.kt @@ -88,11 +88,6 @@ public inline fun java.lang.Iterable.drop(n: Int): List { return dropWhile(countTo(n)) } -private fun countTo(n: Int): (T) -> Boolean { - var count = 0 - return { ++count; count <= n } -} - /** * Returns a list containing the everything but the first elements that satisfy the given *predicate* * diff --git a/libraries/stdlib/src/kotlin/JLangIterablesSpecial.kt b/libraries/stdlib/src/kotlin/JLangIterablesSpecial.kt index d4707acadc2..adc2be1e622 100644 --- a/libraries/stdlib/src/kotlin/JLangIterablesSpecial.kt +++ b/libraries/stdlib/src/kotlin/JLangIterablesSpecial.kt @@ -24,6 +24,12 @@ public fun java.lang.Iterable.count() : Int { return number } +private fun countTo(n: Int): (T) -> Boolean { + var count = 0 + return { ++count; count <= n } +} + + /** * Get the first element in the collection. *