Implement drop, take & filter extension functions for UArrays

This commit is contained in:
Abduqodiri Qurbonzoda
2019-02-15 15:45:39 +03:00
committed by Ilya Gorbunov
parent abb275775e
commit c42dbb34ca
4 changed files with 973 additions and 17 deletions
@@ -2311,6 +2311,14 @@ public final class kotlin/collections/UArraysKt {
public static final fun contentToString-GBYM_sE ([B)Ljava/lang/String;
public static final fun contentToString-QwZRm1k ([J)Ljava/lang/String;
public static final fun contentToString-rL5Bavg ([S)Ljava/lang/String;
public static final fun drop-PpDY95g ([BI)Ljava/util/List;
public static final fun drop-nggk6HY ([SI)Ljava/util/List;
public static final fun drop-qFRl0hI ([II)Ljava/util/List;
public static final fun drop-r7IrZao ([JI)Ljava/util/List;
public static final fun dropLast-PpDY95g ([BI)Ljava/util/List;
public static final fun dropLast-nggk6HY ([SI)Ljava/util/List;
public static final fun dropLast-qFRl0hI ([II)Ljava/util/List;
public static final fun dropLast-r7IrZao ([JI)Ljava/util/List;
public static final fun fill-2fe2U9s ([IIII)V
public static synthetic fun fill-2fe2U9s$default ([IIIIILjava/lang/Object;)V
public static final fun fill-EtDCXyQ ([SSII)V
@@ -2391,6 +2399,14 @@ public final class kotlin/collections/UArraysKt {
public static final fun sumOfUInt ([Lkotlin/UInt;)I
public static final fun sumOfULong ([Lkotlin/ULong;)J
public static final fun sumOfUShort ([Lkotlin/UShort;)I
public static final fun take-PpDY95g ([BI)Ljava/util/List;
public static final fun take-nggk6HY ([SI)Ljava/util/List;
public static final fun take-qFRl0hI ([II)Ljava/util/List;
public static final fun take-r7IrZao ([JI)Ljava/util/List;
public static final fun takeLast-PpDY95g ([BI)Ljava/util/List;
public static final fun takeLast-nggk6HY ([SI)Ljava/util/List;
public static final fun takeLast-qFRl0hI ([II)Ljava/util/List;
public static final fun takeLast-r7IrZao ([JI)Ljava/util/List;
public static final fun toTypedArray--ajY-9A ([I)[Lkotlin/UInt;
public static final fun toTypedArray-GBYM_sE ([B)[Lkotlin/UByte;
public static final fun toTypedArray-QwZRm1k ([J)[Lkotlin/ULong;
@@ -39,7 +39,7 @@ object Filtering : TemplateGroupBase() {
val f_drop = fn("drop(n: Int)") {
includeDefault()
include(CharSequences, Strings)
include(CharSequences, Strings, ArraysOfUnsigned)
} builder {
val n = "\$n"
doc {
@@ -115,7 +115,7 @@ object Filtering : TemplateGroupBase() {
"""
}
body(ArraysOfObjects, ArraysOfPrimitives) {
body(ArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned) {
"""
require(n >= 0) { "Requested element count $n is less than zero." }
return takeLast((size - n).coerceAtLeast(0))
@@ -125,7 +125,7 @@ object Filtering : TemplateGroupBase() {
val f_take = fn("take(n: Int)") {
includeDefault()
include(CharSequences, Strings)
include(CharSequences, Strings, ArraysOfUnsigned)
} builder {
val n = "\$n"
doc {
@@ -185,7 +185,7 @@ object Filtering : TemplateGroupBase() {
"""
}
body(ArraysOfObjects, ArraysOfPrimitives) {
body(ArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned) {
"""
require(n >= 0) { "Requested element count $n is less than zero." }
if (n == 0) return emptyList()
@@ -204,7 +204,7 @@ object Filtering : TemplateGroupBase() {
}
val f_dropLast = fn("dropLast(n: Int)") {
include(Lists, ArraysOfObjects, ArraysOfPrimitives, CharSequences, Strings)
include(Lists, ArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned, CharSequences, Strings)
} builder {
val n = "\$n"
@@ -234,7 +234,7 @@ object Filtering : TemplateGroupBase() {
}
val f_takeLast = fn("takeLast(n: Int)") {
include(Lists, ArraysOfObjects, ArraysOfPrimitives, CharSequences, Strings)
include(Lists, ArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned, CharSequences, Strings)
} builder {
val n = "\$n"
doc {
@@ -262,7 +262,7 @@ object Filtering : TemplateGroupBase() {
"""
}
body(ArraysOfObjects, ArraysOfPrimitives) {
body(ArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned) {
"""
require(n >= 0) { "Requested element count $n is less than zero." }
if (n == 0) return emptyList()
@@ -299,9 +299,10 @@ object Filtering : TemplateGroupBase() {
val f_dropWhile = fn("dropWhile(predicate: (T) -> Boolean)") {
includeDefault()
include(CharSequences, Strings)
include(CharSequences, Strings, ArraysOfUnsigned)
} builder {
inline()
specialFor(ArraysOfUnsigned) { inlineOnly() }
doc {
"""
@@ -355,9 +356,10 @@ object Filtering : TemplateGroupBase() {
val f_takeWhile = fn("takeWhile(predicate: (T) -> Boolean)") {
includeDefault()
include(CharSequences, Strings)
include(CharSequences, Strings, ArraysOfUnsigned)
} builder {
inline()
specialFor(ArraysOfUnsigned) { inlineOnly() }
doc {
"""
@@ -406,9 +408,11 @@ object Filtering : TemplateGroupBase() {
}
val f_dropLastWhile = fn("dropLastWhile(predicate: (T) -> Boolean)") {
include(Lists, ArraysOfObjects, ArraysOfPrimitives, CharSequences, Strings)
include(Lists, ArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned, CharSequences, Strings)
} builder {
inline()
specialFor(ArraysOfUnsigned) { inlineOnly() }
doc {
"""
Returns a list containing all elements except last elements that satisfy the given [predicate].
@@ -462,9 +466,11 @@ object Filtering : TemplateGroupBase() {
}
val f_takeLastWhile = fn("takeLastWhile(predicate: (T) -> Boolean)") {
include(Lists, ArraysOfObjects, ArraysOfPrimitives, CharSequences, Strings)
include(Lists, ArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned, CharSequences, Strings)
} builder {
inline()
specialFor(ArraysOfUnsigned) { inlineOnly() }
doc {
"""
Returns a list containing last elements satisfying the given [predicate].
@@ -528,9 +534,10 @@ object Filtering : TemplateGroupBase() {
val f_filter = fn("filter(predicate: (T) -> Boolean)") {
includeDefault()
include(CharSequences, Strings)
include(CharSequences, Strings, ArraysOfUnsigned)
} builder {
inline()
specialFor(ArraysOfUnsigned) { inlineOnly() }
doc { "Returns a ${f.mapResult} containing only ${f.element.pluralize()} matching the given [predicate]." }
returns("List<T>")
@@ -555,9 +562,10 @@ object Filtering : TemplateGroupBase() {
val f_filterTo = fn("filterTo(destination: C, predicate: (T) -> Boolean)") {
includeDefault()
include(CharSequences)
include(CharSequences, ArraysOfUnsigned)
} builder {
inline()
specialFor(ArraysOfUnsigned) { inlineOnly() }
doc { "Appends all ${f.element.pluralize()} matching the given [predicate] to the given [destination]." }
typeParam("C : TCollection")
@@ -583,9 +591,10 @@ object Filtering : TemplateGroupBase() {
val f_filterIndexed = fn("filterIndexed(predicate: (index: Int, T) -> Boolean)") {
includeDefault()
include(CharSequences, Strings)
include(CharSequences, Strings, ArraysOfUnsigned)
} builder {
inline()
specialFor(ArraysOfUnsigned) { inlineOnly() }
doc {
"""
@@ -627,9 +636,10 @@ object Filtering : TemplateGroupBase() {
val f_filterIndexedTo = fn("filterIndexedTo(destination: C, predicate: (index: Int, T) -> Boolean)") {
includeDefault()
include(CharSequences)
include(CharSequences, ArraysOfUnsigned)
} builder {
inline()
specialFor(ArraysOfUnsigned) { inlineOnly() }
doc {
"""
@@ -652,9 +662,10 @@ object Filtering : TemplateGroupBase() {
val f_filterNot = fn("filterNot(predicate: (T) -> Boolean)") {
includeDefault()
include(CharSequences, Strings)
include(CharSequences, Strings, ArraysOfUnsigned)
} builder {
inline()
specialFor(ArraysOfUnsigned) { inlineOnly() }
doc { "Returns a list containing all elements not matching the given [predicate]." }
returns("List<T>")
@@ -680,9 +691,10 @@ object Filtering : TemplateGroupBase() {
val f_filterNotTo = fn("filterNotTo(destination: C, predicate: (T) -> Boolean)") {
includeDefault()
include(CharSequences)
include(CharSequences, ArraysOfUnsigned)
} builder {
inline()
specialFor(ArraysOfUnsigned) { inlineOnly() }
doc { "Appends all elements not matching the given [predicate] to the given [destination]." }
typeParam("C : TCollection")