move coverage of the standard methods across Iterable, Array, java.util.Iterable (not quite complete but close)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
// Note: this file is used to generate methods on Array<T> too
|
||||
package std.util
|
||||
|
||||
import java.util.*
|
||||
@@ -78,22 +77,6 @@ inline fun <T> java.lang.Iterable<T>.join(separator: String, prefix: String = ""
|
||||
return buffer.toString().sure()
|
||||
}
|
||||
|
||||
/** Returns a new collection containing the results of applying the given function to each element in this collection */
|
||||
/*
|
||||
inline fun <T, R> java.lang.Iterable<T>.map(result: Collection<R> = ArrayList<R>(), transform : (T) -> R) : Collection<R> {
|
||||
for (item in this)
|
||||
result.add(transform(item))
|
||||
return result
|
||||
}
|
||||
*/
|
||||
|
||||
/** Returns a new collection containing the results of applying the given function to each element in this collection */
|
||||
inline fun <T, R> java.util.Collection<T>.map(result: Collection<R> = ArrayList<R>(this.size), transform : (T) -> R) : Collection<R> {
|
||||
for (item in this)
|
||||
result.add(transform(item))
|
||||
return result
|
||||
}
|
||||
|
||||
inline fun <T, C: Collection<T>> java.lang.Iterable<T>.to(result: C) : C {
|
||||
for (elem in this)
|
||||
result.add(elem)
|
||||
|
||||
Reference in New Issue
Block a user