diff --git a/libraries/stdlib/src/kotlin/JUtilJVM.kt b/libraries/stdlib/src/kotlin/JUtilJVM.kt index b010c4dd1f2..41fb606e7b1 100644 --- a/libraries/stdlib/src/kotlin/JUtilJVM.kt +++ b/libraries/stdlib/src/kotlin/JUtilJVM.kt @@ -2,22 +2,31 @@ package kotlin import java.util.* +/** Returns a new read-only list of given elements */ +public fun list(vararg values: T): List = arrayListOf(*values) + +/** Returns a new read-only set of given elements */ +public fun set(vararg values: T): Set = values.toCollection(LinkedHashSet()) + +/** Returns a new read-only map of given pairs, where the first value is the key, and the second is value */ +public fun map(vararg values: Pair): Map = hashMapOf(*values) + /** Returns a new ArrayList with a variable number of initial elements */ public fun arrayListOf(vararg values: T) : ArrayList = values.toCollection(ArrayList(values.size)) -deprecated("Use arrayListOf() instead") +deprecated("Use list(...) or arrayListOf(...) instead") public fun arrayList(vararg values: T) : ArrayList = arrayListOf(*values) /** Returns a new LinkedList with a variable number of initial elements */ public fun linkedListOf(vararg values: T) : LinkedList = values.toCollection(LinkedList()) -deprecated("Use linkedListOf() instead") +deprecated("Use list(...) or linkedListOf(...) instead") public fun linkedList(vararg values: T) : LinkedList = linkedListOf(*values) /** Returns a new HashSet with a variable number of initial elements */ public fun hashSetOf(vararg values: T) : HashSet = values.toCollection(HashSet(values.size)) -deprecated("Use hashSetOf() instead") +deprecated("Use set(...) or hashSetOf(...) instead") public fun hashSet(vararg values: T) : HashSet = hashSetOf(*values) /** @@ -25,7 +34,7 @@ public fun hashSet(vararg values: T) : HashSet = hashSetOf(*values) */ public fun sortedSetOf(vararg values: T) : TreeSet = values.toCollection(TreeSet()) -deprecated("Use sortedSetOf() instead") +deprecated("Use sortedSetOf(...) instead") public fun sortedSet(vararg values: T) : TreeSet = sortedSetOf(*values) /** @@ -33,7 +42,7 @@ public fun sortedSet(vararg values: T) : TreeSet = sortedSetOf(*values) */ public fun sortedSetOf(comparator: Comparator, vararg values: T) : TreeSet = values.toCollection(TreeSet(comparator)) -deprecated("Use sortedSetOf() instead") +deprecated("Use sortedSetOf(...) instead") public fun sortedSet(comparator: Comparator, vararg values: T) : TreeSet = sortedSetOf(comparator, *values) /** @@ -54,7 +63,7 @@ public fun hashMapOf(vararg values: Pair): HashMap { return answer } -deprecated("Use hashMapOf() instead") +deprecated("Use map(...) or hashMapOf(...) instead") public fun hashMap(vararg values: Pair): HashMap = hashMapOf(*values) /** @@ -75,7 +84,7 @@ public fun sortedMapOf(vararg values: Pair): SortedMap { return answer } -deprecated("Use sortedMapOf() instead") +deprecated("Use sortedMapOf(...) instead") public fun sortedMap(vararg values: Pair): SortedMap = sortedMapOf(*values) /** @@ -97,7 +106,7 @@ public fun linkedMapOf(vararg values: Pair): LinkedHashMap { return answer } -deprecated("Use linkedMapOf() instead") +deprecated("Use linkedMapOf(...) instead") public fun linkedMap(vararg values: Pair): LinkedHashMap = linkedMapOf(*values) /** Returns the Set if its not null otherwise returns the empty set */