added proper map with default size passed in for Collection/Array but also added to Iterable and java.util.Iterable with no size; so the collection/iterable methods are now I think replicated; just need iterator methods now
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// NOTE this file is auto-generated from stdlib/ktSrc/JavaCollections.kt
|
||||
package std.util
|
||||
package std
|
||||
|
||||
import java.util.*
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// NOTE this file is auto-generated from stdlib/ktSrc/JavaCollections.kt
|
||||
package std
|
||||
|
||||
import java.util.*
|
||||
|
||||
/** Returns a new collection containing the results of applying the given function to each element in this collection */
|
||||
inline fun <T, R> Iterable<T>.map(result: Collection<R> = ArrayList<R>(), transform : (T) -> R) : Collection<R> {
|
||||
for (item in this)
|
||||
result.add(transform(item))
|
||||
return result
|
||||
}
|
||||
@@ -57,6 +57,7 @@ fun main(args: Array<String>) {
|
||||
val outDir = File(srcDir, "generated")
|
||||
|
||||
|
||||
// JavaIterables - Generic iterable stuff
|
||||
generateFile(File(outDir, "ArraysFromJavaIterables.kt"), "package std", File(srcDir, "JavaIterables.kt")) {
|
||||
it.replaceAll("java.lang.Iterable<T>", "Array<T>")
|
||||
}
|
||||
@@ -65,11 +66,18 @@ fun main(args: Array<String>) {
|
||||
it.replaceAll("java.lang.Iterable<T>", "Iterable<T>")
|
||||
}
|
||||
|
||||
|
||||
// JavaCollections - methods returning a collection of the same input size (if its a collection)
|
||||
|
||||
generateFile(File(outDir, "ArraysFromJavaCollections.kt"), "package std", File(srcDir, "JavaCollections.kt")) {
|
||||
it.replaceAll("java.util.Collection<T>", "Array<T>")
|
||||
}
|
||||
|
||||
generateFile(File(outDir, "JavaUtilIterablesFromJavaCollections.kt"), "package std.util", File(srcDir, "JavaCollections.kt")) {
|
||||
it.replaceAll("java.util.Collection<T>", "java.lang.Iterable<T>").replaceAll("(this.size)", "")
|
||||
}
|
||||
|
||||
generateFile(File(outDir, "ArraysFromJavaCollections.kt"), "package std.util", File(srcDir, "JavaCollections.kt")) {
|
||||
it.replaceAll("java.util.Collection<T>", "Array<T>")
|
||||
generateFile(File(outDir, "StandardFromJavaCollections.kt"), "package std", File(srcDir, "JavaCollections.kt")) {
|
||||
it.replaceAll("java.util.Collection<T>", "Iterable<T>").replaceAll("(this.size)", "")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user