Document 'reduce' operation behavior on empty collections #KT-23322

This commit is contained in:
Abduqodiri Qurbonzoda
2020-04-14 12:31:25 +03:00
parent 0b66330d9f
commit 4d7597fa5a
6 changed files with 1194 additions and 356 deletions
File diff suppressed because it is too large Load Diff
@@ -1602,7 +1602,12 @@ public inline fun <T> Iterable<T>.count(predicate: (T) -> Boolean): Int {
}
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element.
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns the specified [initial] value if the collection is empty.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*/
public inline fun <T, R> Iterable<T>.fold(initial: R, operation: (acc: R, T) -> R): R {
var accumulator = initial
@@ -1613,6 +1618,9 @@ public inline fun <T, R> Iterable<T>.fold(initial: R, operation: (acc: R, T) ->
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element with its index in the original collection.
*
* Returns the specified [initial] value if the collection is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*/
@@ -1624,7 +1632,12 @@ public inline fun <T, R> Iterable<T>.foldIndexed(initial: R, operation: (index:
}
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value.
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each element and current accumulator value.
*
* Returns the specified [initial] value if the list is empty.
*
* @param [operation] function that takes an element and current accumulator value, and calculates the next accumulator value.
*/
public inline fun <T, R> List<T>.foldRight(initial: R, operation: (T, acc: R) -> R): R {
var accumulator = initial
@@ -1640,6 +1653,9 @@ public inline fun <T, R> List<T>.foldRight(initial: R, operation: (T, acc: R) ->
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each element with its index in the original list and current accumulator value.
*
* Returns the specified [initial] value if the list is empty.
*
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*/
@@ -1890,7 +1906,14 @@ public inline fun <T, C : Iterable<T>> C.onEachIndexed(action: (index: Int, T) -
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element.
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Throws an exception if this collection is empty. If the collection can be empty in an expected way,
* please use [reduceOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@@ -1907,8 +1930,12 @@ public inline fun <S, T : S> Iterable<T>.reduce(operation: (acc: S, T) -> S): S
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original collection.
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself and calculates the next accumulator value.
*
* Throws an exception if this collection is empty. If the collection can be empty in an expected way,
* please use [reduceIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@@ -1926,9 +1953,11 @@ public inline fun <S, T : S> Iterable<T>.reduceIndexed(operation: (index: Int, a
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original collection.
* Returns null if the collection is empty.
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself and calculates the next accumulator value.
*
* Returns `null` if the collection is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@@ -1945,7 +1974,13 @@ public inline fun <S, T : S> Iterable<T>.reduceIndexedOrNull(operation: (index:
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element. Returns null if the collection is empty.
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns `null` if the collection is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@@ -1962,7 +1997,14 @@ public inline fun <S, T : S> Iterable<T>.reduceOrNull(operation: (acc: S, T) ->
}
/**
* Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value.
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element and current accumulator value.
*
* Throws an exception if this list is empty. If the list can be empty in an expected way,
* please use [reduceRightOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes an element and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@@ -1978,10 +2020,14 @@ public inline fun <S, T : S> List<T>.reduceRight(operation: (T, acc: S) -> S): S
}
/**
* Accumulates value starting with last element and applying [operation] from right to left
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element with its index in the original list and current accumulator value.
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*
* Throws an exception if this list is empty. If the list can be empty in an expected way,
* please use [reduceRightIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of an element, the element itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@@ -1998,11 +2044,13 @@ public inline fun <S, T : S> List<T>.reduceRightIndexed(operation: (index: Int,
}
/**
* Accumulates value starting with last element and applying [operation] from right to left
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element with its index in the original list and current accumulator value.
* Returns null if the list is empty.
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*
* Returns `null` if the list is empty.
*
* @param [operation] function that takes the index of an element, the element itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/
@@ -2020,7 +2068,13 @@ public inline fun <S, T : S> List<T>.reduceRightIndexedOrNull(operation: (index:
}
/**
* Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value. Returns null if the list is empty.
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element and current accumulator value.
*
* Returns `null` if the list is empty.
*
* @param [operation] function that takes an element and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/
@@ -1078,7 +1078,12 @@ public inline fun <T> Sequence<T>.count(predicate: (T) -> Boolean): Int {
}
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element.
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns the specified [initial] value if the sequence is empty.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*
* The operation is _terminal_.
*/
@@ -1091,6 +1096,9 @@ public inline fun <T, R> Sequence<T>.fold(initial: R, operation: (acc: R, T) ->
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element with its index in the original sequence.
*
* Returns the specified [initial] value if the sequence is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*
@@ -1372,7 +1380,14 @@ public fun <T> Sequence<T>.onEachIndexed(action: (index: Int, T) -> Unit): Seque
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element.
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Throws an exception if this sequence is empty. If the sequence can be empty in an expected way,
* please use [reduceOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* The operation is _terminal_.
*
@@ -1391,8 +1406,12 @@ public inline fun <S, T : S> Sequence<T>.reduce(operation: (acc: S, T) -> S): S
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original sequence.
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself and calculates the next accumulator value.
*
* Throws an exception if this sequence is empty. If the sequence can be empty in an expected way,
* please use [reduceIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* The operation is _terminal_.
*
@@ -1412,9 +1431,11 @@ public inline fun <S, T : S> Sequence<T>.reduceIndexed(operation: (index: Int, a
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original sequence.
* Returns null if the sequence is empty.
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself and calculates the next accumulator value.
*
* Returns `null` if the sequence is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* The operation is _terminal_.
*
@@ -1433,7 +1454,13 @@ public inline fun <S, T : S> Sequence<T>.reduceIndexedOrNull(operation: (index:
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element. Returns null if the sequence is empty.
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns `null` if the sequence is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* The operation is _terminal_.
*
@@ -1006,7 +1006,12 @@ public inline fun CharSequence.count(predicate: (Char) -> Boolean): Int {
}
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each character.
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each character.
*
* Returns the specified [initial] value if the char sequence is empty.
*
* @param [operation] function that takes current accumulator value and a character, and calculates the next accumulator value.
*/
public inline fun <R> CharSequence.fold(initial: R, operation: (acc: R, Char) -> R): R {
var accumulator = initial
@@ -1017,6 +1022,9 @@ public inline fun <R> CharSequence.fold(initial: R, operation: (acc: R, Char) ->
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each character with its index in the original char sequence.
*
* Returns the specified [initial] value if the char sequence is empty.
*
* @param [operation] function that takes the index of a character, current accumulator value
* and the character itself, and calculates the next accumulator value.
*/
@@ -1028,7 +1036,12 @@ public inline fun <R> CharSequence.foldIndexed(initial: R, operation: (index: In
}
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left to each character and current accumulator value.
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each character and current accumulator value.
*
* Returns the specified [initial] value if the char sequence is empty.
*
* @param [operation] function that takes a character and current accumulator value, and calculates the next accumulator value.
*/
public inline fun <R> CharSequence.foldRight(initial: R, operation: (Char, acc: R) -> R): R {
var index = lastIndex
@@ -1042,6 +1055,9 @@ public inline fun <R> CharSequence.foldRight(initial: R, operation: (Char, acc:
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each character with its index in the original char sequence and current accumulator value.
*
* Returns the specified [initial] value if the char sequence is empty.
*
* @param [operation] function that takes the index of a character, the character itself
* and current accumulator value, and calculates the next accumulator value.
*/
@@ -1207,7 +1223,14 @@ public inline fun <S : CharSequence> S.onEachIndexed(action: (index: Int, Char)
}
/**
* Accumulates value starting with the first character and applying [operation] from left to right to current accumulator value and each character.
* Accumulates value starting with the first character and applying [operation] from left to right
* to current accumulator value and each character.
*
* Throws an exception if this char sequence is empty. If the char sequence can be empty in an expected way,
* please use [reduceOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes current accumulator value and a character,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@@ -1224,8 +1247,12 @@ public inline fun CharSequence.reduce(operation: (acc: Char, Char) -> Char): Cha
/**
* Accumulates value starting with the first character and applying [operation] from left to right
* to current accumulator value and each character with its index in the original char sequence.
* @param [operation] function that takes the index of a character, current accumulator value
* and the character itself and calculates the next accumulator value.
*
* Throws an exception if this char sequence is empty. If the char sequence can be empty in an expected way,
* please use [reduceIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of a character, current accumulator value and the character itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@@ -1242,9 +1269,11 @@ public inline fun CharSequence.reduceIndexed(operation: (index: Int, acc: Char,
/**
* Accumulates value starting with the first character and applying [operation] from left to right
* to current accumulator value and each character with its index in the original char sequence.
* Returns null if the char sequence is empty.
* @param [operation] function that takes the index of a character, current accumulator value
* and the character itself and calculates the next accumulator value.
*
* Returns `null` if the char sequence is empty.
*
* @param [operation] function that takes the index of a character, current accumulator value and the character itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@@ -1260,7 +1289,13 @@ public inline fun CharSequence.reduceIndexedOrNull(operation: (index: Int, acc:
}
/**
* Accumulates value starting with the first character and applying [operation] from left to right to current accumulator value and each character. Returns null if the char sequence is empty.
* Accumulates value starting with the first character and applying [operation] from left to right
* to current accumulator value and each character.
*
* Returns `null` if the char sequence is empty.
*
* @param [operation] function that takes current accumulator value and a character,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@@ -1277,7 +1312,14 @@ public inline fun CharSequence.reduceOrNull(operation: (acc: Char, Char) -> Char
}
/**
* Accumulates value starting with last character and applying [operation] from right to left to each character and current accumulator value.
* Accumulates value starting with the last character and applying [operation] from right to left
* to each character and current accumulator value.
*
* Throws an exception if this char sequence is empty. If the char sequence can be empty in an expected way,
* please use [reduceRightOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes a character and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@@ -1292,10 +1334,14 @@ public inline fun CharSequence.reduceRight(operation: (Char, acc: Char) -> Char)
}
/**
* Accumulates value starting with last character and applying [operation] from right to left
* Accumulates value starting with the last character and applying [operation] from right to left
* to each character with its index in the original char sequence and current accumulator value.
* @param [operation] function that takes the index of a character, the character itself
* and current accumulator value, and calculates the next accumulator value.
*
* Throws an exception if this char sequence is empty. If the char sequence can be empty in an expected way,
* please use [reduceRightIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of a character, the character itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@@ -1311,11 +1357,13 @@ public inline fun CharSequence.reduceRightIndexed(operation: (index: Int, Char,
}
/**
* Accumulates value starting with last character and applying [operation] from right to left
* Accumulates value starting with the last character and applying [operation] from right to left
* to each character with its index in the original char sequence and current accumulator value.
* Returns null if the char sequence is empty.
* @param [operation] function that takes the index of a character, the character itself
* and current accumulator value, and calculates the next accumulator value.
*
* Returns `null` if the char sequence is empty.
*
* @param [operation] function that takes the index of a character, the character itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/
@@ -1332,7 +1380,13 @@ public inline fun CharSequence.reduceRightIndexedOrNull(operation: (index: Int,
}
/**
* Accumulates value starting with last character and applying [operation] from right to left to each character and current accumulator value. Returns null if the char sequence is empty.
* Accumulates value starting with the last character and applying [operation] from right to left
* to each character and current accumulator value.
*
* Returns `null` if the char sequence is empty.
*
* @param [operation] function that takes a character and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/
+288 -72
View File
@@ -5091,7 +5091,12 @@ public inline fun UShortArray.count(predicate: (UShort) -> Boolean): Int {
}
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element.
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@@ -5103,7 +5108,12 @@ public inline fun <R> UIntArray.fold(initial: R, operation: (acc: R, UInt) -> R)
}
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element.
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@@ -5115,7 +5125,12 @@ public inline fun <R> ULongArray.fold(initial: R, operation: (acc: R, ULong) ->
}
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element.
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@@ -5127,7 +5142,12 @@ public inline fun <R> UByteArray.fold(initial: R, operation: (acc: R, UByte) ->
}
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element.
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes current accumulator value and an element, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@@ -5141,6 +5161,9 @@ public inline fun <R> UShortArray.fold(initial: R, operation: (acc: R, UShort) -
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*/
@@ -5157,6 +5180,9 @@ public inline fun <R> UIntArray.foldIndexed(initial: R, operation: (index: Int,
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*/
@@ -5173,6 +5199,9 @@ public inline fun <R> ULongArray.foldIndexed(initial: R, operation: (index: Int,
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*/
@@ -5189,6 +5218,9 @@ public inline fun <R> UByteArray.foldIndexed(initial: R, operation: (index: Int,
/**
* Accumulates value starting with [initial] value and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself, and calculates the next accumulator value.
*/
@@ -5203,7 +5235,12 @@ public inline fun <R> UShortArray.foldIndexed(initial: R, operation: (index: Int
}
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value.
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each element and current accumulator value.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes an element and current accumulator value, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@@ -5218,7 +5255,12 @@ public inline fun <R> UIntArray.foldRight(initial: R, operation: (UInt, acc: R)
}
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value.
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each element and current accumulator value.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes an element and current accumulator value, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@@ -5233,7 +5275,12 @@ public inline fun <R> ULongArray.foldRight(initial: R, operation: (ULong, acc: R
}
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value.
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each element and current accumulator value.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes an element and current accumulator value, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@@ -5248,7 +5295,12 @@ public inline fun <R> UByteArray.foldRight(initial: R, operation: (UByte, acc: R
}
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value.
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each element and current accumulator value.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes an element and current accumulator value, and calculates the next accumulator value.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@@ -5265,6 +5317,9 @@ public inline fun <R> UShortArray.foldRight(initial: R, operation: (UShort, acc:
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*/
@@ -5284,6 +5339,9 @@ public inline fun <R> UIntArray.foldRightIndexed(initial: R, operation: (index:
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*/
@@ -5303,6 +5361,9 @@ public inline fun <R> ULongArray.foldRightIndexed(initial: R, operation: (index:
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*/
@@ -5322,6 +5383,9 @@ public inline fun <R> UByteArray.foldRightIndexed(initial: R, operation: (index:
/**
* Accumulates value starting with [initial] value and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
*
* Returns the specified [initial] value if the array is empty.
*
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*/
@@ -6063,7 +6127,14 @@ public inline fun UShortArray.onEachIndexed(action: (index: Int, UShort) -> Unit
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element.
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@@ -6081,7 +6152,14 @@ public inline fun UIntArray.reduce(operation: (acc: UInt, UInt) -> UInt): UInt {
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element.
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@@ -6099,7 +6177,14 @@ public inline fun ULongArray.reduce(operation: (acc: ULong, ULong) -> ULong): UL
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element.
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@@ -6117,7 +6202,14 @@ public inline fun UByteArray.reduce(operation: (acc: UByte, UByte) -> UByte): UB
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element.
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@@ -6137,8 +6229,12 @@ public inline fun UShortArray.reduce(operation: (acc: UShort, UShort) -> UShort)
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself and calculates the next accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@@ -6158,8 +6254,12 @@ public inline fun UIntArray.reduceIndexed(operation: (index: Int, acc: UInt, UIn
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself and calculates the next accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@@ -6179,8 +6279,12 @@ public inline fun ULongArray.reduceIndexed(operation: (index: Int, acc: ULong, U
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself and calculates the next accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@@ -6200,8 +6304,12 @@ public inline fun UByteArray.reduceIndexed(operation: (index: Int, acc: UByte, U
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself and calculates the next accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduce
*/
@@ -6221,9 +6329,11 @@ public inline fun UShortArray.reduceIndexed(operation: (index: Int, acc: UShort,
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
* Returns null if the array is empty.
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself and calculates the next accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@@ -6243,9 +6353,11 @@ public inline fun UIntArray.reduceIndexedOrNull(operation: (index: Int, acc: UIn
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
* Returns null if the array is empty.
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself and calculates the next accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@@ -6265,9 +6377,11 @@ public inline fun ULongArray.reduceIndexedOrNull(operation: (index: Int, acc: UL
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
* Returns null if the array is empty.
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself and calculates the next accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@@ -6287,9 +6401,11 @@ public inline fun UByteArray.reduceIndexedOrNull(operation: (index: Int, acc: UB
/**
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element with its index in the original array.
* Returns null if the array is empty.
* @param [operation] function that takes the index of an element, current accumulator value
* and the element itself and calculates the next accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes the index of an element, current accumulator value and the element itself,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@@ -6307,7 +6423,13 @@ public inline fun UShortArray.reduceIndexedOrNull(operation: (index: Int, acc: U
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element. Returns null if the array is empty.
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@@ -6326,7 +6448,13 @@ public inline fun UIntArray.reduceOrNull(operation: (acc: UInt, UInt) -> UInt):
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element. Returns null if the array is empty.
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@@ -6345,7 +6473,13 @@ public inline fun ULongArray.reduceOrNull(operation: (acc: ULong, ULong) -> ULon
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element. Returns null if the array is empty.
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@@ -6364,7 +6498,13 @@ public inline fun UByteArray.reduceOrNull(operation: (acc: UByte, UByte) -> UByt
}
/**
* Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element. Returns null if the array is empty.
* Accumulates value starting with the first element and applying [operation] from left to right
* to current accumulator value and each element.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes current accumulator value and an element,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceOrNull
*/
@@ -6383,7 +6523,14 @@ public inline fun UShortArray.reduceOrNull(operation: (acc: UShort, UShort) -> U
}
/**
* Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value.
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element and current accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceRightOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes an element and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@@ -6401,7 +6548,14 @@ public inline fun UIntArray.reduceRight(operation: (UInt, acc: UInt) -> UInt): U
}
/**
* Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value.
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element and current accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceRightOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes an element and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@@ -6419,7 +6573,14 @@ public inline fun ULongArray.reduceRight(operation: (ULong, acc: ULong) -> ULong
}
/**
* Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value.
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element and current accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceRightOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes an element and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@@ -6437,7 +6598,14 @@ public inline fun UByteArray.reduceRight(operation: (UByte, acc: UByte) -> UByte
}
/**
* Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value.
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element and current accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceRightOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes an element and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@@ -6455,10 +6623,14 @@ public inline fun UShortArray.reduceRight(operation: (UShort, acc: UShort) -> US
}
/**
* Accumulates value starting with last element and applying [operation] from right to left
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceRightIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of an element, the element itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@@ -6477,10 +6649,14 @@ public inline fun UIntArray.reduceRightIndexed(operation: (index: Int, UInt, acc
}
/**
* Accumulates value starting with last element and applying [operation] from right to left
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceRightIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of an element, the element itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@@ -6499,10 +6675,14 @@ public inline fun ULongArray.reduceRightIndexed(operation: (index: Int, ULong, a
}
/**
* Accumulates value starting with last element and applying [operation] from right to left
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceRightIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of an element, the element itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@@ -6521,10 +6701,14 @@ public inline fun UByteArray.reduceRightIndexed(operation: (index: Int, UByte, a
}
/**
* Accumulates value starting with last element and applying [operation] from right to left
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*
* Throws an exception if this array is empty. If the array can be empty in an expected way,
* please use [reduceRightIndexedOrNull] instead. It returns `null` when its receiver is empty.
*
* @param [operation] function that takes the index of an element, the element itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRight
*/
@@ -6543,11 +6727,13 @@ public inline fun UShortArray.reduceRightIndexed(operation: (index: Int, UShort,
}
/**
* Accumulates value starting with last element and applying [operation] from right to left
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
* Returns null if the array is empty.
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes the index of an element, the element itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/
@@ -6566,11 +6752,13 @@ public inline fun UIntArray.reduceRightIndexedOrNull(operation: (index: Int, UIn
}
/**
* Accumulates value starting with last element and applying [operation] from right to left
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
* Returns null if the array is empty.
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes the index of an element, the element itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/
@@ -6589,11 +6777,13 @@ public inline fun ULongArray.reduceRightIndexedOrNull(operation: (index: Int, UL
}
/**
* Accumulates value starting with last element and applying [operation] from right to left
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
* Returns null if the array is empty.
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes the index of an element, the element itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/
@@ -6612,11 +6802,13 @@ public inline fun UByteArray.reduceRightIndexedOrNull(operation: (index: Int, UB
}
/**
* Accumulates value starting with last element and applying [operation] from right to left
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element with its index in the original array and current accumulator value.
* Returns null if the array is empty.
* @param [operation] function that takes the index of an element, the element itself
* and current accumulator value, and calculates the next accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes the index of an element, the element itself and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/
@@ -6635,7 +6827,13 @@ public inline fun UShortArray.reduceRightIndexedOrNull(operation: (index: Int, U
}
/**
* Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value. Returns null if the array is empty.
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element and current accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes an element and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/
@@ -6654,7 +6852,13 @@ public inline fun UIntArray.reduceRightOrNull(operation: (UInt, acc: UInt) -> UI
}
/**
* Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value. Returns null if the array is empty.
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element and current accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes an element and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/
@@ -6673,7 +6877,13 @@ public inline fun ULongArray.reduceRightOrNull(operation: (ULong, acc: ULong) ->
}
/**
* Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value. Returns null if the array is empty.
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element and current accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes an element and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/
@@ -6692,7 +6902,13 @@ public inline fun UByteArray.reduceRightOrNull(operation: (UByte, acc: UByte) ->
}
/**
* Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value. Returns null if the array is empty.
* Accumulates value starting with the last element and applying [operation] from right to left
* to each element and current accumulator value.
*
* Returns `null` if the array is empty.
*
* @param [operation] function that takes an element and current accumulator value,
* and calculates the next accumulator value.
*
* @sample samples.collections.Collections.Aggregates.reduceRightOrNull
*/