Rename "collection" parameter to "destination" in *To() functions.

This commit is contained in:
Ilya Ryzhenkov
2014-04-15 16:01:51 +04:00
committed by Andrey Breslav
parent e43d08d228
commit 6562ee4967
7 changed files with 300 additions and 300 deletions
@@ -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
"""
}
}