Implement component(N) functions for destructuring UArrays
This commit is contained in:
committed by
Ilya Gorbunov
parent
550c74bb6b
commit
6b92190726
@@ -15,6 +15,206 @@ package kotlin.collections
|
|||||||
|
|
||||||
import kotlin.random.*
|
import kotlin.random.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 1st *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun UIntArray.component1(): UInt {
|
||||||
|
return get(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 1st *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun ULongArray.component1(): ULong {
|
||||||
|
return get(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 1st *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun UByteArray.component1(): UByte {
|
||||||
|
return get(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 1st *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun UShortArray.component1(): UShort {
|
||||||
|
return get(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 2nd *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun UIntArray.component2(): UInt {
|
||||||
|
return get(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 2nd *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun ULongArray.component2(): ULong {
|
||||||
|
return get(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 2nd *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun UByteArray.component2(): UByte {
|
||||||
|
return get(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 2nd *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun UShortArray.component2(): UShort {
|
||||||
|
return get(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 3rd *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun UIntArray.component3(): UInt {
|
||||||
|
return get(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 3rd *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun ULongArray.component3(): ULong {
|
||||||
|
return get(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 3rd *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun UByteArray.component3(): UByte {
|
||||||
|
return get(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 3rd *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun UShortArray.component3(): UShort {
|
||||||
|
return get(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 4th *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun UIntArray.component4(): UInt {
|
||||||
|
return get(3)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 4th *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun ULongArray.component4(): ULong {
|
||||||
|
return get(3)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 4th *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun UByteArray.component4(): UByte {
|
||||||
|
return get(3)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 4th *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun UShortArray.component4(): UShort {
|
||||||
|
return get(3)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 5th *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun UIntArray.component5(): UInt {
|
||||||
|
return get(4)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 5th *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun ULongArray.component5(): ULong {
|
||||||
|
return get(4)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 5th *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun UByteArray.component5(): UByte {
|
||||||
|
return get(4)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 5th *element* from the collection.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.3")
|
||||||
|
@ExperimentalUnsignedTypes
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline operator fun UShortArray.component5(): UShort {
|
||||||
|
return get(4)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a random element from this array.
|
* Returns a random element from this array.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -888,7 +888,7 @@ object Elements : TemplateGroupBase() {
|
|||||||
|
|
||||||
val f_components = (1..5).map { n ->
|
val f_components = (1..5).map { n ->
|
||||||
fn("component$n()") {
|
fn("component$n()") {
|
||||||
include(Lists, ArraysOfObjects, ArraysOfPrimitives)
|
include(Lists, ArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned)
|
||||||
} builder {
|
} builder {
|
||||||
operator(true)
|
operator(true)
|
||||||
inlineOnly()
|
inlineOnly()
|
||||||
|
|||||||
Reference in New Issue
Block a user