
core.kotlin.kt Maven / Gradle / Ivy
package kotlin
import java.util.*
@library
public fun arrayOf(vararg elements: T): Array = noImpl
// "constructors" for primitive types array
@library
public fun doubleArrayOf(vararg elements: Double): DoubleArray = noImpl
@library
public fun floatArrayOf(vararg elements: Float): FloatArray = noImpl
@library
public fun longArrayOf(vararg elements: Long): LongArray = noImpl
@library
public fun intArrayOf(vararg elements: Int): IntArray = noImpl
@library
public fun charArrayOf(vararg elements: Char): CharArray = noImpl
@library
public fun shortArrayOf(vararg elements: Short): ShortArray = noImpl
@library
public fun byteArrayOf(vararg elements: Byte): ByteArray = noImpl
@library
public fun booleanArrayOf(vararg elements: Boolean): BooleanArray = noImpl
@library("copyToArray")
public fun Collection.toTypedArray(): Array = noImpl
/**
* Returns an immutable list containing only the specified object [element].
*/
public fun listOf(element: T): List = arrayListOf(element)
/**
* Returns an immutable set containing only the specified object [element].
*/
public fun setOf(element: T): Set = hashSetOf(element)
/**
* Returns an immutable map, mapping only the specified key to the
* specified value.
*/
public fun mapOf(pair: Pair): Map = hashMapOf(pair)
/**
* 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()
© 2015 - 2025 Weber Informatics LLC | Privacy Policy