From b4dace2c296c1a0508b557319eaeeaf65cffa3dd Mon Sep 17 00:00:00 2001 From: James Strachan Date: Thu, 5 Jul 2012 15:49:10 +0100 Subject: [PATCH] added a native array() function for the JS generation; also refactored the code generated collection APIs so that most of them can be used with JavaScript and included more array based APIs into the JS generation --- js/js.libraries/src/core/kotlin.kt | 4 + js/js.translator/testFiles/kotlin_lib.js | 10 ++ .../src/generated/ArraysFromJLangIterables.kt | 31 ++--- .../generated/ArraysFromJLangIterablesJVM.kt | 16 +++ .../generated/ArraysFromJLangIterablesLazy.kt | 1 - .../generated/ArraysFromJUtilCollections.kt | 26 ---- .../ArraysFromJUtilCollectionsJVM.kt | 27 ++++ .../BooleanArraysFromJLangIterables.kt | 31 ++--- .../BooleanArraysFromJLangIterablesJVM.kt | 16 +++ .../BooleanArraysFromJLangIterablesLazy.kt | 1 - .../BooleanArraysFromJUtilCollections.kt | 26 ---- .../BooleanArraysFromJUtilCollectionsJVM.kt | 27 ++++ .../generated/ByteArraysFromJLangIterables.kt | 31 ++--- .../ByteArraysFromJLangIterablesJVM.kt | 16 +++ .../ByteArraysFromJLangIterablesLazy.kt | 1 - .../ByteArraysFromJUtilCollections.kt | 26 ---- .../ByteArraysFromJUtilCollectionsJVM.kt | 27 ++++ .../generated/CharArraysFromJLangIterables.kt | 31 ++--- .../CharArraysFromJLangIterablesJVM.kt | 16 +++ .../CharArraysFromJLangIterablesLazy.kt | 1 - .../CharArraysFromJUtilCollections.kt | 26 ---- .../CharArraysFromJUtilCollectionsJVM.kt | 27 ++++ .../DoubleArraysFromJLangIterables.kt | 31 ++--- .../DoubleArraysFromJLangIterablesJVM.kt | 16 +++ .../DoubleArraysFromJLangIterablesLazy.kt | 1 - .../DoubleArraysFromJUtilCollections.kt | 26 ---- .../DoubleArraysFromJUtilCollectionsJVM.kt | 27 ++++ .../FloatArraysFromJLangIterables.kt | 31 ++--- .../FloatArraysFromJLangIterablesJVM.kt | 16 +++ .../FloatArraysFromJLangIterablesLazy.kt | 1 - .../FloatArraysFromJUtilCollections.kt | 26 ---- .../FloatArraysFromJUtilCollectionsJVM.kt | 27 ++++ .../generated/IntArraysFromJLangIterables.kt | 31 ++--- .../IntArraysFromJLangIterablesJVM.kt | 16 +++ .../IntArraysFromJLangIterablesLazy.kt | 1 - .../IntArraysFromJUtilCollections.kt | 26 ---- .../IntArraysFromJUtilCollectionsJVM.kt | 27 ++++ .../JUtilIteratorsFromJLangIterables.kt | 16 ++- .../generated/LongArraysFromJLangIterables.kt | 31 ++--- .../LongArraysFromJLangIterablesJVM.kt | 16 +++ .../LongArraysFromJLangIterablesLazy.kt | 1 - .../LongArraysFromJUtilCollections.kt | 26 ---- .../LongArraysFromJUtilCollectionsJVM.kt | 27 ++++ .../ShortArraysFromJLangIterables.kt | 31 ++--- .../ShortArraysFromJLangIterablesJVM.kt | 16 +++ .../ShortArraysFromJLangIterablesLazy.kt | 1 - .../ShortArraysFromJUtilCollections.kt | 26 ---- .../ShortArraysFromJUtilCollectionsJVM.kt | 27 ++++ .../generated/StandardFromJLangIterables.kt | 31 ++--- .../StandardFromJLangIterablesJVM.kt | 16 +++ .../StandardFromJLangIterablesLazy.kt | 1 - .../generated/StandardFromJUtilCollections.kt | 26 ---- .../StandardFromJUtilCollectionsJVM.kt | 27 ++++ libraries/stdlib/src/kotlin/Arrays.kt | 118 ------------------ libraries/stdlib/src/kotlin/ArraysJVM.kt | 115 +++++++++++++++++ libraries/stdlib/test/js/JsArrayTest.kt | 22 ++++ .../kotlin/tools/GenerateStandardLib.kt | 40 ++++-- libraries/tools/kotlin-js-library/pom.xml | 5 + libraries/tools/kotlin-js-tests/pom.xml | 6 + 59 files changed, 744 insertions(+), 602 deletions(-) create mode 100644 libraries/stdlib/src/generated/ArraysFromJLangIterablesJVM.kt create mode 100644 libraries/stdlib/src/generated/ArraysFromJUtilCollectionsJVM.kt create mode 100644 libraries/stdlib/src/generated/BooleanArraysFromJLangIterablesJVM.kt create mode 100644 libraries/stdlib/src/generated/BooleanArraysFromJUtilCollectionsJVM.kt create mode 100644 libraries/stdlib/src/generated/ByteArraysFromJLangIterablesJVM.kt create mode 100644 libraries/stdlib/src/generated/ByteArraysFromJUtilCollectionsJVM.kt create mode 100644 libraries/stdlib/src/generated/CharArraysFromJLangIterablesJVM.kt create mode 100644 libraries/stdlib/src/generated/CharArraysFromJUtilCollectionsJVM.kt create mode 100644 libraries/stdlib/src/generated/DoubleArraysFromJLangIterablesJVM.kt create mode 100644 libraries/stdlib/src/generated/DoubleArraysFromJUtilCollectionsJVM.kt create mode 100644 libraries/stdlib/src/generated/FloatArraysFromJLangIterablesJVM.kt create mode 100644 libraries/stdlib/src/generated/FloatArraysFromJUtilCollectionsJVM.kt create mode 100644 libraries/stdlib/src/generated/IntArraysFromJLangIterablesJVM.kt create mode 100644 libraries/stdlib/src/generated/IntArraysFromJUtilCollectionsJVM.kt create mode 100644 libraries/stdlib/src/generated/LongArraysFromJLangIterablesJVM.kt create mode 100644 libraries/stdlib/src/generated/LongArraysFromJUtilCollectionsJVM.kt create mode 100644 libraries/stdlib/src/generated/ShortArraysFromJLangIterablesJVM.kt create mode 100644 libraries/stdlib/src/generated/ShortArraysFromJUtilCollectionsJVM.kt create mode 100644 libraries/stdlib/src/generated/StandardFromJLangIterablesJVM.kt create mode 100644 libraries/stdlib/src/generated/StandardFromJUtilCollectionsJVM.kt create mode 100644 libraries/stdlib/src/kotlin/ArraysJVM.kt create mode 100644 libraries/stdlib/test/js/JsArrayTest.kt diff --git a/js/js.libraries/src/core/kotlin.kt b/js/js.libraries/src/core/kotlin.kt index 1cc381ad6d3..f5f87f3f79a 100644 --- a/js/js.libraries/src/core/kotlin.kt +++ b/js/js.libraries/src/core/kotlin.kt @@ -4,3 +4,7 @@ import java.util.* library("comparator") public fun comparator(f : (T, T) -> Int) : Comparator = js.noImpl + +library("array") +public fun array(vararg value: T): Array = js.noImpl + diff --git a/js/js.translator/testFiles/kotlin_lib.js b/js/js.translator/testFiles/kotlin_lib.js index 6521bb8111b..3e3676b9b03 100644 --- a/js/js.translator/testFiles/kotlin_lib.js +++ b/js/js.translator/testFiles/kotlin_lib.js @@ -31,6 +31,16 @@ var kotlin = {set:function (receiver, key, value) { return obj1 === obj2; }; + Kotlin.array = function (args) { + var answer = []; + if (args !== null && args !== undefined) { + for (var i = 0, n = args.length; i < n; ++i) { + answer[i] = args[i] + } + } + return answer; + }; + Kotlin.modules = {}; Kotlin.Exceptions = {}; Kotlin.Exception = Kotlin.$createClass(); diff --git a/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt index c5794f3a888..76f4e48198d 100644 --- a/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt @@ -184,21 +183,27 @@ public inline fun Array.reduceRight(operation: (T, T) -> T): T = reverse( */ public inline fun Array.groupBy(toKey: (T) -> K) : Map> = groupByTo(HashMap>(), toKey) +/** + * Groups the elements in the collection into the given [[Map]] using the supplied *toKey* function to calculate the key to group the elements by + * + * @includeFunctionBody ../../test/CollectionTest.kt groupBy + */ public inline fun Array.groupByTo(result: Map>, toKey: (T) -> K) : Map> { for (element in this) { val key = toKey(element) val list = result.getOrPut(key) { ArrayList() } list.add(element) - - val some = key - val more = some - val onceMore = more - val again = println(more) } return result } /** + * Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied. + * + * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will + * a special *truncated* separator (which defaults to "..." + * + * @includeFunctionBody ../../test/CollectionTest.kt makeString */ public inline fun Array.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() @@ -263,17 +268,3 @@ public inline fun Array.toSortedList(transform: fun(T) : java.lang.Com return answer } */ - -// -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt -// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib -// -// Generated from input file: src/kotlin/JLangIterablesJVM.kt -// - - -import java.util.* - -/** Copies all elements into a [[SortedSet]] */ -public inline fun Array.toSortedSet() : SortedSet = toCollection(TreeSet()) - diff --git a/libraries/stdlib/src/generated/ArraysFromJLangIterablesJVM.kt b/libraries/stdlib/src/generated/ArraysFromJLangIterablesJVM.kt new file mode 100644 index 00000000000..9b6d60ff6aa --- /dev/null +++ b/libraries/stdlib/src/generated/ArraysFromJLangIterablesJVM.kt @@ -0,0 +1,16 @@ +package kotlin + + +// +// 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 [[SortedSet]] */ +public inline fun Array.toSortedSet() : SortedSet = toCollection(TreeSet()) + diff --git a/libraries/stdlib/src/generated/ArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/ArraysFromJLangIterablesLazy.kt index 929ba6fd8c9..56ff531f204 100644 --- a/libraries/stdlib/src/generated/ArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/ArraysFromJLangIterablesLazy.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt diff --git a/libraries/stdlib/src/generated/ArraysFromJUtilCollections.kt b/libraries/stdlib/src/generated/ArraysFromJUtilCollections.kt index 577a824017c..654f8cfd992 100644 --- a/libraries/stdlib/src/generated/ArraysFromJUtilCollections.kt +++ b/libraries/stdlib/src/generated/ArraysFromJUtilCollections.kt @@ -26,29 +26,3 @@ public inline fun > Array.mapTo(result: C, transfor 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.* - -// -// 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 Array.map(transform : (T) -> R) : java.util.List { - return mapTo(java.util.ArrayList(this.size), transform) -} diff --git a/libraries/stdlib/src/generated/ArraysFromJUtilCollectionsJVM.kt b/libraries/stdlib/src/generated/ArraysFromJUtilCollectionsJVM.kt new file mode 100644 index 00000000000..cc14f9f97a2 --- /dev/null +++ b/libraries/stdlib/src/generated/ArraysFromJUtilCollectionsJVM.kt @@ -0,0 +1,27 @@ +package kotlin + +// +// 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.* + +// +// 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 Array.map(transform : (T) -> R) : java.util.List { + return mapTo(java.util.ArrayList(this.size), transform) +} diff --git a/libraries/stdlib/src/generated/BooleanArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/BooleanArraysFromJLangIterables.kt index d8da94ea2fe..f9455728249 100644 --- a/libraries/stdlib/src/generated/BooleanArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/BooleanArraysFromJLangIterables.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt @@ -184,21 +183,27 @@ public inline fun BooleanArray.reduceRight(operation: (Boolean, Boolean) -> Bool */ public inline fun BooleanArray.groupBy(toKey: (Boolean) -> K) : Map> = groupByTo(HashMap>(), toKey) +/** + * Groups the elements in the collection into the given [[Map]] using the supplied *toKey* function to calculate the key to group the elements by + * + * @includeFunctionBody ../../test/CollectionTest.kt groupBy + */ public inline fun BooleanArray.groupByTo(result: Map>, toKey: (Boolean) -> K) : Map> { for (element in this) { val key = toKey(element) val list = result.getOrPut(key) { ArrayList() } list.add(element) - - val some = key - val more = some - val onceMore = more - val again = println(more) } return result } /** + * Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied. + * + * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will + * a special *truncated* separator (which defaults to "..." + * + * @includeFunctionBody ../../test/CollectionTest.kt makeString */ public inline fun BooleanArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() @@ -263,17 +268,3 @@ public inline fun BooleanArray.toSortedList(transform: fun(Boolean) : java.lang return answer } */ - -// -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt -// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib -// -// Generated from input file: src/kotlin/JLangIterablesJVM.kt -// - - -import java.util.* - -/** Copies all elements into a [[SortedSet]] */ -public inline fun BooleanArray.toSortedSet() : SortedSet = toCollection(TreeSet()) - diff --git a/libraries/stdlib/src/generated/BooleanArraysFromJLangIterablesJVM.kt b/libraries/stdlib/src/generated/BooleanArraysFromJLangIterablesJVM.kt new file mode 100644 index 00000000000..f46d1cc4214 --- /dev/null +++ b/libraries/stdlib/src/generated/BooleanArraysFromJLangIterablesJVM.kt @@ -0,0 +1,16 @@ +package kotlin + + +// +// 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 [[SortedSet]] */ +public inline fun BooleanArray.toSortedSet() : SortedSet = toCollection(TreeSet()) + diff --git a/libraries/stdlib/src/generated/BooleanArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/BooleanArraysFromJLangIterablesLazy.kt index 1bcc2248e51..21b688bd29d 100644 --- a/libraries/stdlib/src/generated/BooleanArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/BooleanArraysFromJLangIterablesLazy.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt diff --git a/libraries/stdlib/src/generated/BooleanArraysFromJUtilCollections.kt b/libraries/stdlib/src/generated/BooleanArraysFromJUtilCollections.kt index 97b7a0a50f8..b65dac40c20 100644 --- a/libraries/stdlib/src/generated/BooleanArraysFromJUtilCollections.kt +++ b/libraries/stdlib/src/generated/BooleanArraysFromJUtilCollections.kt @@ -26,29 +26,3 @@ public inline fun > BooleanArray.mapTo(result: C, transfo 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.* - -// -// 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 BooleanArray.map(transform : (Boolean) -> R) : java.util.List { - return mapTo(java.util.ArrayList(this.size), transform) -} diff --git a/libraries/stdlib/src/generated/BooleanArraysFromJUtilCollectionsJVM.kt b/libraries/stdlib/src/generated/BooleanArraysFromJUtilCollectionsJVM.kt new file mode 100644 index 00000000000..8bd41f7208d --- /dev/null +++ b/libraries/stdlib/src/generated/BooleanArraysFromJUtilCollectionsJVM.kt @@ -0,0 +1,27 @@ +package kotlin + +// +// 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.* + +// +// 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 BooleanArray.map(transform : (Boolean) -> R) : java.util.List { + return mapTo(java.util.ArrayList(this.size), transform) +} diff --git a/libraries/stdlib/src/generated/ByteArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/ByteArraysFromJLangIterables.kt index cdcac6bdbcc..9c6765da0db 100644 --- a/libraries/stdlib/src/generated/ByteArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/ByteArraysFromJLangIterables.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt @@ -184,21 +183,27 @@ public inline fun ByteArray.reduceRight(operation: (Byte, Byte) -> Byte): Byte = */ public inline fun ByteArray.groupBy(toKey: (Byte) -> K) : Map> = groupByTo(HashMap>(), toKey) +/** + * Groups the elements in the collection into the given [[Map]] using the supplied *toKey* function to calculate the key to group the elements by + * + * @includeFunctionBody ../../test/CollectionTest.kt groupBy + */ public inline fun ByteArray.groupByTo(result: Map>, toKey: (Byte) -> K) : Map> { for (element in this) { val key = toKey(element) val list = result.getOrPut(key) { ArrayList() } list.add(element) - - val some = key - val more = some - val onceMore = more - val again = println(more) } return result } /** + * Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied. + * + * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will + * a special *truncated* separator (which defaults to "..." + * + * @includeFunctionBody ../../test/CollectionTest.kt makeString */ public inline fun ByteArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() @@ -263,17 +268,3 @@ public inline fun ByteArray.toSortedList(transform: fun(Byte) : java.lang.Compa return answer } */ - -// -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt -// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib -// -// Generated from input file: src/kotlin/JLangIterablesJVM.kt -// - - -import java.util.* - -/** Copies all elements into a [[SortedSet]] */ -public inline fun ByteArray.toSortedSet() : SortedSet = toCollection(TreeSet()) - diff --git a/libraries/stdlib/src/generated/ByteArraysFromJLangIterablesJVM.kt b/libraries/stdlib/src/generated/ByteArraysFromJLangIterablesJVM.kt new file mode 100644 index 00000000000..0abc222ae9b --- /dev/null +++ b/libraries/stdlib/src/generated/ByteArraysFromJLangIterablesJVM.kt @@ -0,0 +1,16 @@ +package kotlin + + +// +// 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 [[SortedSet]] */ +public inline fun ByteArray.toSortedSet() : SortedSet = toCollection(TreeSet()) + diff --git a/libraries/stdlib/src/generated/ByteArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/ByteArraysFromJLangIterablesLazy.kt index 4b83b3afd16..deb5732d2e7 100644 --- a/libraries/stdlib/src/generated/ByteArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/ByteArraysFromJLangIterablesLazy.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt diff --git a/libraries/stdlib/src/generated/ByteArraysFromJUtilCollections.kt b/libraries/stdlib/src/generated/ByteArraysFromJUtilCollections.kt index 6081f3b358e..16f54544c71 100644 --- a/libraries/stdlib/src/generated/ByteArraysFromJUtilCollections.kt +++ b/libraries/stdlib/src/generated/ByteArraysFromJUtilCollections.kt @@ -26,29 +26,3 @@ public inline fun > ByteArray.mapTo(result: C, transform 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.* - -// -// 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 ByteArray.map(transform : (Byte) -> R) : java.util.List { - return mapTo(java.util.ArrayList(this.size), transform) -} diff --git a/libraries/stdlib/src/generated/ByteArraysFromJUtilCollectionsJVM.kt b/libraries/stdlib/src/generated/ByteArraysFromJUtilCollectionsJVM.kt new file mode 100644 index 00000000000..fa2a6c33f6f --- /dev/null +++ b/libraries/stdlib/src/generated/ByteArraysFromJUtilCollectionsJVM.kt @@ -0,0 +1,27 @@ +package kotlin + +// +// 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.* + +// +// 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 ByteArray.map(transform : (Byte) -> R) : java.util.List { + return mapTo(java.util.ArrayList(this.size), transform) +} diff --git a/libraries/stdlib/src/generated/CharArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/CharArraysFromJLangIterables.kt index a3ff314a7c7..04774e1d18a 100644 --- a/libraries/stdlib/src/generated/CharArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/CharArraysFromJLangIterables.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt @@ -184,21 +183,27 @@ public inline fun CharArray.reduceRight(operation: (Char, Char) -> Char): Char = */ public inline fun CharArray.groupBy(toKey: (Char) -> K) : Map> = groupByTo(HashMap>(), toKey) +/** + * Groups the elements in the collection into the given [[Map]] using the supplied *toKey* function to calculate the key to group the elements by + * + * @includeFunctionBody ../../test/CollectionTest.kt groupBy + */ public inline fun CharArray.groupByTo(result: Map>, toKey: (Char) -> K) : Map> { for (element in this) { val key = toKey(element) val list = result.getOrPut(key) { ArrayList() } list.add(element) - - val some = key - val more = some - val onceMore = more - val again = println(more) } return result } /** + * Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied. + * + * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will + * a special *truncated* separator (which defaults to "..." + * + * @includeFunctionBody ../../test/CollectionTest.kt makeString */ public inline fun CharArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() @@ -263,17 +268,3 @@ public inline fun CharArray.toSortedList(transform: fun(Char) : java.lang.Compa return answer } */ - -// -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt -// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib -// -// Generated from input file: src/kotlin/JLangIterablesJVM.kt -// - - -import java.util.* - -/** Copies all elements into a [[SortedSet]] */ -public inline fun CharArray.toSortedSet() : SortedSet = toCollection(TreeSet()) - diff --git a/libraries/stdlib/src/generated/CharArraysFromJLangIterablesJVM.kt b/libraries/stdlib/src/generated/CharArraysFromJLangIterablesJVM.kt new file mode 100644 index 00000000000..9c6027558ba --- /dev/null +++ b/libraries/stdlib/src/generated/CharArraysFromJLangIterablesJVM.kt @@ -0,0 +1,16 @@ +package kotlin + + +// +// 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 [[SortedSet]] */ +public inline fun CharArray.toSortedSet() : SortedSet = toCollection(TreeSet()) + diff --git a/libraries/stdlib/src/generated/CharArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/CharArraysFromJLangIterablesLazy.kt index fecc6acaca2..6e4c9d0d59d 100644 --- a/libraries/stdlib/src/generated/CharArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/CharArraysFromJLangIterablesLazy.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt diff --git a/libraries/stdlib/src/generated/CharArraysFromJUtilCollections.kt b/libraries/stdlib/src/generated/CharArraysFromJUtilCollections.kt index 1bf0a1a3c3a..4a107455085 100644 --- a/libraries/stdlib/src/generated/CharArraysFromJUtilCollections.kt +++ b/libraries/stdlib/src/generated/CharArraysFromJUtilCollections.kt @@ -26,29 +26,3 @@ public inline fun > CharArray.mapTo(result: C, transform 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.* - -// -// 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 CharArray.map(transform : (Char) -> R) : java.util.List { - return mapTo(java.util.ArrayList(this.size), transform) -} diff --git a/libraries/stdlib/src/generated/CharArraysFromJUtilCollectionsJVM.kt b/libraries/stdlib/src/generated/CharArraysFromJUtilCollectionsJVM.kt new file mode 100644 index 00000000000..9e4bbd398e2 --- /dev/null +++ b/libraries/stdlib/src/generated/CharArraysFromJUtilCollectionsJVM.kt @@ -0,0 +1,27 @@ +package kotlin + +// +// 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.* + +// +// 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 CharArray.map(transform : (Char) -> R) : java.util.List { + return mapTo(java.util.ArrayList(this.size), transform) +} diff --git a/libraries/stdlib/src/generated/DoubleArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/DoubleArraysFromJLangIterables.kt index a4b765a3306..9148a4ef0b9 100644 --- a/libraries/stdlib/src/generated/DoubleArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/DoubleArraysFromJLangIterables.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt @@ -184,21 +183,27 @@ public inline fun DoubleArray.reduceRight(operation: (Double, Double) -> Double) */ public inline fun DoubleArray.groupBy(toKey: (Double) -> K) : Map> = groupByTo(HashMap>(), toKey) +/** + * Groups the elements in the collection into the given [[Map]] using the supplied *toKey* function to calculate the key to group the elements by + * + * @includeFunctionBody ../../test/CollectionTest.kt groupBy + */ public inline fun DoubleArray.groupByTo(result: Map>, toKey: (Double) -> K) : Map> { for (element in this) { val key = toKey(element) val list = result.getOrPut(key) { ArrayList() } list.add(element) - - val some = key - val more = some - val onceMore = more - val again = println(more) } return result } /** + * Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied. + * + * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will + * a special *truncated* separator (which defaults to "..." + * + * @includeFunctionBody ../../test/CollectionTest.kt makeString */ public inline fun DoubleArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() @@ -263,17 +268,3 @@ public inline fun DoubleArray.toSortedList(transform: fun(Double) : java.lang.C return answer } */ - -// -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt -// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib -// -// Generated from input file: src/kotlin/JLangIterablesJVM.kt -// - - -import java.util.* - -/** Copies all elements into a [[SortedSet]] */ -public inline fun DoubleArray.toSortedSet() : SortedSet = toCollection(TreeSet()) - diff --git a/libraries/stdlib/src/generated/DoubleArraysFromJLangIterablesJVM.kt b/libraries/stdlib/src/generated/DoubleArraysFromJLangIterablesJVM.kt new file mode 100644 index 00000000000..7a0fba09243 --- /dev/null +++ b/libraries/stdlib/src/generated/DoubleArraysFromJLangIterablesJVM.kt @@ -0,0 +1,16 @@ +package kotlin + + +// +// 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 [[SortedSet]] */ +public inline fun DoubleArray.toSortedSet() : SortedSet = toCollection(TreeSet()) + diff --git a/libraries/stdlib/src/generated/DoubleArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/DoubleArraysFromJLangIterablesLazy.kt index b13e669e0d7..1210e6c33f4 100644 --- a/libraries/stdlib/src/generated/DoubleArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/DoubleArraysFromJLangIterablesLazy.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt diff --git a/libraries/stdlib/src/generated/DoubleArraysFromJUtilCollections.kt b/libraries/stdlib/src/generated/DoubleArraysFromJUtilCollections.kt index a60c4183d1f..87864c39ae6 100644 --- a/libraries/stdlib/src/generated/DoubleArraysFromJUtilCollections.kt +++ b/libraries/stdlib/src/generated/DoubleArraysFromJUtilCollections.kt @@ -26,29 +26,3 @@ public inline fun > DoubleArray.mapTo(result: C, transfor 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.* - -// -// 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 DoubleArray.map(transform : (Double) -> R) : java.util.List { - return mapTo(java.util.ArrayList(this.size), transform) -} diff --git a/libraries/stdlib/src/generated/DoubleArraysFromJUtilCollectionsJVM.kt b/libraries/stdlib/src/generated/DoubleArraysFromJUtilCollectionsJVM.kt new file mode 100644 index 00000000000..caeb0a150ca --- /dev/null +++ b/libraries/stdlib/src/generated/DoubleArraysFromJUtilCollectionsJVM.kt @@ -0,0 +1,27 @@ +package kotlin + +// +// 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.* + +// +// 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 DoubleArray.map(transform : (Double) -> R) : java.util.List { + return mapTo(java.util.ArrayList(this.size), transform) +} diff --git a/libraries/stdlib/src/generated/FloatArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/FloatArraysFromJLangIterables.kt index d6f478ead8b..c87c7d30f75 100644 --- a/libraries/stdlib/src/generated/FloatArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/FloatArraysFromJLangIterables.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt @@ -184,21 +183,27 @@ public inline fun FloatArray.reduceRight(operation: (Float, Float) -> Float): Fl */ public inline fun FloatArray.groupBy(toKey: (Float) -> K) : Map> = groupByTo(HashMap>(), toKey) +/** + * Groups the elements in the collection into the given [[Map]] using the supplied *toKey* function to calculate the key to group the elements by + * + * @includeFunctionBody ../../test/CollectionTest.kt groupBy + */ public inline fun FloatArray.groupByTo(result: Map>, toKey: (Float) -> K) : Map> { for (element in this) { val key = toKey(element) val list = result.getOrPut(key) { ArrayList() } list.add(element) - - val some = key - val more = some - val onceMore = more - val again = println(more) } return result } /** + * Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied. + * + * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will + * a special *truncated* separator (which defaults to "..." + * + * @includeFunctionBody ../../test/CollectionTest.kt makeString */ public inline fun FloatArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() @@ -263,17 +268,3 @@ public inline fun FloatArray.toSortedList(transform: fun(Float) : java.lang.Com return answer } */ - -// -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt -// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib -// -// Generated from input file: src/kotlin/JLangIterablesJVM.kt -// - - -import java.util.* - -/** Copies all elements into a [[SortedSet]] */ -public inline fun FloatArray.toSortedSet() : SortedSet = toCollection(TreeSet()) - diff --git a/libraries/stdlib/src/generated/FloatArraysFromJLangIterablesJVM.kt b/libraries/stdlib/src/generated/FloatArraysFromJLangIterablesJVM.kt new file mode 100644 index 00000000000..154bac7ca94 --- /dev/null +++ b/libraries/stdlib/src/generated/FloatArraysFromJLangIterablesJVM.kt @@ -0,0 +1,16 @@ +package kotlin + + +// +// 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 [[SortedSet]] */ +public inline fun FloatArray.toSortedSet() : SortedSet = toCollection(TreeSet()) + diff --git a/libraries/stdlib/src/generated/FloatArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/FloatArraysFromJLangIterablesLazy.kt index e9370209a08..4f71ad6cb37 100644 --- a/libraries/stdlib/src/generated/FloatArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/FloatArraysFromJLangIterablesLazy.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt diff --git a/libraries/stdlib/src/generated/FloatArraysFromJUtilCollections.kt b/libraries/stdlib/src/generated/FloatArraysFromJUtilCollections.kt index 3f48ca12a83..284cd9b55cb 100644 --- a/libraries/stdlib/src/generated/FloatArraysFromJUtilCollections.kt +++ b/libraries/stdlib/src/generated/FloatArraysFromJUtilCollections.kt @@ -26,29 +26,3 @@ public inline fun > FloatArray.mapTo(result: C, transform 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.* - -// -// 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 FloatArray.map(transform : (Float) -> R) : java.util.List { - return mapTo(java.util.ArrayList(this.size), transform) -} diff --git a/libraries/stdlib/src/generated/FloatArraysFromJUtilCollectionsJVM.kt b/libraries/stdlib/src/generated/FloatArraysFromJUtilCollectionsJVM.kt new file mode 100644 index 00000000000..62e33e5dbd6 --- /dev/null +++ b/libraries/stdlib/src/generated/FloatArraysFromJUtilCollectionsJVM.kt @@ -0,0 +1,27 @@ +package kotlin + +// +// 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.* + +// +// 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 FloatArray.map(transform : (Float) -> R) : java.util.List { + return mapTo(java.util.ArrayList(this.size), transform) +} diff --git a/libraries/stdlib/src/generated/IntArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/IntArraysFromJLangIterables.kt index a5d0957592f..f2aa098bfb7 100644 --- a/libraries/stdlib/src/generated/IntArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/IntArraysFromJLangIterables.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt @@ -184,21 +183,27 @@ public inline fun IntArray.reduceRight(operation: (Int, Int) -> Int): Int = reve */ public inline fun IntArray.groupBy(toKey: (Int) -> K) : Map> = groupByTo(HashMap>(), toKey) +/** + * Groups the elements in the collection into the given [[Map]] using the supplied *toKey* function to calculate the key to group the elements by + * + * @includeFunctionBody ../../test/CollectionTest.kt groupBy + */ public inline fun IntArray.groupByTo(result: Map>, toKey: (Int) -> K) : Map> { for (element in this) { val key = toKey(element) val list = result.getOrPut(key) { ArrayList() } list.add(element) - - val some = key - val more = some - val onceMore = more - val again = println(more) } return result } /** + * Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied. + * + * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will + * a special *truncated* separator (which defaults to "..." + * + * @includeFunctionBody ../../test/CollectionTest.kt makeString */ public inline fun IntArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() @@ -263,17 +268,3 @@ public inline fun IntArray.toSortedList(transform: fun(Int) : java.lang.Compara return answer } */ - -// -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt -// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib -// -// Generated from input file: src/kotlin/JLangIterablesJVM.kt -// - - -import java.util.* - -/** Copies all elements into a [[SortedSet]] */ -public inline fun IntArray.toSortedSet() : SortedSet = toCollection(TreeSet()) - diff --git a/libraries/stdlib/src/generated/IntArraysFromJLangIterablesJVM.kt b/libraries/stdlib/src/generated/IntArraysFromJLangIterablesJVM.kt new file mode 100644 index 00000000000..eb938c89bfe --- /dev/null +++ b/libraries/stdlib/src/generated/IntArraysFromJLangIterablesJVM.kt @@ -0,0 +1,16 @@ +package kotlin + + +// +// 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 [[SortedSet]] */ +public inline fun IntArray.toSortedSet() : SortedSet = toCollection(TreeSet()) + diff --git a/libraries/stdlib/src/generated/IntArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/IntArraysFromJLangIterablesLazy.kt index 40f1c986017..e82ea902947 100644 --- a/libraries/stdlib/src/generated/IntArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/IntArraysFromJLangIterablesLazy.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt diff --git a/libraries/stdlib/src/generated/IntArraysFromJUtilCollections.kt b/libraries/stdlib/src/generated/IntArraysFromJUtilCollections.kt index af07262266b..97263c09444 100644 --- a/libraries/stdlib/src/generated/IntArraysFromJUtilCollections.kt +++ b/libraries/stdlib/src/generated/IntArraysFromJUtilCollections.kt @@ -26,29 +26,3 @@ public inline fun > IntArray.mapTo(result: C, transform : 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.* - -// -// 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 IntArray.map(transform : (Int) -> R) : java.util.List { - return mapTo(java.util.ArrayList(this.size), transform) -} diff --git a/libraries/stdlib/src/generated/IntArraysFromJUtilCollectionsJVM.kt b/libraries/stdlib/src/generated/IntArraysFromJUtilCollectionsJVM.kt new file mode 100644 index 00000000000..7b5949e60bc --- /dev/null +++ b/libraries/stdlib/src/generated/IntArraysFromJUtilCollectionsJVM.kt @@ -0,0 +1,27 @@ +package kotlin + +// +// 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.* + +// +// 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 IntArray.map(transform : (Int) -> R) : java.util.List { + return mapTo(java.util.ArrayList(this.size), transform) +} diff --git a/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt b/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt index d6a477702ee..631c1599200 100644 --- a/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt @@ -182,21 +182,27 @@ public inline fun java.util.Iterator.reduceRight(operation: (T, T) -> T): */ public inline fun java.util.Iterator.groupBy(toKey: (T) -> K) : Map> = groupByTo(HashMap>(), toKey) +/** + * Groups the elements in the collection into the given [[Map]] using the supplied *toKey* function to calculate the key to group the elements by + * + * @includeFunctionBody ../../test/CollectionTest.kt groupBy + */ public inline fun java.util.Iterator.groupByTo(result: Map>, toKey: (T) -> K) : Map> { for (element in this) { val key = toKey(element) val list = result.getOrPut(key) { ArrayList() } list.add(element) - - val some = key - val more = some - val onceMore = more - val again = println(more) } return result } /** + * Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied. + * + * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will + * a special *truncated* separator (which defaults to "..." + * + * @includeFunctionBody ../../test/CollectionTest.kt makeString */ public inline fun java.util.Iterator.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() diff --git a/libraries/stdlib/src/generated/LongArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/LongArraysFromJLangIterables.kt index 678788b6f27..0747cc03bc7 100644 --- a/libraries/stdlib/src/generated/LongArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/LongArraysFromJLangIterables.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt @@ -184,21 +183,27 @@ public inline fun LongArray.reduceRight(operation: (Long, Long) -> Long): Long = */ public inline fun LongArray.groupBy(toKey: (Long) -> K) : Map> = groupByTo(HashMap>(), toKey) +/** + * Groups the elements in the collection into the given [[Map]] using the supplied *toKey* function to calculate the key to group the elements by + * + * @includeFunctionBody ../../test/CollectionTest.kt groupBy + */ public inline fun LongArray.groupByTo(result: Map>, toKey: (Long) -> K) : Map> { for (element in this) { val key = toKey(element) val list = result.getOrPut(key) { ArrayList() } list.add(element) - - val some = key - val more = some - val onceMore = more - val again = println(more) } return result } /** + * Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied. + * + * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will + * a special *truncated* separator (which defaults to "..." + * + * @includeFunctionBody ../../test/CollectionTest.kt makeString */ public inline fun LongArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() @@ -263,17 +268,3 @@ public inline fun LongArray.toSortedList(transform: fun(Long) : java.lang.Compa return answer } */ - -// -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt -// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib -// -// Generated from input file: src/kotlin/JLangIterablesJVM.kt -// - - -import java.util.* - -/** Copies all elements into a [[SortedSet]] */ -public inline fun LongArray.toSortedSet() : SortedSet = toCollection(TreeSet()) - diff --git a/libraries/stdlib/src/generated/LongArraysFromJLangIterablesJVM.kt b/libraries/stdlib/src/generated/LongArraysFromJLangIterablesJVM.kt new file mode 100644 index 00000000000..621d07138ba --- /dev/null +++ b/libraries/stdlib/src/generated/LongArraysFromJLangIterablesJVM.kt @@ -0,0 +1,16 @@ +package kotlin + + +// +// 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 [[SortedSet]] */ +public inline fun LongArray.toSortedSet() : SortedSet = toCollection(TreeSet()) + diff --git a/libraries/stdlib/src/generated/LongArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/LongArraysFromJLangIterablesLazy.kt index f3d0a74ea95..ff04120eeb0 100644 --- a/libraries/stdlib/src/generated/LongArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/LongArraysFromJLangIterablesLazy.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt diff --git a/libraries/stdlib/src/generated/LongArraysFromJUtilCollections.kt b/libraries/stdlib/src/generated/LongArraysFromJUtilCollections.kt index 6c87ed391c9..741970169ef 100644 --- a/libraries/stdlib/src/generated/LongArraysFromJUtilCollections.kt +++ b/libraries/stdlib/src/generated/LongArraysFromJUtilCollections.kt @@ -26,29 +26,3 @@ public inline fun > LongArray.mapTo(result: C, transform 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.* - -// -// 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 LongArray.map(transform : (Long) -> R) : java.util.List { - return mapTo(java.util.ArrayList(this.size), transform) -} diff --git a/libraries/stdlib/src/generated/LongArraysFromJUtilCollectionsJVM.kt b/libraries/stdlib/src/generated/LongArraysFromJUtilCollectionsJVM.kt new file mode 100644 index 00000000000..45c74bde6aa --- /dev/null +++ b/libraries/stdlib/src/generated/LongArraysFromJUtilCollectionsJVM.kt @@ -0,0 +1,27 @@ +package kotlin + +// +// 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.* + +// +// 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 LongArray.map(transform : (Long) -> R) : java.util.List { + return mapTo(java.util.ArrayList(this.size), transform) +} diff --git a/libraries/stdlib/src/generated/ShortArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/ShortArraysFromJLangIterables.kt index cc0a7fbee6f..d581b468349 100644 --- a/libraries/stdlib/src/generated/ShortArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/ShortArraysFromJLangIterables.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt @@ -184,21 +183,27 @@ public inline fun ShortArray.reduceRight(operation: (Short, Short) -> Short): Sh */ public inline fun ShortArray.groupBy(toKey: (Short) -> K) : Map> = groupByTo(HashMap>(), toKey) +/** + * Groups the elements in the collection into the given [[Map]] using the supplied *toKey* function to calculate the key to group the elements by + * + * @includeFunctionBody ../../test/CollectionTest.kt groupBy + */ public inline fun ShortArray.groupByTo(result: Map>, toKey: (Short) -> K) : Map> { for (element in this) { val key = toKey(element) val list = result.getOrPut(key) { ArrayList() } list.add(element) - - val some = key - val more = some - val onceMore = more - val again = println(more) } return result } /** + * Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied. + * + * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will + * a special *truncated* separator (which defaults to "..." + * + * @includeFunctionBody ../../test/CollectionTest.kt makeString */ public inline fun ShortArray.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() @@ -263,17 +268,3 @@ public inline fun ShortArray.toSortedList(transform: fun(Short) : java.lang.Com return answer } */ - -// -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt -// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib -// -// Generated from input file: src/kotlin/JLangIterablesJVM.kt -// - - -import java.util.* - -/** Copies all elements into a [[SortedSet]] */ -public inline fun ShortArray.toSortedSet() : SortedSet = toCollection(TreeSet()) - diff --git a/libraries/stdlib/src/generated/ShortArraysFromJLangIterablesJVM.kt b/libraries/stdlib/src/generated/ShortArraysFromJLangIterablesJVM.kt new file mode 100644 index 00000000000..457a1e0767e --- /dev/null +++ b/libraries/stdlib/src/generated/ShortArraysFromJLangIterablesJVM.kt @@ -0,0 +1,16 @@ +package kotlin + + +// +// 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 [[SortedSet]] */ +public inline fun ShortArray.toSortedSet() : SortedSet = toCollection(TreeSet()) + diff --git a/libraries/stdlib/src/generated/ShortArraysFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/ShortArraysFromJLangIterablesLazy.kt index c0ef03623ff..deca3f1acf2 100644 --- a/libraries/stdlib/src/generated/ShortArraysFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/ShortArraysFromJLangIterablesLazy.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt diff --git a/libraries/stdlib/src/generated/ShortArraysFromJUtilCollections.kt b/libraries/stdlib/src/generated/ShortArraysFromJUtilCollections.kt index c39e05ec95b..bb1230cc707 100644 --- a/libraries/stdlib/src/generated/ShortArraysFromJUtilCollections.kt +++ b/libraries/stdlib/src/generated/ShortArraysFromJUtilCollections.kt @@ -26,29 +26,3 @@ public inline fun > ShortArray.mapTo(result: C, transform 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.* - -// -// 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 ShortArray.map(transform : (Short) -> R) : java.util.List { - return mapTo(java.util.ArrayList(this.size), transform) -} diff --git a/libraries/stdlib/src/generated/ShortArraysFromJUtilCollectionsJVM.kt b/libraries/stdlib/src/generated/ShortArraysFromJUtilCollectionsJVM.kt new file mode 100644 index 00000000000..7456ab51fb2 --- /dev/null +++ b/libraries/stdlib/src/generated/ShortArraysFromJUtilCollectionsJVM.kt @@ -0,0 +1,27 @@ +package kotlin + +// +// 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.* + +// +// 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 ShortArray.map(transform : (Short) -> R) : java.util.List { + return mapTo(java.util.ArrayList(this.size), transform) +} diff --git a/libraries/stdlib/src/generated/StandardFromJLangIterables.kt b/libraries/stdlib/src/generated/StandardFromJLangIterables.kt index 55e914b893e..5207d047621 100644 --- a/libraries/stdlib/src/generated/StandardFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/StandardFromJLangIterables.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt @@ -184,21 +183,27 @@ public inline fun Iterable.reduceRight(operation: (T, T) -> T): T = rever */ public inline fun Iterable.groupBy(toKey: (T) -> K) : Map> = groupByTo(HashMap>(), toKey) +/** + * Groups the elements in the collection into the given [[Map]] using the supplied *toKey* function to calculate the key to group the elements by + * + * @includeFunctionBody ../../test/CollectionTest.kt groupBy + */ public inline fun Iterable.groupByTo(result: Map>, toKey: (T) -> K) : Map> { for (element in this) { val key = toKey(element) val list = result.getOrPut(key) { ArrayList() } list.add(element) - - val some = key - val more = some - val onceMore = more - val again = println(more) } return result } /** + * Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied. + * + * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will + * a special *truncated* separator (which defaults to "..." + * + * @includeFunctionBody ../../test/CollectionTest.kt makeString */ public inline fun Iterable.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() @@ -263,17 +268,3 @@ public inline fun Iterable.toSortedList(transform: fun(T) : java.lang. return answer } */ - -// -// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt -// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib -// -// Generated from input file: src/kotlin/JLangIterablesJVM.kt -// - - -import java.util.* - -/** Copies all elements into a [[SortedSet]] */ -public inline fun Iterable.toSortedSet() : SortedSet = toCollection(TreeSet()) - diff --git a/libraries/stdlib/src/generated/StandardFromJLangIterablesJVM.kt b/libraries/stdlib/src/generated/StandardFromJLangIterablesJVM.kt new file mode 100644 index 00000000000..ed093cf8837 --- /dev/null +++ b/libraries/stdlib/src/generated/StandardFromJLangIterablesJVM.kt @@ -0,0 +1,16 @@ +package kotlin + + +// +// 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 [[SortedSet]] */ +public inline fun Iterable.toSortedSet() : SortedSet = toCollection(TreeSet()) + diff --git a/libraries/stdlib/src/generated/StandardFromJLangIterablesLazy.kt b/libraries/stdlib/src/generated/StandardFromJLangIterablesLazy.kt index 5fc38a116f0..89dffd50b7f 100644 --- a/libraries/stdlib/src/generated/StandardFromJLangIterablesLazy.kt +++ b/libraries/stdlib/src/generated/StandardFromJLangIterablesLazy.kt @@ -1,6 +1,5 @@ package kotlin -import kotlin.util.* // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt diff --git a/libraries/stdlib/src/generated/StandardFromJUtilCollections.kt b/libraries/stdlib/src/generated/StandardFromJUtilCollections.kt index 339ad392afe..f66f0524b34 100644 --- a/libraries/stdlib/src/generated/StandardFromJUtilCollections.kt +++ b/libraries/stdlib/src/generated/StandardFromJUtilCollections.kt @@ -26,29 +26,3 @@ public inline fun > Iterable.mapTo(result: C, trans 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.* - -// -// 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 Iterable.map(transform : (T) -> R) : java.util.List { - return mapTo(java.util.ArrayList(), transform) -} diff --git a/libraries/stdlib/src/generated/StandardFromJUtilCollectionsJVM.kt b/libraries/stdlib/src/generated/StandardFromJUtilCollectionsJVM.kt new file mode 100644 index 00000000000..b7f61d063c2 --- /dev/null +++ b/libraries/stdlib/src/generated/StandardFromJUtilCollectionsJVM.kt @@ -0,0 +1,27 @@ +package kotlin + +// +// 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.* + +// +// 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 Iterable.map(transform : (T) -> R) : java.util.List { + return mapTo(java.util.ArrayList(), transform) +} diff --git a/libraries/stdlib/src/kotlin/Arrays.kt b/libraries/stdlib/src/kotlin/Arrays.kt index 677d8735d3f..895c41e234f 100644 --- a/libraries/stdlib/src/kotlin/Arrays.kt +++ b/libraries/stdlib/src/kotlin/Arrays.kt @@ -1,123 +1,5 @@ package kotlin -import java.io.ByteArrayInputStream - -import java.util.Arrays -import java.nio.charset.Charset -import java.util.List -import java.util.ArrayList - -import jet.runtime.Intrinsic - -// Array "constructor" -[Intrinsic("kotlin.arrays.array")] public inline fun array(vararg t : T) : Array = t - -// "constructors" for primitive types array -[Intrinsic("kotlin.arrays.array")] public inline fun doubleArray(vararg content : Double) : DoubleArray = content - -[Intrinsic("kotlin.arrays.array")] public inline fun floatArray(vararg content : Float) : FloatArray = content - -[Intrinsic("kotlin.arrays.array")] public inline fun longArray(vararg content : Long) : LongArray = content - -[Intrinsic("kotlin.arrays.array")] public inline fun intArray(vararg content : Int) : IntArray = content - -[Intrinsic("kotlin.arrays.array")] public inline fun charArray(vararg content : Char) : CharArray = content - -[Intrinsic("kotlin.arrays.array")] public inline fun shortArray(vararg content : Short) : ShortArray = content - -[Intrinsic("kotlin.arrays.array")] public inline fun byteArray(vararg content : Byte) : ByteArray = content - -[Intrinsic("kotlin.arrays.array")] public inline fun booleanArray(vararg content : Boolean) : BooleanArray = content - -public inline fun ByteArray.binarySearch(key: Byte) : Int = Arrays.binarySearch(this, key) -public inline fun ShortArray.binarySearch(key: Short) : Int = Arrays.binarySearch(this, key) -public inline fun IntArray.binarySearch(key: Int) : Int = Arrays.binarySearch(this, key) -public inline fun LongArray.binarySearch(key: Long) : Int = Arrays.binarySearch(this, key) -public inline fun FloatArray.binarySearch(key: Float) : Int = Arrays.binarySearch(this, key) -public inline fun DoubleArray.binarySearch(key: Double) : Int = Arrays.binarySearch(this, key) -public inline fun CharArray.binarySearch(key: Char) : Int = Arrays.binarySearch(this, key) - -public inline fun ByteArray.binarySearch(fromIndex: Int, toIndex: Int, key: Byte) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) -public inline fun ShortArray.binarySearch(fromIndex: Int, toIndex: Int, key: Short) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) -public inline fun IntArray.binarySearch(fromIndex: Int, toIndex: Int, key: Int) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) -public inline fun LongArray.binarySearch(fromIndex: Int, toIndex: Int, key: Long) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) -public inline fun FloatArray.binarySearch(fromIndex: Int, toIndex: Int, key: Float) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) -public inline fun DoubleArray.binarySearch(fromIndex: Int, toIndex: Int, key: Double) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) -public inline fun CharArray.binarySearch(fromIndex: Int, toIndex: Int, key: Char) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) - -/* -public inline fun Array.binarySearch(key: T, comparator: public fun(T,T):Int) = Arrays.binarySearch(this, key, object: java.util.Comparator { - public override fun compare(a: T, b: T) = comparator(a, b) - - public override fun equals(obj: Any?) = obj.identityEquals(this) -}) -*/ -public inline fun BooleanArray.fill(value: Boolean) : Unit = Arrays.fill(this, value) -public inline fun ByteArray.fill(value: Byte) : Unit = Arrays.fill(this, value) -public inline fun ShortArray.fill(value: Short) : Unit = Arrays.fill(this, value) -public inline fun IntArray.fill(value: Int) : Unit = Arrays.fill(this, value) -public inline fun LongArray.fill(value: Long) : Unit = Arrays.fill(this, value) -public inline fun FloatArray.fill(value: Float) : Unit = Arrays.fill(this, value) -public inline fun DoubleArray.fill(value: Double) : Unit = Arrays.fill(this, value) -public inline fun CharArray.fill(value: Char) : Unit = Arrays.fill(this, value) - -public inline fun Array.fill(value: T) : Unit = Arrays.fill(this as Array, value) - -public inline fun ByteArray.sort() : Unit = Arrays.sort(this) -public inline fun ShortArray.sort() : Unit = Arrays.sort(this) -public inline fun IntArray.sort() : Unit = Arrays.sort(this) -public inline fun LongArray.sort() : Unit = Arrays.sort(this) -public inline fun FloatArray.sort() : Unit = Arrays.sort(this) -public inline fun DoubleArray.sort() : Unit = Arrays.sort(this) -public inline fun CharArray.sort() : Unit = Arrays.sort(this) - -public inline fun ByteArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) -public inline fun ShortArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) -public inline fun IntArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) -public inline fun LongArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) -public inline fun FloatArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) -public inline fun DoubleArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) -public inline fun CharArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) - -public inline fun BooleanArray.copyOf(newLength: Int = this.size) : BooleanArray = Arrays.copyOf(this, newLength).sure() -public inline fun ByteArray.copyOf(newLength: Int = this.size) : ByteArray = Arrays.copyOf(this, newLength).sure() -public inline fun ShortArray.copyOf(newLength: Int = this.size) : ShortArray = Arrays.copyOf(this, newLength).sure() -public inline fun IntArray.copyOf(newLength: Int = this.size) : IntArray = Arrays.copyOf(this, newLength).sure() -public inline fun LongArray.copyOf(newLength: Int = this.size) : LongArray = Arrays.copyOf(this, newLength).sure() -public inline fun FloatArray.copyOf(newLength: Int = this.size) : FloatArray = Arrays.copyOf(this, newLength).sure() -public inline fun DoubleArray.copyOf(newLength: Int = this.size) : DoubleArray = Arrays.copyOf(this, newLength).sure() -public inline fun CharArray.copyOf(newLength: Int = this.size) : CharArray = Arrays.copyOf(this, newLength).sure() - -// TODO: resuling array may contain nulls even if T is non-nullable -public inline fun Array.copyOf(newLength: Int = this.size) : Array = Arrays.copyOf(this as Array, newLength) as Array - -public inline fun BooleanArray.copyOfRange(from: Int, to: Int) : BooleanArray = Arrays.copyOfRange(this, from, to).sure() -public inline fun ByteArray.copyOfRange(from: Int, to: Int) : ByteArray = Arrays.copyOfRange(this, from, to).sure() -public inline fun ShortArray.copyOfRange(from: Int, to: Int) : ShortArray = Arrays.copyOfRange(this, from, to).sure() -public inline fun IntArray.copyOfRange(from: Int, to: Int) : IntArray = Arrays.copyOfRange(this, from, to).sure() -public inline fun LongArray.copyOfRange(from: Int, to: Int) : LongArray = Arrays.copyOfRange(this, from, to).sure() -public inline fun FloatArray.copyOfRange(from: Int, to: Int) : FloatArray = Arrays.copyOfRange(this, from, to).sure() -public inline fun DoubleArray.copyOfRange(from: Int, to: Int) : DoubleArray = Arrays.copyOfRange(this, from, to).sure() -public inline fun CharArray.copyOfRange(from: Int, to: Int) : CharArray = Arrays.copyOfRange(this, from, to).sure() - -// TODO: resuling array may contain nulls even if T is non-nullable -public inline fun Array.copyOfRange(from: Int, to: Int) : Array = Arrays.copyOfRange(this as Array, from, to) as Array - -public inline val ByteArray.inputStream : ByteArrayInputStream - get() = ByteArrayInputStream(this) - -public inline fun ByteArray.inputStream(offset: Int, length: Int) : ByteArrayInputStream = ByteArrayInputStream(this, offset, length) - -public inline fun ByteArray.toString(encoding: String?): String { - if (encoding != null) { - return String(this, encoding) - } else { - return String(this) - } -} - -public inline fun ByteArray.toString(encoding: Charset) : String = String(this, encoding) - /** Returns true if the array is not empty */ public inline fun Array.notEmpty() : Boolean = !this.isEmpty() diff --git a/libraries/stdlib/src/kotlin/ArraysJVM.kt b/libraries/stdlib/src/kotlin/ArraysJVM.kt new file mode 100644 index 00000000000..29a8c5f2783 --- /dev/null +++ b/libraries/stdlib/src/kotlin/ArraysJVM.kt @@ -0,0 +1,115 @@ +package kotlin + +import java.io.ByteArrayInputStream +import java.nio.charset.Charset +import java.util.Arrays +import jet.runtime.Intrinsic + +// Array "constructor" +[Intrinsic("kotlin.arrays.array")] public inline fun array(vararg t : T) : Array = t + +// "constructors" for primitive types array +[Intrinsic("kotlin.arrays.array")] public inline fun doubleArray(vararg content : Double) : DoubleArray = content + +[Intrinsic("kotlin.arrays.array")] public inline fun floatArray(vararg content : Float) : FloatArray = content + +[Intrinsic("kotlin.arrays.array")] public inline fun longArray(vararg content : Long) : LongArray = content + +[Intrinsic("kotlin.arrays.array")] public inline fun intArray(vararg content : Int) : IntArray = content + +[Intrinsic("kotlin.arrays.array")] public inline fun charArray(vararg content : Char) : CharArray = content + +[Intrinsic("kotlin.arrays.array")] public inline fun shortArray(vararg content : Short) : ShortArray = content + +[Intrinsic("kotlin.arrays.array")] public inline fun byteArray(vararg content : Byte) : ByteArray = content + +[Intrinsic("kotlin.arrays.array")] public inline fun booleanArray(vararg content : Boolean) : BooleanArray = content + +public inline fun ByteArray.binarySearch(key: Byte) : Int = Arrays.binarySearch(this, key) +public inline fun ShortArray.binarySearch(key: Short) : Int = Arrays.binarySearch(this, key) +public inline fun IntArray.binarySearch(key: Int) : Int = Arrays.binarySearch(this, key) +public inline fun LongArray.binarySearch(key: Long) : Int = Arrays.binarySearch(this, key) +public inline fun FloatArray.binarySearch(key: Float) : Int = Arrays.binarySearch(this, key) +public inline fun DoubleArray.binarySearch(key: Double) : Int = Arrays.binarySearch(this, key) +public inline fun CharArray.binarySearch(key: Char) : Int = Arrays.binarySearch(this, key) + +public inline fun ByteArray.binarySearch(fromIndex: Int, toIndex: Int, key: Byte) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) +public inline fun ShortArray.binarySearch(fromIndex: Int, toIndex: Int, key: Short) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) +public inline fun IntArray.binarySearch(fromIndex: Int, toIndex: Int, key: Int) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) +public inline fun LongArray.binarySearch(fromIndex: Int, toIndex: Int, key: Long) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) +public inline fun FloatArray.binarySearch(fromIndex: Int, toIndex: Int, key: Float) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) +public inline fun DoubleArray.binarySearch(fromIndex: Int, toIndex: Int, key: Double) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) +public inline fun CharArray.binarySearch(fromIndex: Int, toIndex: Int, key: Char) : Int = Arrays.binarySearch(this, fromIndex, toIndex, key) + +/* +public inline fun Array.binarySearch(key: T, comparator: public fun(T,T):Int) = Arrays.binarySearch(this, key, object: java.util.Comparator { + public override fun compare(a: T, b: T) = comparator(a, b) + + public override fun equals(obj: Any?) = obj.identityEquals(this) +}) +*/ +public inline fun BooleanArray.fill(value: Boolean) : Unit = Arrays.fill(this, value) +public inline fun ByteArray.fill(value: Byte) : Unit = Arrays.fill(this, value) +public inline fun ShortArray.fill(value: Short) : Unit = Arrays.fill(this, value) +public inline fun IntArray.fill(value: Int) : Unit = Arrays.fill(this, value) +public inline fun LongArray.fill(value: Long) : Unit = Arrays.fill(this, value) +public inline fun FloatArray.fill(value: Float) : Unit = Arrays.fill(this, value) +public inline fun DoubleArray.fill(value: Double) : Unit = Arrays.fill(this, value) +public inline fun CharArray.fill(value: Char) : Unit = Arrays.fill(this, value) + +public inline fun Array.fill(value: T) : Unit = Arrays.fill(this as Array, value) + +public inline fun ByteArray.sort() : Unit = Arrays.sort(this) +public inline fun ShortArray.sort() : Unit = Arrays.sort(this) +public inline fun IntArray.sort() : Unit = Arrays.sort(this) +public inline fun LongArray.sort() : Unit = Arrays.sort(this) +public inline fun FloatArray.sort() : Unit = Arrays.sort(this) +public inline fun DoubleArray.sort() : Unit = Arrays.sort(this) +public inline fun CharArray.sort() : Unit = Arrays.sort(this) + +public inline fun ByteArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) +public inline fun ShortArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) +public inline fun IntArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) +public inline fun LongArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) +public inline fun FloatArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) +public inline fun DoubleArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) +public inline fun CharArray.sort(fromIndex: Int, toIndex: Int) : Unit = Arrays.sort(this, fromIndex, toIndex) + +public inline fun BooleanArray.copyOf(newLength: Int = this.size) : BooleanArray = Arrays.copyOf(this, newLength).sure() +public inline fun ByteArray.copyOf(newLength: Int = this.size) : ByteArray = Arrays.copyOf(this, newLength).sure() +public inline fun ShortArray.copyOf(newLength: Int = this.size) : ShortArray = Arrays.copyOf(this, newLength).sure() +public inline fun IntArray.copyOf(newLength: Int = this.size) : IntArray = Arrays.copyOf(this, newLength).sure() +public inline fun LongArray.copyOf(newLength: Int = this.size) : LongArray = Arrays.copyOf(this, newLength).sure() +public inline fun FloatArray.copyOf(newLength: Int = this.size) : FloatArray = Arrays.copyOf(this, newLength).sure() +public inline fun DoubleArray.copyOf(newLength: Int = this.size) : DoubleArray = Arrays.copyOf(this, newLength).sure() +public inline fun CharArray.copyOf(newLength: Int = this.size) : CharArray = Arrays.copyOf(this, newLength).sure() + +// TODO: resuling array may contain nulls even if T is non-nullable +public inline fun Array.copyOf(newLength: Int = this.size) : Array = Arrays.copyOf(this as Array, newLength) as Array + +public inline fun BooleanArray.copyOfRange(from: Int, to: Int) : BooleanArray = Arrays.copyOfRange(this, from, to).sure() +public inline fun ByteArray.copyOfRange(from: Int, to: Int) : ByteArray = Arrays.copyOfRange(this, from, to).sure() +public inline fun ShortArray.copyOfRange(from: Int, to: Int) : ShortArray = Arrays.copyOfRange(this, from, to).sure() +public inline fun IntArray.copyOfRange(from: Int, to: Int) : IntArray = Arrays.copyOfRange(this, from, to).sure() +public inline fun LongArray.copyOfRange(from: Int, to: Int) : LongArray = Arrays.copyOfRange(this, from, to).sure() +public inline fun FloatArray.copyOfRange(from: Int, to: Int) : FloatArray = Arrays.copyOfRange(this, from, to).sure() +public inline fun DoubleArray.copyOfRange(from: Int, to: Int) : DoubleArray = Arrays.copyOfRange(this, from, to).sure() +public inline fun CharArray.copyOfRange(from: Int, to: Int) : CharArray = Arrays.copyOfRange(this, from, to).sure() + +// TODO: resuling array may contain nulls even if T is non-nullable +public inline fun Array.copyOfRange(from: Int, to: Int) : Array = Arrays.copyOfRange(this as Array, from, to) as Array + +public inline val ByteArray.inputStream : ByteArrayInputStream + get() = ByteArrayInputStream(this) + +public inline fun ByteArray.inputStream(offset: Int, length: Int) : ByteArrayInputStream = ByteArrayInputStream(this, offset, length) + +public inline fun ByteArray.toString(encoding: String?): String { + if (encoding != null) { + return String(this, encoding) + } else { + return String(this) + } +} + +public inline fun ByteArray.toString(encoding: Charset) : String = String(this, encoding) \ No newline at end of file diff --git a/libraries/stdlib/test/js/JsArrayTest.kt b/libraries/stdlib/test/js/JsArrayTest.kt new file mode 100644 index 00000000000..7278df0e812 --- /dev/null +++ b/libraries/stdlib/test/js/JsArrayTest.kt @@ -0,0 +1,22 @@ +package testPackage + +import org.junit.Test as test +import kotlin.test.* + +class JsArrayTest { + + test fun arrays() { + val a1 = array() + val a2 = array("foo") + val a3 = array("foo", "bar") + + assertEquals(0, a1.size) + assertEquals(1, a2.size) + assertEquals(2, a3.size) + + assertEquals("[]", a1.toList().toString()) + assertEquals("[foo]", a2.toList().toString()) + assertEquals("[foo, bar]", a3.toList().toString()) + + } +} diff --git a/libraries/stdlib/test/org/jetbrains/kotlin/tools/GenerateStandardLib.kt b/libraries/stdlib/test/org/jetbrains/kotlin/tools/GenerateStandardLib.kt index 1b2f20bc72c..5ba4c53a9dd 100644 --- a/libraries/stdlib/test/org/jetbrains/kotlin/tools/GenerateStandardLib.kt +++ b/libraries/stdlib/test/org/jetbrains/kotlin/tools/GenerateStandardLib.kt @@ -73,12 +73,17 @@ fun main(args: Array) { val otherArrayNames = arrayList("Boolean", "Byte", "Char", "Short", "Int", "Long", "Float", "Double") // JLangIterables - Generic iterable stuff - generateFile(File(outDir, "ArraysFromJLangIterables.kt"), "package kotlin\n\nimport kotlin.util.*", File(srcDir, "JLangIterables.kt"), File(srcDir, "JLangIterablesJVM.kt")) { + generateFile(File(outDir, "ArraysFromJLangIterables.kt"), "package kotlin\n", File(srcDir, "JLangIterables.kt")) { it.replaceAll("java.lang.Iterable) { replaceAll("iterator.hasNext\\(\\)", "iterator.hasNext") } - generateFile(File(outDir, "${arrayName}ArraysFromJLangIterables.kt"), "package kotlin\n\nimport kotlin.util.*", File(srcDir, "JLangIterables.kt"), File(srcDir, "JLangIterablesJVM.kt")) { + generateFile(File(outDir, "${arrayName}ArraysFromJLangIterables.kt"), "package kotlin\n", File(srcDir, "JLangIterables.kt")) { replace(it) } - generateFile(File(outDir, "${arrayName}ArraysFromJLangIterablesLazy.kt"), "package kotlin\n\nimport kotlin.util.*", File(srcDir, "JLangIterablesLazy.kt")) { + generateFile(File(outDir, "${arrayName}ArraysFromJLangIterablesJVM.kt"), "package kotlin\n", File(srcDir, "JLangIterablesJVM.kt")) { + replace(it) + } + generateFile(File(outDir, "${arrayName}ArraysFromJLangIterablesLazy.kt"), "package kotlin\n", File(srcDir, "JLangIterablesLazy.kt")) { replace(it) } } - generateFile(File(outDir, "StandardFromJLangIterables.kt"), "package kotlin\n\nimport kotlin.util.*", File(srcDir, "JLangIterables.kt"), File(srcDir, "JLangIterablesJVM.kt")) { + generateFile(File(outDir, "StandardFromJLangIterables.kt"), "package kotlin\n", File(srcDir, "JLangIterables.kt")) { it.replaceAll("java.lang.Iterable) { // 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"), File(srcDir, "JUtilCollectionsJVM.kt")) { + generateFile(File(outDir, "ArraysFromJUtilCollections.kt"), "package kotlin", File(srcDir, "JUtilCollections.kt")) { + it.replaceAll("java.util.Collection java.util.Collection", "${arrayName}Array"). + replaceAll("java.util.Collection", "${arrayName}Array")) + } + generateFile(File(outDir, "${arrayName}ArraysFromJUtilCollectionsJVM.kt"), "package kotlin", File(srcDir, "JUtilCollectionsJVM.kt")) { replaceGenerics(arrayName, it.replaceAll(" java.util.Collection", "${arrayName}Array"). replaceAll("java.util.Collection", "${arrayName}Array")) } @@ -132,7 +151,10 @@ fun main(args: Array) { it.replaceAll("java.util.Collection + @@ -78,8 +79,12 @@ + + + + + + @@ -52,6 +55,9 @@ +