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
+4
View File
@@ -0,0 +1,4 @@
package java.io
library
class IOException(message: String = "") : Exception() {}
+12
View File
@@ -1,5 +1,6 @@
package java.lang package java.lang
import java.io.IOException
import java.util.Iterator import java.util.Iterator
import js.library import js.library
@@ -28,3 +29,14 @@ class UnsupportedOperationException(message: String = "") : Exception() {}
library library
class NumberFormatException(message: String = "") : Exception() {} class NumberFormatException(message: String = "") : Exception() {}
public trait Comparable<T> {
fun compareTo(that: T): Int
}
public trait Appendable {
open fun append(csq: CharSequence?): Appendable?
open fun append(csq: CharSequence?, start: Int, end: Int): Appendable?
open fun append(c: Char): Appendable?
}
+46 -3
View File
@@ -28,9 +28,36 @@ val Collections = object {
// TODO should be immutable! // TODO should be immutable!
private val emptyList = ArrayList<Any>() private val emptyList = ArrayList<Any>()
private val emptyMap = HashMap<Any,Any>()
public val <T> EMPTY_LIST: List<T> public val <T> EMPTY_LIST: List<T>
get() = emptyList as List<T> get() = emptyList<T>()
public val <K,V> EMPTY_MAP: Map<K,V>
get() = emptyMap<K,V>()
public fun <T> emptyList(): List<T> = emptyList as List<T>
public fun <K,V> emptyMap(): Map<K,V> = emptyMap as Map<K,V>
public fun <in T> sort(list: List<T>): Unit {
throw UnsupportedOperationException()
}
public fun <in T> sort(list: List<T>, comparator: java.util.Comparator<T>): Unit {
throw UnsupportedOperationException()
}
public fun <T> reverse(list: List<T>): Unit {
val size = list.size()
for (i in 0.upto(size / 2)) {
val i2 = size - i
val tmp = list[i]
list[i] = list[i2]
list[i2] = tmp
}
}
} }
library library
@@ -163,6 +190,18 @@ public trait Map<K, V> {
open fun clear() : Unit open fun clear() : Unit
open fun keySet() : java.util.Set<K> open fun keySet() : java.util.Set<K>
open fun values() : java.util.Collection<V> open fun values() : java.util.Collection<V>
open fun entrySet() : java.util.Set<Entry<K, V>>
// open fun equals(o : Any?) : Boolean
// open fun hashCode() : Int
trait Entry<K, V> {
open fun getKey() : K
open fun getValue() : V
open fun setValue(value : V) : V
// open fun equals(o : Any?) : Boolean
// open fun hashCode() : Int
}
} }
library library
@@ -178,6 +217,7 @@ public open class HashMap<K, V>() : java.util.Map<K, V> {
public override fun containsValue(value : Any?) : Boolean = js.noImpl public override fun containsValue(value : Any?) : Boolean = js.noImpl
public override fun keySet() : java.util.Set<K> = js.noImpl public override fun keySet() : java.util.Set<K> = js.noImpl
public override fun values() : java.util.Collection<V> = js.noImpl public override fun values() : java.util.Collection<V> = js.noImpl
public override fun entrySet() : java.util.Set<Map.Entry<K, V>> = js.noImpl
} }
library library
@@ -200,8 +240,11 @@ public open class LinkedList<E>() : List<E> {
} }
library library
public class StringBuilder() { public class StringBuilder() : Appendable {
public fun append(obj : Any) : StringBuilder = js.noImpl override fun append(c: Char): Appendable? = js.noImpl
override fun append(csq: CharSequence?): Appendable? = js.noImpl
override fun append(csq: CharSequence?, start: Int, end: Int): Appendable? = js.noImpl
public fun append(obj : Any?) : StringBuilder = js.noImpl
public fun toString() : String = js.noImpl public fun toString() : String = js.noImpl
} }
+42
View File
@@ -0,0 +1,42 @@
package kotlin
import java.util.*
/** Returns a new ArrayList with a variable number of initial elements */
public inline fun arrayList<T>(vararg values: T) : ArrayList<T> {
val list = ArrayList<T>()
for (value in values) {
list.add(value)
}
return list
}
/**
* 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>(), 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>(), transform)
}
/**
* 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>(), transform)
}
@@ -57,6 +57,7 @@ public abstract class Config {
"/jquery/ui.kt", "/jquery/ui.kt",
"/core/javautil.kt", "/core/javautil.kt",
"/core/javalang.kt", "/core/javalang.kt",
"/core/javaio.kt",
"/core/date.kt", "/core/date.kt",
"/core/core.kt", "/core/core.kt",
"/core/math.kt", "/core/math.kt",
@@ -78,6 +79,10 @@ public abstract class Config {
*/ */
@NotNull @NotNull
public static final List<String> LIB_FILE_NAMES_DEPENDENT_ON_STDLIB = Arrays.asList( public static final List<String> LIB_FILE_NAMES_DEPENDENT_ON_STDLIB = Arrays.asList(
/**
TODO include ASAP...
"/stdlib/jutil.kt",
*/
"/stdlib/test.kt", "/stdlib/test.kt",
"/core/stringDefs.kt", "/core/stringDefs.kt",
"/core/strings.kt" "/core/strings.kt"
@@ -91,6 +96,17 @@ public abstract class Config {
@NotNull @NotNull
public static final List<String> STDLIB_FILE_NAMES = Arrays.asList( public static final List<String> STDLIB_FILE_NAMES = Arrays.asList(
"/kotlin/Preconditions.kt", "/kotlin/Preconditions.kt",
/*
TODO include ASAP - right now it generates an issue
"/kotlin/Iterators.kt",
"/kotlin/JUtil.kt",
"/kotlin/JUtilCollections.kt",
"/kotlin/JUtilMaps.kt",
"/kotlin/JLangIterables.kt",
"/kotlin/JLangIterablesLazy.kt",
"/kotlin/JLangIterablesSpecial.kt",
"/kotlin/support/AbstractIterator.kt"
*/
"/kotlin/Strings.kt", "/kotlin/Strings.kt",
"/kotlin/test/Test.kt" "/kotlin/test/Test.kt"
); );
+1
View File
@@ -37,6 +37,7 @@
Kotlin.Exceptions.IllegalStateException = Kotlin.$createClass(Kotlin.Exception); Kotlin.Exceptions.IllegalStateException = Kotlin.$createClass(Kotlin.Exception);
Kotlin.Exceptions.IndexOutOfBoundsException = Kotlin.$createClass(Kotlin.Exception); Kotlin.Exceptions.IndexOutOfBoundsException = Kotlin.$createClass(Kotlin.Exception);
Kotlin.Exceptions.UnsupportedOperationException = Kotlin.$createClass(Kotlin.Exception); Kotlin.Exceptions.UnsupportedOperationException = Kotlin.$createClass(Kotlin.Exception);
Kotlin.Exceptions.IOException = Kotlin.$createClass(Kotlin.Exception);
Kotlin.throwNPE = function() { Kotlin.throwNPE = function() {
throw Kotlin.$new(Kotlin.Exceptions.NullPointerException)(); throw Kotlin.$new(Kotlin.Exceptions.NullPointerException)();
@@ -1,3 +1,6 @@
package kotlin
import kotlin.util.*
// //
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt // Generated from input file: src/kotlin/JLangIterables.kt
// //
package kotlin
import kotlin.util.*
import java.util.* import java.util.*
@@ -232,21 +232,20 @@ public inline fun <T, C: Collection<in T>> Array<T>.takeWhileTo(result: C, predi
return result 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 * Reverses the order the elements into a list
* *
* @includeFunctionBody ../../test/CollectionTest.kt reverse * @includeFunctionBody ../../test/CollectionTest.kt reverse
*/ */
public inline fun <T> Array<T>.reverse() : List<T> { public inline fun <T> Array<T>.reverse() : List<T> {
val answer = LinkedList<T>() val list = toList()
for (element in this) answer.addFirst(element) return list.reverse()
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
} }
/** Copies all elements into a [[LinkedList]] */ /** 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] */ /** Copies all elements into a [[List] */
public inline fun <in T> Array<T>.toCollection() : Collection<T> = toCollection(ArrayList<T>()) 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... :) TODO figure out necessary variance/generics ninja stuff... :)
public inline fun <in T> Array<T>.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List<T> { 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 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt // Generated from input file: src/kotlin/JLangIterablesLazy.kt
// //
package kotlin
import kotlin.util.*
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
// //
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt // 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.* 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> { public inline fun <T, R> Array<T>.map(transform : (T) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt // Generated from input file: src/kotlin/JLangIterables.kt
// //
package kotlin
import kotlin.util.*
import java.util.* import java.util.*
@@ -232,21 +232,20 @@ public inline fun <C: Collection<Boolean>> BooleanArray.takeWhileTo(result: C, p
return result 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 * Reverses the order the elements into a list
* *
* @includeFunctionBody ../../test/CollectionTest.kt reverse * @includeFunctionBody ../../test/CollectionTest.kt reverse
*/ */
public inline fun BooleanArray.reverse() : List<Boolean> { public inline fun BooleanArray.reverse() : List<Boolean> {
val answer = LinkedList<Boolean>() val list = toList()
for (element in this) answer.addFirst(element) return list.reverse()
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
} }
/** Copies all elements into a [[LinkedList]] */ /** 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] */ /** Copies all elements into a [[List] */
public inline fun BooleanArray.toCollection() : Collection<Boolean> = toCollection(ArrayList<Boolean>()) 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... :) TODO figure out necessary variance/generics ninja stuff... :)
public inline fun BooleanArray.toSortedList(transform: fun(Boolean) : java.lang.Comparable<*>) : List<Boolean> { 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 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt // Generated from input file: src/kotlin/JLangIterablesLazy.kt
// //
package kotlin
import kotlin.util.*
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
// //
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt // 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.* import java.util.*
@@ -25,13 +52,3 @@ import java.util.*
public inline fun <R> BooleanArray.map(transform : (Boolean) -> R) : java.util.List<R> { public inline fun <R> BooleanArray.map(transform : (Boolean) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt // Generated from input file: src/kotlin/JLangIterables.kt
// //
package kotlin
import kotlin.util.*
import java.util.* import java.util.*
@@ -232,21 +232,20 @@ public inline fun <C: Collection<Byte>> ByteArray.takeWhileTo(result: C, predica
return result 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 * Reverses the order the elements into a list
* *
* @includeFunctionBody ../../test/CollectionTest.kt reverse * @includeFunctionBody ../../test/CollectionTest.kt reverse
*/ */
public inline fun ByteArray.reverse() : List<Byte> { public inline fun ByteArray.reverse() : List<Byte> {
val answer = LinkedList<Byte>() val list = toList()
for (element in this) answer.addFirst(element) return list.reverse()
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
} }
/** Copies all elements into a [[LinkedList]] */ /** 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] */ /** Copies all elements into a [[List] */
public inline fun ByteArray.toCollection() : Collection<Byte> = toCollection(ArrayList<Byte>()) 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... :) TODO figure out necessary variance/generics ninja stuff... :)
public inline fun ByteArray.toSortedList(transform: fun(Byte) : java.lang.Comparable<*>) : List<Byte> { 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 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt // Generated from input file: src/kotlin/JLangIterablesLazy.kt
// //
package kotlin
import kotlin.util.*
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
// //
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt // 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.* import java.util.*
@@ -25,13 +52,3 @@ import java.util.*
public inline fun <R> ByteArray.map(transform : (Byte) -> R) : java.util.List<R> { public inline fun <R> ByteArray.map(transform : (Byte) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt // Generated from input file: src/kotlin/JLangIterables.kt
// //
package kotlin
import kotlin.util.*
import java.util.* import java.util.*
@@ -232,21 +232,20 @@ public inline fun <C: Collection<Char>> CharArray.takeWhileTo(result: C, predica
return result 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 * Reverses the order the elements into a list
* *
* @includeFunctionBody ../../test/CollectionTest.kt reverse * @includeFunctionBody ../../test/CollectionTest.kt reverse
*/ */
public inline fun CharArray.reverse() : List<Char> { public inline fun CharArray.reverse() : List<Char> {
val answer = LinkedList<Char>() val list = toList()
for (element in this) answer.addFirst(element) return list.reverse()
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
} }
/** Copies all elements into a [[LinkedList]] */ /** 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] */ /** Copies all elements into a [[List] */
public inline fun CharArray.toCollection() : Collection<Char> = toCollection(ArrayList<Char>()) 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... :) TODO figure out necessary variance/generics ninja stuff... :)
public inline fun CharArray.toSortedList(transform: fun(Char) : java.lang.Comparable<*>) : List<Char> { 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 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt // Generated from input file: src/kotlin/JLangIterablesLazy.kt
// //
package kotlin
import kotlin.util.*
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
// //
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt // 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.* import java.util.*
@@ -25,13 +52,3 @@ import java.util.*
public inline fun <R> CharArray.map(transform : (Char) -> R) : java.util.List<R> { public inline fun <R> CharArray.map(transform : (Char) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt // Generated from input file: src/kotlin/JLangIterables.kt
// //
package kotlin
import kotlin.util.*
import java.util.* import java.util.*
@@ -232,21 +232,20 @@ public inline fun <C: Collection<Double>> DoubleArray.takeWhileTo(result: C, pre
return result 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 * Reverses the order the elements into a list
* *
* @includeFunctionBody ../../test/CollectionTest.kt reverse * @includeFunctionBody ../../test/CollectionTest.kt reverse
*/ */
public inline fun DoubleArray.reverse() : List<Double> { public inline fun DoubleArray.reverse() : List<Double> {
val answer = LinkedList<Double>() val list = toList()
for (element in this) answer.addFirst(element) return list.reverse()
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
} }
/** Copies all elements into a [[LinkedList]] */ /** 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] */ /** Copies all elements into a [[List] */
public inline fun DoubleArray.toCollection() : Collection<Double> = toCollection(ArrayList<Double>()) 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... :) TODO figure out necessary variance/generics ninja stuff... :)
public inline fun DoubleArray.toSortedList(transform: fun(Double) : java.lang.Comparable<*>) : List<Double> { 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 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt // Generated from input file: src/kotlin/JLangIterablesLazy.kt
// //
package kotlin
import kotlin.util.*
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
// //
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt // 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.* import java.util.*
@@ -25,13 +52,3 @@ import java.util.*
public inline fun <R> DoubleArray.map(transform : (Double) -> R) : java.util.List<R> { public inline fun <R> DoubleArray.map(transform : (Double) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt // Generated from input file: src/kotlin/JLangIterables.kt
// //
package kotlin
import kotlin.util.*
import java.util.* import java.util.*
@@ -232,21 +232,20 @@ public inline fun <C: Collection<Float>> FloatArray.takeWhileTo(result: C, predi
return result 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 * Reverses the order the elements into a list
* *
* @includeFunctionBody ../../test/CollectionTest.kt reverse * @includeFunctionBody ../../test/CollectionTest.kt reverse
*/ */
public inline fun FloatArray.reverse() : List<Float> { public inline fun FloatArray.reverse() : List<Float> {
val answer = LinkedList<Float>() val list = toList()
for (element in this) answer.addFirst(element) return list.reverse()
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
} }
/** Copies all elements into a [[LinkedList]] */ /** 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] */ /** Copies all elements into a [[List] */
public inline fun FloatArray.toCollection() : Collection<Float> = toCollection(ArrayList<Float>()) 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... :) TODO figure out necessary variance/generics ninja stuff... :)
public inline fun FloatArray.toSortedList(transform: fun(Float) : java.lang.Comparable<*>) : List<Float> { 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 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt // Generated from input file: src/kotlin/JLangIterablesLazy.kt
// //
package kotlin
import kotlin.util.*
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
// //
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt // 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.* import java.util.*
@@ -25,13 +52,3 @@ import java.util.*
public inline fun <R> FloatArray.map(transform : (Float) -> R) : java.util.List<R> { public inline fun <R> FloatArray.map(transform : (Float) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt // Generated from input file: src/kotlin/JLangIterables.kt
// //
package kotlin
import kotlin.util.*
import java.util.* import java.util.*
@@ -232,21 +232,20 @@ public inline fun <C: Collection<Int>> IntArray.takeWhileTo(result: C, predicate
return result 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 * Reverses the order the elements into a list
* *
* @includeFunctionBody ../../test/CollectionTest.kt reverse * @includeFunctionBody ../../test/CollectionTest.kt reverse
*/ */
public inline fun IntArray.reverse() : List<Int> { public inline fun IntArray.reverse() : List<Int> {
val answer = LinkedList<Int>() val list = toList()
for (element in this) answer.addFirst(element) return list.reverse()
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
} }
/** Copies all elements into a [[LinkedList]] */ /** 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] */ /** Copies all elements into a [[List] */
public inline fun IntArray.toCollection() : Collection<Int> = toCollection(ArrayList<Int>()) 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... :) TODO figure out necessary variance/generics ninja stuff... :)
public inline fun IntArray.toSortedList(transform: fun(Int) : java.lang.Comparable<*>) : List<Int> { 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 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt // Generated from input file: src/kotlin/JLangIterablesLazy.kt
// //
package kotlin
import kotlin.util.*
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
// //
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt // 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.* import java.util.*
@@ -25,13 +52,3 @@ import java.util.*
public inline fun <R> IntArray.map(transform : (Int) -> R) : java.util.List<R> { public inline fun <R> IntArray.map(transform : (Int) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt // 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.* 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> { public inline fun <T, R> java.lang.Iterable<T>.map(transform : (T) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(), transform) 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt // Generated from input file: src/kotlin/JLangIterables.kt
// //
package kotlin
import java.util.* import java.util.*
@@ -230,21 +230,20 @@ public inline fun <T, C: Collection<in T>> java.util.Iterator<T>.takeWhileTo(res
return result 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 * Reverses the order the elements into a list
* *
* @includeFunctionBody ../../test/CollectionTest.kt reverse * @includeFunctionBody ../../test/CollectionTest.kt reverse
*/ */
public inline fun <T> java.util.Iterator<T>.reverse() : List<T> { public inline fun <T> java.util.Iterator<T>.reverse() : List<T> {
val answer = LinkedList<T>() val list = toList()
for (element in this) answer.addFirst(element) return list.reverse()
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
} }
/** Copies all elements into a [[LinkedList]] */ /** 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] */ /** Copies all elements into a [[List] */
public inline fun <in T> java.util.Iterator<T>.toCollection() : Collection<T> = toCollection(ArrayList<T>()) 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... :) 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> { 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 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt // Generated from input file: src/kotlin/JLangIterables.kt
// //
package kotlin
import kotlin.util.*
import java.util.* import java.util.*
@@ -232,21 +232,20 @@ public inline fun <C: Collection<Long>> LongArray.takeWhileTo(result: C, predica
return result 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 * Reverses the order the elements into a list
* *
* @includeFunctionBody ../../test/CollectionTest.kt reverse * @includeFunctionBody ../../test/CollectionTest.kt reverse
*/ */
public inline fun LongArray.reverse() : List<Long> { public inline fun LongArray.reverse() : List<Long> {
val answer = LinkedList<Long>() val list = toList()
for (element in this) answer.addFirst(element) return list.reverse()
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
} }
/** Copies all elements into a [[LinkedList]] */ /** 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] */ /** Copies all elements into a [[List] */
public inline fun LongArray.toCollection() : Collection<Long> = toCollection(ArrayList<Long>()) 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... :) TODO figure out necessary variance/generics ninja stuff... :)
public inline fun LongArray.toSortedList(transform: fun(Long) : java.lang.Comparable<*>) : List<Long> { 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 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt // Generated from input file: src/kotlin/JLangIterablesLazy.kt
// //
package kotlin
import kotlin.util.*
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
// //
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt // 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.* import java.util.*
@@ -25,13 +52,3 @@ import java.util.*
public inline fun <R> LongArray.map(transform : (Long) -> R) : java.util.List<R> { public inline fun <R> LongArray.map(transform : (Long) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt // Generated from input file: src/kotlin/JLangIterables.kt
// //
package kotlin
import kotlin.util.*
import java.util.* import java.util.*
@@ -232,21 +232,20 @@ public inline fun <C: Collection<Short>> ShortArray.takeWhileTo(result: C, predi
return result 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 * Reverses the order the elements into a list
* *
* @includeFunctionBody ../../test/CollectionTest.kt reverse * @includeFunctionBody ../../test/CollectionTest.kt reverse
*/ */
public inline fun ShortArray.reverse() : List<Short> { public inline fun ShortArray.reverse() : List<Short> {
val answer = LinkedList<Short>() val list = toList()
for (element in this) answer.addFirst(element) return list.reverse()
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
} }
/** Copies all elements into a [[LinkedList]] */ /** 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] */ /** Copies all elements into a [[List] */
public inline fun ShortArray.toCollection() : Collection<Short> = toCollection(ArrayList<Short>()) 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... :) TODO figure out necessary variance/generics ninja stuff... :)
public inline fun ShortArray.toSortedList(transform: fun(Short) : java.lang.Comparable<*>) : List<Short> { 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 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt // Generated from input file: src/kotlin/JLangIterablesLazy.kt
// //
package kotlin
import kotlin.util.*
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
// //
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt // 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.* import java.util.*
@@ -25,13 +52,3 @@ import java.util.*
public inline fun <R> ShortArray.map(transform : (Short) -> R) : java.util.List<R> { public inline fun <R> ShortArray.map(transform : (Short) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterables.kt // Generated from input file: src/kotlin/JLangIterables.kt
// //
package kotlin
import kotlin.util.*
import java.util.* import java.util.*
@@ -232,21 +232,20 @@ public inline fun <T, C: Collection<in T>> Iterable<T>.takeWhileTo(result: C, pr
return result 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 * Reverses the order the elements into a list
* *
* @includeFunctionBody ../../test/CollectionTest.kt reverse * @includeFunctionBody ../../test/CollectionTest.kt reverse
*/ */
public inline fun <T> Iterable<T>.reverse() : List<T> { public inline fun <T> Iterable<T>.reverse() : List<T> {
val answer = LinkedList<T>() val list = toList()
for (element in this) answer.addFirst(element) return list.reverse()
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
} }
/** Copies all elements into a [[LinkedList]] */ /** 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] */ /** Copies all elements into a [[List] */
public inline fun <in T> Iterable<T>.toCollection() : Collection<T> = toCollection(ArrayList<T>()) 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... :) TODO figure out necessary variance/generics ninja stuff... :)
public inline fun <in T> Iterable<T>.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List<T> { 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 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 // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,9 +9,6 @@
// Generated from input file: src/kotlin/JLangIterablesLazy.kt // Generated from input file: src/kotlin/JLangIterablesLazy.kt
// //
package kotlin
import kotlin.util.*
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection import java.util.Collection
@@ -1,3 +1,4 @@
package kotlin
// //
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -6,7 +7,33 @@
// Generated from input file: src/kotlin/JUtilCollections.kt // 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.* 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> { public inline fun <T, R> Iterable<T>.map(transform : (T) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(), transform) 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) 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* * 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 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 * Reverses the order the elements into a list
* *
* @includeFunctionBody ../../test/CollectionTest.kt reverse * @includeFunctionBody ../../test/CollectionTest.kt reverse
*/ */
public inline fun <T> java.lang.Iterable<T>.reverse() : List<T> { public inline fun <T> java.lang.Iterable<T>.reverse() : List<T> {
val answer = LinkedList<T>() val list = toList()
for (element in this) answer.addFirst(element) return list.reverse()
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
} }
/** Copies all elements into a [[LinkedList]] */ /** 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] */ /** Copies all elements into a [[List] */
public inline fun <in T> java.lang.Iterable<T>.toCollection() : Collection<T> = toCollection(ArrayList<T>()) 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... :) 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> { 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 package kotlin
import java.util.* import java.util.*
import java.util.regex.Pattern
/** Returns the size of the collection */ /** Returns the size of the collection */
val Collection<*>.size : Int val Collection<*>.size : Int
@@ -11,81 +10,6 @@ val Collection<*>.size : Int
val Collection<*>.empty : Boolean val Collection<*>.empty : Boolean
get() = isEmpty() 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 val Collection<*>.indices : IntRange
get() = 0..size-1 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 */ /** Returns the Collection if its not null otherwise it returns the empty list */
public inline fun <T> java.util.Collection<T>?.orEmpty() : Collection<T> 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 */ /** 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 // 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> { public inline fun <in T: java.lang.Comparable<T>> List<T>.sort() : List<T> {
Collections.sort(this) Collections.sort(this)
return 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 */ /** 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> 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> = if (this != null) this else Collections.emptyList<T>() 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>
/** /**
TODO figure out necessary variance/generics ninja stuff... :) TODO figure out necessary variance/generics ninja stuff... :)
@@ -9,15 +9,6 @@ import java.util.*
// See [[GenerateStandardLib.kt]] for more details // 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 * Transforms each element of this collection with the given *transform* function and
* adds each return value to the given *results* collection * 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 package kotlin
import java.util.Map as JMap
import java.util.Map.Entry as JEntry
import java.util.Collection import java.util.Collection
import java.util.Collections import java.util.Collections
import java.util.HashMap import java.util.HashMap
import java.util.List import java.util.List
import java.util.LinkedHashMap import java.util.Map as JMap
import java.util.Map import java.util.Map
import java.util.TreeMap
import java.util.SortedMap
import java.util.Comparator
// Map APIs // 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]] */ /** 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> 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 */ /** 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() get() = getKey().sure()
/** Returns the value of the entry */ /** 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() 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()!! 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 * Transforms each [[Map.Entry]] in this [[Map]] with the given *transform* function and
* adds each return value to the given *results* collection * 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 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]] * 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* * 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)
}
@@ -1,24 +1,34 @@
package org.jetbrains.kotlin.tools package org.jetbrains.kotlin.tools
import java.io.* import java.io.*
import java.util.List
fun generateFile(outFile: File, header: String, inputFile: File, f: (String)-> String) { fun generateFile(outFile: File, header: String, inputFile: File, f: (String)-> String) {
println("Parsing $inputFile and writing $outFile") generateFile(outFile, header, arrayList(inputFile), f)
}
fun generateFile(outFile: File, header: String, inputFile: File, jvmFile: File, f: (String)-> String) {
generateFile(outFile, header, arrayList(inputFile, jvmFile), f)
}
fun generateFile(outFile: File, header: String, inputFiles: List<File>, f: (String)-> String) {
outFile.getParentFile()?.mkdirs() outFile.getParentFile()?.mkdirs()
val writer = PrintWriter(FileWriter(outFile)) val writer = PrintWriter(FileWriter(outFile))
try { try {
writer.println(""" writer.println(header)
for (file in inputFiles) {
writer.println("""
// //
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib // See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
// //
// Generated from input file: $inputFile // Generated from input file: $file
// //
""") """)
writer.println(header)
val reader = FileReader(inputFile).buffered() println("Parsing $file and writing $outFile")
val reader = FileReader(file).buffered()
try { try {
// TODO ideally we'd use a filterNot() here :) // TODO ideally we'd use a filterNot() here :)
val iter = reader.lineIterator() val iter = reader.lineIterator()
@@ -34,6 +44,7 @@ fun generateFile(outFile: File, header: String, inputFile: File, f: (String)-> S
reader.close() reader.close()
reader.close() reader.close()
} }
}
} finally { } finally {
writer.close() writer.close()
} }
@@ -62,7 +73,7 @@ fun main(args: Array<String>) {
val otherArrayNames = arrayList("Boolean", "Byte", "Char", "Short", "Int", "Long", "Float", "Double") val otherArrayNames = arrayList("Boolean", "Byte", "Char", "Short", "Int", "Long", "Float", "Double")
// JLangIterables - Generic iterable stuff // JLangIterables - Generic iterable stuff
generateFile(File(outDir, "ArraysFromJLangIterables.kt"), "package kotlin\n\nimport kotlin.util.*", File(srcDir, "JLangIterables.kt")) { generateFile(File(outDir, "ArraysFromJLangIterables.kt"), "package kotlin\n\nimport kotlin.util.*", File(srcDir, "JLangIterables.kt"), File(srcDir, "JLangIterablesJVM.kt")) {
it.replaceAll("java.lang.Iterable<T", "Array<T"). it.replaceAll("java.lang.Iterable<T", "Array<T").
replaceAll("java.lang.Iterable<T", "Array<T"). replaceAll("java.lang.Iterable<T", "Array<T").
replaceAll("iterator.hasNext\\(\\)", "iterator.hasNext") replaceAll("iterator.hasNext\\(\\)", "iterator.hasNext")
@@ -79,7 +90,7 @@ fun main(args: Array<String>) {
replaceAll("iterator.hasNext\\(\\)", "iterator.hasNext") replaceAll("iterator.hasNext\\(\\)", "iterator.hasNext")
} }
generateFile(File(outDir, "${arrayName}ArraysFromJLangIterables.kt"), "package kotlin\n\nimport kotlin.util.*", File(srcDir, "JLangIterables.kt")) { generateFile(File(outDir, "${arrayName}ArraysFromJLangIterables.kt"), "package kotlin\n\nimport kotlin.util.*", File(srcDir, "JLangIterables.kt"), File(srcDir, "JLangIterablesJVM.kt")) {
replace(it) replace(it)
} }
generateFile(File(outDir, "${arrayName}ArraysFromJLangIterablesLazy.kt"), "package kotlin\n\nimport kotlin.util.*", File(srcDir, "JLangIterablesLazy.kt")) { generateFile(File(outDir, "${arrayName}ArraysFromJLangIterablesLazy.kt"), "package kotlin\n\nimport kotlin.util.*", File(srcDir, "JLangIterablesLazy.kt")) {
@@ -87,7 +98,7 @@ fun main(args: Array<String>) {
} }
} }
generateFile(File(outDir, "StandardFromJLangIterables.kt"), "package kotlin\n\nimport kotlin.util.*", File(srcDir, "JLangIterables.kt")) { generateFile(File(outDir, "StandardFromJLangIterables.kt"), "package kotlin\n\nimport kotlin.util.*", File(srcDir, "JLangIterables.kt"), File(srcDir, "JLangIterablesJVM.kt")) {
it.replaceAll("java.lang.Iterable<T", "Iterable<T"). it.replaceAll("java.lang.Iterable<T", "Iterable<T").
replaceAll("iterator.hasNext\\(\\)", "iterator.hasNext") replaceAll("iterator.hasNext\\(\\)", "iterator.hasNext")
} }
@@ -95,27 +106,27 @@ fun main(args: Array<String>) {
it.replaceAll("java.lang.Iterable<T", "Iterable<T") it.replaceAll("java.lang.Iterable<T", "Iterable<T")
} }
generateFile(File(outDir, "JUtilIteratorsFromJLangIterables.kt"), "package kotlin", File(srcDir, "JLangIterables.kt")) { generateFile(File(outDir, "JUtilIteratorsFromJLangIterables.kt"), "package kotlin", File(srcDir, "JLangIterables.kt"), File(srcDir, "JLangIterablesJVM.kt")) {
it.replaceAll("java.lang.Iterable<T", "java.util.Iterator<T") it.replaceAll("java.lang.Iterable<T", "java.util.Iterator<T")
} }
// JUtilCollections - methods returning a collection of the same input size (if its a collection) // JUtilCollections - methods returning a collection of the same input size (if its a collection)
generateFile(File(outDir, "ArraysFromJUtilCollections.kt"), "package kotlin", File(srcDir, "JUtilCollections.kt")) { generateFile(File(outDir, "ArraysFromJUtilCollections.kt"), "package kotlin", File(srcDir, "JUtilCollections.kt"), File(srcDir, "JUtilCollectionsJVM.kt")) {
it.replaceAll("java.util.Collection<T", "Array<T") it.replaceAll("java.util.Collection<T", "Array<T")
} }
for (arrayName in otherArrayNames) { for (arrayName in otherArrayNames) {
generateFile(File(outDir, "${arrayName}ArraysFromJUtilCollections.kt"), "package kotlin", File(srcDir, "JUtilCollections.kt")) { generateFile(File(outDir, "${arrayName}ArraysFromJUtilCollections.kt"), "package kotlin", File(srcDir, "JUtilCollections.kt"), File(srcDir, "JUtilCollectionsJVM.kt")) {
replaceGenerics(arrayName, it.replaceAll("<T> java.util.Collection<T>", "${arrayName}Array"). replaceGenerics(arrayName, it.replaceAll("<T> java.util.Collection<T>", "${arrayName}Array").
replaceAll("java.util.Collection<T>", "${arrayName}Array")) replaceAll("java.util.Collection<T>", "${arrayName}Array"))
} }
} }
generateFile(File(outDir, "JUtilIterablesFromJUtilCollections.kt"), "package kotlin", File(srcDir, "JUtilCollections.kt")) { generateFile(File(outDir, "JUtilIterablesFromJUtilCollections.kt"), "package kotlin", File(srcDir, "JUtilCollections.kt"), File(srcDir, "JUtilCollectionsJVM.kt")) {
it.replaceAll("java.util.Collection<T", "java.lang.Iterable<T").replaceAll("(this.size)", "") it.replaceAll("java.util.Collection<T", "java.lang.Iterable<T").replaceAll("(this.size)", "")
} }
generateFile(File(outDir, "StandardFromJUtilCollections.kt"), "package kotlin", File(srcDir, "JUtilCollections.kt")) { generateFile(File(outDir, "StandardFromJUtilCollections.kt"), "package kotlin", File(srcDir, "JUtilCollections.kt"), File(srcDir, "JUtilCollectionsJVM.kt")) {
it.replaceAll("java.util.Collection<T", "Iterable<T").replaceAll("(this.size)", "") it.replaceAll("java.util.Collection<T", "Iterable<T").replaceAll("(this.size)", "")
} }
} }
+10
View File
@@ -41,6 +41,7 @@
<exclude name="dom/html/window.kt"/> <exclude name="dom/html/window.kt"/>
<exclude name="stdlib/test.kt"/> <exclude name="stdlib/test.kt"/>
<exclude name="stdlib/dom.kt"/> <exclude name="stdlib/dom.kt"/>
<exclude name="stdlib/jutil.kt"/>
</fileset> </fileset>
</copy> </copy>
<copy todir="${basedir}/target/generated-js-library"> <copy todir="${basedir}/target/generated-js-library">
@@ -67,6 +68,15 @@
</fileset> </fileset>
<fileset dir="${basedir}/../../stdlib/src/kotlin"> <fileset dir="${basedir}/../../stdlib/src/kotlin">
<include name="Preconditions.kt"/> <include name="Preconditions.kt"/>
<!--
<include name="Iterators.kt"/>
<include name="JUtil.kt"/>
<include name="JUtilCollections.kt"/>
<include name="JUtilMaps.kt"/>
<include name="JLangIterables.kt"/>
<include name="JLangIterablesLazy.kt"/>
<include name="JLangIterablesSpecial.kt"/>
-->
<!-- <!--
<include name="Ordering.kt"/> <include name="Ordering.kt"/>
--> -->