In-place array sorting in JS.

This commit is contained in:
Ilya Gorbunov
2015-07-25 01:31:52 +03:00
parent 8d481fc611
commit 6f71e54268
6 changed files with 181 additions and 9 deletions
+126
View File
@@ -489,6 +489,132 @@ public inline fun ShortArray.plus(element: Short): ShortArray {
return (this: dynamic).concat(arrayOf(element))
}
/**
* Sorts the array inplace.
*/
library("primitiveArraySort")
public fun ByteArray.sort(): Unit {
return noImpl
}
/**
* Sorts the array inplace.
*/
library("primitiveArraySort")
public fun CharArray.sort(): Unit {
return noImpl
}
/**
* Sorts the array inplace.
*/
library("primitiveArraySort")
public fun DoubleArray.sort(): Unit {
return noImpl
}
/**
* Sorts the array inplace.
*/
library("primitiveArraySort")
public fun FloatArray.sort(): Unit {
return noImpl
}
/**
* Sorts the array inplace.
*/
library("primitiveArraySort")
public fun IntArray.sort(): Unit {
return noImpl
}
/**
* Sorts the array inplace.
*/
library("primitiveArraySort")
public fun ShortArray.sort(): Unit {
return noImpl
}
/**
* Sorts the array inplace.
*/
public fun <T: Comparable<T>> Array<out T>.sort(): Unit {
sort { a: T, b: T -> a.compareTo(b) }
}
/**
* Sorts the array inplace.
*/
public fun LongArray.sort(): Unit {
sort { a: Long, b: Long -> a.compareTo(b) }
}
/**
* Sorts the array inplace according to the order specified by the given [comparison] function.
*/
native
public fun <T> Array<out T>.sort(comparison: (T, T) -> Int): Unit {
return noImpl
}
/**
* Sorts the array inplace according to the order specified by the given [comparison] function.
*/
native
public fun ByteArray.sort(comparison: (Byte, Byte) -> Int): Unit {
return noImpl
}
/**
* Sorts the array inplace according to the order specified by the given [comparison] function.
*/
native
public fun CharArray.sort(comparison: (Char, Char) -> Int): Unit {
return noImpl
}
/**
* Sorts the array inplace according to the order specified by the given [comparison] function.
*/
native
public fun DoubleArray.sort(comparison: (Double, Double) -> Int): Unit {
return noImpl
}
/**
* Sorts the array inplace according to the order specified by the given [comparison] function.
*/
native
public fun FloatArray.sort(comparison: (Float, Float) -> Int): Unit {
return noImpl
}
/**
* Sorts the array inplace according to the order specified by the given [comparison] function.
*/
native
public fun IntArray.sort(comparison: (Int, Int) -> Int): Unit {
return noImpl
}
/**
* Sorts the array inplace according to the order specified by the given [comparison] function.
*/
native
public fun LongArray.sort(comparison: (Long, Long) -> Int): Unit {
return noImpl
}
/**
* Sorts the array inplace according to the order specified by the given [comparison] function.
*/
native
public fun ShortArray.sort(comparison: (Short, Short) -> Int): Unit {
return noImpl
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/