Generate to[Primitive]Array() methods for generic arrays and collections.
#KT-4180 Fixed
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
package kotlin
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
import kotlin.platform.*
|
||||
import java.util.*
|
||||
|
||||
import java.util.Collections // TODO: it's temporary while we have java.util.Collections in js
|
||||
|
||||
/**
|
||||
* Returns an array of Boolean containing all of the elements of this generic array.
|
||||
*/
|
||||
public fun Array<out Boolean>.toBooleanArray(): BooleanArray {
|
||||
val result = BooleanArray(size())
|
||||
for (index in indices)
|
||||
result[index] = this[index]
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Boolean containing all of the elements of this collection.
|
||||
*/
|
||||
public fun Collection<Boolean>.toBooleanArray(): BooleanArray {
|
||||
val result = BooleanArray(size())
|
||||
var index = 0
|
||||
for (element in this)
|
||||
result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Byte containing all of the elements of this generic array.
|
||||
*/
|
||||
public fun Array<out Byte>.toByteArray(): ByteArray {
|
||||
val result = ByteArray(size())
|
||||
for (index in indices)
|
||||
result[index] = this[index]
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Byte containing all of the elements of this collection.
|
||||
*/
|
||||
public fun Collection<Byte>.toByteArray(): ByteArray {
|
||||
val result = ByteArray(size())
|
||||
var index = 0
|
||||
for (element in this)
|
||||
result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Char containing all of the elements of this generic array.
|
||||
*/
|
||||
public fun Array<out Char>.toCharArray(): CharArray {
|
||||
val result = CharArray(size())
|
||||
for (index in indices)
|
||||
result[index] = this[index]
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Char containing all of the elements of this collection.
|
||||
*/
|
||||
public fun Collection<Char>.toCharArray(): CharArray {
|
||||
val result = CharArray(size())
|
||||
var index = 0
|
||||
for (element in this)
|
||||
result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Double containing all of the elements of this generic array.
|
||||
*/
|
||||
public fun Array<out Double>.toDoubleArray(): DoubleArray {
|
||||
val result = DoubleArray(size())
|
||||
for (index in indices)
|
||||
result[index] = this[index]
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Double containing all of the elements of this collection.
|
||||
*/
|
||||
public fun Collection<Double>.toDoubleArray(): DoubleArray {
|
||||
val result = DoubleArray(size())
|
||||
var index = 0
|
||||
for (element in this)
|
||||
result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Float containing all of the elements of this generic array.
|
||||
*/
|
||||
public fun Array<out Float>.toFloatArray(): FloatArray {
|
||||
val result = FloatArray(size())
|
||||
for (index in indices)
|
||||
result[index] = this[index]
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Float containing all of the elements of this collection.
|
||||
*/
|
||||
public fun Collection<Float>.toFloatArray(): FloatArray {
|
||||
val result = FloatArray(size())
|
||||
var index = 0
|
||||
for (element in this)
|
||||
result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Int containing all of the elements of this generic array.
|
||||
*/
|
||||
public fun Array<out Int>.toIntArray(): IntArray {
|
||||
val result = IntArray(size())
|
||||
for (index in indices)
|
||||
result[index] = this[index]
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Int containing all of the elements of this collection.
|
||||
*/
|
||||
public fun Collection<Int>.toIntArray(): IntArray {
|
||||
val result = IntArray(size())
|
||||
var index = 0
|
||||
for (element in this)
|
||||
result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Long containing all of the elements of this generic array.
|
||||
*/
|
||||
public fun Array<out Long>.toLongArray(): LongArray {
|
||||
val result = LongArray(size())
|
||||
for (index in indices)
|
||||
result[index] = this[index]
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Long containing all of the elements of this collection.
|
||||
*/
|
||||
public fun Collection<Long>.toLongArray(): LongArray {
|
||||
val result = LongArray(size())
|
||||
var index = 0
|
||||
for (element in this)
|
||||
result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Short containing all of the elements of this generic array.
|
||||
*/
|
||||
public fun Array<out Short>.toShortArray(): ShortArray {
|
||||
val result = ShortArray(size())
|
||||
for (index in indices)
|
||||
result[index] = this[index]
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of Short containing all of the elements of this collection.
|
||||
*/
|
||||
public fun Collection<Short>.toShortArray(): ShortArray {
|
||||
val result = ShortArray(size())
|
||||
var index = 0
|
||||
for (element in this)
|
||||
result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user