changed js tests/library after collections mapping
This commit is contained in:
@@ -36,7 +36,7 @@ public object Collections {
|
||||
}
|
||||
|
||||
library
|
||||
public fun <T> reverse(list: List<T>): Unit {
|
||||
public fun <T> reverse(list: MutableList<T>): Unit {
|
||||
val size = list.size()
|
||||
for (i in 0.rangeTo(size / 2)) {
|
||||
val i2 = size - i
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package js
|
||||
|
||||
import java.util.List
|
||||
|
||||
native public fun String.toUpperCase() : String = js.noImpl
|
||||
|
||||
native public fun String.toLowerCase() : String = js.noImpl
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package kotlin
|
||||
|
||||
import java.util.Map
|
||||
import java.util.HashMap
|
||||
|
||||
/** Provides [] access to maps */
|
||||
public fun <K, V> Map<K, V>.set(key : K, value : V): Unit {
|
||||
public fun <K, V> MutableMap<K, V>.set(key : K, value : V): Unit {
|
||||
this.put(key, value)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ public inline fun <T> Iterable<T>.toString(): String {
|
||||
return makeString(", ", "[", "]")
|
||||
}
|
||||
|
||||
public inline fun <T> java.util.List<T>.equals(that: List<T>): Boolean {
|
||||
public inline fun <T> List<T>.equals(that: List<T>): Boolean {
|
||||
val s1 = this.size()
|
||||
val s2 = that.size()
|
||||
if (s1 == s2) {
|
||||
@@ -45,7 +45,7 @@ public inline fun hashSet<T>(vararg values: T) : HashSet<T> {
|
||||
*
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt map
|
||||
*/
|
||||
public inline fun <K,V,R> java.util.Map<K,V>.map(transform: (java.util.Map.Entry<K,V>) -> R) : java.util.List<R> {
|
||||
public inline fun <K,V,R> Map<K,V>.map(transform: (Map.Entry<K,V>) -> R) : List<R> {
|
||||
return mapTo(java.util.ArrayList<R>(), transform)
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ public inline fun <K,V,R> java.util.Map<K,V>.map(transform: (java.util.Map.Entry
|
||||
*
|
||||
* @includeFunctionBody ../../test/MapTest.kt mapValues
|
||||
*/
|
||||
public inline fun <K,V,R> java.util.Map<K,V>.mapValues(transform : (java.util.Map.Entry<K,V>) -> R): java.util.Map<K,R> {
|
||||
return mapValuesTo(java.util.HashMap<K,R>(), transform)
|
||||
public inline fun <K,V,R> MutableMap<K,V>.mapValues(transform : (Map.Entry<K,V>) -> R): Map<K,R> {
|
||||
return mapValuesTo(HashMap<K,R>(), transform)
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,6 @@ public inline fun <K,V,R> java.util.Map<K,V>.mapValues(transform : (java.util.Ma
|
||||
*
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt map
|
||||
*/
|
||||
public inline fun <T, R> java.util.Collection<T>.map(transform : (T) -> R) : java.util.List<R> {
|
||||
public inline fun <T, R> Collection<T>.map(transform : (T) -> R) : List<R> {
|
||||
return mapTo(java.util.ArrayList<R>(), transform)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package foo
|
||||
import java.util.*
|
||||
import java.lang.*
|
||||
|
||||
public inline fun <T, C: Collection<in T>> Iterator<T>.takeWhileTo(result: C, predicate: (T) -> Boolean) : C {
|
||||
public inline fun <T, C: MutableCollection<in T>> Iterator<T>.takeWhileTo(result: C, predicate: (T) -> Boolean) : C {
|
||||
for (element in this) if (predicate(element)) result.add(element) else break
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import js.jquery.*
|
||||
import js.dom.html5.CanvasGradient
|
||||
import js.dom.html5.HTMLCanvasElement
|
||||
import java.util.ArrayList
|
||||
import java.util.List
|
||||
import js.dom.html.window
|
||||
import js.dom.html.HTMLElement
|
||||
import js.dom.html.HTMLImageElement
|
||||
|
||||
@@ -126,7 +126,7 @@ fun <T> Array<T>.toList() : List<T> = this.to(ArrayList<T>())
|
||||
val String?.size : Int
|
||||
get() = if (this != null) this.length else 0;
|
||||
|
||||
fun <T, C: Collection<T>> Array<T>.to(result: C) : C {
|
||||
fun <T, C: MutableCollection<T>> Array<T>.to(result: C) : C {
|
||||
for (elem in this)
|
||||
result.add(elem)
|
||||
return result
|
||||
@@ -162,6 +162,6 @@ fun makeField(s : String) : Field {
|
||||
// An excerpt from the Standard Library
|
||||
val String?.indices : IntRange get() = IntRange(0, this.sure().size)
|
||||
|
||||
fun <K, V> Map<K, V>.set(k : K, v : V) { put(k, v) }
|
||||
fun <K, V> MutableMap<K, V>.set(k : K, v : V) { put(k, v) }
|
||||
|
||||
val <T> Array<T>.isEmpty : Boolean get() = size == 0
|
||||
|
||||
Reference in New Issue
Block a user