library changes after collections mapping

This commit is contained in:
Svetlana Isakova
2012-09-04 16:52:43 +04:00
parent 7c828b9ff7
commit 8b749084b5
75 changed files with 222 additions and 268 deletions
@@ -5,7 +5,7 @@ package kotlin
// 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: src/kotlin/JLangIterables.kt // Generated from input file: JLangIterables.kt
// //
@@ -79,7 +79,7 @@ public inline fun <T> Array<T>.find(predicate: (T) -> Boolean) : T? {
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList
*/ */
public inline fun <T, C: Collection<in T>> Array<T>.filterTo(result: C, predicate: (T) -> Boolean) : C { public inline fun <T, C: MutableCollection<in T>> Array<T>.filterTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) for (element in this) if (predicate(element)) result.add(element)
return result return result
} }
@@ -89,7 +89,7 @@ public inline fun <T, C: Collection<in T>> Array<T>.filterTo(result: C, predicat
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/ */
public inline fun <T, C: Collection<in T>> Array<T>.filterNotTo(result: C, predicate: (T) -> Boolean) : C { public inline fun <T, C: MutableCollection<in T>> Array<T>.filterNotTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element) for (element in this) if (!predicate(element)) result.add(element)
return result return result
} }
@@ -99,7 +99,7 @@ public inline fun <T, C: Collection<in T>> Array<T>.filterNotTo(result: C, predi
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/ */
public inline fun <T, C: Collection<in T>> Array<T?>?.filterNotNullTo(result: C) : C { public inline fun <T, C: MutableCollection<in T>> Array<T?>?.filterNotNullTo(result: C) : C {
if (this != null) { if (this != null) {
for (element in this) if (element != null) result.add(element) for (element in this) if (element != null) result.add(element)
} }
@@ -111,7 +111,7 @@ public inline fun <T, C: Collection<in T>> Array<T?>?.filterNotNullTo(result: C)
* *
* @includeFunctionBody ../../test/CollectionTest.kt flatMap * @includeFunctionBody ../../test/CollectionTest.kt flatMap
*/ */
public inline fun <T, R> Array<T>.flatMapTo(result: Collection<R>, transform: (T) -> Collection<R>) : Collection<R> { public inline fun <T, R> Array<T>.flatMapTo(result: MutableCollection<R>, transform: (T) -> Collection<R>) : Collection<R> {
for (element in this) { for (element in this) {
val list = transform(element) val list = transform(element)
if (list != null) { if (list != null) {
@@ -181,14 +181,14 @@ public inline fun <T> Array<T>.reduceRight(operation: (T, T) -> T): T = reverse(
* *
* @includeFunctionBody ../../test/CollectionTest.kt groupBy * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <T, K> Array<T>.groupBy(toKey: (T) -> K) : Map<K, List<T>> = groupByTo<T,K>(HashMap<K, List<T>>(), toKey) public inline fun <T, K> Array<T>.groupBy(toKey: (T) -> K) : Map<K, MutableList<T>> = groupByTo<T,K>(HashMap<K, MutableList<T>>(), 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 * 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 * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <T, K> Array<T>.groupByTo(result: Map<K, List<T>>, toKey: (T) -> K) : Map<K, List<T>> { public inline fun <T, K> Array<T>.groupByTo(result: MutableMap<K, MutableList<T>>, toKey: (T) -> K) : Map<K, MutableList<T>> {
for (element in this) { for (element in this) {
val key = toKey(element) val key = toKey(element)
val list = result.getOrPut(key) { ArrayList<T>() } val list = result.getOrPut(key) { ArrayList<T>() }
@@ -212,7 +212,7 @@ public inline fun <T> Array<T>.makeString(separator: String = ", ", prefix: Stri
} }
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ /** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
public inline fun <T, L: List<in T>> Array<T>.dropWhileTo(result: L, predicate: (T) -> Boolean) : L { public inline fun <T, L: MutableList<in T>> Array<T>.dropWhileTo(result: L, predicate: (T) -> Boolean) : L {
var start = true var start = true
for (element in this) { for (element in this) {
if (start && predicate(element)) { if (start && predicate(element)) {
@@ -226,13 +226,13 @@ public inline fun <T, L: List<in T>> Array<T>.dropWhileTo(result: L, predicate:
} }
/** Returns a list containing the first elements that satisfy the given *predicate* */ /** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <T, C: Collection<in T>> Array<T>.takeWhileTo(result: C, predicate: (T) -> Boolean) : C { public inline fun <T, C: MutableCollection<in T>> Array<T>.takeWhileTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break for (element in this) if (predicate(element)) result.add(element) else break
return result return result
} }
/** Copies all elements into the given collection */ /** Copies all elements into the given collection */
public inline fun <in T, C: Collection<in T>> Array<T>.toCollection(result: C) : C { public inline fun <in T, C: MutableCollection<in T>> Array<T>.toCollection(result: C) : C {
for (element in this) result.add(element) for (element in this) result.add(element)
return result return result
} }
@@ -5,7 +5,7 @@ package kotlin
// 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: src/kotlin/JLangIterablesJVM.kt // Generated from input file: JLangIterablesJVM.kt
// //
@@ -5,13 +5,11 @@ package kotlin
// 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: src/kotlin/JLangIterablesLazy.kt // Generated from input file: JLangIterablesLazy.kt
// //
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection
import java.util.List
// //
// This file contains methods which could have a lazy implementation for things like // This file contains methods which could have a lazy implementation for things like
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollections.kt // Generated from input file: JUtilCollections.kt
// //
@@ -21,7 +21,7 @@ import java.util.*
* 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
*/ */
public inline fun <T, R, C: Collection<in R>> Array<T>.mapTo(result: C, transform : (T) -> R) : C { public inline fun <T, R, C: MutableCollection<in R>> Array<T>.mapTo(result: C, transform : (T) -> R) : C {
for (item in this) for (item in this)
result.add(transform(item)) result.add(transform(item))
return result return result
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollectionsJVM.kt // Generated from input file: JUtilCollectionsJVM.kt
// //
@@ -22,6 +22,6 @@ import java.util.*
* *
* @includeFunctionBody ../../test/CollectionTest.kt map * @includeFunctionBody ../../test/CollectionTest.kt map
*/ */
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) : List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) return mapTo(java.util.ArrayList<R>(this.size), transform)
} }
@@ -5,7 +5,7 @@ package kotlin
// 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: src/kotlin/JLangIterables.kt // Generated from input file: JLangIterables.kt
// //
@@ -79,7 +79,7 @@ public inline fun BooleanArray.find(predicate: (Boolean) -> Boolean) : Boolean?
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList
*/ */
public inline fun <C: Collection<Boolean>> BooleanArray.filterTo(result: C, predicate: (Boolean) -> Boolean) : C { public inline fun <C: MutableCollection<Boolean>> BooleanArray.filterTo(result: C, predicate: (Boolean) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) for (element in this) if (predicate(element)) result.add(element)
return result return result
} }
@@ -89,7 +89,7 @@ public inline fun <C: Collection<Boolean>> BooleanArray.filterTo(result: C, pred
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/ */
public inline fun <C: Collection<Boolean>> BooleanArray.filterNotTo(result: C, predicate: (Boolean) -> Boolean) : C { public inline fun <C: MutableCollection<Boolean>> BooleanArray.filterNotTo(result: C, predicate: (Boolean) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element) for (element in this) if (!predicate(element)) result.add(element)
return result return result
} }
@@ -99,7 +99,7 @@ public inline fun <C: Collection<Boolean>> BooleanArray.filterNotTo(result: C, p
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/ */
public inline fun <C: Collection<Boolean>> BooleanArray?.filterNotNullTo(result: C) : C { public inline fun <C: MutableCollection<Boolean>> BooleanArray?.filterNotNullTo(result: C) : C {
if (this != null) { if (this != null) {
for (element in this) if (element != null) result.add(element) for (element in this) if (element != null) result.add(element)
} }
@@ -111,7 +111,7 @@ public inline fun <C: Collection<Boolean>> BooleanArray?.filterNotNullTo(result:
* *
* @includeFunctionBody ../../test/CollectionTest.kt flatMap * @includeFunctionBody ../../test/CollectionTest.kt flatMap
*/ */
public inline fun <R> BooleanArray.flatMapTo(result: Collection<R>, transform: (Boolean) -> Collection<R>) : Collection<R> { public inline fun <R> BooleanArray.flatMapTo(result: MutableCollection<R>, transform: (Boolean) -> Collection<R>) : Collection<R> {
for (element in this) { for (element in this) {
val list = transform(element) val list = transform(element)
if (list != null) { if (list != null) {
@@ -181,14 +181,14 @@ public inline fun BooleanArray.reduceRight(operation: (Boolean, Boolean) -> Bool
* *
* @includeFunctionBody ../../test/CollectionTest.kt groupBy * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <K> BooleanArray.groupBy(toKey: (Boolean) -> K) : Map<K, List<Boolean>> = groupByTo<K>(HashMap<K, List<Boolean>>(), toKey) public inline fun <K> BooleanArray.groupBy(toKey: (Boolean) -> K) : Map<K, MutableList<Boolean>> = groupByTo<K>(HashMap<K, MutableList<Boolean>>(), 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 * 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 * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <K> BooleanArray.groupByTo(result: Map<K, List<Boolean>>, toKey: (Boolean) -> K) : Map<K, List<Boolean>> { public inline fun <K> BooleanArray.groupByTo(result: MutableMap<K, MutableList<Boolean>>, toKey: (Boolean) -> K) : Map<K, MutableList<Boolean>> {
for (element in this) { for (element in this) {
val key = toKey(element) val key = toKey(element)
val list = result.getOrPut(key) { ArrayList<Boolean>() } val list = result.getOrPut(key) { ArrayList<Boolean>() }
@@ -212,7 +212,7 @@ public inline fun BooleanArray.makeString(separator: String = ", ", prefix: Stri
} }
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ /** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
public inline fun <L: List<Boolean>> BooleanArray.dropWhileTo(result: L, predicate: (Boolean) -> Boolean) : L { public inline fun <L: MutableList<Boolean>> BooleanArray.dropWhileTo(result: L, predicate: (Boolean) -> Boolean) : L {
var start = true var start = true
for (element in this) { for (element in this) {
if (start && predicate(element)) { if (start && predicate(element)) {
@@ -226,13 +226,13 @@ public inline fun <L: List<Boolean>> BooleanArray.dropWhileTo(result: L, predica
} }
/** Returns a list containing the first elements that satisfy the given *predicate* */ /** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <C: Collection<Boolean>> BooleanArray.takeWhileTo(result: C, predicate: (Boolean) -> Boolean) : C { public inline fun <C: MutableCollection<Boolean>> BooleanArray.takeWhileTo(result: C, predicate: (Boolean) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break for (element in this) if (predicate(element)) result.add(element) else break
return result return result
} }
/** Copies all elements into the given collection */ /** Copies all elements into the given collection */
public inline fun <C: Collection<Boolean>> BooleanArray.toCollection(result: C) : C { public inline fun <C: MutableCollection<Boolean>> BooleanArray.toCollection(result: C) : C {
for (element in this) result.add(element) for (element in this) result.add(element)
return result return result
} }
@@ -5,7 +5,7 @@ package kotlin
// 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: src/kotlin/JLangIterablesJVM.kt // Generated from input file: JLangIterablesJVM.kt
// //
@@ -5,13 +5,11 @@ package kotlin
// 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: src/kotlin/JLangIterablesLazy.kt // Generated from input file: JLangIterablesLazy.kt
// //
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection
import java.util.List
// //
// This file contains methods which could have a lazy implementation for things like // This file contains methods which could have a lazy implementation for things like
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollections.kt // Generated from input file: JUtilCollections.kt
// //
@@ -21,7 +21,7 @@ import java.util.*
* 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
*/ */
public inline fun <R, C: Collection<in R>> BooleanArray.mapTo(result: C, transform : (Boolean) -> R) : C { public inline fun <R, C: MutableCollection<in R>> BooleanArray.mapTo(result: C, transform : (Boolean) -> R) : C {
for (item in this) for (item in this)
result.add(transform(item)) result.add(transform(item))
return result return result
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollectionsJVM.kt // Generated from input file: JUtilCollectionsJVM.kt
// //
@@ -22,6 +22,6 @@ import java.util.*
* *
* @includeFunctionBody ../../test/CollectionTest.kt map * @includeFunctionBody ../../test/CollectionTest.kt map
*/ */
public inline fun <R> BooleanArray.map(transform : (Boolean) -> R) : java.util.List<R> { public inline fun <R> BooleanArray.map(transform : (Boolean) -> R) : List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) return mapTo(java.util.ArrayList<R>(this.size), transform)
} }
@@ -5,7 +5,7 @@ package kotlin
// 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: src/kotlin/JLangIterables.kt // Generated from input file: JLangIterables.kt
// //
@@ -79,7 +79,7 @@ public inline fun ByteArray.find(predicate: (Byte) -> Boolean) : Byte? {
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList
*/ */
public inline fun <C: Collection<Byte>> ByteArray.filterTo(result: C, predicate: (Byte) -> Boolean) : C { public inline fun <C: MutableCollection<Byte>> ByteArray.filterTo(result: C, predicate: (Byte) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) for (element in this) if (predicate(element)) result.add(element)
return result return result
} }
@@ -89,7 +89,7 @@ public inline fun <C: Collection<Byte>> ByteArray.filterTo(result: C, predicate:
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/ */
public inline fun <C: Collection<Byte>> ByteArray.filterNotTo(result: C, predicate: (Byte) -> Boolean) : C { public inline fun <C: MutableCollection<Byte>> ByteArray.filterNotTo(result: C, predicate: (Byte) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element) for (element in this) if (!predicate(element)) result.add(element)
return result return result
} }
@@ -99,7 +99,7 @@ public inline fun <C: Collection<Byte>> ByteArray.filterNotTo(result: C, predica
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/ */
public inline fun <C: Collection<Byte>> ByteArray?.filterNotNullTo(result: C) : C { public inline fun <C: MutableCollection<Byte>> ByteArray?.filterNotNullTo(result: C) : C {
if (this != null) { if (this != null) {
for (element in this) if (element != null) result.add(element) for (element in this) if (element != null) result.add(element)
} }
@@ -111,7 +111,7 @@ public inline fun <C: Collection<Byte>> ByteArray?.filterNotNullTo(result: C) :
* *
* @includeFunctionBody ../../test/CollectionTest.kt flatMap * @includeFunctionBody ../../test/CollectionTest.kt flatMap
*/ */
public inline fun <R> ByteArray.flatMapTo(result: Collection<R>, transform: (Byte) -> Collection<R>) : Collection<R> { public inline fun <R> ByteArray.flatMapTo(result: MutableCollection<R>, transform: (Byte) -> Collection<R>) : Collection<R> {
for (element in this) { for (element in this) {
val list = transform(element) val list = transform(element)
if (list != null) { if (list != null) {
@@ -181,14 +181,14 @@ public inline fun ByteArray.reduceRight(operation: (Byte, Byte) -> Byte): Byte =
* *
* @includeFunctionBody ../../test/CollectionTest.kt groupBy * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <K> ByteArray.groupBy(toKey: (Byte) -> K) : Map<K, List<Byte>> = groupByTo<K>(HashMap<K, List<Byte>>(), toKey) public inline fun <K> ByteArray.groupBy(toKey: (Byte) -> K) : Map<K, MutableList<Byte>> = groupByTo<K>(HashMap<K, MutableList<Byte>>(), 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 * 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 * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <K> ByteArray.groupByTo(result: Map<K, List<Byte>>, toKey: (Byte) -> K) : Map<K, List<Byte>> { public inline fun <K> ByteArray.groupByTo(result: MutableMap<K, MutableList<Byte>>, toKey: (Byte) -> K) : Map<K, MutableList<Byte>> {
for (element in this) { for (element in this) {
val key = toKey(element) val key = toKey(element)
val list = result.getOrPut(key) { ArrayList<Byte>() } val list = result.getOrPut(key) { ArrayList<Byte>() }
@@ -212,7 +212,7 @@ public inline fun ByteArray.makeString(separator: String = ", ", prefix: String
} }
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ /** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
public inline fun <L: List<Byte>> ByteArray.dropWhileTo(result: L, predicate: (Byte) -> Boolean) : L { public inline fun <L: MutableList<Byte>> ByteArray.dropWhileTo(result: L, predicate: (Byte) -> Boolean) : L {
var start = true var start = true
for (element in this) { for (element in this) {
if (start && predicate(element)) { if (start && predicate(element)) {
@@ -226,13 +226,13 @@ public inline fun <L: List<Byte>> ByteArray.dropWhileTo(result: L, predicate: (B
} }
/** Returns a list containing the first elements that satisfy the given *predicate* */ /** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <C: Collection<Byte>> ByteArray.takeWhileTo(result: C, predicate: (Byte) -> Boolean) : C { public inline fun <C: MutableCollection<Byte>> ByteArray.takeWhileTo(result: C, predicate: (Byte) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break for (element in this) if (predicate(element)) result.add(element) else break
return result return result
} }
/** Copies all elements into the given collection */ /** Copies all elements into the given collection */
public inline fun <C: Collection<Byte>> ByteArray.toCollection(result: C) : C { public inline fun <C: MutableCollection<Byte>> ByteArray.toCollection(result: C) : C {
for (element in this) result.add(element) for (element in this) result.add(element)
return result return result
} }
@@ -5,7 +5,7 @@ package kotlin
// 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: src/kotlin/JLangIterablesJVM.kt // Generated from input file: JLangIterablesJVM.kt
// //
@@ -5,13 +5,11 @@ package kotlin
// 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: src/kotlin/JLangIterablesLazy.kt // Generated from input file: JLangIterablesLazy.kt
// //
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection
import java.util.List
// //
// This file contains methods which could have a lazy implementation for things like // This file contains methods which could have a lazy implementation for things like
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollections.kt // Generated from input file: JUtilCollections.kt
// //
@@ -21,7 +21,7 @@ import java.util.*
* 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
*/ */
public inline fun <R, C: Collection<in R>> ByteArray.mapTo(result: C, transform : (Byte) -> R) : C { public inline fun <R, C: MutableCollection<in R>> ByteArray.mapTo(result: C, transform : (Byte) -> R) : C {
for (item in this) for (item in this)
result.add(transform(item)) result.add(transform(item))
return result return result
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollectionsJVM.kt // Generated from input file: JUtilCollectionsJVM.kt
// //
@@ -22,6 +22,6 @@ import java.util.*
* *
* @includeFunctionBody ../../test/CollectionTest.kt map * @includeFunctionBody ../../test/CollectionTest.kt map
*/ */
public inline fun <R> ByteArray.map(transform : (Byte) -> R) : java.util.List<R> { public inline fun <R> ByteArray.map(transform : (Byte) -> R) : List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) return mapTo(java.util.ArrayList<R>(this.size), transform)
} }
@@ -5,7 +5,7 @@ package kotlin
// 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: src/kotlin/JLangIterables.kt // Generated from input file: JLangIterables.kt
// //
@@ -79,7 +79,7 @@ public inline fun CharArray.find(predicate: (Char) -> Boolean) : Char? {
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList
*/ */
public inline fun <C: Collection<Char>> CharArray.filterTo(result: C, predicate: (Char) -> Boolean) : C { public inline fun <C: MutableCollection<Char>> CharArray.filterTo(result: C, predicate: (Char) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) for (element in this) if (predicate(element)) result.add(element)
return result return result
} }
@@ -89,7 +89,7 @@ public inline fun <C: Collection<Char>> CharArray.filterTo(result: C, predicate:
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/ */
public inline fun <C: Collection<Char>> CharArray.filterNotTo(result: C, predicate: (Char) -> Boolean) : C { public inline fun <C: MutableCollection<Char>> CharArray.filterNotTo(result: C, predicate: (Char) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element) for (element in this) if (!predicate(element)) result.add(element)
return result return result
} }
@@ -99,7 +99,7 @@ public inline fun <C: Collection<Char>> CharArray.filterNotTo(result: C, predica
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/ */
public inline fun <C: Collection<Char>> CharArray?.filterNotNullTo(result: C) : C { public inline fun <C: MutableCollection<Char>> CharArray?.filterNotNullTo(result: C) : C {
if (this != null) { if (this != null) {
for (element in this) if (element != null) result.add(element) for (element in this) if (element != null) result.add(element)
} }
@@ -111,7 +111,7 @@ public inline fun <C: Collection<Char>> CharArray?.filterNotNullTo(result: C) :
* *
* @includeFunctionBody ../../test/CollectionTest.kt flatMap * @includeFunctionBody ../../test/CollectionTest.kt flatMap
*/ */
public inline fun <R> CharArray.flatMapTo(result: Collection<R>, transform: (Char) -> Collection<R>) : Collection<R> { public inline fun <R> CharArray.flatMapTo(result: MutableCollection<R>, transform: (Char) -> Collection<R>) : Collection<R> {
for (element in this) { for (element in this) {
val list = transform(element) val list = transform(element)
if (list != null) { if (list != null) {
@@ -181,14 +181,14 @@ public inline fun CharArray.reduceRight(operation: (Char, Char) -> Char): Char =
* *
* @includeFunctionBody ../../test/CollectionTest.kt groupBy * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <K> CharArray.groupBy(toKey: (Char) -> K) : Map<K, List<Char>> = groupByTo<K>(HashMap<K, List<Char>>(), toKey) public inline fun <K> CharArray.groupBy(toKey: (Char) -> K) : Map<K, MutableList<Char>> = groupByTo<K>(HashMap<K, MutableList<Char>>(), 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 * 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 * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <K> CharArray.groupByTo(result: Map<K, List<Char>>, toKey: (Char) -> K) : Map<K, List<Char>> { public inline fun <K> CharArray.groupByTo(result: MutableMap<K, MutableList<Char>>, toKey: (Char) -> K) : Map<K, MutableList<Char>> {
for (element in this) { for (element in this) {
val key = toKey(element) val key = toKey(element)
val list = result.getOrPut(key) { ArrayList<Char>() } val list = result.getOrPut(key) { ArrayList<Char>() }
@@ -212,7 +212,7 @@ public inline fun CharArray.makeString(separator: String = ", ", prefix: String
} }
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ /** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
public inline fun <L: List<Char>> CharArray.dropWhileTo(result: L, predicate: (Char) -> Boolean) : L { public inline fun <L: MutableList<Char>> CharArray.dropWhileTo(result: L, predicate: (Char) -> Boolean) : L {
var start = true var start = true
for (element in this) { for (element in this) {
if (start && predicate(element)) { if (start && predicate(element)) {
@@ -226,13 +226,13 @@ public inline fun <L: List<Char>> CharArray.dropWhileTo(result: L, predicate: (C
} }
/** Returns a list containing the first elements that satisfy the given *predicate* */ /** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <C: Collection<Char>> CharArray.takeWhileTo(result: C, predicate: (Char) -> Boolean) : C { public inline fun <C: MutableCollection<Char>> CharArray.takeWhileTo(result: C, predicate: (Char) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break for (element in this) if (predicate(element)) result.add(element) else break
return result return result
} }
/** Copies all elements into the given collection */ /** Copies all elements into the given collection */
public inline fun <C: Collection<Char>> CharArray.toCollection(result: C) : C { public inline fun <C: MutableCollection<Char>> CharArray.toCollection(result: C) : C {
for (element in this) result.add(element) for (element in this) result.add(element)
return result return result
} }
@@ -5,7 +5,7 @@ package kotlin
// 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: src/kotlin/JLangIterablesJVM.kt // Generated from input file: JLangIterablesJVM.kt
// //
@@ -5,13 +5,11 @@ package kotlin
// 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: src/kotlin/JLangIterablesLazy.kt // Generated from input file: JLangIterablesLazy.kt
// //
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection
import java.util.List
// //
// This file contains methods which could have a lazy implementation for things like // This file contains methods which could have a lazy implementation for things like
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollections.kt // Generated from input file: JUtilCollections.kt
// //
@@ -21,7 +21,7 @@ import java.util.*
* 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
*/ */
public inline fun <R, C: Collection<in R>> CharArray.mapTo(result: C, transform : (Char) -> R) : C { public inline fun <R, C: MutableCollection<in R>> CharArray.mapTo(result: C, transform : (Char) -> R) : C {
for (item in this) for (item in this)
result.add(transform(item)) result.add(transform(item))
return result return result
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollectionsJVM.kt // Generated from input file: JUtilCollectionsJVM.kt
// //
@@ -22,6 +22,6 @@ import java.util.*
* *
* @includeFunctionBody ../../test/CollectionTest.kt map * @includeFunctionBody ../../test/CollectionTest.kt map
*/ */
public inline fun <R> CharArray.map(transform : (Char) -> R) : java.util.List<R> { public inline fun <R> CharArray.map(transform : (Char) -> R) : List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) return mapTo(java.util.ArrayList<R>(this.size), transform)
} }
@@ -5,7 +5,7 @@ package kotlin
// 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: src/kotlin/JLangIterables.kt // Generated from input file: JLangIterables.kt
// //
@@ -79,7 +79,7 @@ public inline fun DoubleArray.find(predicate: (Double) -> Boolean) : Double? {
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList
*/ */
public inline fun <C: Collection<Double>> DoubleArray.filterTo(result: C, predicate: (Double) -> Boolean) : C { public inline fun <C: MutableCollection<Double>> DoubleArray.filterTo(result: C, predicate: (Double) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) for (element in this) if (predicate(element)) result.add(element)
return result return result
} }
@@ -89,7 +89,7 @@ public inline fun <C: Collection<Double>> DoubleArray.filterTo(result: C, predic
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/ */
public inline fun <C: Collection<Double>> DoubleArray.filterNotTo(result: C, predicate: (Double) -> Boolean) : C { public inline fun <C: MutableCollection<Double>> DoubleArray.filterNotTo(result: C, predicate: (Double) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element) for (element in this) if (!predicate(element)) result.add(element)
return result return result
} }
@@ -99,7 +99,7 @@ public inline fun <C: Collection<Double>> DoubleArray.filterNotTo(result: C, pre
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/ */
public inline fun <C: Collection<Double>> DoubleArray?.filterNotNullTo(result: C) : C { public inline fun <C: MutableCollection<Double>> DoubleArray?.filterNotNullTo(result: C) : C {
if (this != null) { if (this != null) {
for (element in this) if (element != null) result.add(element) for (element in this) if (element != null) result.add(element)
} }
@@ -111,7 +111,7 @@ public inline fun <C: Collection<Double>> DoubleArray?.filterNotNullTo(result: C
* *
* @includeFunctionBody ../../test/CollectionTest.kt flatMap * @includeFunctionBody ../../test/CollectionTest.kt flatMap
*/ */
public inline fun <R> DoubleArray.flatMapTo(result: Collection<R>, transform: (Double) -> Collection<R>) : Collection<R> { public inline fun <R> DoubleArray.flatMapTo(result: MutableCollection<R>, transform: (Double) -> Collection<R>) : Collection<R> {
for (element in this) { for (element in this) {
val list = transform(element) val list = transform(element)
if (list != null) { if (list != null) {
@@ -181,14 +181,14 @@ public inline fun DoubleArray.reduceRight(operation: (Double, Double) -> Double)
* *
* @includeFunctionBody ../../test/CollectionTest.kt groupBy * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <K> DoubleArray.groupBy(toKey: (Double) -> K) : Map<K, List<Double>> = groupByTo<K>(HashMap<K, List<Double>>(), toKey) public inline fun <K> DoubleArray.groupBy(toKey: (Double) -> K) : Map<K, MutableList<Double>> = groupByTo<K>(HashMap<K, MutableList<Double>>(), 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 * 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 * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <K> DoubleArray.groupByTo(result: Map<K, List<Double>>, toKey: (Double) -> K) : Map<K, List<Double>> { public inline fun <K> DoubleArray.groupByTo(result: MutableMap<K, MutableList<Double>>, toKey: (Double) -> K) : Map<K, MutableList<Double>> {
for (element in this) { for (element in this) {
val key = toKey(element) val key = toKey(element)
val list = result.getOrPut(key) { ArrayList<Double>() } val list = result.getOrPut(key) { ArrayList<Double>() }
@@ -212,7 +212,7 @@ public inline fun DoubleArray.makeString(separator: String = ", ", prefix: Strin
} }
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ /** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
public inline fun <L: List<Double>> DoubleArray.dropWhileTo(result: L, predicate: (Double) -> Boolean) : L { public inline fun <L: MutableList<Double>> DoubleArray.dropWhileTo(result: L, predicate: (Double) -> Boolean) : L {
var start = true var start = true
for (element in this) { for (element in this) {
if (start && predicate(element)) { if (start && predicate(element)) {
@@ -226,13 +226,13 @@ public inline fun <L: List<Double>> DoubleArray.dropWhileTo(result: L, predicate
} }
/** Returns a list containing the first elements that satisfy the given *predicate* */ /** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <C: Collection<Double>> DoubleArray.takeWhileTo(result: C, predicate: (Double) -> Boolean) : C { public inline fun <C: MutableCollection<Double>> DoubleArray.takeWhileTo(result: C, predicate: (Double) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break for (element in this) if (predicate(element)) result.add(element) else break
return result return result
} }
/** Copies all elements into the given collection */ /** Copies all elements into the given collection */
public inline fun <C: Collection<Double>> DoubleArray.toCollection(result: C) : C { public inline fun <C: MutableCollection<Double>> DoubleArray.toCollection(result: C) : C {
for (element in this) result.add(element) for (element in this) result.add(element)
return result return result
} }
@@ -5,7 +5,7 @@ package kotlin
// 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: src/kotlin/JLangIterablesJVM.kt // Generated from input file: JLangIterablesJVM.kt
// //
@@ -5,13 +5,11 @@ package kotlin
// 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: src/kotlin/JLangIterablesLazy.kt // Generated from input file: JLangIterablesLazy.kt
// //
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection
import java.util.List
// //
// This file contains methods which could have a lazy implementation for things like // This file contains methods which could have a lazy implementation for things like
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollections.kt // Generated from input file: JUtilCollections.kt
// //
@@ -21,7 +21,7 @@ import java.util.*
* 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
*/ */
public inline fun <R, C: Collection<in R>> DoubleArray.mapTo(result: C, transform : (Double) -> R) : C { public inline fun <R, C: MutableCollection<in R>> DoubleArray.mapTo(result: C, transform : (Double) -> R) : C {
for (item in this) for (item in this)
result.add(transform(item)) result.add(transform(item))
return result return result
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollectionsJVM.kt // Generated from input file: JUtilCollectionsJVM.kt
// //
@@ -22,6 +22,6 @@ import java.util.*
* *
* @includeFunctionBody ../../test/CollectionTest.kt map * @includeFunctionBody ../../test/CollectionTest.kt map
*/ */
public inline fun <R> DoubleArray.map(transform : (Double) -> R) : java.util.List<R> { public inline fun <R> DoubleArray.map(transform : (Double) -> R) : List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) return mapTo(java.util.ArrayList<R>(this.size), transform)
} }
@@ -5,7 +5,7 @@ package kotlin
// 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: src/kotlin/JLangIterables.kt // Generated from input file: JLangIterables.kt
// //
@@ -79,7 +79,7 @@ public inline fun FloatArray.find(predicate: (Float) -> Boolean) : Float? {
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList
*/ */
public inline fun <C: Collection<Float>> FloatArray.filterTo(result: C, predicate: (Float) -> Boolean) : C { public inline fun <C: MutableCollection<Float>> FloatArray.filterTo(result: C, predicate: (Float) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) for (element in this) if (predicate(element)) result.add(element)
return result return result
} }
@@ -89,7 +89,7 @@ public inline fun <C: Collection<Float>> FloatArray.filterTo(result: C, predicat
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/ */
public inline fun <C: Collection<Float>> FloatArray.filterNotTo(result: C, predicate: (Float) -> Boolean) : C { public inline fun <C: MutableCollection<Float>> FloatArray.filterNotTo(result: C, predicate: (Float) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element) for (element in this) if (!predicate(element)) result.add(element)
return result return result
} }
@@ -99,7 +99,7 @@ public inline fun <C: Collection<Float>> FloatArray.filterNotTo(result: C, predi
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/ */
public inline fun <C: Collection<Float>> FloatArray?.filterNotNullTo(result: C) : C { public inline fun <C: MutableCollection<Float>> FloatArray?.filterNotNullTo(result: C) : C {
if (this != null) { if (this != null) {
for (element in this) if (element != null) result.add(element) for (element in this) if (element != null) result.add(element)
} }
@@ -111,7 +111,7 @@ public inline fun <C: Collection<Float>> FloatArray?.filterNotNullTo(result: C)
* *
* @includeFunctionBody ../../test/CollectionTest.kt flatMap * @includeFunctionBody ../../test/CollectionTest.kt flatMap
*/ */
public inline fun <R> FloatArray.flatMapTo(result: Collection<R>, transform: (Float) -> Collection<R>) : Collection<R> { public inline fun <R> FloatArray.flatMapTo(result: MutableCollection<R>, transform: (Float) -> Collection<R>) : Collection<R> {
for (element in this) { for (element in this) {
val list = transform(element) val list = transform(element)
if (list != null) { if (list != null) {
@@ -181,14 +181,14 @@ public inline fun FloatArray.reduceRight(operation: (Float, Float) -> Float): Fl
* *
* @includeFunctionBody ../../test/CollectionTest.kt groupBy * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <K> FloatArray.groupBy(toKey: (Float) -> K) : Map<K, List<Float>> = groupByTo<K>(HashMap<K, List<Float>>(), toKey) public inline fun <K> FloatArray.groupBy(toKey: (Float) -> K) : Map<K, MutableList<Float>> = groupByTo<K>(HashMap<K, MutableList<Float>>(), 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 * 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 * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <K> FloatArray.groupByTo(result: Map<K, List<Float>>, toKey: (Float) -> K) : Map<K, List<Float>> { public inline fun <K> FloatArray.groupByTo(result: MutableMap<K, MutableList<Float>>, toKey: (Float) -> K) : Map<K, MutableList<Float>> {
for (element in this) { for (element in this) {
val key = toKey(element) val key = toKey(element)
val list = result.getOrPut(key) { ArrayList<Float>() } val list = result.getOrPut(key) { ArrayList<Float>() }
@@ -212,7 +212,7 @@ public inline fun FloatArray.makeString(separator: String = ", ", prefix: String
} }
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ /** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
public inline fun <L: List<Float>> FloatArray.dropWhileTo(result: L, predicate: (Float) -> Boolean) : L { public inline fun <L: MutableList<Float>> FloatArray.dropWhileTo(result: L, predicate: (Float) -> Boolean) : L {
var start = true var start = true
for (element in this) { for (element in this) {
if (start && predicate(element)) { if (start && predicate(element)) {
@@ -226,13 +226,13 @@ public inline fun <L: List<Float>> FloatArray.dropWhileTo(result: L, predicate:
} }
/** Returns a list containing the first elements that satisfy the given *predicate* */ /** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <C: Collection<Float>> FloatArray.takeWhileTo(result: C, predicate: (Float) -> Boolean) : C { public inline fun <C: MutableCollection<Float>> FloatArray.takeWhileTo(result: C, predicate: (Float) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break for (element in this) if (predicate(element)) result.add(element) else break
return result return result
} }
/** Copies all elements into the given collection */ /** Copies all elements into the given collection */
public inline fun <C: Collection<Float>> FloatArray.toCollection(result: C) : C { public inline fun <C: MutableCollection<Float>> FloatArray.toCollection(result: C) : C {
for (element in this) result.add(element) for (element in this) result.add(element)
return result return result
} }
@@ -5,7 +5,7 @@ package kotlin
// 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: src/kotlin/JLangIterablesJVM.kt // Generated from input file: JLangIterablesJVM.kt
// //
@@ -5,13 +5,11 @@ package kotlin
// 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: src/kotlin/JLangIterablesLazy.kt // Generated from input file: JLangIterablesLazy.kt
// //
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection
import java.util.List
// //
// This file contains methods which could have a lazy implementation for things like // This file contains methods which could have a lazy implementation for things like
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollections.kt // Generated from input file: JUtilCollections.kt
// //
@@ -21,7 +21,7 @@ import java.util.*
* 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
*/ */
public inline fun <R, C: Collection<in R>> FloatArray.mapTo(result: C, transform : (Float) -> R) : C { public inline fun <R, C: MutableCollection<in R>> FloatArray.mapTo(result: C, transform : (Float) -> R) : C {
for (item in this) for (item in this)
result.add(transform(item)) result.add(transform(item))
return result return result
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollectionsJVM.kt // Generated from input file: JUtilCollectionsJVM.kt
// //
@@ -22,6 +22,6 @@ import java.util.*
* *
* @includeFunctionBody ../../test/CollectionTest.kt map * @includeFunctionBody ../../test/CollectionTest.kt map
*/ */
public inline fun <R> FloatArray.map(transform : (Float) -> R) : java.util.List<R> { public inline fun <R> FloatArray.map(transform : (Float) -> R) : List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) return mapTo(java.util.ArrayList<R>(this.size), transform)
} }
@@ -5,7 +5,7 @@ package kotlin
// 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: src/kotlin/JLangIterables.kt // Generated from input file: JLangIterables.kt
// //
@@ -79,7 +79,7 @@ public inline fun IntArray.find(predicate: (Int) -> Boolean) : Int? {
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList
*/ */
public inline fun <C: Collection<Int>> IntArray.filterTo(result: C, predicate: (Int) -> Boolean) : C { public inline fun <C: MutableCollection<Int>> IntArray.filterTo(result: C, predicate: (Int) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) for (element in this) if (predicate(element)) result.add(element)
return result return result
} }
@@ -89,7 +89,7 @@ public inline fun <C: Collection<Int>> IntArray.filterTo(result: C, predicate: (
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/ */
public inline fun <C: Collection<Int>> IntArray.filterNotTo(result: C, predicate: (Int) -> Boolean) : C { public inline fun <C: MutableCollection<Int>> IntArray.filterNotTo(result: C, predicate: (Int) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element) for (element in this) if (!predicate(element)) result.add(element)
return result return result
} }
@@ -99,7 +99,7 @@ public inline fun <C: Collection<Int>> IntArray.filterNotTo(result: C, predicate
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/ */
public inline fun <C: Collection<Int>> IntArray?.filterNotNullTo(result: C) : C { public inline fun <C: MutableCollection<Int>> IntArray?.filterNotNullTo(result: C) : C {
if (this != null) { if (this != null) {
for (element in this) if (element != null) result.add(element) for (element in this) if (element != null) result.add(element)
} }
@@ -111,7 +111,7 @@ public inline fun <C: Collection<Int>> IntArray?.filterNotNullTo(result: C) : C
* *
* @includeFunctionBody ../../test/CollectionTest.kt flatMap * @includeFunctionBody ../../test/CollectionTest.kt flatMap
*/ */
public inline fun <R> IntArray.flatMapTo(result: Collection<R>, transform: (Int) -> Collection<R>) : Collection<R> { public inline fun <R> IntArray.flatMapTo(result: MutableCollection<R>, transform: (Int) -> Collection<R>) : Collection<R> {
for (element in this) { for (element in this) {
val list = transform(element) val list = transform(element)
if (list != null) { if (list != null) {
@@ -181,14 +181,14 @@ public inline fun IntArray.reduceRight(operation: (Int, Int) -> Int): Int = reve
* *
* @includeFunctionBody ../../test/CollectionTest.kt groupBy * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <K> IntArray.groupBy(toKey: (Int) -> K) : Map<K, List<Int>> = groupByTo<K>(HashMap<K, List<Int>>(), toKey) public inline fun <K> IntArray.groupBy(toKey: (Int) -> K) : Map<K, MutableList<Int>> = groupByTo<K>(HashMap<K, MutableList<Int>>(), 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 * 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 * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <K> IntArray.groupByTo(result: Map<K, List<Int>>, toKey: (Int) -> K) : Map<K, List<Int>> { public inline fun <K> IntArray.groupByTo(result: MutableMap<K, MutableList<Int>>, toKey: (Int) -> K) : Map<K, MutableList<Int>> {
for (element in this) { for (element in this) {
val key = toKey(element) val key = toKey(element)
val list = result.getOrPut(key) { ArrayList<Int>() } val list = result.getOrPut(key) { ArrayList<Int>() }
@@ -212,7 +212,7 @@ public inline fun IntArray.makeString(separator: String = ", ", prefix: String =
} }
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ /** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
public inline fun <L: List<Int>> IntArray.dropWhileTo(result: L, predicate: (Int) -> Boolean) : L { public inline fun <L: MutableList<Int>> IntArray.dropWhileTo(result: L, predicate: (Int) -> Boolean) : L {
var start = true var start = true
for (element in this) { for (element in this) {
if (start && predicate(element)) { if (start && predicate(element)) {
@@ -226,13 +226,13 @@ public inline fun <L: List<Int>> IntArray.dropWhileTo(result: L, predicate: (Int
} }
/** Returns a list containing the first elements that satisfy the given *predicate* */ /** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <C: Collection<Int>> IntArray.takeWhileTo(result: C, predicate: (Int) -> Boolean) : C { public inline fun <C: MutableCollection<Int>> IntArray.takeWhileTo(result: C, predicate: (Int) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break for (element in this) if (predicate(element)) result.add(element) else break
return result return result
} }
/** Copies all elements into the given collection */ /** Copies all elements into the given collection */
public inline fun <C: Collection<Int>> IntArray.toCollection(result: C) : C { public inline fun <C: MutableCollection<Int>> IntArray.toCollection(result: C) : C {
for (element in this) result.add(element) for (element in this) result.add(element)
return result return result
} }
@@ -5,7 +5,7 @@ package kotlin
// 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: src/kotlin/JLangIterablesJVM.kt // Generated from input file: JLangIterablesJVM.kt
// //
@@ -5,13 +5,11 @@ package kotlin
// 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: src/kotlin/JLangIterablesLazy.kt // Generated from input file: JLangIterablesLazy.kt
// //
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection
import java.util.List
// //
// This file contains methods which could have a lazy implementation for things like // This file contains methods which could have a lazy implementation for things like
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollections.kt // Generated from input file: JUtilCollections.kt
// //
@@ -21,7 +21,7 @@ import java.util.*
* 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
*/ */
public inline fun <R, C: Collection<in R>> IntArray.mapTo(result: C, transform : (Int) -> R) : C { public inline fun <R, C: MutableCollection<in R>> IntArray.mapTo(result: C, transform : (Int) -> R) : C {
for (item in this) for (item in this)
result.add(transform(item)) result.add(transform(item))
return result return result
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollectionsJVM.kt // Generated from input file: JUtilCollectionsJVM.kt
// //
@@ -22,6 +22,6 @@ import java.util.*
* *
* @includeFunctionBody ../../test/CollectionTest.kt map * @includeFunctionBody ../../test/CollectionTest.kt map
*/ */
public inline fun <R> IntArray.map(transform : (Int) -> R) : java.util.List<R> { public inline fun <R> IntArray.map(transform : (Int) -> R) : List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) return mapTo(java.util.ArrayList<R>(this.size), transform)
} }
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JLangIterables.kt // Generated from input file: JLangIterables.kt
// //
@@ -78,7 +78,7 @@ public inline fun <T> Iterator<T>.find(predicate: (T) -> Boolean) : T? {
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList
*/ */
public inline fun <T, C: Collection<in T>> Iterator<T>.filterTo(result: C, predicate: (T) -> Boolean) : C { public inline fun <T, C: MutableCollection<in T>> Iterator<T>.filterTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) for (element in this) if (predicate(element)) result.add(element)
return result return result
} }
@@ -88,7 +88,7 @@ public inline fun <T, C: Collection<in T>> Iterator<T>.filterTo(result: C, predi
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/ */
public inline fun <T, C: Collection<in T>> Iterator<T>.filterNotTo(result: C, predicate: (T) -> Boolean) : C { public inline fun <T, C: MutableCollection<in T>> Iterator<T>.filterNotTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element) for (element in this) if (!predicate(element)) result.add(element)
return result return result
} }
@@ -98,7 +98,7 @@ public inline fun <T, C: Collection<in T>> Iterator<T>.filterNotTo(result: C, pr
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/ */
public inline fun <T, C: Collection<in T>> Iterator<T?>?.filterNotNullTo(result: C) : C { public inline fun <T, C: MutableCollection<in T>> Iterator<T?>?.filterNotNullTo(result: C) : C {
if (this != null) { if (this != null) {
for (element in this) if (element != null) result.add(element) for (element in this) if (element != null) result.add(element)
} }
@@ -110,7 +110,7 @@ public inline fun <T, C: Collection<in T>> Iterator<T?>?.filterNotNullTo(result:
* *
* @includeFunctionBody ../../test/CollectionTest.kt flatMap * @includeFunctionBody ../../test/CollectionTest.kt flatMap
*/ */
public inline fun <T, R> Iterator<T>.flatMapTo(result: Collection<R>, transform: (T) -> Collection<R>) : Collection<R> { public inline fun <T, R> Iterator<T>.flatMapTo(result: MutableCollection<R>, transform: (T) -> Collection<R>) : Collection<R> {
for (element in this) { for (element in this) {
val list = transform(element) val list = transform(element)
if (list != null) { if (list != null) {
@@ -180,14 +180,14 @@ public inline fun <T> Iterator<T>.reduceRight(operation: (T, T) -> T): T = rever
* *
* @includeFunctionBody ../../test/CollectionTest.kt groupBy * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <T, K> Iterator<T>.groupBy(toKey: (T) -> K) : Map<K, List<T>> = groupByTo<T,K>(HashMap<K, List<T>>(), toKey) public inline fun <T, K> Iterator<T>.groupBy(toKey: (T) -> K) : Map<K, MutableList<T>> = groupByTo<T,K>(HashMap<K, MutableList<T>>(), 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 * 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 * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <T, K> Iterator<T>.groupByTo(result: Map<K, List<T>>, toKey: (T) -> K) : Map<K, List<T>> { public inline fun <T, K> Iterator<T>.groupByTo(result: MutableMap<K, MutableList<T>>, toKey: (T) -> K) : Map<K, MutableList<T>> {
for (element in this) { for (element in this) {
val key = toKey(element) val key = toKey(element)
val list = result.getOrPut(key) { ArrayList<T>() } val list = result.getOrPut(key) { ArrayList<T>() }
@@ -211,7 +211,7 @@ public inline fun <T> Iterator<T>.makeString(separator: String = ", ", prefix: S
} }
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ /** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
public inline fun <T, L: List<in T>> Iterator<T>.dropWhileTo(result: L, predicate: (T) -> Boolean) : L { public inline fun <T, L: MutableList<in T>> Iterator<T>.dropWhileTo(result: L, predicate: (T) -> Boolean) : L {
var start = true var start = true
for (element in this) { for (element in this) {
if (start && predicate(element)) { if (start && predicate(element)) {
@@ -225,13 +225,13 @@ public inline fun <T, L: List<in T>> Iterator<T>.dropWhileTo(result: L, predicat
} }
/** Returns a list containing the first elements that satisfy the given *predicate* */ /** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <T, C: Collection<in T>> Iterator<T>.takeWhileTo(result: C, predicate: (T) -> Boolean) : C { public inline fun <T, C: MutableCollection<in T>> Iterator<T>.takeWhileTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break for (element in this) if (predicate(element)) result.add(element) else break
return result return result
} }
/** Copies all elements into the given collection */ /** Copies all elements into the given collection */
public inline fun <in T, C: Collection<in T>> Iterator<T>.toCollection(result: C) : C { public inline fun <in T, C: MutableCollection<in T>> Iterator<T>.toCollection(result: C) : C {
for (element in this) result.add(element) for (element in this) result.add(element)
return result return result
} }
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JLangIterablesJVM.kt // Generated from input file: JLangIterablesJVM.kt
// //
@@ -5,7 +5,7 @@ package kotlin
// 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: src/kotlin/JLangIterables.kt // Generated from input file: JLangIterables.kt
// //
@@ -79,7 +79,7 @@ public inline fun LongArray.find(predicate: (Long) -> Boolean) : Long? {
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList
*/ */
public inline fun <C: Collection<Long>> LongArray.filterTo(result: C, predicate: (Long) -> Boolean) : C { public inline fun <C: MutableCollection<Long>> LongArray.filterTo(result: C, predicate: (Long) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) for (element in this) if (predicate(element)) result.add(element)
return result return result
} }
@@ -89,7 +89,7 @@ public inline fun <C: Collection<Long>> LongArray.filterTo(result: C, predicate:
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/ */
public inline fun <C: Collection<Long>> LongArray.filterNotTo(result: C, predicate: (Long) -> Boolean) : C { public inline fun <C: MutableCollection<Long>> LongArray.filterNotTo(result: C, predicate: (Long) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element) for (element in this) if (!predicate(element)) result.add(element)
return result return result
} }
@@ -99,7 +99,7 @@ public inline fun <C: Collection<Long>> LongArray.filterNotTo(result: C, predica
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/ */
public inline fun <C: Collection<Long>> LongArray?.filterNotNullTo(result: C) : C { public inline fun <C: MutableCollection<Long>> LongArray?.filterNotNullTo(result: C) : C {
if (this != null) { if (this != null) {
for (element in this) if (element != null) result.add(element) for (element in this) if (element != null) result.add(element)
} }
@@ -111,7 +111,7 @@ public inline fun <C: Collection<Long>> LongArray?.filterNotNullTo(result: C) :
* *
* @includeFunctionBody ../../test/CollectionTest.kt flatMap * @includeFunctionBody ../../test/CollectionTest.kt flatMap
*/ */
public inline fun <R> LongArray.flatMapTo(result: Collection<R>, transform: (Long) -> Collection<R>) : Collection<R> { public inline fun <R> LongArray.flatMapTo(result: MutableCollection<R>, transform: (Long) -> Collection<R>) : Collection<R> {
for (element in this) { for (element in this) {
val list = transform(element) val list = transform(element)
if (list != null) { if (list != null) {
@@ -181,14 +181,14 @@ public inline fun LongArray.reduceRight(operation: (Long, Long) -> Long): Long =
* *
* @includeFunctionBody ../../test/CollectionTest.kt groupBy * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <K> LongArray.groupBy(toKey: (Long) -> K) : Map<K, List<Long>> = groupByTo<K>(HashMap<K, List<Long>>(), toKey) public inline fun <K> LongArray.groupBy(toKey: (Long) -> K) : Map<K, MutableList<Long>> = groupByTo<K>(HashMap<K, MutableList<Long>>(), 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 * 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 * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <K> LongArray.groupByTo(result: Map<K, List<Long>>, toKey: (Long) -> K) : Map<K, List<Long>> { public inline fun <K> LongArray.groupByTo(result: MutableMap<K, MutableList<Long>>, toKey: (Long) -> K) : Map<K, MutableList<Long>> {
for (element in this) { for (element in this) {
val key = toKey(element) val key = toKey(element)
val list = result.getOrPut(key) { ArrayList<Long>() } val list = result.getOrPut(key) { ArrayList<Long>() }
@@ -212,7 +212,7 @@ public inline fun LongArray.makeString(separator: String = ", ", prefix: String
} }
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ /** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
public inline fun <L: List<Long>> LongArray.dropWhileTo(result: L, predicate: (Long) -> Boolean) : L { public inline fun <L: MutableList<Long>> LongArray.dropWhileTo(result: L, predicate: (Long) -> Boolean) : L {
var start = true var start = true
for (element in this) { for (element in this) {
if (start && predicate(element)) { if (start && predicate(element)) {
@@ -226,13 +226,13 @@ public inline fun <L: List<Long>> LongArray.dropWhileTo(result: L, predicate: (L
} }
/** Returns a list containing the first elements that satisfy the given *predicate* */ /** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <C: Collection<Long>> LongArray.takeWhileTo(result: C, predicate: (Long) -> Boolean) : C { public inline fun <C: MutableCollection<Long>> LongArray.takeWhileTo(result: C, predicate: (Long) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break for (element in this) if (predicate(element)) result.add(element) else break
return result return result
} }
/** Copies all elements into the given collection */ /** Copies all elements into the given collection */
public inline fun <C: Collection<Long>> LongArray.toCollection(result: C) : C { public inline fun <C: MutableCollection<Long>> LongArray.toCollection(result: C) : C {
for (element in this) result.add(element) for (element in this) result.add(element)
return result return result
} }
@@ -5,7 +5,7 @@ package kotlin
// 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: src/kotlin/JLangIterablesJVM.kt // Generated from input file: JLangIterablesJVM.kt
// //
@@ -5,13 +5,11 @@ package kotlin
// 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: src/kotlin/JLangIterablesLazy.kt // Generated from input file: JLangIterablesLazy.kt
// //
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection
import java.util.List
// //
// This file contains methods which could have a lazy implementation for things like // This file contains methods which could have a lazy implementation for things like
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollections.kt // Generated from input file: JUtilCollections.kt
// //
@@ -21,7 +21,7 @@ import java.util.*
* 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
*/ */
public inline fun <R, C: Collection<in R>> LongArray.mapTo(result: C, transform : (Long) -> R) : C { public inline fun <R, C: MutableCollection<in R>> LongArray.mapTo(result: C, transform : (Long) -> R) : C {
for (item in this) for (item in this)
result.add(transform(item)) result.add(transform(item))
return result return result
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollectionsJVM.kt // Generated from input file: JUtilCollectionsJVM.kt
// //
@@ -22,6 +22,6 @@ import java.util.*
* *
* @includeFunctionBody ../../test/CollectionTest.kt map * @includeFunctionBody ../../test/CollectionTest.kt map
*/ */
public inline fun <R> LongArray.map(transform : (Long) -> R) : java.util.List<R> { public inline fun <R> LongArray.map(transform : (Long) -> R) : List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) return mapTo(java.util.ArrayList<R>(this.size), transform)
} }
@@ -5,7 +5,7 @@ package kotlin
// 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: src/kotlin/JLangIterables.kt // Generated from input file: JLangIterables.kt
// //
@@ -79,7 +79,7 @@ public inline fun ShortArray.find(predicate: (Short) -> Boolean) : Short? {
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList
*/ */
public inline fun <C: Collection<Short>> ShortArray.filterTo(result: C, predicate: (Short) -> Boolean) : C { public inline fun <C: MutableCollection<Short>> ShortArray.filterTo(result: C, predicate: (Short) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) for (element in this) if (predicate(element)) result.add(element)
return result return result
} }
@@ -89,7 +89,7 @@ public inline fun <C: Collection<Short>> ShortArray.filterTo(result: C, predicat
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/ */
public inline fun <C: Collection<Short>> ShortArray.filterNotTo(result: C, predicate: (Short) -> Boolean) : C { public inline fun <C: MutableCollection<Short>> ShortArray.filterNotTo(result: C, predicate: (Short) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element) for (element in this) if (!predicate(element)) result.add(element)
return result return result
} }
@@ -99,7 +99,7 @@ public inline fun <C: Collection<Short>> ShortArray.filterNotTo(result: C, predi
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/ */
public inline fun <C: Collection<Short>> ShortArray?.filterNotNullTo(result: C) : C { public inline fun <C: MutableCollection<Short>> ShortArray?.filterNotNullTo(result: C) : C {
if (this != null) { if (this != null) {
for (element in this) if (element != null) result.add(element) for (element in this) if (element != null) result.add(element)
} }
@@ -111,7 +111,7 @@ public inline fun <C: Collection<Short>> ShortArray?.filterNotNullTo(result: C)
* *
* @includeFunctionBody ../../test/CollectionTest.kt flatMap * @includeFunctionBody ../../test/CollectionTest.kt flatMap
*/ */
public inline fun <R> ShortArray.flatMapTo(result: Collection<R>, transform: (Short) -> Collection<R>) : Collection<R> { public inline fun <R> ShortArray.flatMapTo(result: MutableCollection<R>, transform: (Short) -> Collection<R>) : Collection<R> {
for (element in this) { for (element in this) {
val list = transform(element) val list = transform(element)
if (list != null) { if (list != null) {
@@ -181,14 +181,14 @@ public inline fun ShortArray.reduceRight(operation: (Short, Short) -> Short): Sh
* *
* @includeFunctionBody ../../test/CollectionTest.kt groupBy * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <K> ShortArray.groupBy(toKey: (Short) -> K) : Map<K, List<Short>> = groupByTo<K>(HashMap<K, List<Short>>(), toKey) public inline fun <K> ShortArray.groupBy(toKey: (Short) -> K) : Map<K, MutableList<Short>> = groupByTo<K>(HashMap<K, MutableList<Short>>(), 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 * 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 * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <K> ShortArray.groupByTo(result: Map<K, List<Short>>, toKey: (Short) -> K) : Map<K, List<Short>> { public inline fun <K> ShortArray.groupByTo(result: MutableMap<K, MutableList<Short>>, toKey: (Short) -> K) : Map<K, MutableList<Short>> {
for (element in this) { for (element in this) {
val key = toKey(element) val key = toKey(element)
val list = result.getOrPut(key) { ArrayList<Short>() } val list = result.getOrPut(key) { ArrayList<Short>() }
@@ -212,7 +212,7 @@ public inline fun ShortArray.makeString(separator: String = ", ", prefix: String
} }
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ /** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
public inline fun <L: List<Short>> ShortArray.dropWhileTo(result: L, predicate: (Short) -> Boolean) : L { public inline fun <L: MutableList<Short>> ShortArray.dropWhileTo(result: L, predicate: (Short) -> Boolean) : L {
var start = true var start = true
for (element in this) { for (element in this) {
if (start && predicate(element)) { if (start && predicate(element)) {
@@ -226,13 +226,13 @@ public inline fun <L: List<Short>> ShortArray.dropWhileTo(result: L, predicate:
} }
/** Returns a list containing the first elements that satisfy the given *predicate* */ /** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <C: Collection<Short>> ShortArray.takeWhileTo(result: C, predicate: (Short) -> Boolean) : C { public inline fun <C: MutableCollection<Short>> ShortArray.takeWhileTo(result: C, predicate: (Short) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break for (element in this) if (predicate(element)) result.add(element) else break
return result return result
} }
/** Copies all elements into the given collection */ /** Copies all elements into the given collection */
public inline fun <C: Collection<Short>> ShortArray.toCollection(result: C) : C { public inline fun <C: MutableCollection<Short>> ShortArray.toCollection(result: C) : C {
for (element in this) result.add(element) for (element in this) result.add(element)
return result return result
} }
@@ -5,7 +5,7 @@ package kotlin
// 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: src/kotlin/JLangIterablesJVM.kt // Generated from input file: JLangIterablesJVM.kt
// //
@@ -5,13 +5,11 @@ package kotlin
// 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: src/kotlin/JLangIterablesLazy.kt // Generated from input file: JLangIterablesLazy.kt
// //
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection
import java.util.List
// //
// This file contains methods which could have a lazy implementation for things like // This file contains methods which could have a lazy implementation for things like
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollections.kt // Generated from input file: JUtilCollections.kt
// //
@@ -21,7 +21,7 @@ import java.util.*
* 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
*/ */
public inline fun <R, C: Collection<in R>> ShortArray.mapTo(result: C, transform : (Short) -> R) : C { public inline fun <R, C: MutableCollection<in R>> ShortArray.mapTo(result: C, transform : (Short) -> R) : C {
for (item in this) for (item in this)
result.add(transform(item)) result.add(transform(item))
return result return result
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollectionsJVM.kt // Generated from input file: JUtilCollectionsJVM.kt
// //
@@ -22,6 +22,6 @@ import java.util.*
* *
* @includeFunctionBody ../../test/CollectionTest.kt map * @includeFunctionBody ../../test/CollectionTest.kt map
*/ */
public inline fun <R> ShortArray.map(transform : (Short) -> R) : java.util.List<R> { public inline fun <R> ShortArray.map(transform : (Short) -> R) : List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) return mapTo(java.util.ArrayList<R>(this.size), transform)
} }
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollections.kt // Generated from input file: JUtilCollections.kt
// //
@@ -21,7 +21,7 @@ import java.util.*
* 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
*/ */
public inline fun <T, R, C: Collection<in R>> Iterable<T>.mapTo(result: C, transform : (T) -> R) : C { public inline fun <T, R, C: MutableCollection<in R>> Iterable<T>.mapTo(result: C, transform : (T) -> R) : C {
for (item in this) for (item in this)
result.add(transform(item)) result.add(transform(item))
return result return result
@@ -4,7 +4,7 @@ package kotlin
// 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: src/kotlin/JUtilCollectionsJVM.kt // Generated from input file: JUtilCollectionsJVM.kt
// //
@@ -22,6 +22,6 @@ import java.util.*
* *
* @includeFunctionBody ../../test/CollectionTest.kt map * @includeFunctionBody ../../test/CollectionTest.kt map
*/ */
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) : List<R> {
return mapTo(java.util.ArrayList<R>(), transform) return mapTo(java.util.ArrayList<R>(), transform)
} }
@@ -1,6 +1,5 @@
package kotlin package kotlin
import java.util.List
import java.util.AbstractList import java.util.AbstractList
private class ImmutableArrayList<T>( private class ImmutableArrayList<T>(
@@ -37,7 +36,7 @@ private class ImmutableArrayList<T>(
public override fun size() : Int = length public override fun size() : Int = length
public override fun subList(fromIndex: Int, toIndex: Int) : List<T> { public override fun subList(fromIndex: Int, toIndex: Int) : MutableList<T> {
if (fromIndex < 0) { if (fromIndex < 0) {
throw IndexOutOfBoundsException("Negative from index ($fromIndex)") throw IndexOutOfBoundsException("Negative from index ($fromIndex)")
} }
@@ -48,7 +47,7 @@ private class ImmutableArrayList<T>(
throw IndexOutOfBoundsException("fromIndex ($fromIndex) + toIndex ($toIndex) > length ($length)") throw IndexOutOfBoundsException("fromIndex ($fromIndex) + toIndex ($toIndex) > length ($length)")
} }
if (fromIndex == toIndex) { if (fromIndex == toIndex) {
return emptyImmutableArrayList as List<T> return emptyImmutableArrayList as MutableList<T>
} }
if (fromIndex == 0 && toIndex == length) { if (fromIndex == 0 && toIndex == length) {
return this return this
@@ -70,7 +70,7 @@ public inline fun <T> Iterable<T>.find(predicate: (T) -> Boolean) : T? {
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterIntoLinkedList
*/ */
public inline fun <T, C: Collection<in T>> Iterable<T>.filterTo(result: C, predicate: (T) -> Boolean) : C { public inline fun <T, C: MutableCollection<in T>> Iterable<T>.filterTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) for (element in this) if (predicate(element)) result.add(element)
return result return result
} }
@@ -80,7 +80,7 @@ public inline fun <T, C: Collection<in T>> Iterable<T>.filterTo(result: C, predi
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotIntoLinkedList
*/ */
public inline fun <T, C: Collection<in T>> Iterable<T>.filterNotTo(result: C, predicate: (T) -> Boolean) : C { public inline fun <T, C: MutableCollection<in T>> Iterable<T>.filterNotTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (!predicate(element)) result.add(element) for (element in this) if (!predicate(element)) result.add(element)
return result return result
} }
@@ -90,7 +90,7 @@ public inline fun <T, C: Collection<in T>> Iterable<T>.filterNotTo(result: C, pr
* *
* @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList * @includeFunctionBody ../../test/CollectionTest.kt filterNotNullIntoLinkedList
*/ */
public inline fun <T, C: Collection<in T>> Iterable<T?>?.filterNotNullTo(result: C) : C { public inline fun <T, C: MutableCollection<in T>> Iterable<T?>?.filterNotNullTo(result: C) : C {
if (this != null) { if (this != null) {
for (element in this) if (element != null) result.add(element) for (element in this) if (element != null) result.add(element)
} }
@@ -102,7 +102,7 @@ public inline fun <T, C: Collection<in T>> Iterable<T?>?.filterNotNullTo(result:
* *
* @includeFunctionBody ../../test/CollectionTest.kt flatMap * @includeFunctionBody ../../test/CollectionTest.kt flatMap
*/ */
public inline fun <T, R> Iterable<T>.flatMapTo(result: Collection<R>, transform: (T) -> Collection<R>) : Collection<R> { public inline fun <T, R> Iterable<T>.flatMapTo(result: MutableCollection<R>, transform: (T) -> Collection<R>) : Collection<R> {
for (element in this) { for (element in this) {
val list = transform(element) val list = transform(element)
if (list != null) { if (list != null) {
@@ -172,14 +172,14 @@ public inline fun <T> Iterable<T>.reduceRight(operation: (T, T) -> T): T = rever
* *
* @includeFunctionBody ../../test/CollectionTest.kt groupBy * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <T, K> Iterable<T>.groupBy(toKey: (T) -> K) : Map<K, List<T>> = groupByTo<T,K>(HashMap<K, List<T>>(), toKey) public inline fun <T, K> Iterable<T>.groupBy(toKey: (T) -> K) : Map<K, MutableList<T>> = groupByTo<T,K>(HashMap<K, MutableList<T>>(), 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 * 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 * @includeFunctionBody ../../test/CollectionTest.kt groupBy
*/ */
public inline fun <T, K> Iterable<T>.groupByTo(result: Map<K, List<T>>, toKey: (T) -> K) : Map<K, List<T>> { public inline fun <T, K> Iterable<T>.groupByTo(result: MutableMap<K, MutableList<T>>, toKey: (T) -> K) : Map<K, MutableList<T>> {
for (element in this) { for (element in this) {
val key = toKey(element) val key = toKey(element)
val list = result.getOrPut(key) { ArrayList<T>() } val list = result.getOrPut(key) { ArrayList<T>() }
@@ -203,7 +203,7 @@ public inline fun <T> Iterable<T>.makeString(separator: String = ", ", prefix: S
} }
/** Returns a list containing the everything but the first elements that satisfy the given *predicate* */ /** Returns a list containing the everything but the first elements that satisfy the given *predicate* */
public inline fun <T, L: List<in T>> Iterable<T>.dropWhileTo(result: L, predicate: (T) -> Boolean) : L { public inline fun <T, L: MutableList<in T>> Iterable<T>.dropWhileTo(result: L, predicate: (T) -> Boolean) : L {
var start = true var start = true
for (element in this) { for (element in this) {
if (start && predicate(element)) { if (start && predicate(element)) {
@@ -217,13 +217,13 @@ public inline fun <T, L: List<in T>> Iterable<T>.dropWhileTo(result: L, predicat
} }
/** Returns a list containing the first elements that satisfy the given *predicate* */ /** Returns a list containing the first elements that satisfy the given *predicate* */
public inline fun <T, C: Collection<in T>> Iterable<T>.takeWhileTo(result: C, predicate: (T) -> Boolean) : C { public inline fun <T, C: MutableCollection<in T>> Iterable<T>.takeWhileTo(result: C, predicate: (T) -> Boolean) : C {
for (element in this) if (predicate(element)) result.add(element) else break for (element in this) if (predicate(element)) result.add(element) else break
return result return result
} }
/** Copies all elements into the given collection */ /** Copies all elements into the given collection */
public inline fun <in T, C: Collection<in T>> Iterable<T>.toCollection(result: C) : C { public inline fun <in T, C: MutableCollection<in T>> Iterable<T>.toCollection(result: C) : C {
for (element in this) result.add(element) for (element in this) result.add(element)
return result return result
} }
@@ -1,8 +1,6 @@
package kotlin package kotlin
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection
import java.util.List
// //
// This file contains methods which could have a lazy implementation for things like // This file contains methods which could have a lazy implementation for things like
@@ -1,8 +1,6 @@
package kotlin package kotlin
// Number of extension function for java.lang.Iterable that shouldn't participate in auto generation // Number of extension function for java.lang.Iterable that shouldn't participate in auto generation
import java.util.Collection
import java.util.List
import java.util.AbstractList import java.util.AbstractList
import java.util.Comparator import java.util.Comparator
import java.util.ArrayList import java.util.ArrayList
@@ -59,7 +57,7 @@ public inline fun <T> Iterable<T>.first() : T {
// TODO: Specify type of the exception // TODO: Specify type of the exception
public fun <T> Iterable<T>.last() : T { public fun <T> Iterable<T>.last() : T {
if (this is List<T>) { if (this is List<T>) {
return this.get(this.size() - 1); return this.get(this.size() - 1)
} }
val iterator = this.iterator().sure() val iterator = this.iterator().sure()
@@ -98,7 +96,7 @@ public fun <T> Iterable<T>.contains(item : T) : Boolean {
* *
* @includeFunctionBody ../../test/ListTest.kt withIndices * @includeFunctionBody ../../test/ListTest.kt withIndices
*/ */
public fun <T> Iterable<T>.withIndices(): java.util.List<#(Int, T)> { public fun <T> Iterable<T>.withIndices(): List<#(Int, T)> {
val answer = ArrayList<#(Int, T)>() val answer = ArrayList<#(Int, T)>()
var nextIndex = 0 var nextIndex = 0
for (e in this) { for (e in this) {
@@ -1,10 +1,7 @@
package kotlin package kotlin
import java.util.AbstractList import java.util.AbstractList
import java.util.Collection
import java.util.Comparator import java.util.Comparator
import java.util.Iterator
import java.util.List
// TODO this function is here as it breaks the JS compiler; lets move back to JLangIterablesSpecial when it works again :) // TODO this function is here as it breaks the JS compiler; lets move back to JLangIterablesSpecial when it works again :)
@@ -15,7 +12,7 @@ import java.util.List
* *
* @includeFunctionBody ../../test/CollectionTest.kt sortBy * @includeFunctionBody ../../test/CollectionTest.kt sortBy
*/ */
public inline fun <in T, R: Comparable<in R>> Iterable<T>.sortBy(f: (T) -> R): java.util.List<T> { public inline fun <in T, R: Comparable<in R>> Iterable<T>.sortBy(f: (T) -> R): List<T> {
val sortedList = this.toList() val sortedList = this.toList()
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) ->
val xr = f(x) val xr = f(x)
+5 -5
View File
@@ -19,7 +19,7 @@ val Int.indices: IntRange
/** /**
* Converts the collection to an array * Converts the collection to an array
*/ */
public inline fun <T> java.util.Collection<T>.toArray() : Array<T> { public inline fun <T> Collection<T>.toArray() : Array<T> {
val answer = arrayOfNulls<T>(this.size) val answer = arrayOfNulls<T>(this.size)
var idx = 0 var idx = 0
for (elem in this) for (elem in this)
@@ -28,10 +28,10 @@ public inline fun <T> java.util.Collection<T>.toArray() : Array<T> {
} }
/** Returns true if the collection is not empty */ /** Returns true if the collection is not empty */
public inline fun <T> java.util.Collection<T>.notEmpty() : Boolean = !this.isEmpty() public inline fun <T> Collection<T>.notEmpty() : Boolean = !this.isEmpty()
/** 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> Collection<T>?.orEmpty() : Collection<T>
= if (this != null) this else Collections.emptyList<T>() as Collection<T> = if (this != null) this else Collections.emptyList<T>() as Collection<T>
@@ -44,8 +44,8 @@ public inline fun <in T: Comparable<T>> Iterable<T>.toSortedList(comparator: jav
// List APIs // List APIs
/** 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> List<T>?.orEmpty() : List<T>
= if (this != null) this else Collections.emptyList<T>() as java.util.List<T> = if (this != null) this else Collections.emptyList<T>() as List<T>
/** /**
TODO figure out necessary variance/generics ninja stuff... :) TODO figure out necessary variance/generics ninja stuff... :)
@@ -13,7 +13,7 @@ import java.util.*
* 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
*/ */
public inline fun <T, R, C: Collection<in R>> java.util.Collection<T>.mapTo(result: C, transform : (T) -> R) : C { public inline fun <T, R, C: MutableCollection<in R>> Collection<T>.mapTo(result: C, transform : (T) -> R) : C {
for (item in this) for (item in this)
result.add(transform(item)) result.add(transform(item))
return result return result
@@ -14,6 +14,6 @@ import java.util.*
* *
* @includeFunctionBody ../../test/CollectionTest.kt map * @includeFunctionBody ../../test/CollectionTest.kt map
*/ */
public inline fun <T, R> java.util.Collection<T>.map(transform : (T) -> R) : java.util.List<R> { public inline fun <T, R> Collection<T>.map(transform : (T) -> R) : List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) return mapTo(java.util.ArrayList<R>(this.size), transform)
} }
+2 -2
View File
@@ -75,8 +75,8 @@ public inline fun <K,V> linkedMap(vararg values: #(K,V)): LinkedHashMap<K,V> {
/** Returns the Set if its not null otherwise returns the empty set */ /** 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> public inline fun <T> Set<T>?.orEmpty() : Set<T>
= if (this != null) this else Collections.EMPTY_SET as java.util.Set<T> = if (this != null) this else Collections.EMPTY_SET as Set<T>
/** Returns a new ArrayList with a variable number of initial elements */ /** 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)) public inline fun arrayList<T>(vararg values: T) : ArrayList<T> = values.toCollection(ArrayList<T>(values.size))
+12 -16
View File
@@ -1,28 +1,24 @@
package kotlin package kotlin
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.Map as JMap
import java.util.Map
// Map APIs // Map APIs
/** Returns the size of the map */ /** Returns the size of the map */
val JMap<*,*>.size : Int val Map<*,*>.size : Int
get() = size() get() = size()
/** Returns true if this map is empty */ /** Returns true if this map is empty */
val JMap<*,*>.empty : Boolean val Map<*,*>.empty : Boolean
get() = isEmpty() get() = isEmpty()
/** Provides [] access to maps */ /** Provides [] access to maps */
public fun <K, V> JMap<K, V>.set(key : K, value : V) : V? = this.put(key, value) public fun <K, V> MutableMap<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> Map<K,V>?.orEmpty() : Map<K,V>
= if (this != null) this else Collections.emptyMap<K,V>() as java.util.Map<K,V> = if (this != null) this else Collections.emptyMap<K,V>() as Map<K,V>
/** Returns the key of the entry */ /** Returns the key of the entry */
@@ -38,7 +34,7 @@ val <K,V> Map.Entry<K,V>.value : V
* *
* @includeFunctionBody ../../test/MapTest.kt getOrElse * @includeFunctionBody ../../test/MapTest.kt getOrElse
*/ */
public inline fun <K,V> java.util.Map<K,V>.getOrElse(key: K, defaultValue: ()-> V) : V { public inline fun <K,V> Map<K,V>.getOrElse(key: K, defaultValue: ()-> V) : V {
val current = this.get(key) val current = this.get(key)
if (current != null) { if (current != null) {
return current return current
@@ -52,7 +48,7 @@ public inline fun <K,V> java.util.Map<K,V>.getOrElse(key: K, defaultValue: ()->
* *
* @includeFunctionBody ../../test/MapTest.kt getOrElse * @includeFunctionBody ../../test/MapTest.kt getOrElse
*/ */
public inline fun <K,V> java.util.Map<K,V>.getOrPut(key: K, defaultValue: ()-> V) : V { public inline fun <K,V> MutableMap<K,V>.getOrPut(key: K, defaultValue: ()-> V) : V {
val current = this.get(key) val current = this.get(key)
if (current != null) { if (current != null) {
return current return current
@@ -69,7 +65,7 @@ public inline fun <K,V> java.util.Map<K,V>.getOrPut(key: K, defaultValue: ()-> V
* *
* @includeFunctionBody ../../test/MapTest.kt iterateWithProperties * @includeFunctionBody ../../test/MapTest.kt iterateWithProperties
*/ */
public inline fun <K,V> java.util.Map<K,V>.iterator(): Iterator<java.util.Map.Entry<K,V>> { public inline fun <K,V> Map<K,V>.iterator(): Iterator<Map.Entry<K,V>> {
val entrySet = this.entrySet()!! val entrySet = this.entrySet()!!
return entrySet.iterator()!! return entrySet.iterator()!!
} }
@@ -78,7 +74,7 @@ public inline fun <K,V> java.util.Map<K,V>.iterator(): Iterator<java.util.Map.En
* 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
*/ */
public inline fun <K,V,R, C: Collection<in R>> java.util.Map<K,V>.mapTo(result: C, transform: (java.util.Map.Entry<K,V>) -> R) : C { public inline fun <K,V,R, C: MutableCollection<in R>> Map<K,V>.mapTo(result: C, transform: (Map.Entry<K,V>) -> R) : C {
for (item in this) for (item in this)
result.add(transform(item)) result.add(transform(item))
return result return result
@@ -87,7 +83,7 @@ public inline fun <K,V,R, C: Collection<in R>> java.util.Map<K,V>.mapTo(result:
/** /**
* 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]]
*/ */
public inline fun <K,V,R,C: java.util.Map<K,R>> java.util.Map<K,V>.mapValuesTo(result: C, transform : (java.util.Map.Entry<K,V>) -> R) : C { public inline fun <K,V,R,C: MutableMap<K,R>> MutableMap<K,V>.mapValuesTo(result: C, transform : (Map.Entry<K,V>) -> R) : C {
for (e in this) { for (e in this) {
val newValue = transform(e) val newValue = transform(e)
result.put(e.key, newValue) result.put(e.key, newValue)
@@ -98,7 +94,7 @@ public inline fun <K,V,R,C: java.util.Map<K,R>> java.util.Map<K,V>.mapValuesTo(r
/** /**
* Puts all the entries into the map with the first value in the tuple being the key and the second the value * Puts all the entries into the map with the first value in the tuple being the key and the second the value
*/ */
public inline fun <K,V> java.util.Map<K,V>.putAll(vararg values: #(K,V)): Unit { public inline fun <K,V> MutableMap<K,V>.putAll(vararg values: #(K,V)): Unit {
for (v in values) { for (v in values) {
put(v._1, v._2) put(v._1, v._2)
} }
@@ -107,7 +103,7 @@ public inline fun <K,V> java.util.Map<K,V>.putAll(vararg values: #(K,V)): Unit {
/** /**
* Copies the entries in this [[Map]] to the given *map* * Copies the entries in this [[Map]] to the given *map*
*/ */
public inline fun <K,V> java.util.Map<K,V>.toMap(map: Map<K,V>): Map<K,V> { public inline fun <K,V> Map<K,V>.toMap(map: MutableMap<K,V>): Map<K,V> {
map.putAll(this) map.putAll(this)
return map return map
} }
+5 -8
View File
@@ -2,9 +2,6 @@ package kotlin
import java.util.Comparator import java.util.Comparator
import java.util.LinkedHashMap 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.SortedMap
import java.util.TreeMap import java.util.TreeMap
import java.util.Properties import java.util.Properties
@@ -14,14 +11,14 @@ import java.util.Properties
/** /**
* Converts this [[Map]] to a [[LinkedHashMap]] so future insertion orders are maintained * 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> public inline fun <K,V> 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 * Converts this [[Map]] to a [[SortedMap]] so iteration order will be in key order
* *
* @includeFunctionBody ../../test/MapTest.kt toSortedMap * @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> public inline fun <K,V> 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 * Converts this [[Map]] to a [[SortedMap]] using the given *comparator* so that iteration order will be in the order
@@ -29,7 +26,7 @@ public inline fun <K,V> java.util.Map<K,V>.toSortedMap(): SortedMap<K,V> = toMap
* *
* @includeFunctionBody ../../test/MapTest.kt toSortedMapWithComparator * @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> public inline fun <K,V> Map<K,V>.toSortedMap(comparator: Comparator<K>): SortedMap<K,V> = toMap<K,V>(TreeMap(comparator)) as SortedMap<K,V>
/** /**
@@ -50,7 +47,7 @@ public inline fun Map<String, String>.toProperties(): Properties {
* *
* @includeFunctionBody ../../test/CollectionTest.kt 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> { public inline fun <K,V,R> Map<K,V>.map(transform: (Map.Entry<K,V>) -> R) : List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform) return mapTo(java.util.ArrayList<R>(this.size), transform)
} }
@@ -60,7 +57,7 @@ public inline fun <K,V,R> java.util.Map<K,V>.map(transform: (java.util.Map.Entry
* *
* @includeFunctionBody ../../test/MapTest.kt mapValues * @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> { public inline fun <K,V,R> MutableMap<K,V>.mapValues(transform : (Map.Entry<K,V>) -> R): Map<K,R> {
return mapValuesTo(java.util.HashMap<K,R>(this.size), transform) return mapValuesTo(java.util.HashMap<K,R>(this.size), transform)
} }
-1
View File
@@ -1,7 +1,6 @@
package kotlin package kotlin
import java.util.ArrayList import java.util.ArrayList
import java.util.Collection
import java.util.HashSet import java.util.HashSet
import java.util.LinkedList import java.util.LinkedList
@@ -1,6 +1,5 @@
package kotlin package kotlin
import java.util.Collection
import java.util.ArrayList import java.util.ArrayList
import java.util.LinkedList import java.util.LinkedList
import java.util.HashSet import java.util.HashSet
-1
View File
@@ -1,6 +1,5 @@
package kotlin package kotlin
import java.util.List
import java.util.ArrayList import java.util.ArrayList
/** Returns the string with leading and trailing text matching the given string removed */ /** Returns the string with leading and trailing text matching the given string removed */
@@ -1,7 +1,6 @@
package kotlin package kotlin
import java.io.StringReader import java.io.StringReader
import java.util.List
public inline fun String.lastIndexOf(str: String) : Int = (this as java.lang.String).lastIndexOf(str) public inline fun String.lastIndexOf(str: String) : Int = (this as java.lang.String).lastIndexOf(str)
+1 -1
View File
@@ -118,7 +118,7 @@ fun Node.nextElements(): Iterator<Element> = nextSiblings().filterIsInstance<Nod
fun Node.previousElements(): Iterator<Element> = previousSiblings().filterIsInstance<Node, Element>(javaClass<Element>()) fun Node.previousElements(): Iterator<Element> = previousSiblings().filterIsInstance<Node, Element>(javaClass<Element>())
var Element.classSet : Set<String> var Element.classSet : MutableSet<String>
get() { get() {
val answer = LinkedHashSet<String>() val answer = LinkedHashSet<String>()
val array = this.classes.split("""\s""") val array = this.classes.split("""\s""")
-1
View File
@@ -3,7 +3,6 @@ package kotlin.io
import java.io.* import java.io.*
import java.nio.charset.* import java.nio.charset.*
import java.util.NoSuchElementException import java.util.NoSuchElementException
import java.util.List
import java.util.ArrayList import java.util.ArrayList
import java.net.URL import java.net.URL
@@ -54,9 +54,9 @@ open class ModuleBuilder(val name: String): Module {
annotationsRoots0.add(name) annotationsRoots0.add(name)
} }
public override fun getSourceFiles(): List<String?>? = sourceFiles0 public override fun getSourceFiles(): MutableList<String?>? = sourceFiles0
public override fun getClasspathRoots(): List<String?>? = classpathRoots0 public override fun getClasspathRoots(): MutableList<String?>? = classpathRoots0
public override fun getAnnotationsRoots(): List<String?>? = annotationsRoots0 public override fun getAnnotationsRoots(): MutableList<String?>? = annotationsRoots0
public override fun getModuleName(): String? = name public override fun getModuleName(): String? = name
} }
@@ -26,7 +26,7 @@ public inline fun <T> T?.find(predicate: (T)-> Boolean): T? {
public inline fun <T> T?.filter(predicate: (T)-> Boolean): T? = find(predicate) public inline fun <T> T?.filter(predicate: (T)-> Boolean): T? = find(predicate)
/** Filters all elements in this collection which match the given predicate into the given result collection */ /** Filters all elements in this collection which match the given predicate into the given result collection */
public inline fun <T, C: Collection<in T>> T?.filterTo(result: C, predicate: (T)-> Boolean): C { public inline fun <T, C: MutableCollection<in T>> T?.filterTo(result: C, predicate: (T)-> Boolean): C {
if (this != null && predicate(this)) if (this != null && predicate(this))
result.add(this) result.add(this)
return result return result
@@ -36,7 +36,7 @@ public inline fun <T, C: Collection<in T>> T?.filterTo(result: C, predicate: (T)
public inline fun <T> T?.filterNotNull(): Collection<T> = filterNotNullTo(java.util.ArrayList<T>()) public inline fun <T> T?.filterNotNull(): Collection<T> = filterNotNullTo(java.util.ArrayList<T>())
/** Filters all the null elements in this collection winto the given result collection */ /** Filters all the null elements in this collection winto the given result collection */
public inline fun <T, C: Collection<in T>> T?.filterNotNullTo(result: C): C { public inline fun <T, C: MutableCollection<in T>> T?.filterNotNullTo(result: C): C {
if (this != null) { if (this != null) {
result.add(this) result.add(this)
} }
@@ -47,7 +47,7 @@ public inline fun <T, C: Collection<in T>> T?.filterNotNullTo(result: C): C {
public inline fun <T> T?.filterNot(predicate: (T)-> Boolean): Collection<T> = filterNotTo(ArrayList<T>(), predicate) public inline fun <T> T?.filterNot(predicate: (T)-> Boolean): Collection<T> = filterNotTo(ArrayList<T>(), predicate)
/** Returns a new collection containing all elements in this collection which do not match the given predicate */ /** Returns a new collection containing all elements in this collection which do not match the given predicate */
public inline fun <T, C: Collection<in T>> T?.filterNotTo(result: C, predicate: (T)-> Boolean): C { public inline fun <T, C: MutableCollection<in T>> T?.filterNotTo(result: C, predicate: (T)-> Boolean): C {
if (this != null && !predicate(this)) { if (this != null && !predicate(this)) {
result.add(this) result.add(this)
} }
@@ -58,7 +58,7 @@ public inline fun <T, C: Collection<in T>> T?.filterNotTo(result: C, predicate:
* Returns the result of transforming each item in the collection to a one or more values which * Returns the result of transforming each item in the collection to a one or more values which
* are concatenated together into a single collection * are concatenated together into a single collection
*/ */
public inline fun <T, R> T?.flatMap(transform: (T)-> Collection<R>): Collection<R> { public inline fun <T, R> T?.flatMap(transform: (T)-> MutableCollection<R>): Collection<R> {
return flatMapTo(ArrayList<R>(), transform) return flatMapTo(ArrayList<R>(), transform)
} }
@@ -66,7 +66,7 @@ public inline fun <T, R> T?.flatMap(transform: (T)-> Collection<R>): Collection<
* Returns the result of transforming each item in the collection to a one or more values which * Returns the result of transforming each item in the collection to a one or more values which
* are concatenated together into a single collection * are concatenated together into a single collection
*/ */
public inline fun <T, R> T?.flatMapTo(result: Collection<R>, transform: (T)-> Collection<R>): Collection<R> { public inline fun <T, R> T?.flatMapTo(result: MutableCollection<R>, transform: (T)-> MutableCollection<R>): Collection<R> {
if (this != null) { if (this != null) {
val coll = transform(this) val coll = transform(this)
if (coll != null) { if (coll != null) {
@@ -111,7 +111,7 @@ public inline fun <T> T?.foldRight(initial: T, operation: (it: T, it2: T) -> T):
* Iterates through the collection performing the transformation on each element and using the result * Iterates through the collection performing the transformation on each element and using the result
* as the key in a map to group elements by the result * as the key in a map to group elements by the result
*/ */
public inline fun <T, K> T?.groupBy(result: Map<K, List<T>> = HashMap<K, List<T>>(), toKey: (T)-> K): Map<K, List<T>> { public inline fun <T, K> T?.groupBy(result: MutableMap<K, MutableList<T>> = HashMap<K, MutableList<T>>(), toKey: (T)-> K): Map<K, MutableList<T>> {
if (this != null) { if (this != null) {
val key = toKey(this) val key = toKey(this)
val list = result.getOrPut(key){ ArrayList<T>() } val list = result.getOrPut(key){ ArrayList<T>() }
@@ -143,7 +143,7 @@ public inline fun <T, R> T?.map(transform : (T) -> R) : R? {
} }
/** Transforms each element of this collection with the given function then adds the results to the given collection */ /** Transforms each element of this collection with the given function then adds the results to the given collection */
public inline fun <T, R, C: Collection<in R>> T?.mapTo(result: C, transform : (T) -> R) : C { public inline fun <T, R, C: MutableCollection<in R>> T?.mapTo(result: C, transform : (T) -> R) : C {
if (this != null) { if (this != null) {
result.add(transform(this)) result.add(transform(this))
} }
@@ -156,7 +156,7 @@ public inline fun <T> T?.reverse(): T? {
} }
/** Copies the collection into the given collection */ /** Copies the collection into the given collection */
public inline fun <T, C: Collection<T>> T?.toCollection(result: C): C { public inline fun <T, C: MutableCollection<T>> T?.toCollection(result: C): C {
if (this != null) if (this != null)
result.add(this) result.add(this)
return result return result
@@ -2,8 +2,6 @@ package kotlin.properties
import kotlin.* import kotlin.*
import kotlin.util.* import kotlin.util.*
import java.util.List
import java.util.Map
import java.util.HashMap import java.util.HashMap
import java.util.ArrayList import java.util.ArrayList
@@ -23,8 +21,8 @@ public trait ChangeListener {
* change tracking mechanisms for persistence or distributed change notifications. * change tracking mechanisms for persistence or distributed change notifications.
*/ */
public abstract class ChangeSupport { public abstract class ChangeSupport {
private var allListeners: List<ChangeListener>? = null private var allListeners: MutableList<ChangeListener>? = null
private var nameListeners: Map<String, List<ChangeListener>>? = null private var nameListeners: MutableMap<String, MutableList<ChangeListener>>? = null
public fun addChangeListener(listener: ChangeListener) { public fun addChangeListener(listener: ChangeListener) {
@@ -36,7 +34,7 @@ public abstract class ChangeSupport {
public fun addChangeListener(name: String, listener: ChangeListener) { public fun addChangeListener(name: String, listener: ChangeListener) {
if (nameListeners == null) { if (nameListeners == null) {
nameListeners = HashMap<String, List<ChangeListener>>() nameListeners = HashMap<String, MutableList<ChangeListener>>()
} }
var listeners = nameListeners?.get(name) var listeners = nameListeners?.get(name)
if (listeners == null) { if (listeners == null) {
@@ -3,7 +3,6 @@ package test.collection
import kotlin.test.* import kotlin.test.*
import junit.framework.TestCase import junit.framework.TestCase
import java.util.List
import java.util.Random import java.util.Random
class ImmutableArrayListTest() : TestCase() { class ImmutableArrayListTest() : TestCase() {
@@ -1,6 +1,5 @@
package test.stdlib.issues package test.stdlib.issues
import java.util.List
import kotlin.util.* import kotlin.util.*
import kotlin.test.* import kotlin.test.*
import junit.framework.TestCase import junit.framework.TestCase
@@ -9,7 +9,6 @@ import java.util.ArrayList
import java.util.TreeMap import java.util.TreeMap
import org.w3c.dom.* import org.w3c.dom.*
import org.w3c.dom.events.* import org.w3c.dom.events.*
import java.util.List
/** /**
* This tool generates JavaScript stubs for classes available in the JDK which are already available in the browser environment * This tool generates JavaScript stubs for classes available in the JDK which are already available in the browser environment
@@ -1,7 +1,6 @@
package org.jetbrains.kotlin.tools package org.jetbrains.kotlin.tools
import java.io.* import java.io.*
import java.util.List
private val COMMON_AUTOGENERATED_WARNING: String = """// private val COMMON_AUTOGENERATED_WARNING: String = """//
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
@@ -116,27 +115,27 @@ fun main(args: Array<String>) {
// 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")) {
it.replaceAll("java.util.Collection<T", "Array<T") it.replaceAll("Collection<T", "Array<T")
} }
generateFile(File(outDir, "ArraysFromJUtilCollectionsJVM.kt"), "package kotlin", File(srcDir, "JUtilCollectionsJVM.kt")) { generateFile(File(outDir, "ArraysFromJUtilCollectionsJVM.kt"), "package kotlin", File(srcDir, "JUtilCollectionsJVM.kt")) {
it.replaceAll("java.util.Collection<T", "Array<T") it.replaceAll("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")) {
replaceGenerics(arrayName, it.replaceAll("<T> java.util.Collection<T>", "${arrayName}Array"). replaceGenerics(arrayName, it.replaceAll("<T> Collection<T>", "${arrayName}Array").
replaceAll("java.util.Collection<T>", "${arrayName}Array")) replaceAll("Collection<T>", "${arrayName}Array"))
} }
generateFile(File(outDir, "${arrayName}ArraysFromJUtilCollectionsJVM.kt"), "package kotlin", File(srcDir, "JUtilCollectionsJVM.kt")) { generateFile(File(outDir, "${arrayName}ArraysFromJUtilCollectionsJVM.kt"), "package kotlin", File(srcDir, "JUtilCollectionsJVM.kt")) {
replaceGenerics(arrayName, it.replaceAll("<T> java.util.Collection<T>", "${arrayName}Array"). replaceGenerics(arrayName, it.replaceAll("<T> Collection<T>", "${arrayName}Array").
replaceAll("java.util.Collection<T>", "${arrayName}Array")) replaceAll("Collection<T>", "${arrayName}Array"))
} }
} }
generateFile(File(outDir, "StandardFromJUtilCollections.kt"), "package kotlin", File(srcDir, "JUtilCollections.kt")) { generateFile(File(outDir, "StandardFromJUtilCollections.kt"), "package kotlin", File(srcDir, "JUtilCollections.kt")) {
it.replaceAll("java.util.Collection<T", "Iterable<T").replaceAll("(this.size)", "") it.replaceAll("Collection<T", "Iterable<T").replaceAll("(this.size)", "")
} }
generateFile(File(outDir, "StandardFromJUtilCollectionsJVM.kt"), "package kotlin", File(srcDir, "JUtilCollectionsJVM.kt")) { generateFile(File(outDir, "StandardFromJUtilCollectionsJVM.kt"), "package kotlin", File(srcDir, "JUtilCollectionsJVM.kt")) {
it.replaceAll("java.util.Collection<T", "Iterable<T").replaceAll("(this.size)", "") it.replaceAll("Collection<T", "Iterable<T").replaceAll("(this.size)", "")
} }
generateDownTos(File(outDir, "DownTo.kt"), "package kotlin") generateDownTos(File(outDir, "DownTo.kt"), "package kotlin")
@@ -3,7 +3,6 @@ package regressions
// TODO comment out the next line to reproduce KT-1617 // TODO comment out the next line to reproduce KT-1617
//import kotlin.util.map //import kotlin.util.map
import java.util.Collection
import java.io.File import java.io.File
import junit.framework.TestCase import junit.framework.TestCase
@@ -1,7 +1,6 @@
package regressions package regressions
import junit.framework.TestCase import junit.framework.TestCase
import java.util.List
class Kt1619Test: TestCase() { class Kt1619Test: TestCase() {