Rename "collection" parameter to "destination" in *To() functions.
This commit is contained in:
committed by
Andrey Breslav
parent
e43d08d228
commit
6562ee4967
@@ -565,231 +565,231 @@ public fun <T : Any> Stream<T?>.filterNotNull(): Stream<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements that are not null to the given *collection*
|
||||
* Appends all elements that are not null to the given *destination*
|
||||
*/
|
||||
public fun <C : MutableCollection<in T>, T : Any> Array<T?>.filterNotNullTo(collection: C): C {
|
||||
for (element in this) if (element != null) collection.add(element)
|
||||
return collection
|
||||
public fun <C : MutableCollection<in T>, T : Any> Array<T?>.filterNotNullTo(destination: C): C {
|
||||
for (element in this) if (element != null) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements that are not null to the given *collection*
|
||||
* Appends all elements that are not null to the given *destination*
|
||||
*/
|
||||
public fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(collection: C): C {
|
||||
for (element in this) if (element != null) collection.add(element)
|
||||
return collection
|
||||
public fun <C : MutableCollection<in T>, T : Any> Iterable<T?>.filterNotNullTo(destination: C): C {
|
||||
for (element in this) if (element != null) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements that are not null to the given *collection*
|
||||
* Appends all elements that are not null to the given *destination*
|
||||
*/
|
||||
public fun <C : MutableCollection<in T>, T : Any> Stream<T?>.filterNotNullTo(collection: C): C {
|
||||
for (element in this) if (element != null) collection.add(element)
|
||||
return collection
|
||||
public fun <C : MutableCollection<in T>, T : Any> Stream<T?>.filterNotNullTo(destination: C): C {
|
||||
for (element in this) if (element != null) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements not matching the given *predicate* to the given *collection*
|
||||
* Appends all elements not matching the given *predicate* to the given *destination*
|
||||
*/
|
||||
public inline fun <T, C : MutableCollection<in T>> Array<out T>.filterNotTo(collection: C, predicate: (T) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <T, C : MutableCollection<in T>> Array<out T>.filterNotTo(destination: C, predicate: (T) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements not matching the given *predicate* to the given *collection*
|
||||
* Appends all elements not matching the given *predicate* to the given *destination*
|
||||
*/
|
||||
public inline fun <C : MutableCollection<in Boolean>> BooleanArray.filterNotTo(collection: C, predicate: (Boolean) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <C : MutableCollection<in Boolean>> BooleanArray.filterNotTo(destination: C, predicate: (Boolean) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements not matching the given *predicate* to the given *collection*
|
||||
* Appends all elements not matching the given *predicate* to the given *destination*
|
||||
*/
|
||||
public inline fun <C : MutableCollection<in Byte>> ByteArray.filterNotTo(collection: C, predicate: (Byte) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <C : MutableCollection<in Byte>> ByteArray.filterNotTo(destination: C, predicate: (Byte) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements not matching the given *predicate* to the given *collection*
|
||||
* Appends all elements not matching the given *predicate* to the given *destination*
|
||||
*/
|
||||
public inline fun <C : MutableCollection<in Char>> CharArray.filterNotTo(collection: C, predicate: (Char) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <C : MutableCollection<in Char>> CharArray.filterNotTo(destination: C, predicate: (Char) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements not matching the given *predicate* to the given *collection*
|
||||
* Appends all elements not matching the given *predicate* to the given *destination*
|
||||
*/
|
||||
public inline fun <C : MutableCollection<in Double>> DoubleArray.filterNotTo(collection: C, predicate: (Double) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <C : MutableCollection<in Double>> DoubleArray.filterNotTo(destination: C, predicate: (Double) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements not matching the given *predicate* to the given *collection*
|
||||
* Appends all elements not matching the given *predicate* to the given *destination*
|
||||
*/
|
||||
public inline fun <C : MutableCollection<in Float>> FloatArray.filterNotTo(collection: C, predicate: (Float) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <C : MutableCollection<in Float>> FloatArray.filterNotTo(destination: C, predicate: (Float) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements not matching the given *predicate* to the given *collection*
|
||||
* Appends all elements not matching the given *predicate* to the given *destination*
|
||||
*/
|
||||
public inline fun <C : MutableCollection<in Int>> IntArray.filterNotTo(collection: C, predicate: (Int) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <C : MutableCollection<in Int>> IntArray.filterNotTo(destination: C, predicate: (Int) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements not matching the given *predicate* to the given *collection*
|
||||
* Appends all elements not matching the given *predicate* to the given *destination*
|
||||
*/
|
||||
public inline fun <C : MutableCollection<in Long>> LongArray.filterNotTo(collection: C, predicate: (Long) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <C : MutableCollection<in Long>> LongArray.filterNotTo(destination: C, predicate: (Long) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements not matching the given *predicate* to the given *collection*
|
||||
* Appends all elements not matching the given *predicate* to the given *destination*
|
||||
*/
|
||||
public inline fun <C : MutableCollection<in Short>> ShortArray.filterNotTo(collection: C, predicate: (Short) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <C : MutableCollection<in Short>> ShortArray.filterNotTo(destination: C, predicate: (Short) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements not matching the given *predicate* to the given *collection*
|
||||
* Appends all elements not matching the given *predicate* to the given *destination*
|
||||
*/
|
||||
public inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(collection: C, predicate: (T) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterNotTo(destination: C, predicate: (T) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements not matching the given *predicate* to the given *collection*
|
||||
* Appends all elements not matching the given *predicate* to the given *destination*
|
||||
*/
|
||||
public inline fun <K, V, C : MutableCollection<in Map.Entry<K, V>>> Map<K, V>.filterNotTo(collection: C, predicate: (Map.Entry<K, V>) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <K, V, C : MutableCollection<in Map.Entry<K, V>>> Map<K, V>.filterNotTo(destination: C, predicate: (Map.Entry<K, V>) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements not matching the given *predicate* to the given *collection*
|
||||
* Appends all elements not matching the given *predicate* to the given *destination*
|
||||
*/
|
||||
public inline fun <T, C : MutableCollection<in T>> Stream<T>.filterNotTo(collection: C, predicate: (T) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <T, C : MutableCollection<in T>> Stream<T>.filterNotTo(destination: C, predicate: (T) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all characters not matching the given *predicate* to the given *collection*
|
||||
* Appends all characters not matching the given *predicate* to the given *destination*
|
||||
*/
|
||||
public inline fun <C : Appendable> String.filterNotTo(collection: C, predicate: (Char) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) collection.append(element)
|
||||
return collection
|
||||
public inline fun <C : Appendable> String.filterNotTo(destination: C, predicate: (Char) -> Boolean): C {
|
||||
for (element in this) if (!predicate(element)) destination.append(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements matching the given *predicate* into the given *collection*
|
||||
* Appends all elements matching the given *predicate* into the given *destination*
|
||||
*/
|
||||
public inline fun <T, C : MutableCollection<in T>> Array<out T>.filterTo(collection: C, predicate: (T) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <T, C : MutableCollection<in T>> Array<out T>.filterTo(destination: C, predicate: (T) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements matching the given *predicate* into the given *collection*
|
||||
* Appends all elements matching the given *predicate* into the given *destination*
|
||||
*/
|
||||
public inline fun <C : MutableCollection<in Boolean>> BooleanArray.filterTo(collection: C, predicate: (Boolean) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <C : MutableCollection<in Boolean>> BooleanArray.filterTo(destination: C, predicate: (Boolean) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements matching the given *predicate* into the given *collection*
|
||||
* Appends all elements matching the given *predicate* into the given *destination*
|
||||
*/
|
||||
public inline fun <C : MutableCollection<in Byte>> ByteArray.filterTo(collection: C, predicate: (Byte) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <C : MutableCollection<in Byte>> ByteArray.filterTo(destination: C, predicate: (Byte) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements matching the given *predicate* into the given *collection*
|
||||
* Appends all elements matching the given *predicate* into the given *destination*
|
||||
*/
|
||||
public inline fun <C : MutableCollection<in Char>> CharArray.filterTo(collection: C, predicate: (Char) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <C : MutableCollection<in Char>> CharArray.filterTo(destination: C, predicate: (Char) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements matching the given *predicate* into the given *collection*
|
||||
* Appends all elements matching the given *predicate* into the given *destination*
|
||||
*/
|
||||
public inline fun <C : MutableCollection<in Double>> DoubleArray.filterTo(collection: C, predicate: (Double) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <C : MutableCollection<in Double>> DoubleArray.filterTo(destination: C, predicate: (Double) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements matching the given *predicate* into the given *collection*
|
||||
* Appends all elements matching the given *predicate* into the given *destination*
|
||||
*/
|
||||
public inline fun <C : MutableCollection<in Float>> FloatArray.filterTo(collection: C, predicate: (Float) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <C : MutableCollection<in Float>> FloatArray.filterTo(destination: C, predicate: (Float) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements matching the given *predicate* into the given *collection*
|
||||
* Appends all elements matching the given *predicate* into the given *destination*
|
||||
*/
|
||||
public inline fun <C : MutableCollection<in Int>> IntArray.filterTo(collection: C, predicate: (Int) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <C : MutableCollection<in Int>> IntArray.filterTo(destination: C, predicate: (Int) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements matching the given *predicate* into the given *collection*
|
||||
* Appends all elements matching the given *predicate* into the given *destination*
|
||||
*/
|
||||
public inline fun <C : MutableCollection<in Long>> LongArray.filterTo(collection: C, predicate: (Long) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <C : MutableCollection<in Long>> LongArray.filterTo(destination: C, predicate: (Long) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements matching the given *predicate* into the given *collection*
|
||||
* Appends all elements matching the given *predicate* into the given *destination*
|
||||
*/
|
||||
public inline fun <C : MutableCollection<in Short>> ShortArray.filterTo(collection: C, predicate: (Short) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <C : MutableCollection<in Short>> ShortArray.filterTo(destination: C, predicate: (Short) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements matching the given *predicate* into the given *collection*
|
||||
* Appends all elements matching the given *predicate* into the given *destination*
|
||||
*/
|
||||
public inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(collection: C, predicate: (T) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(destination: C, predicate: (T) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements matching the given *predicate* into the given *collection*
|
||||
* Appends all elements matching the given *predicate* into the given *destination*
|
||||
*/
|
||||
public inline fun <K, V, C : MutableCollection<in Map.Entry<K, V>>> Map<K, V>.filterTo(collection: C, predicate: (Map.Entry<K, V>) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <K, V, C : MutableCollection<in Map.Entry<K, V>>> Map<K, V>.filterTo(destination: C, predicate: (Map.Entry<K, V>) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements matching the given *predicate* into the given *collection*
|
||||
* Appends all elements matching the given *predicate* into the given *destination*
|
||||
*/
|
||||
public inline fun <T, C : MutableCollection<in T>> Stream<T>.filterTo(collection: C, predicate: (T) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) collection.add(element)
|
||||
return collection
|
||||
public inline fun <T, C : MutableCollection<in T>> Stream<T>.filterTo(destination: C, predicate: (T) -> Boolean): C {
|
||||
for (element in this) if (predicate(element)) destination.add(element)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all characters matching the given *predicate* to the given *collection*
|
||||
* Appends all characters matching the given *predicate* to the given *destination*
|
||||
*/
|
||||
public inline fun <C : Appendable> String.filterTo(destination: C, predicate: (Char) -> Boolean): C {
|
||||
for (index in 0..length - 1) {
|
||||
|
||||
@@ -99,146 +99,146 @@ public fun <T, R> Stream<T>.flatMap(transform: (T) -> Stream<R>): Stream<R> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection*
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *destination*
|
||||
*/
|
||||
public inline fun <T, R, C : MutableCollection<in R>> Array<out T>.flatMapTo(collection: C, transform: (T) -> Iterable<R>): C {
|
||||
public inline fun <T, R, C : MutableCollection<in R>> Array<out T>.flatMapTo(destination: C, transform: (T) -> Iterable<R>): C {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
collection.addAll(list)
|
||||
destination.addAll(list)
|
||||
}
|
||||
return collection
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection*
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *destination*
|
||||
*/
|
||||
public inline fun <R, C : MutableCollection<in R>> BooleanArray.flatMapTo(collection: C, transform: (Boolean) -> Iterable<R>): C {
|
||||
public inline fun <R, C : MutableCollection<in R>> BooleanArray.flatMapTo(destination: C, transform: (Boolean) -> Iterable<R>): C {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
collection.addAll(list)
|
||||
destination.addAll(list)
|
||||
}
|
||||
return collection
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection*
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *destination*
|
||||
*/
|
||||
public inline fun <R, C : MutableCollection<in R>> ByteArray.flatMapTo(collection: C, transform: (Byte) -> Iterable<R>): C {
|
||||
public inline fun <R, C : MutableCollection<in R>> ByteArray.flatMapTo(destination: C, transform: (Byte) -> Iterable<R>): C {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
collection.addAll(list)
|
||||
destination.addAll(list)
|
||||
}
|
||||
return collection
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection*
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *destination*
|
||||
*/
|
||||
public inline fun <R, C : MutableCollection<in R>> CharArray.flatMapTo(collection: C, transform: (Char) -> Iterable<R>): C {
|
||||
public inline fun <R, C : MutableCollection<in R>> CharArray.flatMapTo(destination: C, transform: (Char) -> Iterable<R>): C {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
collection.addAll(list)
|
||||
destination.addAll(list)
|
||||
}
|
||||
return collection
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection*
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *destination*
|
||||
*/
|
||||
public inline fun <R, C : MutableCollection<in R>> DoubleArray.flatMapTo(collection: C, transform: (Double) -> Iterable<R>): C {
|
||||
public inline fun <R, C : MutableCollection<in R>> DoubleArray.flatMapTo(destination: C, transform: (Double) -> Iterable<R>): C {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
collection.addAll(list)
|
||||
destination.addAll(list)
|
||||
}
|
||||
return collection
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection*
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *destination*
|
||||
*/
|
||||
public inline fun <R, C : MutableCollection<in R>> FloatArray.flatMapTo(collection: C, transform: (Float) -> Iterable<R>): C {
|
||||
public inline fun <R, C : MutableCollection<in R>> FloatArray.flatMapTo(destination: C, transform: (Float) -> Iterable<R>): C {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
collection.addAll(list)
|
||||
destination.addAll(list)
|
||||
}
|
||||
return collection
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection*
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *destination*
|
||||
*/
|
||||
public inline fun <R, C : MutableCollection<in R>> IntArray.flatMapTo(collection: C, transform: (Int) -> Iterable<R>): C {
|
||||
public inline fun <R, C : MutableCollection<in R>> IntArray.flatMapTo(destination: C, transform: (Int) -> Iterable<R>): C {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
collection.addAll(list)
|
||||
destination.addAll(list)
|
||||
}
|
||||
return collection
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection*
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *destination*
|
||||
*/
|
||||
public inline fun <R, C : MutableCollection<in R>> LongArray.flatMapTo(collection: C, transform: (Long) -> Iterable<R>): C {
|
||||
public inline fun <R, C : MutableCollection<in R>> LongArray.flatMapTo(destination: C, transform: (Long) -> Iterable<R>): C {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
collection.addAll(list)
|
||||
destination.addAll(list)
|
||||
}
|
||||
return collection
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection*
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *destination*
|
||||
*/
|
||||
public inline fun <R, C : MutableCollection<in R>> ShortArray.flatMapTo(collection: C, transform: (Short) -> Iterable<R>): C {
|
||||
public inline fun <R, C : MutableCollection<in R>> ShortArray.flatMapTo(destination: C, transform: (Short) -> Iterable<R>): C {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
collection.addAll(list)
|
||||
destination.addAll(list)
|
||||
}
|
||||
return collection
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection*
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *destination*
|
||||
*/
|
||||
public inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(collection: C, transform: (T) -> Iterable<R>): C {
|
||||
public inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.flatMapTo(destination: C, transform: (T) -> Iterable<R>): C {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
collection.addAll(list)
|
||||
destination.addAll(list)
|
||||
}
|
||||
return collection
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection*
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *destination*
|
||||
*/
|
||||
public inline fun <K, V, R, C : MutableCollection<in R>> Map<K, V>.flatMapTo(collection: C, transform: (Map.Entry<K, V>) -> Iterable<R>): C {
|
||||
public inline fun <K, V, R, C : MutableCollection<in R>> Map<K, V>.flatMapTo(destination: C, transform: (Map.Entry<K, V>) -> Iterable<R>): C {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
collection.addAll(list)
|
||||
destination.addAll(list)
|
||||
}
|
||||
return collection
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection*
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *destination*
|
||||
*/
|
||||
public inline fun <R, C : MutableCollection<in R>> String.flatMapTo(collection: C, transform: (Char) -> Iterable<R>): C {
|
||||
public inline fun <R, C : MutableCollection<in R>> String.flatMapTo(destination: C, transform: (Char) -> Iterable<R>): C {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
collection.addAll(list)
|
||||
destination.addAll(list)
|
||||
}
|
||||
return collection
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original stream, to the given *collection*
|
||||
* Appends all elements yielded from results of *transform* function being invoked on each element of original stream, to the given *destination*
|
||||
*/
|
||||
public inline fun <T, R, C : MutableCollection<in R>> Stream<T>.flatMapTo(collection: C, transform: (T) -> Stream<R>): C {
|
||||
public inline fun <T, R, C : MutableCollection<in R>> Stream<T>.flatMapTo(destination: C, transform: (T) -> Stream<R>): C {
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
collection.addAll(list)
|
||||
destination.addAll(list)
|
||||
}
|
||||
return collection
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -602,171 +602,171 @@ public fun <T : Any, R> Stream<T?>.mapNotNull(transform: (T) -> R): Stream<R> {
|
||||
|
||||
/**
|
||||
* Appends transformed non-null elements of original collection using the given *transform* function
|
||||
* to the given *collection*
|
||||
* to the given *destination*
|
||||
*/
|
||||
public inline fun <T : Any, R, C : MutableCollection<in R>> Array<T?>.mapNotNullTo(collection: C, transform: (T) -> R): C {
|
||||
public inline fun <T : Any, R, C : MutableCollection<in R>> Array<T?>.mapNotNullTo(destination: C, transform: (T) -> R): C {
|
||||
for (element in this) {
|
||||
if (element != null) {
|
||||
collection.add(transform(element))
|
||||
destination.add(transform(element))
|
||||
}
|
||||
}
|
||||
return collection
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends transformed non-null elements of original collection using the given *transform* function
|
||||
* to the given *collection*
|
||||
* to the given *destination*
|
||||
*/
|
||||
public inline fun <T : Any, R, C : MutableCollection<in R>> Iterable<T?>.mapNotNullTo(collection: C, transform: (T) -> R): C {
|
||||
public inline fun <T : Any, R, C : MutableCollection<in R>> Iterable<T?>.mapNotNullTo(destination: C, transform: (T) -> R): C {
|
||||
for (element in this) {
|
||||
if (element != null) {
|
||||
collection.add(transform(element))
|
||||
destination.add(transform(element))
|
||||
}
|
||||
}
|
||||
return collection
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends transformed non-null elements of original collection using the given *transform* function
|
||||
* to the given *collection*
|
||||
* to the given *destination*
|
||||
*/
|
||||
public inline fun <T : Any, R, C : MutableCollection<in R>> Stream<T?>.mapNotNullTo(collection: C, transform: (T) -> R): C {
|
||||
public inline fun <T : Any, R, C : MutableCollection<in R>> Stream<T?>.mapNotNullTo(destination: C, transform: (T) -> R): C {
|
||||
for (element in this) {
|
||||
if (element != null) {
|
||||
collection.add(transform(element))
|
||||
destination.add(transform(element))
|
||||
}
|
||||
}
|
||||
return collection
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends transformed elements of original collection using the given *transform* function
|
||||
* to the given *collection*
|
||||
* to the given *destination*
|
||||
*/
|
||||
public inline fun <T, R, C : MutableCollection<in R>> Array<out T>.mapTo(collection: C, transform: (T) -> R): C {
|
||||
public inline fun <T, R, C : MutableCollection<in R>> Array<out T>.mapTo(destination: C, transform: (T) -> R): C {
|
||||
for (item in this)
|
||||
collection.add(transform(item))
|
||||
return collection
|
||||
destination.add(transform(item))
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends transformed elements of original collection using the given *transform* function
|
||||
* to the given *collection*
|
||||
* to the given *destination*
|
||||
*/
|
||||
public inline fun <R, C : MutableCollection<in R>> BooleanArray.mapTo(collection: C, transform: (Boolean) -> R): C {
|
||||
public inline fun <R, C : MutableCollection<in R>> BooleanArray.mapTo(destination: C, transform: (Boolean) -> R): C {
|
||||
for (item in this)
|
||||
collection.add(transform(item))
|
||||
return collection
|
||||
destination.add(transform(item))
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends transformed elements of original collection using the given *transform* function
|
||||
* to the given *collection*
|
||||
* to the given *destination*
|
||||
*/
|
||||
public inline fun <R, C : MutableCollection<in R>> ByteArray.mapTo(collection: C, transform: (Byte) -> R): C {
|
||||
public inline fun <R, C : MutableCollection<in R>> ByteArray.mapTo(destination: C, transform: (Byte) -> R): C {
|
||||
for (item in this)
|
||||
collection.add(transform(item))
|
||||
return collection
|
||||
destination.add(transform(item))
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends transformed elements of original collection using the given *transform* function
|
||||
* to the given *collection*
|
||||
* to the given *destination*
|
||||
*/
|
||||
public inline fun <R, C : MutableCollection<in R>> CharArray.mapTo(collection: C, transform: (Char) -> R): C {
|
||||
public inline fun <R, C : MutableCollection<in R>> CharArray.mapTo(destination: C, transform: (Char) -> R): C {
|
||||
for (item in this)
|
||||
collection.add(transform(item))
|
||||
return collection
|
||||
destination.add(transform(item))
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends transformed elements of original collection using the given *transform* function
|
||||
* to the given *collection*
|
||||
* to the given *destination*
|
||||
*/
|
||||
public inline fun <R, C : MutableCollection<in R>> DoubleArray.mapTo(collection: C, transform: (Double) -> R): C {
|
||||
public inline fun <R, C : MutableCollection<in R>> DoubleArray.mapTo(destination: C, transform: (Double) -> R): C {
|
||||
for (item in this)
|
||||
collection.add(transform(item))
|
||||
return collection
|
||||
destination.add(transform(item))
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends transformed elements of original collection using the given *transform* function
|
||||
* to the given *collection*
|
||||
* to the given *destination*
|
||||
*/
|
||||
public inline fun <R, C : MutableCollection<in R>> FloatArray.mapTo(collection: C, transform: (Float) -> R): C {
|
||||
public inline fun <R, C : MutableCollection<in R>> FloatArray.mapTo(destination: C, transform: (Float) -> R): C {
|
||||
for (item in this)
|
||||
collection.add(transform(item))
|
||||
return collection
|
||||
destination.add(transform(item))
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends transformed elements of original collection using the given *transform* function
|
||||
* to the given *collection*
|
||||
* to the given *destination*
|
||||
*/
|
||||
public inline fun <R, C : MutableCollection<in R>> IntArray.mapTo(collection: C, transform: (Int) -> R): C {
|
||||
public inline fun <R, C : MutableCollection<in R>> IntArray.mapTo(destination: C, transform: (Int) -> R): C {
|
||||
for (item in this)
|
||||
collection.add(transform(item))
|
||||
return collection
|
||||
destination.add(transform(item))
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends transformed elements of original collection using the given *transform* function
|
||||
* to the given *collection*
|
||||
* to the given *destination*
|
||||
*/
|
||||
public inline fun <R, C : MutableCollection<in R>> LongArray.mapTo(collection: C, transform: (Long) -> R): C {
|
||||
public inline fun <R, C : MutableCollection<in R>> LongArray.mapTo(destination: C, transform: (Long) -> R): C {
|
||||
for (item in this)
|
||||
collection.add(transform(item))
|
||||
return collection
|
||||
destination.add(transform(item))
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends transformed elements of original collection using the given *transform* function
|
||||
* to the given *collection*
|
||||
* to the given *destination*
|
||||
*/
|
||||
public inline fun <R, C : MutableCollection<in R>> ShortArray.mapTo(collection: C, transform: (Short) -> R): C {
|
||||
public inline fun <R, C : MutableCollection<in R>> ShortArray.mapTo(destination: C, transform: (Short) -> R): C {
|
||||
for (item in this)
|
||||
collection.add(transform(item))
|
||||
return collection
|
||||
destination.add(transform(item))
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends transformed elements of original collection using the given *transform* function
|
||||
* to the given *collection*
|
||||
* to the given *destination*
|
||||
*/
|
||||
public inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(collection: C, transform: (T) -> R): C {
|
||||
public inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapTo(destination: C, transform: (T) -> R): C {
|
||||
for (item in this)
|
||||
collection.add(transform(item))
|
||||
return collection
|
||||
destination.add(transform(item))
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends transformed elements of original collection using the given *transform* function
|
||||
* to the given *collection*
|
||||
* to the given *destination*
|
||||
*/
|
||||
public inline fun <K, V, R, C : MutableCollection<in R>> Map<K, V>.mapTo(collection: C, transform: (Map.Entry<K, V>) -> R): C {
|
||||
public inline fun <K, V, R, C : MutableCollection<in R>> Map<K, V>.mapTo(destination: C, transform: (Map.Entry<K, V>) -> R): C {
|
||||
for (item in this)
|
||||
collection.add(transform(item))
|
||||
return collection
|
||||
destination.add(transform(item))
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends transformed elements of original collection using the given *transform* function
|
||||
* to the given *collection*
|
||||
* to the given *destination*
|
||||
*/
|
||||
public inline fun <T, R, C : MutableCollection<in R>> Stream<T>.mapTo(collection: C, transform: (T) -> R): C {
|
||||
public inline fun <T, R, C : MutableCollection<in R>> Stream<T>.mapTo(destination: C, transform: (T) -> R): C {
|
||||
for (item in this)
|
||||
collection.add(transform(item))
|
||||
return collection
|
||||
destination.add(transform(item))
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends transformed elements of original collection using the given *transform* function
|
||||
* to the given *collection*
|
||||
* to the given *destination*
|
||||
*/
|
||||
public inline fun <R, C : MutableCollection<in R>> String.mapTo(collection: C, transform: (Char) -> R): C {
|
||||
public inline fun <R, C : MutableCollection<in R>> String.mapTo(destination: C, transform: (Char) -> R): C {
|
||||
for (item in this)
|
||||
collection.add(transform(item))
|
||||
return collection
|
||||
destination.add(transform(item))
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -353,35 +353,35 @@ public fun <R : Char> String.filterIsInstance(klass: Class<R>): List<R> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements that are instances of specified class into the given *collection*
|
||||
* Appends all elements that are instances of specified class to the given *destination*
|
||||
*/
|
||||
public fun <T, C : MutableCollection<in R>, R : T> Array<out T>.filterIsInstanceTo(collection: C, klass: Class<R>): C {
|
||||
for (element in this) if (klass.isInstance(element)) collection.add(element as R)
|
||||
return collection
|
||||
public fun <T, C : MutableCollection<in R>, R : T> Array<out T>.filterIsInstanceTo(destination: C, klass: Class<R>): C {
|
||||
for (element in this) if (klass.isInstance(element)) destination.add(element as R)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements that are instances of specified class into the given *collection*
|
||||
* Appends all elements that are instances of specified class to the given *destination*
|
||||
*/
|
||||
public fun <T, C : MutableCollection<in R>, R : T> Iterable<T>.filterIsInstanceTo(collection: C, klass: Class<R>): C {
|
||||
for (element in this) if (klass.isInstance(element)) collection.add(element as R)
|
||||
return collection
|
||||
public fun <T, C : MutableCollection<in R>, R : T> Iterable<T>.filterIsInstanceTo(destination: C, klass: Class<R>): C {
|
||||
for (element in this) if (klass.isInstance(element)) destination.add(element as R)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements that are instances of specified class into the given *collection*
|
||||
* Appends all elements that are instances of specified class to the given *destination*
|
||||
*/
|
||||
public fun <T, C : MutableCollection<in R>, R : T> Stream<T>.filterIsInstanceTo(collection: C, klass: Class<R>): C {
|
||||
for (element in this) if (klass.isInstance(element)) collection.add(element as R)
|
||||
return collection
|
||||
public fun <T, C : MutableCollection<in R>, R : T> Stream<T>.filterIsInstanceTo(destination: C, klass: Class<R>): C {
|
||||
for (element in this) if (klass.isInstance(element)) destination.add(element as R)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends all elements that are instances of specified class into the given *collection*
|
||||
* Appends all elements that are instances of specified class to the given *destination*
|
||||
*/
|
||||
public fun <C : MutableCollection<in R>, R : Char> String.filterIsInstanceTo(collection: C, klass: Class<R>): C {
|
||||
for (element in this) if (klass.isInstance(element)) collection.add(element as R)
|
||||
return collection
|
||||
public fun <C : MutableCollection<in R>, R : Char> String.filterIsInstanceTo(destination: C, klass: Class<R>): C {
|
||||
for (element in this) if (klass.isInstance(element)) destination.add(element as R)
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -208,21 +208,21 @@ fun filtering(): List<GenericFunction> {
|
||||
include(Maps)
|
||||
}
|
||||
|
||||
templates add f("filterTo(collection: C, predicate: (T) -> Boolean)") {
|
||||
templates add f("filterTo(destination: C, predicate: (T) -> Boolean)") {
|
||||
inline(true)
|
||||
|
||||
doc { "Appends all elements matching the given *predicate* into the given *collection*" }
|
||||
doc { "Appends all elements matching the given *predicate* into the given *destination*" }
|
||||
typeParam("C : TCollection")
|
||||
returns("C")
|
||||
|
||||
body {
|
||||
"""
|
||||
for (element in this) if (predicate(element)) collection.add(element)
|
||||
return collection
|
||||
for (element in this) if (predicate(element)) destination.add(element)
|
||||
return destination
|
||||
"""
|
||||
}
|
||||
|
||||
doc(Strings) { "Appends all characters matching the given *predicate* to the given *collection*" }
|
||||
doc(Strings) { "Appends all characters matching the given *predicate* to the given *destination*" }
|
||||
body(Strings) {
|
||||
"""
|
||||
for (index in 0..length - 1) {
|
||||
@@ -265,25 +265,25 @@ fun filtering(): List<GenericFunction> {
|
||||
include(Maps)
|
||||
}
|
||||
|
||||
templates add f("filterNotTo(collection: C, predicate: (T) -> Boolean)") {
|
||||
templates add f("filterNotTo(destination: C, predicate: (T) -> Boolean)") {
|
||||
inline(true)
|
||||
|
||||
doc { "Appends all elements not matching the given *predicate* to the given *collection*" }
|
||||
doc { "Appends all elements not matching the given *predicate* to the given *destination*" }
|
||||
typeParam("C : TCollection")
|
||||
returns("C")
|
||||
|
||||
body {
|
||||
"""
|
||||
for (element in this) if (!predicate(element)) collection.add(element)
|
||||
return collection
|
||||
for (element in this) if (!predicate(element)) destination.add(element)
|
||||
return destination
|
||||
"""
|
||||
}
|
||||
|
||||
doc(Strings) { "Appends all characters not matching the given *predicate* to the given *collection*" }
|
||||
doc(Strings) { "Appends all characters not matching the given *predicate* to the given *destination*" }
|
||||
body(Strings) {
|
||||
"""
|
||||
for (element in this) if (!predicate(element)) collection.append(element)
|
||||
return collection
|
||||
for (element in this) if (!predicate(element)) destination.append(element)
|
||||
return destination
|
||||
"""
|
||||
}
|
||||
include(Maps)
|
||||
@@ -310,17 +310,17 @@ fun filtering(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("filterNotNullTo(collection: C)") {
|
||||
templates add f("filterNotNullTo(destination: C)") {
|
||||
exclude(ArraysOfPrimitives, Strings)
|
||||
doc { "Appends all elements that are not null to the given *collection*" }
|
||||
doc { "Appends all elements that are not null to the given *destination*" }
|
||||
returns("C")
|
||||
typeParam("C : TCollection")
|
||||
typeParam("T : Any")
|
||||
toNullableT = true
|
||||
body {
|
||||
"""
|
||||
for (element in this) if (element != null) collection.add(element)
|
||||
return collection
|
||||
for (element in this) if (element != null) destination.add(element)
|
||||
return destination
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,13 +68,13 @@ fun mapping(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("mapTo(collection: C, transform: (T) -> R)") {
|
||||
templates add f("mapTo(destination: C, transform: (T) -> R)") {
|
||||
inline(true)
|
||||
|
||||
doc {
|
||||
"""
|
||||
Appends transformed elements of original collection using the given *transform* function
|
||||
to the given *collection*
|
||||
to the given *destination*
|
||||
"""
|
||||
}
|
||||
typeParam("R")
|
||||
@@ -84,20 +84,20 @@ fun mapping(): List<GenericFunction> {
|
||||
body {
|
||||
"""
|
||||
for (item in this)
|
||||
collection.add(transform(item))
|
||||
return collection
|
||||
destination.add(transform(item))
|
||||
return destination
|
||||
"""
|
||||
}
|
||||
include(Maps)
|
||||
}
|
||||
|
||||
templates add f("mapNotNullTo(collection: C, transform: (T) -> R)") {
|
||||
templates add f("mapNotNullTo(destination: C, transform: (T) -> R)") {
|
||||
inline(true)
|
||||
exclude(Strings, ArraysOfPrimitives)
|
||||
doc {
|
||||
"""
|
||||
Appends transformed non-null elements of original collection using the given *transform* function
|
||||
to the given *collection*
|
||||
to the given *destination*
|
||||
"""
|
||||
}
|
||||
typeParam("T : Any")
|
||||
@@ -109,10 +109,10 @@ fun mapping(): List<GenericFunction> {
|
||||
"""
|
||||
for (element in this) {
|
||||
if (element != null) {
|
||||
collection.add(transform(element))
|
||||
destination.add(transform(element))
|
||||
}
|
||||
}
|
||||
return collection
|
||||
return destination
|
||||
"""
|
||||
}
|
||||
}
|
||||
@@ -140,10 +140,10 @@ fun mapping(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("flatMapTo(collection: C, transform: (T) -> Iterable<R>)") {
|
||||
templates add f("flatMapTo(destination: C, transform: (T) -> Iterable<R>)") {
|
||||
inline(true)
|
||||
exclude(Streams)
|
||||
doc { "Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *collection*" }
|
||||
doc { "Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *destination*" }
|
||||
typeParam("R")
|
||||
typeParam("C : MutableCollection<in R>")
|
||||
returns("C")
|
||||
@@ -151,19 +151,19 @@ fun mapping(): List<GenericFunction> {
|
||||
"""
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
collection.addAll(list)
|
||||
destination.addAll(list)
|
||||
}
|
||||
return collection
|
||||
return destination
|
||||
"""
|
||||
}
|
||||
include(Maps)
|
||||
}
|
||||
|
||||
templates add f("flatMapTo(collection: C, transform: (T) -> Stream<R>)") {
|
||||
templates add f("flatMapTo(destination: C, transform: (T) -> Stream<R>)") {
|
||||
inline(true)
|
||||
|
||||
only(Streams)
|
||||
doc { "Appends all elements yielded from results of *transform* function being invoked on each element of original stream, to the given *collection*" }
|
||||
doc { "Appends all elements yielded from results of *transform* function being invoked on each element of original stream, to the given *destination*" }
|
||||
typeParam("R")
|
||||
typeParam("C : MutableCollection<in R>")
|
||||
returns("C")
|
||||
@@ -171,9 +171,9 @@ fun mapping(): List<GenericFunction> {
|
||||
"""
|
||||
for (element in this) {
|
||||
val list = transform(element)
|
||||
collection.addAll(list)
|
||||
destination.addAll(list)
|
||||
}
|
||||
return collection
|
||||
return destination
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,13 +43,13 @@ fun snapshots(): List<GenericFunction> {
|
||||
body { "return toCollection(ArrayList<T>())" }
|
||||
|
||||
// ISSUE: JavaScript can't perform this operation
|
||||
/*
|
||||
body(Collections) {
|
||||
"""
|
||||
return ArrayList<T>(this)
|
||||
"""
|
||||
}
|
||||
*/
|
||||
/*
|
||||
body(Collections) {
|
||||
"""
|
||||
return ArrayList<T>(this)
|
||||
"""
|
||||
}
|
||||
*/
|
||||
body(ArraysOfObjects, ArraysOfPrimitives) {
|
||||
"""
|
||||
val list = ArrayList<T>(size)
|
||||
@@ -65,18 +65,18 @@ fun snapshots(): List<GenericFunction> {
|
||||
body { "return toCollection(ArrayList<T>())" }
|
||||
|
||||
// ISSUE: JavaScript can't perform this operations
|
||||
/*
|
||||
body(Collections) {
|
||||
"""
|
||||
return ArrayList<T>(this)
|
||||
"""
|
||||
}
|
||||
body(ArraysOfObjects) {
|
||||
"""
|
||||
return ArrayList<T>(Arrays.asList(*this))
|
||||
"""
|
||||
}
|
||||
*/
|
||||
/*
|
||||
body(Collections) {
|
||||
"""
|
||||
return ArrayList<T>(this)
|
||||
"""
|
||||
}
|
||||
body(ArraysOfObjects) {
|
||||
"""
|
||||
return ArrayList<T>(Arrays.asList(*this))
|
||||
"""
|
||||
}
|
||||
*/
|
||||
body(ArraysOfPrimitives) {
|
||||
"""
|
||||
val list = ArrayList<T>(size)
|
||||
|
||||
@@ -73,16 +73,16 @@ fun specialJVM(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("filterIsInstanceTo(collection: C, klass: Class<R>)") {
|
||||
doc { "Appends all elements that are instances of specified class into the given *collection*" }
|
||||
templates add f("filterIsInstanceTo(destination: C, klass: Class<R>)") {
|
||||
doc { "Appends all elements that are instances of specified class to the given *destination*" }
|
||||
typeParam("C : MutableCollection<in R>")
|
||||
typeParam("R : T")
|
||||
returns("C")
|
||||
exclude(ArraysOfPrimitives)
|
||||
body {
|
||||
"""
|
||||
for (element in this) if (klass.isInstance(element)) collection.add(element as R)
|
||||
return collection
|
||||
for (element in this) if (klass.isInstance(element)) destination.add(element as R)
|
||||
return destination
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user