Add upperbound constraint Comparable<T> to toSortedSet() and sortedMapOf()
Provide an overload of toSortedSet() with Comparator<in T> parameter #KT-10115 Fixed
This commit is contained in:
@@ -6274,7 +6274,7 @@ public fun ShortArray.toSet(): Set<Short> {
|
||||
/**
|
||||
* Returns a [SortedSet] of all elements.
|
||||
*/
|
||||
public fun <T> Array<out T>.toSortedSet(): SortedSet<T> {
|
||||
public fun <T: Comparable<T>> Array<out T>.toSortedSet(): SortedSet<T> {
|
||||
return toCollection(TreeSet<T>())
|
||||
}
|
||||
|
||||
@@ -6334,6 +6334,15 @@ public fun ShortArray.toSortedSet(): SortedSet<Short> {
|
||||
return toCollection(TreeSet<Short>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [SortedSet] of all elements.
|
||||
* Elements in the set returned are sorted according to the given [comparator].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public fun <T> Array<out T>.toSortedSet(comparator: Comparator<in T>): SortedSet<T> {
|
||||
return toCollection(TreeSet<T>(comparator))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user