mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
23 lines
500 B
Kotlin
Vendored
23 lines
500 B
Kotlin
Vendored
// !LANGUAGE: +InlineClasses
|
|
|
|
inline class UInt(private val value: Int) {
|
|
fun asInt() = value
|
|
}
|
|
|
|
inline class UIntArray(private val intArray: IntArray) {
|
|
operator fun get(index: Int): UInt = UInt(intArray[index])
|
|
|
|
operator fun set(index: Int, value: UInt) {
|
|
intArray[index] = value.asInt()
|
|
}
|
|
}
|
|
|
|
fun UIntArray.swap(i: Int, j: Int) {
|
|
this[j] = this[i].also { this[i] = this[j] }
|
|
}
|
|
|
|
// 2 INVOKEVIRTUAL UInt.unbox
|
|
// 1 INVOKESTATIC UInt\$Erased.box
|
|
|
|
// 0 intValue
|
|
// 0 valueOf |