Introduce sumOf with various selector types
#KT-11253
This commit is contained in:
@@ -17483,6 +17483,744 @@ public inline fun CharArray.sumByDouble(selector: (Char) -> Double): Double {
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfDouble")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Array<out T>.sumOf(selector: (T) -> Double): Double {
|
||||
var sum: Double = 0.toDouble()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfDouble")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ByteArray.sumOf(selector: (Byte) -> Double): Double {
|
||||
var sum: Double = 0.toDouble()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfDouble")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ShortArray.sumOf(selector: (Short) -> Double): Double {
|
||||
var sum: Double = 0.toDouble()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfDouble")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun IntArray.sumOf(selector: (Int) -> Double): Double {
|
||||
var sum: Double = 0.toDouble()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfDouble")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun LongArray.sumOf(selector: (Long) -> Double): Double {
|
||||
var sum: Double = 0.toDouble()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfDouble")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun FloatArray.sumOf(selector: (Float) -> Double): Double {
|
||||
var sum: Double = 0.toDouble()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfDouble")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun DoubleArray.sumOf(selector: (Double) -> Double): Double {
|
||||
var sum: Double = 0.toDouble()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfDouble")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun BooleanArray.sumOf(selector: (Boolean) -> Double): Double {
|
||||
var sum: Double = 0.toDouble()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfDouble")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun CharArray.sumOf(selector: (Char) -> Double): Double {
|
||||
var sum: Double = 0.toDouble()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfInt")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Array<out T>.sumOf(selector: (T) -> Int): Int {
|
||||
var sum: Int = 0.toInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfInt")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ByteArray.sumOf(selector: (Byte) -> Int): Int {
|
||||
var sum: Int = 0.toInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfInt")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ShortArray.sumOf(selector: (Short) -> Int): Int {
|
||||
var sum: Int = 0.toInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfInt")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun IntArray.sumOf(selector: (Int) -> Int): Int {
|
||||
var sum: Int = 0.toInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfInt")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun LongArray.sumOf(selector: (Long) -> Int): Int {
|
||||
var sum: Int = 0.toInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfInt")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun FloatArray.sumOf(selector: (Float) -> Int): Int {
|
||||
var sum: Int = 0.toInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfInt")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun DoubleArray.sumOf(selector: (Double) -> Int): Int {
|
||||
var sum: Int = 0.toInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfInt")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun BooleanArray.sumOf(selector: (Boolean) -> Int): Int {
|
||||
var sum: Int = 0.toInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfInt")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun CharArray.sumOf(selector: (Char) -> Int): Int {
|
||||
var sum: Int = 0.toInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfLong")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Array<out T>.sumOf(selector: (T) -> Long): Long {
|
||||
var sum: Long = 0.toLong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfLong")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ByteArray.sumOf(selector: (Byte) -> Long): Long {
|
||||
var sum: Long = 0.toLong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfLong")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ShortArray.sumOf(selector: (Short) -> Long): Long {
|
||||
var sum: Long = 0.toLong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfLong")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun IntArray.sumOf(selector: (Int) -> Long): Long {
|
||||
var sum: Long = 0.toLong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfLong")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun LongArray.sumOf(selector: (Long) -> Long): Long {
|
||||
var sum: Long = 0.toLong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfLong")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun FloatArray.sumOf(selector: (Float) -> Long): Long {
|
||||
var sum: Long = 0.toLong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfLong")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun DoubleArray.sumOf(selector: (Double) -> Long): Long {
|
||||
var sum: Long = 0.toLong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfLong")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun BooleanArray.sumOf(selector: (Boolean) -> Long): Long {
|
||||
var sum: Long = 0.toLong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfLong")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun CharArray.sumOf(selector: (Char) -> Long): Long {
|
||||
var sum: Long = 0.toLong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfUInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Array<out T>.sumOf(selector: (T) -> UInt): UInt {
|
||||
var sum: UInt = 0.toUInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfUInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ByteArray.sumOf(selector: (Byte) -> UInt): UInt {
|
||||
var sum: UInt = 0.toUInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfUInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ShortArray.sumOf(selector: (Short) -> UInt): UInt {
|
||||
var sum: UInt = 0.toUInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfUInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun IntArray.sumOf(selector: (Int) -> UInt): UInt {
|
||||
var sum: UInt = 0.toUInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfUInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun LongArray.sumOf(selector: (Long) -> UInt): UInt {
|
||||
var sum: UInt = 0.toUInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfUInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun FloatArray.sumOf(selector: (Float) -> UInt): UInt {
|
||||
var sum: UInt = 0.toUInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfUInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun DoubleArray.sumOf(selector: (Double) -> UInt): UInt {
|
||||
var sum: UInt = 0.toUInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfUInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun BooleanArray.sumOf(selector: (Boolean) -> UInt): UInt {
|
||||
var sum: UInt = 0.toUInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfUInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun CharArray.sumOf(selector: (Char) -> UInt): UInt {
|
||||
var sum: UInt = 0.toUInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfULong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Array<out T>.sumOf(selector: (T) -> ULong): ULong {
|
||||
var sum: ULong = 0.toULong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfULong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ByteArray.sumOf(selector: (Byte) -> ULong): ULong {
|
||||
var sum: ULong = 0.toULong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfULong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ShortArray.sumOf(selector: (Short) -> ULong): ULong {
|
||||
var sum: ULong = 0.toULong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfULong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun IntArray.sumOf(selector: (Int) -> ULong): ULong {
|
||||
var sum: ULong = 0.toULong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfULong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun LongArray.sumOf(selector: (Long) -> ULong): ULong {
|
||||
var sum: ULong = 0.toULong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfULong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun FloatArray.sumOf(selector: (Float) -> ULong): ULong {
|
||||
var sum: ULong = 0.toULong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfULong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun DoubleArray.sumOf(selector: (Double) -> ULong): ULong {
|
||||
var sum: ULong = 0.toULong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfULong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun BooleanArray.sumOf(selector: (Boolean) -> ULong): ULong {
|
||||
var sum: ULong = 0.toULong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfULong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun CharArray.sumOf(selector: (Char) -> ULong): ULong {
|
||||
var sum: ULong = 0.toULong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException] if there are any `null` elements.
|
||||
*/
|
||||
|
||||
@@ -2293,6 +2293,88 @@ public inline fun <T> Iterable<T>.sumByDouble(selector: (T) -> Double): Double {
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the collection.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfDouble")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Iterable<T>.sumOf(selector: (T) -> Double): Double {
|
||||
var sum: Double = 0.toDouble()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the collection.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfInt")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Iterable<T>.sumOf(selector: (T) -> Int): Int {
|
||||
var sum: Int = 0.toInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the collection.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfLong")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Iterable<T>.sumOf(selector: (T) -> Long): Long {
|
||||
var sum: Long = 0.toLong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the collection.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfUInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Iterable<T>.sumOf(selector: (T) -> UInt): UInt {
|
||||
var sum: UInt = 0.toUInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the collection.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfULong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Iterable<T>.sumOf(selector: (T) -> ULong): ULong {
|
||||
var sum: ULong = 0.toULong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException] if there are any `null` elements.
|
||||
*/
|
||||
|
||||
@@ -1710,6 +1710,98 @@ public inline fun <T> Sequence<T>.sumByDouble(selector: (T) -> Double): Double {
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the sequence.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfDouble")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Sequence<T>.sumOf(selector: (T) -> Double): Double {
|
||||
var sum: Double = 0.toDouble()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the sequence.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfInt")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Sequence<T>.sumOf(selector: (T) -> Int): Int {
|
||||
var sum: Int = 0.toInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the sequence.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfLong")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Sequence<T>.sumOf(selector: (T) -> Long): Long {
|
||||
var sum: Long = 0.toLong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the sequence.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfUInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Sequence<T>.sumOf(selector: (T) -> UInt): UInt {
|
||||
var sum: UInt = 0.toUInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the sequence.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfULong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Sequence<T>.sumOf(selector: (T) -> ULong): ULong {
|
||||
var sum: ULong = 0.toULong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException] if there are any `null` elements.
|
||||
*
|
||||
|
||||
@@ -1567,6 +1567,88 @@ public inline fun CharSequence.sumByDouble(selector: (Char) -> Double): Double {
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each character in the char sequence.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfDouble")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun CharSequence.sumOf(selector: (Char) -> Double): Double {
|
||||
var sum: Double = 0.toDouble()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each character in the char sequence.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfInt")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun CharSequence.sumOf(selector: (Char) -> Int): Int {
|
||||
var sum: Int = 0.toInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each character in the char sequence.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfLong")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun CharSequence.sumOf(selector: (Char) -> Long): Long {
|
||||
var sum: Long = 0.toLong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each character in the char sequence.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfUInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun CharSequence.sumOf(selector: (Char) -> UInt): UInt {
|
||||
var sum: UInt = 0.toUInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each character in the char sequence.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfULong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun CharSequence.sumOf(selector: (Char) -> ULong): ULong {
|
||||
var sum: ULong = 0.toULong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits this char sequence into a list of strings each not exceeding the given [size].
|
||||
*
|
||||
|
||||
@@ -7890,6 +7890,346 @@ public inline fun UShortArray.sumByDouble(selector: (UShort) -> Double): Double
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfDouble")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UIntArray.sumOf(selector: (UInt) -> Double): Double {
|
||||
var sum: Double = 0.toDouble()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfDouble")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ULongArray.sumOf(selector: (ULong) -> Double): Double {
|
||||
var sum: Double = 0.toDouble()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfDouble")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UByteArray.sumOf(selector: (UByte) -> Double): Double {
|
||||
var sum: Double = 0.toDouble()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfDouble")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UShortArray.sumOf(selector: (UShort) -> Double): Double {
|
||||
var sum: Double = 0.toDouble()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UIntArray.sumOf(selector: (UInt) -> Int): Int {
|
||||
var sum: Int = 0.toInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ULongArray.sumOf(selector: (ULong) -> Int): Int {
|
||||
var sum: Int = 0.toInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UByteArray.sumOf(selector: (UByte) -> Int): Int {
|
||||
var sum: Int = 0.toInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UShortArray.sumOf(selector: (UShort) -> Int): Int {
|
||||
var sum: Int = 0.toInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfLong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UIntArray.sumOf(selector: (UInt) -> Long): Long {
|
||||
var sum: Long = 0.toLong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfLong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ULongArray.sumOf(selector: (ULong) -> Long): Long {
|
||||
var sum: Long = 0.toLong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfLong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UByteArray.sumOf(selector: (UByte) -> Long): Long {
|
||||
var sum: Long = 0.toLong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfLong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UShortArray.sumOf(selector: (UShort) -> Long): Long {
|
||||
var sum: Long = 0.toLong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfUInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UIntArray.sumOf(selector: (UInt) -> UInt): UInt {
|
||||
var sum: UInt = 0.toUInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfUInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ULongArray.sumOf(selector: (ULong) -> UInt): UInt {
|
||||
var sum: UInt = 0.toUInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfUInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UByteArray.sumOf(selector: (UByte) -> UInt): UInt {
|
||||
var sum: UInt = 0.toUInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfUInt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UShortArray.sumOf(selector: (UShort) -> UInt): UInt {
|
||||
var sum: UInt = 0.toUInt()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfULong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UIntArray.sumOf(selector: (UInt) -> ULong): ULong {
|
||||
var sum: ULong = 0.toULong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfULong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ULongArray.sumOf(selector: (ULong) -> ULong): ULong {
|
||||
var sum: ULong = 0.toULong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfULong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UByteArray.sumOf(selector: (UByte) -> ULong): ULong {
|
||||
var sum: ULong = 0.toULong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfULong")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UShortArray.sumOf(selector: (UShort) -> ULong): ULong {
|
||||
var sum: ULong = 0.toULong()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of pairs built from the elements of `this` array and the [other] array with the same index.
|
||||
* The returned list has length of the shortest collection.
|
||||
|
||||
@@ -2702,3 +2702,291 @@ public fun <T> Array<out T>.toSortedSet(comparator: Comparator<in T>): java.util
|
||||
return toCollection(java.util.TreeSet<T>(comparator))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigDecimal")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Array<out T>.sumOf(selector: (T) -> java.math.BigDecimal): java.math.BigDecimal {
|
||||
var sum: java.math.BigDecimal = 0.toBigDecimal()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigDecimal")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ByteArray.sumOf(selector: (Byte) -> java.math.BigDecimal): java.math.BigDecimal {
|
||||
var sum: java.math.BigDecimal = 0.toBigDecimal()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigDecimal")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ShortArray.sumOf(selector: (Short) -> java.math.BigDecimal): java.math.BigDecimal {
|
||||
var sum: java.math.BigDecimal = 0.toBigDecimal()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigDecimal")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun IntArray.sumOf(selector: (Int) -> java.math.BigDecimal): java.math.BigDecimal {
|
||||
var sum: java.math.BigDecimal = 0.toBigDecimal()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigDecimal")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun LongArray.sumOf(selector: (Long) -> java.math.BigDecimal): java.math.BigDecimal {
|
||||
var sum: java.math.BigDecimal = 0.toBigDecimal()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigDecimal")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun FloatArray.sumOf(selector: (Float) -> java.math.BigDecimal): java.math.BigDecimal {
|
||||
var sum: java.math.BigDecimal = 0.toBigDecimal()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigDecimal")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun DoubleArray.sumOf(selector: (Double) -> java.math.BigDecimal): java.math.BigDecimal {
|
||||
var sum: java.math.BigDecimal = 0.toBigDecimal()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigDecimal")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun BooleanArray.sumOf(selector: (Boolean) -> java.math.BigDecimal): java.math.BigDecimal {
|
||||
var sum: java.math.BigDecimal = 0.toBigDecimal()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigDecimal")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun CharArray.sumOf(selector: (Char) -> java.math.BigDecimal): java.math.BigDecimal {
|
||||
var sum: java.math.BigDecimal = 0.toBigDecimal()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigInteger")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Array<out T>.sumOf(selector: (T) -> java.math.BigInteger): java.math.BigInteger {
|
||||
var sum: java.math.BigInteger = 0.toBigInteger()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigInteger")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ByteArray.sumOf(selector: (Byte) -> java.math.BigInteger): java.math.BigInteger {
|
||||
var sum: java.math.BigInteger = 0.toBigInteger()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigInteger")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ShortArray.sumOf(selector: (Short) -> java.math.BigInteger): java.math.BigInteger {
|
||||
var sum: java.math.BigInteger = 0.toBigInteger()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigInteger")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun IntArray.sumOf(selector: (Int) -> java.math.BigInteger): java.math.BigInteger {
|
||||
var sum: java.math.BigInteger = 0.toBigInteger()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigInteger")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun LongArray.sumOf(selector: (Long) -> java.math.BigInteger): java.math.BigInteger {
|
||||
var sum: java.math.BigInteger = 0.toBigInteger()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigInteger")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun FloatArray.sumOf(selector: (Float) -> java.math.BigInteger): java.math.BigInteger {
|
||||
var sum: java.math.BigInteger = 0.toBigInteger()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigInteger")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun DoubleArray.sumOf(selector: (Double) -> java.math.BigInteger): java.math.BigInteger {
|
||||
var sum: java.math.BigInteger = 0.toBigInteger()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigInteger")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun BooleanArray.sumOf(selector: (Boolean) -> java.math.BigInteger): java.math.BigInteger {
|
||||
var sum: java.math.BigInteger = 0.toBigInteger()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigInteger")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun CharArray.sumOf(selector: (Char) -> java.math.BigInteger): java.math.BigInteger {
|
||||
var sum: java.math.BigInteger = 0.toBigInteger()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
|
||||
@@ -55,3 +55,35 @@ public fun <T> Iterable<T>.toSortedSet(comparator: Comparator<in T>): java.util.
|
||||
return toCollection(java.util.TreeSet<T>(comparator))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the collection.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigDecimal")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Iterable<T>.sumOf(selector: (T) -> java.math.BigDecimal): java.math.BigDecimal {
|
||||
var sum: java.math.BigDecimal = 0.toBigDecimal()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the collection.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigInteger")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Iterable<T>.sumOf(selector: (T) -> java.math.BigInteger): java.math.BigInteger {
|
||||
var sum: java.math.BigInteger = 0.toBigInteger()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
|
||||
@@ -55,3 +55,39 @@ public fun <T> Sequence<T>.toSortedSet(comparator: Comparator<in T>): java.util.
|
||||
return toCollection(java.util.TreeSet<T>(comparator))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the sequence.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigDecimal")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Sequence<T>.sumOf(selector: (T) -> java.math.BigDecimal): java.math.BigDecimal {
|
||||
var sum: java.math.BigDecimal = 0.toBigDecimal()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the sequence.
|
||||
*
|
||||
* The operation is _terminal_.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigInteger")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Sequence<T>.sumOf(selector: (T) -> java.math.BigInteger): java.math.BigInteger {
|
||||
var sum: java.math.BigInteger = 0.toBigInteger()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
|
||||
@@ -31,3 +31,35 @@ public fun CharSequence.toSortedSet(): java.util.SortedSet<Char> {
|
||||
return toCollection(java.util.TreeSet<Char>())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each character in the char sequence.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigDecimal")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun CharSequence.sumOf(selector: (Char) -> java.math.BigDecimal): java.math.BigDecimal {
|
||||
var sum: java.math.BigDecimal = 0.toBigDecimal()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each character in the char sequence.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigInteger")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun CharSequence.sumOf(selector: (Char) -> java.math.BigInteger): java.math.BigInteger {
|
||||
var sum: java.math.BigInteger = 0.toBigInteger()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
|
||||
@@ -285,3 +285,139 @@ public fun UShortArray.binarySearch(element: UShort, fromIndex: Int = 0, toIndex
|
||||
return -(low + 1) // key not found
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigDecimal")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UIntArray.sumOf(selector: (UInt) -> java.math.BigDecimal): java.math.BigDecimal {
|
||||
var sum: java.math.BigDecimal = 0.toBigDecimal()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigDecimal")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ULongArray.sumOf(selector: (ULong) -> java.math.BigDecimal): java.math.BigDecimal {
|
||||
var sum: java.math.BigDecimal = 0.toBigDecimal()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigDecimal")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UByteArray.sumOf(selector: (UByte) -> java.math.BigDecimal): java.math.BigDecimal {
|
||||
var sum: java.math.BigDecimal = 0.toBigDecimal()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigDecimal")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UShortArray.sumOf(selector: (UShort) -> java.math.BigDecimal): java.math.BigDecimal {
|
||||
var sum: java.math.BigDecimal = 0.toBigDecimal()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigInteger")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UIntArray.sumOf(selector: (UInt) -> java.math.BigInteger): java.math.BigInteger {
|
||||
var sum: java.math.BigInteger = 0.toBigInteger()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigInteger")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun ULongArray.sumOf(selector: (ULong) -> java.math.BigInteger): java.math.BigInteger {
|
||||
var sum: java.math.BigInteger = 0.toBigInteger()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigInteger")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UByteArray.sumOf(selector: (UByte) -> java.math.BigInteger): java.math.BigInteger {
|
||||
var sum: java.math.BigInteger = 0.toBigInteger()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sum of all values produced by [selector] function applied to each element in the array.
|
||||
*/
|
||||
@SinceKotlin("1.4")
|
||||
@OptIn(kotlin.experimental.ExperimentalTypeInference::class)
|
||||
@OverloadResolutionByLambdaReturnType
|
||||
@kotlin.jvm.JvmName("sumOfBigInteger")
|
||||
@ExperimentalUnsignedTypes
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun UShortArray.sumOf(selector: (UShort) -> java.math.BigInteger): java.math.BigInteger {
|
||||
var sum: java.math.BigInteger = 0.toBigInteger()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,18 @@ class BigNumbersTest {
|
||||
assertEquals(BigInteger("2"), c)
|
||||
}
|
||||
|
||||
@Test fun sumOfBigInteger() {
|
||||
val numbers = (1..10).map { it.toBigInteger() }
|
||||
val i55 = 55.toBigInteger()
|
||||
assertEquals(i55, numbers.sumOf { it })
|
||||
assertEquals(i55, numbers.asSequence().sumOf { it })
|
||||
assertEquals(i55, numbers.toTypedArray().sumOf { it })
|
||||
|
||||
val chars = ('0'..'9').joinToString("")
|
||||
assertEquals(i55, chars.sumOf { it.toString().toBigInteger().inc() })
|
||||
assertEquals(i55, chars.toCharArray().sumOf { it.toString().toBigInteger().inc() })
|
||||
}
|
||||
|
||||
@Test fun testBigDecimal() {
|
||||
val a = BigDecimal("2")
|
||||
val b = BigDecimal("3")
|
||||
@@ -103,5 +115,17 @@ class BigNumbersTest {
|
||||
assertEquals(d4, d7 / d2)
|
||||
assertEquals(d1, d7 / d5)
|
||||
}
|
||||
|
||||
@Test fun sumOfBigDecimal() {
|
||||
val numbers = (1..10).map { it.toBigDecimal() }
|
||||
val d55 = 55.toBigDecimal()
|
||||
assertEquals(d55, numbers.sumOf { it })
|
||||
assertEquals(d55, numbers.asSequence().sumOf { it })
|
||||
assertEquals(d55, numbers.toTypedArray().sumOf { it })
|
||||
|
||||
val chars = ('0'..'9').joinToString("")
|
||||
assertEquals(d55, chars.sumOf { it.toString().toBigDecimal().inc() })
|
||||
assertEquals(d55, chars.toCharArray().sumOf { it.toString().toBigDecimal().inc() })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -903,6 +903,22 @@ class CollectionTest {
|
||||
expect(3.0.toFloat()) { sequenceOf<Float>(1.0.toFloat(), 2.0.toFloat()).sum() }
|
||||
}
|
||||
|
||||
@Test fun sumOf() {
|
||||
assertEquals(0, emptyList<Nothing>().sumOf { 1.toInt() })
|
||||
assertEquals(0L, emptyList<Nothing>().sumOf { 1L })
|
||||
assertEquals(0U, emptyList<Nothing>().sumOf { 1U.toUInt() })
|
||||
assertEquals(0UL, emptyList<Nothing>().sumOf { 1UL })
|
||||
assertEquals(0.0, emptyList<Nothing>().sumOf { 1.0 })
|
||||
|
||||
val items = listOf("", "a", "bc", "de", "fgh", "klmnop")
|
||||
assertEquals(items.size + 14, items.sumOf { it.length + 1 })
|
||||
assertEquals(14L, items.sumOf { it.length.toLong() })
|
||||
assertEquals(items.size.toUInt(), items.sumOf { 1U.toUInt() })
|
||||
assertEquals(14UL, items.sumOf { it.length.toULong() })
|
||||
assertEquals(14.0, items.sumOf { it.length.toDouble() })
|
||||
assertEquals(Double.NaN, items.sumOf { 0.0 / it.length })
|
||||
}
|
||||
|
||||
@Test fun average() {
|
||||
assertTrue { arrayListOf<Int>().average().isNaN() }
|
||||
expect(3.8) { listOf(1, 2, 5, 8, 3).average() }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -250,6 +250,38 @@ object Aggregates : TemplateGroupBase() {
|
||||
}
|
||||
}
|
||||
|
||||
fun f_sumOf() = listOf("Int", "Long", "UInt", "ULong", "Double", "java.math.BigInteger", "java.math.BigDecimal").map { selectorType ->
|
||||
fn("sumOf(selector: (T) -> $selectorType)") {
|
||||
includeDefault()
|
||||
include(CharSequences, ArraysOfUnsigned)
|
||||
if (selectorType.startsWith("java")) platforms(Platform.JVM)
|
||||
} builder {
|
||||
inlineOnly()
|
||||
since("1.4")
|
||||
val typeShortName = when {
|
||||
selectorType.startsWith("java") -> selectorType.substringAfterLast('.')
|
||||
else -> selectorType
|
||||
}
|
||||
annotation("@OptIn(kotlin.experimental.ExperimentalTypeInference::class)")
|
||||
annotation("@OverloadResolutionByLambdaReturnType")
|
||||
annotation("""@kotlin.jvm.JvmName("sumOf$typeShortName")""") // should not be needed if inline return type is mangled
|
||||
if (selectorType.startsWith("U"))
|
||||
annotation("@ExperimentalUnsignedTypes")
|
||||
|
||||
doc { "Returns the sum of all values produced by [selector] function applied to each ${f.element} in the ${f.collection}." }
|
||||
returns(selectorType)
|
||||
body {
|
||||
"""
|
||||
var sum: $selectorType = 0.to$typeShortName()
|
||||
for (element in this) {
|
||||
sum += selector(element)
|
||||
}
|
||||
return sum
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val f_sumByDouble = fn("sumByDouble(selector: (T) -> Double)") {
|
||||
includeDefault()
|
||||
include(CharSequences, ArraysOfUnsigned)
|
||||
|
||||
Reference in New Issue
Block a user