#KT-1788 Fixed - added standard collection APIs to the various kinds of Array and removed the few old hand-crafted versions of these methods

This commit is contained in:
James Strachan
2012-04-17 14:05:32 +01:00
parent 5e8b0d39db
commit 7500808e11
28 changed files with 2885 additions and 13 deletions
@@ -0,0 +1,30 @@
// NOTE this file is auto-generated from src/kotlin/JUtilCollections.kt
package kotlin
import java.util.*
//
// This file contains methods which are optimised for working on Collection / Array collections where the size
// could be used to implement a more optimal solution
//
// See [[GenerateStandardLib.kt]] for more details
//
/**
* Returns a new List containing the results of applying the given *transform* function to each element in this collection
*
* @includeFunctionBody ../../test/CollectionTest.kt map
*/
public inline fun <R> IntArray.map(transform : (Int) -> R) : java.util.List<R> {
return mapTo(java.util.ArrayList<R>(this.size), transform)
}
/**
* Transforms each element of this collection with the given *transform* function and
* 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 {
for (item in this)
result.add(transform(item))
return result
}