All Downloads are FREE. Search and download functionalities are using the official Maven repository.

core.kotlin.kt Maven / Gradle / Ivy

There is a newer version: 1.0.7
Show newest version
package kotlin

import java.util.*

/**
 * Returns an empty array of the specified type [T].
 */
public inline fun  emptyArray(): Array = arrayOfNulls(0) as Array

@library
public fun  arrayOf(vararg elements: T): Array = noImpl

@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

/**
 * 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 - 2024 Weber Informatics LLC | Privacy Policy