kotlin.collections.ArraysJVM.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rapidpm-dynamic-cdi Show documentation
Show all versions of rapidpm-dynamic-cdi Show documentation
Dynamic Dependency Injection with different ways to manage the resolver-strategy
@file:kotlin.jvm.JvmMultifileClass
@file:kotlin.jvm.JvmName("ArraysKt")
package kotlin.collections
import java.nio.charset.Charset
/**
* Converts the contents of this byte array to a string using the specified [charset].
*/
@kotlin.internal.InlineOnly
public inline fun ByteArray.toString(charset: Charset): String = String(this, charset)
/**
* Returns a *typed* array containing all of the elements of this collection.
*
* Allocates an array of runtime type `T` having its size equal to the size of this collection
* and populates the array with the elements of this collection.
*/
public inline fun Collection.toTypedArray(): Array {
val thisCollection = this as java.util.Collection
return thisCollection.toArray(arrayOfNulls(thisCollection.size())) as Array
}
/** Returns the array if it's not `null`, or an empty array otherwise. */
public inline fun Array?.orEmpty(): Array = this ?: arrayOf()
/** Internal unsafe construction of array based on reference array type */
internal fun arrayOfNulls(reference: Array, size: Int): Array {
return java.lang.reflect.Array.newInstance(reference.javaClass.componentType, size) as Array
}