New stdlib generators
This commit is contained in:
committed by
Andrey Breslav
parent
0980f5e40a
commit
e37d8174c3
@@ -67,7 +67,7 @@ public open class LinkedList<E>() : AbstractList<E>() {
|
||||
}
|
||||
|
||||
library
|
||||
public open class HashSet<E>() : AbstractCollection<E>(), MutableSet<E> {
|
||||
public open class HashSet<E>(capacity: Int = 0) : AbstractCollection<E>(), MutableSet<E> {
|
||||
}
|
||||
|
||||
library
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package kotlin
|
||||
|
||||
import java.util.HashMap
|
||||
|
||||
/**
|
||||
* Returns a new [[HashMap]] populated with the given pairs where the first value in each pair
|
||||
* is the key and the second value is the value
|
||||
*
|
||||
* @includeFunctionBody ../../test/MapTest.kt createUsingPairs
|
||||
*/
|
||||
public inline fun <K,V> hashMap(vararg values: Pair<K,V>): HashMap<K,V> {
|
||||
val answer = HashMap<K,V>()
|
||||
/**
|
||||
TODO replace by this simpler call when we can pass vararg values into other methods
|
||||
answer.putAll(values)
|
||||
*/
|
||||
for (v in values) {
|
||||
answer.put(v.first, v.second)
|
||||
}
|
||||
return answer
|
||||
}
|
||||
@@ -6,34 +6,6 @@ public inline fun <T> Iterable<T>.toString(): String {
|
||||
return makeString(", ", "[", "]")
|
||||
}
|
||||
|
||||
/** Returns a new ArrayList with a variable number of initial elements */
|
||||
public inline fun arrayList<T>(vararg values: T) : ArrayList<T> {
|
||||
val list = ArrayList<T>()
|
||||
for (value in values) {
|
||||
list.add(value)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
/** Returns a new HashSet with a variable number of initial elements */
|
||||
public inline fun hashSet<T>(vararg values: T) : HashSet<T> {
|
||||
val list = HashSet<T>()
|
||||
for (value in values) {
|
||||
list.add(value)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new List containing the results of applying the given *transform* function to each [[Map.Entry]] in this [[Map]]
|
||||
*
|
||||
* @includeFunctionBody ../../test/CollectionTest.kt map
|
||||
*/
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a new Map containing the results of applying the given *transform* function to each [[Map.Entry]] in this [[Map]]
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user