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:
@@ -1065,10 +1065,19 @@ public fun <T> Iterable<T>.toSet(): Set<T> {
|
||||
/**
|
||||
* Returns a [SortedSet] of all elements.
|
||||
*/
|
||||
public fun <T> Iterable<T>.toSortedSet(): SortedSet<T> {
|
||||
public fun <T: Comparable<T>> Iterable<T>.toSortedSet(): SortedSet<T> {
|
||||
return toCollection(TreeSet<T>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [SortedSet] of all elements.
|
||||
* Elements in the set returned are sorted according to the given [comparator].
|
||||
*/
|
||||
@kotlin.jvm.JvmVersion
|
||||
public fun <T> Iterable<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 collection.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user