refactored the standard library so most of the collection APIs in the standard library can be compiled to JS

This commit is contained in:
James Strachan
2012-06-21 15:53:39 +01:00
parent da31a9696c
commit 8a6b752357
51 changed files with 1010 additions and 533 deletions
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt
//
package kotlin
import kotlin.util.*
import java.util.*
@@ -232,21 +232,20 @@ public inline fun <T, C: Collection<in T>> Array<T>.takeWhileTo(result: C, predi
return result
}
/** Copies all elements into the given collection */
public inline fun <in T, C: Collection<in T>> Array<T>.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
}
/**
* Reverses the order the elements into a list
*
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun <T> Array<T>.reverse() : List<T> {
val answer = LinkedList<T>()
for (element in this) answer.addFirst(element)
return answer
}
/** Copies all elements into the given collection */
public inline fun <in T, C: Collection<in T>> Array<T>.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
val list = toList()
return list.reverse()
}
/** Copies all elements into a [[LinkedList]] */
@@ -258,12 +257,6 @@ public inline fun <in T> Array<T>.toList() : List<T> = toCollection(ArrayList<T>
/** Copies all elements into a [[List] */
public inline fun <in T> Array<T>.toCollection() : Collection<T> = toCollection(ArrayList<T>())
/** Copies all elements into a [[Set]] */
public inline fun <in T> Array<T>.toSet() : Set<T> = toCollection(HashSet<T>())
/** Copies all elements into a [[SortedSet]] */
public inline fun <in T> Array<T>.toSortedSet() : SortedSet<T> = toCollection(TreeSet<T>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun <in T> Array<T>.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List<T> {
@@ -272,3 +265,20 @@ public inline fun <in T> Array<T>.toSortedList(transform: fun(T) : java.lang.Com
return answer
}
*/
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JLangIterablesJVM.kt
//
import java.util.*
/** Copies all elements into a [[Set]] */
public inline fun <in T> Array<T>.toSet() : Set<T> = toCollection(HashSet<T>())
/** Copies all elements into a [[SortedSet]] */
public inline fun <in T> Array<T>.toSortedSet() : SortedSet<T> = toCollection(TreeSet<T>())
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt
//
package kotlin
import kotlin.util.*
import java.util.ArrayList
import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt
//
package kotlin
import java.util.*
//
// This file contains methods which are optimised for working on Collection / Array collections where the size
// could be used to implement a more optimal solution
//
// See [[GenerateStandardLib.kt]] for more details
//
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <T, R, C: Collection<in R>> Array<T>.mapTo(result: C, transform : (T) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JUtilCollectionsJVM.kt
//
import java.util.*
@@ -25,13 +52,3 @@ import java.util.*
public inline fun <T, R> Array<T>.map(transform : (T) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform)
}
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <T, R, C: Collection<in R>> Array<T>.mapTo(result: C, transform : (T) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt
//
package kotlin
import kotlin.util.*
import java.util.*
@@ -232,21 +232,20 @@ public inline fun <C: Collection<Boolean>> BooleanArray.takeWhileTo(result: C, p
return result
}
/** Copies all elements into the given collection */
public inline fun <C: Collection<Boolean>> BooleanArray.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
}
/**
* Reverses the order the elements into a list
*
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun BooleanArray.reverse() : List<Boolean> {
val answer = LinkedList<Boolean>()
for (element in this) answer.addFirst(element)
return answer
}
/** Copies all elements into the given collection */
public inline fun <C: Collection<Boolean>> BooleanArray.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
val list = toList()
return list.reverse()
}
/** Copies all elements into a [[LinkedList]] */
@@ -258,12 +257,6 @@ public inline fun BooleanArray.toList() : List<Boolean> = toCollection(ArrayLis
/** Copies all elements into a [[List] */
public inline fun BooleanArray.toCollection() : Collection<Boolean> = toCollection(ArrayList<Boolean>())
/** Copies all elements into a [[Set]] */
public inline fun BooleanArray.toSet() : Set<Boolean> = toCollection(HashSet<Boolean>())
/** Copies all elements into a [[SortedSet]] */
public inline fun BooleanArray.toSortedSet() : SortedSet<Boolean> = toCollection(TreeSet<Boolean>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun BooleanArray.toSortedList(transform: fun(Boolean) : java.lang.Comparable<*>) : List<Boolean> {
@@ -272,3 +265,20 @@ public inline fun BooleanArray.toSortedList(transform: fun(Boolean) : java.lang
return answer
}
*/
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JLangIterablesJVM.kt
//
import java.util.*
/** Copies all elements into a [[Set]] */
public inline fun BooleanArray.toSet() : Set<Boolean> = toCollection(HashSet<Boolean>())
/** Copies all elements into a [[SortedSet]] */
public inline fun BooleanArray.toSortedSet() : SortedSet<Boolean> = toCollection(TreeSet<Boolean>())
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt
//
package kotlin
import kotlin.util.*
import java.util.ArrayList
import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt
//
package kotlin
import java.util.*
//
// This file contains methods which are optimised for working on Collection / Array collections where the size
// could be used to implement a more optimal solution
//
// See [[GenerateStandardLib.kt]] for more details
//
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <R, C: Collection<in R>> BooleanArray.mapTo(result: C, transform : (Boolean) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JUtilCollectionsJVM.kt
//
import java.util.*
@@ -25,13 +52,3 @@ import java.util.*
public inline fun <R> BooleanArray.map(transform : (Boolean) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform)
}
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <R, C: Collection<in R>> BooleanArray.mapTo(result: C, transform : (Boolean) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt
//
package kotlin
import kotlin.util.*
import java.util.*
@@ -232,21 +232,20 @@ public inline fun <C: Collection<Byte>> ByteArray.takeWhileTo(result: C, predica
return result
}
/** Copies all elements into the given collection */
public inline fun <C: Collection<Byte>> ByteArray.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
}
/**
* Reverses the order the elements into a list
*
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun ByteArray.reverse() : List<Byte> {
val answer = LinkedList<Byte>()
for (element in this) answer.addFirst(element)
return answer
}
/** Copies all elements into the given collection */
public inline fun <C: Collection<Byte>> ByteArray.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
val list = toList()
return list.reverse()
}
/** Copies all elements into a [[LinkedList]] */
@@ -258,12 +257,6 @@ public inline fun ByteArray.toList() : List<Byte> = toCollection(ArrayList<Byte
/** Copies all elements into a [[List] */
public inline fun ByteArray.toCollection() : Collection<Byte> = toCollection(ArrayList<Byte>())
/** Copies all elements into a [[Set]] */
public inline fun ByteArray.toSet() : Set<Byte> = toCollection(HashSet<Byte>())
/** Copies all elements into a [[SortedSet]] */
public inline fun ByteArray.toSortedSet() : SortedSet<Byte> = toCollection(TreeSet<Byte>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun ByteArray.toSortedList(transform: fun(Byte) : java.lang.Comparable<*>) : List<Byte> {
@@ -272,3 +265,20 @@ public inline fun ByteArray.toSortedList(transform: fun(Byte) : java.lang.Compa
return answer
}
*/
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JLangIterablesJVM.kt
//
import java.util.*
/** Copies all elements into a [[Set]] */
public inline fun ByteArray.toSet() : Set<Byte> = toCollection(HashSet<Byte>())
/** Copies all elements into a [[SortedSet]] */
public inline fun ByteArray.toSortedSet() : SortedSet<Byte> = toCollection(TreeSet<Byte>())
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt
//
package kotlin
import kotlin.util.*
import java.util.ArrayList
import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt
//
package kotlin
import java.util.*
//
// This file contains methods which are optimised for working on Collection / Array collections where the size
// could be used to implement a more optimal solution
//
// See [[GenerateStandardLib.kt]] for more details
//
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <R, C: Collection<in R>> ByteArray.mapTo(result: C, transform : (Byte) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JUtilCollectionsJVM.kt
//
import java.util.*
@@ -25,13 +52,3 @@ import java.util.*
public inline fun <R> ByteArray.map(transform : (Byte) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform)
}
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <R, C: Collection<in R>> ByteArray.mapTo(result: C, transform : (Byte) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt
//
package kotlin
import kotlin.util.*
import java.util.*
@@ -232,21 +232,20 @@ public inline fun <C: Collection<Char>> CharArray.takeWhileTo(result: C, predica
return result
}
/** Copies all elements into the given collection */
public inline fun <C: Collection<Char>> CharArray.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
}
/**
* Reverses the order the elements into a list
*
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun CharArray.reverse() : List<Char> {
val answer = LinkedList<Char>()
for (element in this) answer.addFirst(element)
return answer
}
/** Copies all elements into the given collection */
public inline fun <C: Collection<Char>> CharArray.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
val list = toList()
return list.reverse()
}
/** Copies all elements into a [[LinkedList]] */
@@ -258,12 +257,6 @@ public inline fun CharArray.toList() : List<Char> = toCollection(ArrayList<Char
/** Copies all elements into a [[List] */
public inline fun CharArray.toCollection() : Collection<Char> = toCollection(ArrayList<Char>())
/** Copies all elements into a [[Set]] */
public inline fun CharArray.toSet() : Set<Char> = toCollection(HashSet<Char>())
/** Copies all elements into a [[SortedSet]] */
public inline fun CharArray.toSortedSet() : SortedSet<Char> = toCollection(TreeSet<Char>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun CharArray.toSortedList(transform: fun(Char) : java.lang.Comparable<*>) : List<Char> {
@@ -272,3 +265,20 @@ public inline fun CharArray.toSortedList(transform: fun(Char) : java.lang.Compa
return answer
}
*/
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JLangIterablesJVM.kt
//
import java.util.*
/** Copies all elements into a [[Set]] */
public inline fun CharArray.toSet() : Set<Char> = toCollection(HashSet<Char>())
/** Copies all elements into a [[SortedSet]] */
public inline fun CharArray.toSortedSet() : SortedSet<Char> = toCollection(TreeSet<Char>())
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt
//
package kotlin
import kotlin.util.*
import java.util.ArrayList
import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt
//
package kotlin
import java.util.*
//
// This file contains methods which are optimised for working on Collection / Array collections where the size
// could be used to implement a more optimal solution
//
// See [[GenerateStandardLib.kt]] for more details
//
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <R, C: Collection<in R>> CharArray.mapTo(result: C, transform : (Char) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JUtilCollectionsJVM.kt
//
import java.util.*
@@ -25,13 +52,3 @@ import java.util.*
public inline fun <R> CharArray.map(transform : (Char) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform)
}
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <R, C: Collection<in R>> CharArray.mapTo(result: C, transform : (Char) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt
//
package kotlin
import kotlin.util.*
import java.util.*
@@ -232,21 +232,20 @@ public inline fun <C: Collection<Double>> DoubleArray.takeWhileTo(result: C, pre
return result
}
/** Copies all elements into the given collection */
public inline fun <C: Collection<Double>> DoubleArray.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
}
/**
* Reverses the order the elements into a list
*
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun DoubleArray.reverse() : List<Double> {
val answer = LinkedList<Double>()
for (element in this) answer.addFirst(element)
return answer
}
/** Copies all elements into the given collection */
public inline fun <C: Collection<Double>> DoubleArray.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
val list = toList()
return list.reverse()
}
/** Copies all elements into a [[LinkedList]] */
@@ -258,12 +257,6 @@ public inline fun DoubleArray.toList() : List<Double> = toCollection(ArrayList<
/** Copies all elements into a [[List] */
public inline fun DoubleArray.toCollection() : Collection<Double> = toCollection(ArrayList<Double>())
/** Copies all elements into a [[Set]] */
public inline fun DoubleArray.toSet() : Set<Double> = toCollection(HashSet<Double>())
/** Copies all elements into a [[SortedSet]] */
public inline fun DoubleArray.toSortedSet() : SortedSet<Double> = toCollection(TreeSet<Double>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun DoubleArray.toSortedList(transform: fun(Double) : java.lang.Comparable<*>) : List<Double> {
@@ -272,3 +265,20 @@ public inline fun DoubleArray.toSortedList(transform: fun(Double) : java.lang.C
return answer
}
*/
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JLangIterablesJVM.kt
//
import java.util.*
/** Copies all elements into a [[Set]] */
public inline fun DoubleArray.toSet() : Set<Double> = toCollection(HashSet<Double>())
/** Copies all elements into a [[SortedSet]] */
public inline fun DoubleArray.toSortedSet() : SortedSet<Double> = toCollection(TreeSet<Double>())
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt
//
package kotlin
import kotlin.util.*
import java.util.ArrayList
import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt
//
package kotlin
import java.util.*
//
// This file contains methods which are optimised for working on Collection / Array collections where the size
// could be used to implement a more optimal solution
//
// See [[GenerateStandardLib.kt]] for more details
//
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <R, C: Collection<in R>> DoubleArray.mapTo(result: C, transform : (Double) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JUtilCollectionsJVM.kt
//
import java.util.*
@@ -25,13 +52,3 @@ import java.util.*
public inline fun <R> DoubleArray.map(transform : (Double) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform)
}
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <R, C: Collection<in R>> DoubleArray.mapTo(result: C, transform : (Double) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt
//
package kotlin
import kotlin.util.*
import java.util.*
@@ -232,21 +232,20 @@ public inline fun <C: Collection<Float>> FloatArray.takeWhileTo(result: C, predi
return result
}
/** Copies all elements into the given collection */
public inline fun <C: Collection<Float>> FloatArray.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
}
/**
* Reverses the order the elements into a list
*
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun FloatArray.reverse() : List<Float> {
val answer = LinkedList<Float>()
for (element in this) answer.addFirst(element)
return answer
}
/** Copies all elements into the given collection */
public inline fun <C: Collection<Float>> FloatArray.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
val list = toList()
return list.reverse()
}
/** Copies all elements into a [[LinkedList]] */
@@ -258,12 +257,6 @@ public inline fun FloatArray.toList() : List<Float> = toCollection(ArrayList<Fl
/** Copies all elements into a [[List] */
public inline fun FloatArray.toCollection() : Collection<Float> = toCollection(ArrayList<Float>())
/** Copies all elements into a [[Set]] */
public inline fun FloatArray.toSet() : Set<Float> = toCollection(HashSet<Float>())
/** Copies all elements into a [[SortedSet]] */
public inline fun FloatArray.toSortedSet() : SortedSet<Float> = toCollection(TreeSet<Float>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun FloatArray.toSortedList(transform: fun(Float) : java.lang.Comparable<*>) : List<Float> {
@@ -272,3 +265,20 @@ public inline fun FloatArray.toSortedList(transform: fun(Float) : java.lang.Com
return answer
}
*/
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JLangIterablesJVM.kt
//
import java.util.*
/** Copies all elements into a [[Set]] */
public inline fun FloatArray.toSet() : Set<Float> = toCollection(HashSet<Float>())
/** Copies all elements into a [[SortedSet]] */
public inline fun FloatArray.toSortedSet() : SortedSet<Float> = toCollection(TreeSet<Float>())
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt
//
package kotlin
import kotlin.util.*
import java.util.ArrayList
import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt
//
package kotlin
import java.util.*
//
// This file contains methods which are optimised for working on Collection / Array collections where the size
// could be used to implement a more optimal solution
//
// See [[GenerateStandardLib.kt]] for more details
//
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <R, C: Collection<in R>> FloatArray.mapTo(result: C, transform : (Float) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JUtilCollectionsJVM.kt
//
import java.util.*
@@ -25,13 +52,3 @@ import java.util.*
public inline fun <R> FloatArray.map(transform : (Float) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform)
}
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <R, C: Collection<in R>> FloatArray.mapTo(result: C, transform : (Float) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt
//
package kotlin
import kotlin.util.*
import java.util.*
@@ -232,21 +232,20 @@ public inline fun <C: Collection<Int>> IntArray.takeWhileTo(result: C, predicate
return result
}
/** Copies all elements into the given collection */
public inline fun <C: Collection<Int>> IntArray.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
}
/**
* Reverses the order the elements into a list
*
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun IntArray.reverse() : List<Int> {
val answer = LinkedList<Int>()
for (element in this) answer.addFirst(element)
return answer
}
/** Copies all elements into the given collection */
public inline fun <C: Collection<Int>> IntArray.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
val list = toList()
return list.reverse()
}
/** Copies all elements into a [[LinkedList]] */
@@ -258,12 +257,6 @@ public inline fun IntArray.toList() : List<Int> = toCollection(ArrayList<Int>()
/** Copies all elements into a [[List] */
public inline fun IntArray.toCollection() : Collection<Int> = toCollection(ArrayList<Int>())
/** Copies all elements into a [[Set]] */
public inline fun IntArray.toSet() : Set<Int> = toCollection(HashSet<Int>())
/** Copies all elements into a [[SortedSet]] */
public inline fun IntArray.toSortedSet() : SortedSet<Int> = toCollection(TreeSet<Int>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun IntArray.toSortedList(transform: fun(Int) : java.lang.Comparable<*>) : List<Int> {
@@ -272,3 +265,20 @@ public inline fun IntArray.toSortedList(transform: fun(Int) : java.lang.Compara
return answer
}
*/
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JLangIterablesJVM.kt
//
import java.util.*
/** Copies all elements into a [[Set]] */
public inline fun IntArray.toSet() : Set<Int> = toCollection(HashSet<Int>())
/** Copies all elements into a [[SortedSet]] */
public inline fun IntArray.toSortedSet() : SortedSet<Int> = toCollection(TreeSet<Int>())
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt
//
package kotlin
import kotlin.util.*
import java.util.ArrayList
import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt
//
package kotlin
import java.util.*
//
// This file contains methods which are optimised for working on Collection / Array collections where the size
// could be used to implement a more optimal solution
//
// See [[GenerateStandardLib.kt]] for more details
//
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <R, C: Collection<in R>> IntArray.mapTo(result: C, transform : (Int) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JUtilCollectionsJVM.kt
//
import java.util.*
@@ -25,13 +52,3 @@ import java.util.*
public inline fun <R> IntArray.map(transform : (Int) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform)
}
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <R, C: Collection<in R>> IntArray.mapTo(result: C, transform : (Int) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
@@ -1,3 +1,4 @@
package kotlin
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt
//
package kotlin
import java.util.*
//
// This file contains methods which are optimised for working on Collection / Array collections where the size
// could be used to implement a more optimal solution
//
// See [[GenerateStandardLib.kt]] for more details
//
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <T, R, C: Collection<in R>> java.lang.Iterable<T>.mapTo(result: C, transform : (T) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JUtilCollectionsJVM.kt
//
import java.util.*
@@ -25,13 +52,3 @@ import java.util.*
public inline fun <T, R> java.lang.Iterable<T>.map(transform : (T) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(), transform)
}
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <T, R, C: Collection<in R>> java.lang.Iterable<T>.mapTo(result: C, transform : (T) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
@@ -1,3 +1,4 @@
package kotlin
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt
//
package kotlin
import java.util.*
@@ -230,21 +230,20 @@ public inline fun <T, C: Collection<in T>> java.util.Iterator<T>.takeWhileTo(res
return result
}
/** Copies all elements into the given collection */
public inline fun <in T, C: Collection<in T>> java.util.Iterator<T>.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
}
/**
* Reverses the order the elements into a list
*
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun <T> java.util.Iterator<T>.reverse() : List<T> {
val answer = LinkedList<T>()
for (element in this) answer.addFirst(element)
return answer
}
/** Copies all elements into the given collection */
public inline fun <in T, C: Collection<in T>> java.util.Iterator<T>.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
val list = toList()
return list.reverse()
}
/** Copies all elements into a [[LinkedList]] */
@@ -256,12 +255,6 @@ public inline fun <in T> java.util.Iterator<T>.toList() : List<T> = toCollection
/** Copies all elements into a [[List] */
public inline fun <in T> java.util.Iterator<T>.toCollection() : Collection<T> = toCollection(ArrayList<T>())
/** Copies all elements into a [[Set]] */
public inline fun <in T> java.util.Iterator<T>.toSet() : Set<T> = toCollection(HashSet<T>())
/** Copies all elements into a [[SortedSet]] */
public inline fun <in T> java.util.Iterator<T>.toSortedSet() : SortedSet<T> = toCollection(TreeSet<T>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun <in T> java.util.Iterator<T>.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List<T> {
@@ -270,3 +263,20 @@ public inline fun <in T> java.util.Iterator<T>.toSortedList(transform: fun(T) :
return answer
}
*/
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JLangIterablesJVM.kt
//
import java.util.*
/** Copies all elements into a [[Set]] */
public inline fun <in T> java.util.Iterator<T>.toSet() : Set<T> = toCollection(HashSet<T>())
/** Copies all elements into a [[SortedSet]] */
public inline fun <in T> java.util.Iterator<T>.toSortedSet() : SortedSet<T> = toCollection(TreeSet<T>())
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt
//
package kotlin
import kotlin.util.*
import java.util.*
@@ -232,21 +232,20 @@ public inline fun <C: Collection<Long>> LongArray.takeWhileTo(result: C, predica
return result
}
/** Copies all elements into the given collection */
public inline fun <C: Collection<Long>> LongArray.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
}
/**
* Reverses the order the elements into a list
*
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun LongArray.reverse() : List<Long> {
val answer = LinkedList<Long>()
for (element in this) answer.addFirst(element)
return answer
}
/** Copies all elements into the given collection */
public inline fun <C: Collection<Long>> LongArray.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
val list = toList()
return list.reverse()
}
/** Copies all elements into a [[LinkedList]] */
@@ -258,12 +257,6 @@ public inline fun LongArray.toList() : List<Long> = toCollection(ArrayList<Long
/** Copies all elements into a [[List] */
public inline fun LongArray.toCollection() : Collection<Long> = toCollection(ArrayList<Long>())
/** Copies all elements into a [[Set]] */
public inline fun LongArray.toSet() : Set<Long> = toCollection(HashSet<Long>())
/** Copies all elements into a [[SortedSet]] */
public inline fun LongArray.toSortedSet() : SortedSet<Long> = toCollection(TreeSet<Long>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun LongArray.toSortedList(transform: fun(Long) : java.lang.Comparable<*>) : List<Long> {
@@ -272,3 +265,20 @@ public inline fun LongArray.toSortedList(transform: fun(Long) : java.lang.Compa
return answer
}
*/
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JLangIterablesJVM.kt
//
import java.util.*
/** Copies all elements into a [[Set]] */
public inline fun LongArray.toSet() : Set<Long> = toCollection(HashSet<Long>())
/** Copies all elements into a [[SortedSet]] */
public inline fun LongArray.toSortedSet() : SortedSet<Long> = toCollection(TreeSet<Long>())
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt
//
package kotlin
import kotlin.util.*
import java.util.ArrayList
import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt
//
package kotlin
import java.util.*
//
// This file contains methods which are optimised for working on Collection / Array collections where the size
// could be used to implement a more optimal solution
//
// See [[GenerateStandardLib.kt]] for more details
//
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <R, C: Collection<in R>> LongArray.mapTo(result: C, transform : (Long) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JUtilCollectionsJVM.kt
//
import java.util.*
@@ -25,13 +52,3 @@ import java.util.*
public inline fun <R> LongArray.map(transform : (Long) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform)
}
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <R, C: Collection<in R>> LongArray.mapTo(result: C, transform : (Long) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt
//
package kotlin
import kotlin.util.*
import java.util.*
@@ -232,21 +232,20 @@ public inline fun <C: Collection<Short>> ShortArray.takeWhileTo(result: C, predi
return result
}
/** Copies all elements into the given collection */
public inline fun <C: Collection<Short>> ShortArray.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
}
/**
* Reverses the order the elements into a list
*
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun ShortArray.reverse() : List<Short> {
val answer = LinkedList<Short>()
for (element in this) answer.addFirst(element)
return answer
}
/** Copies all elements into the given collection */
public inline fun <C: Collection<Short>> ShortArray.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
val list = toList()
return list.reverse()
}
/** Copies all elements into a [[LinkedList]] */
@@ -258,12 +257,6 @@ public inline fun ShortArray.toList() : List<Short> = toCollection(ArrayList<Sh
/** Copies all elements into a [[List] */
public inline fun ShortArray.toCollection() : Collection<Short> = toCollection(ArrayList<Short>())
/** Copies all elements into a [[Set]] */
public inline fun ShortArray.toSet() : Set<Short> = toCollection(HashSet<Short>())
/** Copies all elements into a [[SortedSet]] */
public inline fun ShortArray.toSortedSet() : SortedSet<Short> = toCollection(TreeSet<Short>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun ShortArray.toSortedList(transform: fun(Short) : java.lang.Comparable<*>) : List<Short> {
@@ -272,3 +265,20 @@ public inline fun ShortArray.toSortedList(transform: fun(Short) : java.lang.Com
return answer
}
*/
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JLangIterablesJVM.kt
//
import java.util.*
/** Copies all elements into a [[Set]] */
public inline fun ShortArray.toSet() : Set<Short> = toCollection(HashSet<Short>())
/** Copies all elements into a [[SortedSet]] */
public inline fun ShortArray.toSortedSet() : SortedSet<Short> = toCollection(TreeSet<Short>())
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt
//
package kotlin
import kotlin.util.*
import java.util.ArrayList
import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt
//
package kotlin
import java.util.*
//
// This file contains methods which are optimised for working on Collection / Array collections where the size
// could be used to implement a more optimal solution
//
// See [[GenerateStandardLib.kt]] for more details
//
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <R, C: Collection<in R>> ShortArray.mapTo(result: C, transform : (Short) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JUtilCollectionsJVM.kt
//
import java.util.*
@@ -25,13 +52,3 @@ import java.util.*
public inline fun <R> ShortArray.map(transform : (Short) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform)
}
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <R, C: Collection<in R>> ShortArray.mapTo(result: C, transform : (Short) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt
//
package kotlin
import kotlin.util.*
import java.util.*
@@ -232,21 +232,20 @@ public inline fun <T, C: Collection<in T>> Iterable<T>.takeWhileTo(result: C, pr
return result
}
/** Copies all elements into the given collection */
public inline fun <in T, C: Collection<in T>> Iterable<T>.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
}
/**
* Reverses the order the elements into a list
*
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun <T> Iterable<T>.reverse() : List<T> {
val answer = LinkedList<T>()
for (element in this) answer.addFirst(element)
return answer
}
/** Copies all elements into the given collection */
public inline fun <in T, C: Collection<in T>> Iterable<T>.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
val list = toList()
return list.reverse()
}
/** Copies all elements into a [[LinkedList]] */
@@ -258,12 +257,6 @@ public inline fun <in T> Iterable<T>.toList() : List<T> = toCollection(ArrayList
/** Copies all elements into a [[List] */
public inline fun <in T> Iterable<T>.toCollection() : Collection<T> = toCollection(ArrayList<T>())
/** Copies all elements into a [[Set]] */
public inline fun <in T> Iterable<T>.toSet() : Set<T> = toCollection(HashSet<T>())
/** Copies all elements into a [[SortedSet]] */
public inline fun <in T> Iterable<T>.toSortedSet() : SortedSet<T> = toCollection(TreeSet<T>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun <in T> Iterable<T>.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List<T> {
@@ -272,3 +265,20 @@ public inline fun <in T> Iterable<T>.toSortedList(transform: fun(T) : java.lang.
return answer
}
*/
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JLangIterablesJVM.kt
//
import java.util.*
/** Copies all elements into a [[Set]] */
public inline fun <in T> Iterable<T>.toSet() : Set<T> = toCollection(HashSet<T>())
/** Copies all elements into a [[SortedSet]] */
public inline fun <in T> Iterable<T>.toSortedSet() : SortedSet<T> = toCollection(TreeSet<T>())
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt
//
package kotlin
import kotlin.util.*
import java.util.ArrayList
import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt
//
package kotlin
import java.util.*
//
// This file contains methods which are optimised for working on Collection / Array collections where the size
// could be used to implement a more optimal solution
//
// See [[GenerateStandardLib.kt]] for more details
//
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <T, R, C: Collection<in R>> Iterable<T>.mapTo(result: C, transform : (T) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
// Generated from input file: src/kotlin/JUtilCollectionsJVM.kt
//
import java.util.*
@@ -25,13 +52,3 @@ import java.util.*
public inline fun <T, R> Iterable<T>.map(transform : (T) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(), transform)
}
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
*/
public inline fun <T, R, C: Collection<in R>> Iterable<T>.mapTo(result: C, transform : (T) -> R) : C {
for (item in this)
result.add(transform(item))
return result
}
-16
View File
@@ -10,22 +10,6 @@ import java.util.Collections
*/
public inline fun <T> iterate(nextFunction: () -> T?) : java.util.Iterator<T> = FunctionIterator(nextFunction)
/** Returns an iterator over elements that are instances of a given type *R* which is a subclass of *T* */
public inline fun <T, R: T> java.util.Iterator<T>.filterIsInstance(klass: Class<R>): java.util.Iterator<R> = FilterIsIterator<T,R>(this, klass)
private class FilterIsIterator<T, R :T>(val iterator : java.util.Iterator<T>, val klass: Class<R>) : AbstractIterator<R>() {
override protected fun computeNext(): Unit {
while (iterator.hasNext()) {
val next = iterator.next()
if (klass.isInstance(next)) {
setNext(next as R)
return
}
}
done()
}
}
/**
* Returns an iterator over elements which match the given *predicate*
*
@@ -0,0 +1,21 @@
package kotlin
import kotlin.support.*
import java.util.Collections
/** Returns an iterator over elements that are instances of a given type *R* which is a subclass of *T* */
public inline fun <T, R: T> java.util.Iterator<T>.filterIsInstance(klass: Class<R>): java.util.Iterator<R> = FilterIsIterator<T,R>(this, klass)
private class FilterIsIterator<T, R :T>(val iterator : java.util.Iterator<T>, val klass: Class<R>) : AbstractIterator<R>() {
override protected fun computeNext(): Unit {
while (iterator.hasNext()) {
val next = iterator.next()
if (klass.isInstance(next)) {
setNext(next as R)
return
}
}
done()
}
}
+8 -15
View File
@@ -222,21 +222,20 @@ public inline fun <T, C: Collection<in T>> java.lang.Iterable<T>.takeWhileTo(res
return result
}
/** Copies all elements into the given collection */
public inline fun <in T, C: Collection<in T>> java.lang.Iterable<T>.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
}
/**
* Reverses the order the elements into a list
*
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun <T> java.lang.Iterable<T>.reverse() : List<T> {
val answer = LinkedList<T>()
for (element in this) answer.addFirst(element)
return answer
}
/** Copies all elements into the given collection */
public inline fun <in T, C: Collection<in T>> java.lang.Iterable<T>.toCollection(result: C) : C {
for (element in this) result.add(element)
return result
val list = toList()
return list.reverse()
}
/** Copies all elements into a [[LinkedList]] */
@@ -248,12 +247,6 @@ public inline fun <in T> java.lang.Iterable<T>.toList() : List<T> = toCollection
/** Copies all elements into a [[List] */
public inline fun <in T> java.lang.Iterable<T>.toCollection() : Collection<T> = toCollection(ArrayList<T>())
/** Copies all elements into a [[Set]] */
public inline fun <in T> java.lang.Iterable<T>.toSet() : Set<T> = toCollection(HashSet<T>())
/** Copies all elements into a [[SortedSet]] */
public inline fun <in T> java.lang.Iterable<T>.toSortedSet() : SortedSet<T> = toCollection(TreeSet<T>())
/**
TODO figure out necessary variance/generics ninja stuff... :)
public inline fun <in T> java.lang.Iterable<T>.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List<T> {
@@ -0,0 +1,10 @@
package kotlin
import java.util.*
/** Copies all elements into a [[Set]] */
public inline fun <in T> java.lang.Iterable<T>.toSet() : Set<T> = toCollection(HashSet<T>())
/** Copies all elements into a [[SortedSet]] */
public inline fun <in T> java.lang.Iterable<T>.toSortedSet() : SortedSet<T> = toCollection(TreeSet<T>())
+12 -82
View File
@@ -1,7 +1,6 @@
package kotlin
import java.util.*
import java.util.regex.Pattern
/** Returns the size of the collection */
val Collection<*>.size : Int
@@ -11,81 +10,6 @@ val Collection<*>.size : Int
val Collection<*>.empty : Boolean
get() = isEmpty()
/** Returns a new ArrayList with a variable number of initial elements */
public inline fun arrayList<T>(vararg values: T) : ArrayList<T> = values.toCollection(ArrayList<T>(values.size))
/** Returns a new LinkedList with a variable number of initial elements */
public inline fun linkedList<T>(vararg values: T) : LinkedList<T> = values.toCollection(LinkedList<T>())
/** Returns a new HashSet with a variable number of initial elements */
public inline fun hashSet<T>(vararg values: T) : HashSet<T> = values.toCollection(HashSet<T>(values.size))
/**
* Returns a new [[SortedSet]] with the initial elements
*/
public inline fun sortedSet<T>(vararg values: T) : TreeSet<T> = values.toCollection(TreeSet<T>())
/**
* Returns a new [[SortedSet]] with the given *comparator* and the initial elements
*/
public inline fun sortedSet<T>(comparator: Comparator<T>, vararg values: T) : TreeSet<T> = values.toCollection(TreeSet<T>(comparator))
/**
* Returns a new [[HashMap]] populated with the given tuple values where the first value in each tuple
* is the key and the second value is the value
*
* @includeFunctionBody ../../test/MapTest.kt createUsingTuples
*/
public inline fun <K,V> hashMap(vararg values: #(K,V)): HashMap<K,V> {
val answer = HashMap<K,V>(values.size)
/**
TODO replace by this simpler call when we can pass vararg values into other methods
answer.putAll(values)
*/
for (v in values) {
answer.put(v._1, v._2)
}
return answer
}
/**
* Returns a new [[SortedMap]] populated with the given tuple values where the first value in each tuple
* is the key and the second value is the value
*
* @includeFunctionBody ../../test/MapTest.kt createSortedMap
*/
public inline fun <K,V> sortedMap(vararg values: #(K,V)): SortedMap<K,V> {
val answer = TreeMap<K,V>()
/**
TODO replace by this simpler call when we can pass vararg values into other methods
answer.putAll(values)
*/
for (v in values) {
answer.put(v._1, v._2)
}
return answer
}
/**
* Returns a new [[LinkedHashMap]] populated with the given tuple values where the first value in each tuple
* is the key and the second value is the value. This map preserves insertion order so iterating through
* the map's entries will be in the same order
*
* @includeFunctionBody ../../test/MapTest.kt createLinkedMap
*/
public inline fun <K,V> linkedMap(vararg values: #(K,V)): LinkedHashMap<K,V> {
val answer = LinkedHashMap<K,V>(values.size)
/**
TODO replace by this simpler call when we can pass vararg values into other methods
answer.putAll(values)
*/
for (v in values) {
answer.put(v._1, v._2)
}
return answer
}
val Collection<*>.indices : IntRange
get() = 0..size-1
@@ -105,7 +29,7 @@ public inline fun <T> java.util.Collection<T>.notEmpty() : Boolean = !this.isEmp
/** Returns the Collection if its not null otherwise it returns the empty list */
public inline fun <T> java.util.Collection<T>?.orEmpty() : Collection<T>
= if (this != null) this else Collections.EMPTY_LIST as Collection<T>
= if (this != null) this else Collections.emptyList<T>() as Collection<T>
/** TODO these functions don't work when they generate the Array<T> versions when they are in JLIterables */
@@ -116,6 +40,16 @@ public inline fun <in T: java.lang.Comparable<T>> java.lang.Iterable<T>.toSorted
// List APIs
/**
* Reverses the order the elements into a list
*
* @includeFunctionBody ../../test/CollectionTest.kt reverse
*/
public inline fun <T> List<T>.reverse() : List<T> {
Collections.reverse(this)
return this
}
public inline fun <in T: java.lang.Comparable<T>> List<T>.sort() : List<T> {
Collections.sort(this)
return this
@@ -128,11 +62,7 @@ public inline fun <in T> List<T>.sort(comparator: java.util.Comparator<T>) : Lis
/** Returns the List if its not null otherwise returns the empty list */
public inline fun <T> java.util.List<T>?.orEmpty() : java.util.List<T>
= if (this != null) this else Collections.EMPTY_LIST as java.util.List<T>
/** Returns the Set if its not null otherwise returns the empty set */
public inline fun <T> java.util.Set<T>?.orEmpty() : java.util.Set<T>
= if (this != null) this else Collections.EMPTY_SET as java.util.Set<T>
= if (this != null) this else Collections.emptyList<T>() as java.util.List<T>
/**
TODO figure out necessary variance/generics ninja stuff... :)
@@ -9,15 +9,6 @@ import java.util.*
// See [[GenerateStandardLib.kt]] for more details
//
/**
* Returns a new List containing the results of applying the given *transform* function to each element in this collection
*
* @includeFunctionBody ../../test/CollectionTest.kt map
*/
public inline fun <T, R> java.util.Collection<T>.map(transform : (T) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform)
}
/**
* Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection
@@ -0,0 +1,19 @@
package kotlin
import java.util.*
//
// This file contains methods which are optimised for working on Collection / Array collections where the size
// could be used to implement a more optimal solution
//
// See [[GenerateStandardLib.kt]] for more details
//
/**
* Returns a new List containing the results of applying the given *transform* function to each element in this collection
*
* @includeFunctionBody ../../test/CollectionTest.kt map
*/
public inline fun <T, R> java.util.Collection<T>.map(transform : (T) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform)
}
+85
View File
@@ -0,0 +1,85 @@
package kotlin
import java.util.*
/** Returns a new LinkedList with a variable number of initial elements */
public inline fun linkedList<T>(vararg values: T) : LinkedList<T> = values.toCollection(LinkedList<T>())
/** Returns a new HashSet with a variable number of initial elements */
public inline fun hashSet<T>(vararg values: T) : HashSet<T> = values.toCollection(HashSet<T>(values.size))
/**
* Returns a new [[SortedSet]] with the initial elements
*/
public inline fun sortedSet<T>(vararg values: T) : TreeSet<T> = values.toCollection(TreeSet<T>())
/**
* Returns a new [[SortedSet]] with the given *comparator* and the initial elements
*/
public inline fun sortedSet<T>(comparator: Comparator<T>, vararg values: T) : TreeSet<T> = values.toCollection(TreeSet<T>(comparator))
/**
* Returns a new [[HashMap]] populated with the given tuple values where the first value in each tuple
* is the key and the second value is the value
*
* @includeFunctionBody ../../test/MapTest.kt createUsingTuples
*/
public inline fun <K,V> hashMap(vararg values: #(K,V)): HashMap<K,V> {
val answer = HashMap<K,V>(values.size)
/**
TODO replace by this simpler call when we can pass vararg values into other methods
answer.putAll(values)
*/
for (v in values) {
answer.put(v._1, v._2)
}
return answer
}
/**
* Returns a new [[SortedMap]] populated with the given tuple values where the first value in each tuple
* is the key and the second value is the value
*
* @includeFunctionBody ../../test/MapTest.kt createSortedMap
*/
public inline fun <K,V> sortedMap(vararg values: #(K,V)): SortedMap<K,V> {
val answer = TreeMap<K,V>()
/**
TODO replace by this simpler call when we can pass vararg values into other methods
answer.putAll(values)
*/
for (v in values) {
answer.put(v._1, v._2)
}
return answer
}
/**
* Returns a new [[LinkedHashMap]] populated with the given tuple values where the first value in each tuple
* is the key and the second value is the value. This map preserves insertion order so iterating through
* the map's entries will be in the same order
*
* @includeFunctionBody ../../test/MapTest.kt createLinkedMap
*/
public inline fun <K,V> linkedMap(vararg values: #(K,V)): LinkedHashMap<K,V> {
val answer = LinkedHashMap<K,V>(values.size)
/**
TODO replace by this simpler call when we can pass vararg values into other methods
answer.putAll(values)
*/
for (v in values) {
answer.put(v._1, v._2)
}
return answer
}
/** Returns the Set if its not null otherwise returns the empty set */
public inline fun <T> java.util.Set<T>?.orEmpty() : java.util.Set<T>
= if (this != null) this else Collections.EMPTY_SET as java.util.Set<T>
/** Returns a new ArrayList with a variable number of initial elements */
public inline fun arrayList<T>(vararg values: T) : ArrayList<T> = values.toCollection(ArrayList<T>(values.size))
+4 -48
View File
@@ -1,16 +1,11 @@
package kotlin
import java.util.Map as JMap
import java.util.Map.Entry as JEntry
import java.util.Collection
import java.util.Collections
import java.util.HashMap
import java.util.List
import java.util.LinkedHashMap
import java.util.Map as JMap
import java.util.Map
import java.util.TreeMap
import java.util.SortedMap
import java.util.Comparator
// Map APIs
@@ -27,15 +22,15 @@ public fun <K, V> JMap<K, V>.set(key : K, value : V) : V? = this.put(key, value)
/** Returns the [[Map]] if its not null otherwise it returns the empty [[Map]] */
public inline fun <K,V> java.util.Map<K,V>?.orEmpty() : java.util.Map<K,V>
= if (this != null) this else Collections.EMPTY_MAP as java.util.Map<K,V>
= if (this != null) this else Collections.emptyMap<K,V>() as java.util.Map<K,V>
/** Returns the key of the entry */
val <K,V> JEntry<K,V>.key : K
val <K,V> Map.Entry<K,V>.key : K
get() = getKey().sure()
/** Returns the value of the entry */
val <K,V> JEntry<K,V>.value : V
val <K,V> Map.Entry<K,V>.value : V
get() = getValue().sure()
/**
@@ -79,15 +74,6 @@ public inline fun <K,V> java.util.Map<K,V>.iterator(): java.util.Iterator<java.u
return entrySet.iterator()!!
}
/**
* Returns a new List containing the results of applying the given *transform* function to each [[Map.Entry]] in this [[Map]]
*
* @includeFunctionBody ../../test/CollectionTest.kt map
*/
public inline fun <K,V,R> java.util.Map<K,V>.map(transform: (java.util.Map.Entry<K,V>) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform)
}
/**
* Transforms each [[Map.Entry]] in this [[Map]] with the given *transform* function and
* adds each return value to the given *results* collection
@@ -98,16 +84,6 @@ public inline fun <K,V,R, C: Collection<in R>> java.util.Map<K,V>.mapTo(result:
return result
}
/**
* Returns a new Map containing the results of applying the given *transform* function to each [[Map.Entry]] in this [[Map]]
*
* @includeFunctionBody ../../test/MapTest.kt mapValues
*/
public inline fun <K,V,R> java.util.Map<K,V>.mapValues(transform : (java.util.Map.Entry<K,V>) -> R): java.util.Map<K,R> {
return mapValuesTo(java.util.HashMap<K,R>(this.size), transform)
}
/**
* Populates the given *result* [[Map]] with the value returned by applying the *transform* function on each [[Map.Entry]] in this [[Map]]
*/
@@ -128,26 +104,6 @@ public inline fun <K,V> java.util.Map<K,V>.putAll(vararg values: #(K,V)): Unit {
}
}
/**
* Converts this [[Map]] to a [[LinkedHashMap]] so future insertion orders are maintained
*/
public inline fun <K,V> java.util.Map<K,V>.toLinkedMap(): LinkedHashMap<K,V> = toMap<K,V>(LinkedHashMap(size)) as LinkedHashMap<K,V>
/**
* Converts this [[Map]] to a [[SortedMap]] so iteration order will be in key order
*
* @includeFunctionBody ../../test/MapTest.kt toSortedMap
*/
public inline fun <K,V> java.util.Map<K,V>.toSortedMap(): SortedMap<K,V> = toMap<K,V>(TreeMap()) as SortedMap<K,V>
/**
* Converts this [[Map]] to a [[SortedMap]] using the given *comparator* so that iteration order will be in the order
* defined by the comparator
*
* @includeFunctionBody ../../test/MapTest.kt toSortedMapWithComparator
*/
public inline fun <K,V> java.util.Map<K,V>.toSortedMap(comparator: Comparator<K>): SortedMap<K,V> = toMap<K,V>(TreeMap(comparator)) as SortedMap<K,V>
/**
* Copies the entries in this [[Map]] to the given *map*
*/
@@ -0,0 +1,52 @@
package kotlin
import java.util.Comparator
import java.util.LinkedHashMap
import java.util.Map as JMap
import java.util.Map
import java.util.Map.Entry as JEntry
import java.util.SortedMap
import java.util.TreeMap
// Map APIs
/**
* Converts this [[Map]] to a [[LinkedHashMap]] so future insertion orders are maintained
*/
public inline fun <K,V> java.util.Map<K,V>.toLinkedMap(): LinkedHashMap<K,V> = toMap<K,V>(LinkedHashMap(size)) as LinkedHashMap<K,V>
/**
* Converts this [[Map]] to a [[SortedMap]] so iteration order will be in key order
*
* @includeFunctionBody ../../test/MapTest.kt toSortedMap
*/
public inline fun <K,V> java.util.Map<K,V>.toSortedMap(): SortedMap<K,V> = toMap<K,V>(TreeMap()) as SortedMap<K,V>
/**
* Converts this [[Map]] to a [[SortedMap]] using the given *comparator* so that iteration order will be in the order
* defined by the comparator
*
* @includeFunctionBody ../../test/MapTest.kt toSortedMapWithComparator
*/
public inline fun <K,V> java.util.Map<K,V>.toSortedMap(comparator: Comparator<K>): SortedMap<K,V> = toMap<K,V>(TreeMap(comparator)) as SortedMap<K,V>
/**
* Returns a new List containing the results of applying the given *transform* function to each [[Map.Entry]] in this [[Map]]
*
* @includeFunctionBody ../../test/CollectionTest.kt map
*/
public inline fun <K,V,R> java.util.Map<K,V>.map(transform: (java.util.Map.Entry<K,V>) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform)
}
/**
* Returns a new Map containing the results of applying the given *transform* function to each [[Map.Entry]] in this [[Map]]
*
* @includeFunctionBody ../../test/MapTest.kt mapValues
*/
public inline fun <K,V,R> java.util.Map<K,V>.mapValues(transform : (java.util.Map.Entry<K,V>) -> R): java.util.Map<K,R> {
return mapValuesTo(java.util.HashMap<K,R>(this.size), transform)
}