list(), set() and map() -> listOf(), setOf() and mapOf()
This commit is contained in:
@@ -3,30 +3,30 @@ package kotlin
|
|||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
/** Returns a new read-only list of given elements */
|
/** Returns a new read-only list of given elements */
|
||||||
public fun list<T>(vararg values: T): List<T> = arrayListOf(*values)
|
public fun listOf<T>(vararg values: T): List<T> = arrayListOf(*values)
|
||||||
|
|
||||||
/** Returns a new read-only set of given elements */
|
/** Returns a new read-only set of given elements */
|
||||||
public fun set<T>(vararg values: T): Set<T> = values.toCollection(LinkedHashSet<T>())
|
public fun setOf<T>(vararg values: T): Set<T> = values.toCollection(LinkedHashSet<T>())
|
||||||
|
|
||||||
/** Returns a new read-only map of given pairs, where the first value is the key, and the second is value */
|
/** Returns a new read-only map of given pairs, where the first value is the key, and the second is value */
|
||||||
public fun map<K, V>(vararg values: Pair<K, V>): Map<K, V> = hashMapOf(*values)
|
public fun mapOf<K, V>(vararg values: Pair<K, V>): Map<K, V> = hashMapOf(*values)
|
||||||
|
|
||||||
/** Returns a new ArrayList with a variable number of initial elements */
|
/** Returns a new ArrayList with a variable number of initial elements */
|
||||||
public fun arrayListOf<T>(vararg values: T) : ArrayList<T> = values.toCollection(ArrayList<T>(values.size))
|
public fun arrayListOf<T>(vararg values: T) : ArrayList<T> = values.toCollection(ArrayList<T>(values.size))
|
||||||
|
|
||||||
deprecated("Use list(...) or arrayListOf(...) instead")
|
deprecated("Use listOf(...) or arrayListOf(...) instead")
|
||||||
public fun arrayList<T>(vararg values: T) : ArrayList<T> = arrayListOf(*values)
|
public fun arrayList<T>(vararg values: T) : ArrayList<T> = arrayListOf(*values)
|
||||||
|
|
||||||
/** Returns a new LinkedList with a variable number of initial elements */
|
/** Returns a new LinkedList with a variable number of initial elements */
|
||||||
public fun linkedListOf<T>(vararg values: T) : LinkedList<T> = values.toCollection(LinkedList<T>())
|
public fun linkedListOf<T>(vararg values: T) : LinkedList<T> = values.toCollection(LinkedList<T>())
|
||||||
|
|
||||||
deprecated("Use list(...) or linkedListOf(...) instead")
|
deprecated("Use listOf(...) or linkedListOf(...) instead")
|
||||||
public fun linkedList<T>(vararg values: T) : LinkedList<T> = linkedListOf(*values)
|
public fun linkedList<T>(vararg values: T) : LinkedList<T> = linkedListOf(*values)
|
||||||
|
|
||||||
/** Returns a new HashSet with a variable number of initial elements */
|
/** Returns a new HashSet with a variable number of initial elements */
|
||||||
public fun hashSetOf<T>(vararg values: T) : HashSet<T> = values.toCollection(HashSet<T>(values.size))
|
public fun hashSetOf<T>(vararg values: T) : HashSet<T> = values.toCollection(HashSet<T>(values.size))
|
||||||
|
|
||||||
deprecated("Use set(...) or hashSetOf(...) instead")
|
deprecated("Use setOf(...) or hashSetOf(...) instead")
|
||||||
public fun hashSet<T>(vararg values: T) : HashSet<T> = hashSetOf(*values)
|
public fun hashSet<T>(vararg values: T) : HashSet<T> = hashSetOf(*values)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,7 +63,7 @@ public fun <K,V> hashMapOf(vararg values: Pair<K,V>): HashMap<K,V> {
|
|||||||
return answer
|
return answer
|
||||||
}
|
}
|
||||||
|
|
||||||
deprecated("Use map(...) or hashMapOf(...) instead")
|
deprecated("Use mapOf(...) or hashMapOf(...) instead")
|
||||||
public fun <K,V> hashMap(vararg values: Pair<K,V>): HashMap<K,V> = hashMapOf(*values)
|
public fun <K,V> hashMap(vararg values: Pair<K,V>): HashMap<K,V> = hashMapOf(*values)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user