[WASM] Add std methods for collections
This commit is contained in:
committed by
igoriakovlev
parent
c9a92d71ae
commit
e58d4163ad
@@ -22,22 +22,6 @@ internal inline fun <E> arrayOfUninitializedElements(size: Int): Array<E> {
|
||||
return Array<E>(size)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a new array which is a copy of the original array with new elements filled with null values.
|
||||
*/
|
||||
internal fun <E> Array<E>.copyOfNulls(newSize: Int): Array<E?> = copyOfNulls(0, newSize)
|
||||
|
||||
internal fun <E> Array<E>.copyOfNulls(fromIndex: Int, toIndex: Int): Array<E?> {
|
||||
val newSize = toIndex - fromIndex
|
||||
if (newSize < 0) {
|
||||
throw IllegalArgumentException("$fromIndex > $toIndex")
|
||||
}
|
||||
val result = @Suppress("TYPE_PARAMETER_AS_REIFIED") arrayOfNulls<E>(newSize)
|
||||
this.copyInto(result, 0, fromIndex, toIndex.coerceAtMost(size))
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies elements of the [collection] into the given [array].
|
||||
* If the array is too small, allocates a new one of collection.size size.
|
||||
|
||||
Reference in New Issue
Block a user