core.kotlin.kt Maven / Gradle / Ivy
package kotlin
import java.util.*
@library
public fun arrayOf(vararg value : T): Array = noImpl
// "constructors" for primitive types array
@library
public fun doubleArrayOf(vararg content : Double): DoubleArray = noImpl
@library
public fun floatArrayOf(vararg content : Float): FloatArray = noImpl
@library
public fun longArrayOf(vararg content : Long): LongArray = noImpl
@library
public fun intArrayOf(vararg content : Int): IntArray = noImpl
@library
public fun charArrayOf(vararg content : Char): CharArray = noImpl
@library
public fun shortArrayOf(vararg content : Short): ShortArray = noImpl
@library
public fun byteArrayOf(vararg content : Byte): ByteArray = noImpl
@library
public fun booleanArrayOf(vararg content : Boolean): BooleanArray = noImpl
@library("copyToArray")
public fun Collection.toTypedArray(): Array = noImpl
/**
* Returns an immutable list containing only the specified object [value].
*/
public fun listOf(value: T): List = arrayListOf(value)
/**
* Returns an immutable set containing only the specified object [value].
*/
public fun setOf(value: T): Set = hashSetOf(value)
/**
* Returns an immutable map, mapping only the specified key to the
* specified value.
*/
public fun mapOf(keyValuePair: Pair): Map = hashMapOf(keyValuePair)
/**
* Creates a new instance of the [Lazy] that uses the specified initialization function [initializer].
*/
public fun lazy(initializer: () -> T): Lazy = UnsafeLazyImpl(initializer)
/**
* Creates a new instance of the [Lazy] that uses the specified initialization function [initializer].
*
* The [mode] parameter is ignored. */
public fun lazy(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy = UnsafeLazyImpl(initializer)
/**
* Creates a new instance of the [Lazy] that uses the specified initialization function [initializer].
*
* The [lock] parameter is ignored.
*/
public fun lazy(lock: Any?, initializer: () -> T): Lazy = UnsafeLazyImpl(initializer)
internal fun arrayOfNulls(reference: Array, size: Int): Array {
return arrayOfNulls(size) as Array
}
internal fun arrayCopyResize(source: dynamic, newSize: Int, defaultValue: Any?): dynamic {
val result = source.slice(0, newSize)
var index: Int = source.length
if (newSize > index) {
result.length = newSize
while (index < newSize) result[index++] = defaultValue
}
return result
}
internal fun arrayPlusCollection(array: dynamic, collection: Collection): dynamic {
val result = array.slice(0)
result.length += collection.size()
var index: Int = array.length
for (element in collection) result[index++] = element
return result
}
// copies vararg array due to different spread vararg behavior in JS.
// After fixing #KT-6491 may return `this`
internal inline fun Array.varargToArrayOfAny(): Array = this.copyOf()