Unify toTypedArray and asList templates between JVM and JS

This commit is contained in:
Ilya Gorbunov
2016-12-06 07:23:36 +03:00
parent 3d7e6e1996
commit f3df648f4a
5 changed files with 174 additions and 214 deletions
+56 -56
View File
@@ -12560,6 +12560,62 @@ public inline fun CharArray.asList(): List<Char> {
return this.unsafeCast<Array<Char>>().asList()
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public fun ByteArray.toTypedArray(): Array<Byte> {
return copyOf().unsafeCast<Array<Byte>>()
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public fun ShortArray.toTypedArray(): Array<Short> {
return copyOf().unsafeCast<Array<Short>>()
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public fun IntArray.toTypedArray(): Array<Int> {
return copyOf().unsafeCast<Array<Int>>()
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public fun LongArray.toTypedArray(): Array<Long> {
return copyOf().unsafeCast<Array<Long>>()
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public fun FloatArray.toTypedArray(): Array<Float> {
return copyOf().unsafeCast<Array<Float>>()
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public fun DoubleArray.toTypedArray(): Array<Double> {
return copyOf().unsafeCast<Array<Double>>()
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public fun BooleanArray.toTypedArray(): Array<Boolean> {
return copyOf().unsafeCast<Array<Boolean>>()
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public fun CharArray.toTypedArray(): Array<Char> {
return copyOf().unsafeCast<Array<Char>>()
}
/**
* Returns `true` if the two specified arrays are *deeply* equal to one another,
* i.e. contain the same number of the same elements in the same order.
@@ -13400,59 +13456,3 @@ public fun <T> Array<out T>.sortWith(comparator: Comparator<in T>): Unit {
sort { a, b -> comparator.compare(a, b) }
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public fun ByteArray.toTypedArray(): Array<Byte> {
return copyOf().unsafeCast<Array<Byte>>()
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public fun ShortArray.toTypedArray(): Array<Short> {
return copyOf().unsafeCast<Array<Short>>()
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public fun IntArray.toTypedArray(): Array<Int> {
return copyOf().unsafeCast<Array<Int>>()
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public fun LongArray.toTypedArray(): Array<Long> {
return copyOf().unsafeCast<Array<Long>>()
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public fun FloatArray.toTypedArray(): Array<Float> {
return copyOf().unsafeCast<Array<Float>>()
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public fun DoubleArray.toTypedArray(): Array<Double> {
return copyOf().unsafeCast<Array<Double>>()
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public fun BooleanArray.toTypedArray(): Array<Boolean> {
return copyOf().unsafeCast<Array<Boolean>>()
}
/**
* Returns a *typed* object array containing all of the elements of this primitive array.
*/
public fun CharArray.toTypedArray(): Array<Char> {
return copyOf().unsafeCast<Array<Char>>()
}