JS: drop Collections.sort
This commit is contained in:
@@ -13,8 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
import java.util.Comparator
|
||||
import kotlin.comparisons.naturalOrder
|
||||
|
||||
@library("copyToArray")
|
||||
public fun <reified T> Collection<T>.toTypedArray(): Array<T> = noImpl
|
||||
@@ -41,3 +44,20 @@ public fun <T> setOf(element: T): Set<T> = hashSetOf(element)
|
||||
* specified value.
|
||||
*/
|
||||
public fun <K, V> mapOf(pair: Pair<K, V>): Map<K, V> = hashMapOf(pair)
|
||||
|
||||
/**
|
||||
* Sorts elements in the list in-place according to their natural sort order.
|
||||
*/
|
||||
public fun <T : Comparable<T>> MutableList<T>.sort(): Unit {
|
||||
if (size > 1) collectionsSort(this, naturalOrder())
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts elements in the list in-place according to the order specified with [comparator].
|
||||
*/
|
||||
public fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>): Unit {
|
||||
if (size > 1) collectionsSort(this, comparator)
|
||||
}
|
||||
|
||||
@library("collectionsSort")
|
||||
private fun <T> collectionsSort(list: MutableList<T>, comparator: Comparator<in T>): Unit = noImpl
|
||||
|
||||
@@ -8,12 +8,6 @@ public object Collections {
|
||||
@Deprecated("Use collection.maxWith(comparator) instead.", ReplaceWith("col.maxWith(comp)"))
|
||||
public fun <T> max(col: Collection<T>, comp: Comparator<in T>): T = java.util.max(col, comp)
|
||||
|
||||
@Deprecated("Use list.sort() instead.", ReplaceWith("list.sort()"))
|
||||
public fun <T: Comparable<T>> sort(list: MutableList<T>): Unit = java.util.sort(list, naturalOrder())
|
||||
|
||||
@Deprecated("Use list.sortWith(comparator) instead.", ReplaceWith("list.sortWith(comparator)"))
|
||||
public fun <T> sort(list: MutableList<T>, comparator: java.util.Comparator<in T>): Unit = java.util.sort(list, comparator)
|
||||
|
||||
@Deprecated("Use list.reverse() instead.", ReplaceWith("list.reverse()"))
|
||||
public fun <T> reverse(list: MutableList<T>): Unit {
|
||||
val size = list.size
|
||||
@@ -28,6 +22,3 @@ public object Collections {
|
||||
|
||||
@library("collectionsMax")
|
||||
private fun <T> max(col: Collection<T>, comp: Comparator<in T>): T = noImpl
|
||||
|
||||
@library("collectionsSort")
|
||||
private fun <T> sort(list: MutableList<T>, comparator: Comparator<in T>): Unit = noImpl
|
||||
|
||||
Reference in New Issue
Block a user