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:
@@ -44,11 +44,26 @@ fun snapshots(): List<GenericFunction> {
|
||||
templates add f("toSortedSet()") {
|
||||
deprecate(Strings) { forBinaryCompatibility }
|
||||
include(CharSequences, Strings)
|
||||
typeParam("T: Comparable<T>")
|
||||
doc { f -> "Returns a [SortedSet] of all ${f.element}s." }
|
||||
returns("SortedSet<T>")
|
||||
body { "return toCollection(TreeSet<T>())" }
|
||||
}
|
||||
|
||||
templates add f("toSortedSet(comparator: Comparator<in T>)") {
|
||||
only(Iterables, ArraysOfObjects, Sequences)
|
||||
jvmOnly(true)
|
||||
doc { f ->
|
||||
"""
|
||||
Returns a [SortedSet] of all ${f.element}s.
|
||||
|
||||
Elements in the set returned are sorted according to the given [comparator].
|
||||
"""
|
||||
}
|
||||
returns("SortedSet<T>")
|
||||
body { "return toCollection(TreeSet<T>(comparator))" }
|
||||
}
|
||||
|
||||
templates add f("toArrayList()") {
|
||||
doc { f -> "Returns an [ArrayList] of all ${f.element}s." }
|
||||
returns("ArrayList<T>")
|
||||
|
||||
Reference in New Issue
Block a user