Implement reversing extension functions for UArrays
This commit is contained in:
committed by
Ilya Gorbunov
parent
92cd84682c
commit
114736c09b
+4
@@ -2335,6 +2335,10 @@ public final class kotlin/collections/UArraysKt {
|
||||
public static final fun random-JzugnMA ([JLkotlin/random/Random;)J
|
||||
public static final fun random-oSF2wD8 ([BLkotlin/random/Random;)B
|
||||
public static final fun random-s5X_as8 ([SLkotlin/random/Random;)S
|
||||
public static final fun reversed--ajY-9A ([I)Ljava/util/List;
|
||||
public static final fun reversed-GBYM_sE ([B)Ljava/util/List;
|
||||
public static final fun reversed-QwZRm1k ([J)Ljava/util/List;
|
||||
public static final fun reversed-rL5Bavg ([S)Ljava/util/List;
|
||||
public static final fun singleOrNull--ajY-9A ([I)Lkotlin/UInt;
|
||||
public static final fun singleOrNull-GBYM_sE ([B)Lkotlin/UByte;
|
||||
public static final fun singleOrNull-QwZRm1k ([J)Lkotlin/ULong;
|
||||
|
||||
@@ -10,8 +10,17 @@ import templates.SequenceClass.*
|
||||
|
||||
object Ordering : TemplateGroupBase() {
|
||||
|
||||
init {
|
||||
defaultBuilder {
|
||||
specialFor(ArraysOfUnsigned) {
|
||||
since("1.3")
|
||||
annotation("@ExperimentalUnsignedTypes")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val f_reverse = fn("reverse()") {
|
||||
include(Lists, InvariantArraysOfObjects, ArraysOfPrimitives)
|
||||
include(Lists, InvariantArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned)
|
||||
} builder {
|
||||
doc { "Reverses ${f.element.pluralize()} in the ${f.collection} in-place." }
|
||||
returns("Unit")
|
||||
@@ -28,6 +37,14 @@ object Ordering : TemplateGroupBase() {
|
||||
}
|
||||
"""
|
||||
}
|
||||
specialFor(ArraysOfUnsigned) {
|
||||
inlineOnly()
|
||||
body {
|
||||
"""
|
||||
storage.reverse()
|
||||
"""
|
||||
}
|
||||
}
|
||||
specialFor(Lists) {
|
||||
receiver("MutableList<T>")
|
||||
on(Platform.JVM) {
|
||||
@@ -37,7 +54,7 @@ object Ordering : TemplateGroupBase() {
|
||||
}
|
||||
|
||||
val f_reversed = fn("reversed()") {
|
||||
include(Iterables, ArraysOfObjects, ArraysOfPrimitives, CharSequences, Strings)
|
||||
include(Iterables, ArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned, CharSequences, Strings)
|
||||
} builder {
|
||||
doc { "Returns a list with elements in reversed order." }
|
||||
returns("List<T>")
|
||||
@@ -50,7 +67,7 @@ object Ordering : TemplateGroupBase() {
|
||||
"""
|
||||
}
|
||||
|
||||
body(ArraysOfObjects, ArraysOfPrimitives) {
|
||||
body(ArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned) {
|
||||
"""
|
||||
if (isEmpty()) return emptyList()
|
||||
val list = toMutableList()
|
||||
@@ -70,7 +87,7 @@ object Ordering : TemplateGroupBase() {
|
||||
}
|
||||
|
||||
val f_reversedArray = fn("reversedArray()") {
|
||||
include(InvariantArraysOfObjects, ArraysOfPrimitives)
|
||||
include(InvariantArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned)
|
||||
} builder {
|
||||
doc { "Returns an array with elements of this array in reversed order." }
|
||||
returns("SELF")
|
||||
@@ -94,6 +111,14 @@ object Ordering : TemplateGroupBase() {
|
||||
return result
|
||||
"""
|
||||
}
|
||||
specialFor(ArraysOfUnsigned) {
|
||||
inlineOnly()
|
||||
body {
|
||||
"""
|
||||
return SELF(storage.reversedArray())
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val stableSortNote =
|
||||
|
||||
Reference in New Issue
Block a user