From b19c0363fd90a6231e1b983d1dd914e85399da4a Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Wed, 17 Feb 2016 06:56:05 +0300 Subject: [PATCH] Clarify parameter order of lambda function parameter of *Indexed functions. #KT-10953 Fixed --- libraries/stdlib/src/generated/_Arrays.kt | 166 ++++++++++++++++++ .../stdlib/src/generated/_Collections.kt | 22 +++ libraries/stdlib/src/generated/_Sequences.kt | 18 ++ libraries/stdlib/src/generated/_Strings.kt | 24 +++ .../src/templates/Aggregates.kt | 19 +- .../src/templates/Filtering.kt | 23 ++- .../src/templates/Mapping.kt | 8 + 7 files changed, 276 insertions(+), 4 deletions(-) diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index d8376eb398b..07bd5328ba1 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -3046,6 +3046,8 @@ public inline fun CharArray.filter(predicate: (Char) -> Boolean): List { /** * Returns a list containing only elements matching the given [predicate]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun Array.filterIndexed(predicate: (Int, T) -> Boolean): List { return filterIndexedTo(ArrayList(), predicate) @@ -3053,6 +3055,8 @@ public inline fun Array.filterIndexed(predicate: (Int, T) -> Boolean) /** * Returns a list containing only elements matching the given [predicate]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun ByteArray.filterIndexed(predicate: (Int, Byte) -> Boolean): List { return filterIndexedTo(ArrayList(), predicate) @@ -3060,6 +3064,8 @@ public inline fun ByteArray.filterIndexed(predicate: (Int, Byte) -> Boolean): Li /** * Returns a list containing only elements matching the given [predicate]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun ShortArray.filterIndexed(predicate: (Int, Short) -> Boolean): List { return filterIndexedTo(ArrayList(), predicate) @@ -3067,6 +3073,8 @@ public inline fun ShortArray.filterIndexed(predicate: (Int, Short) -> Boolean): /** * Returns a list containing only elements matching the given [predicate]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun IntArray.filterIndexed(predicate: (Int, Int) -> Boolean): List { return filterIndexedTo(ArrayList(), predicate) @@ -3074,6 +3082,8 @@ public inline fun IntArray.filterIndexed(predicate: (Int, Int) -> Boolean): List /** * Returns a list containing only elements matching the given [predicate]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun LongArray.filterIndexed(predicate: (Int, Long) -> Boolean): List { return filterIndexedTo(ArrayList(), predicate) @@ -3081,6 +3091,8 @@ public inline fun LongArray.filterIndexed(predicate: (Int, Long) -> Boolean): Li /** * Returns a list containing only elements matching the given [predicate]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun FloatArray.filterIndexed(predicate: (Int, Float) -> Boolean): List { return filterIndexedTo(ArrayList(), predicate) @@ -3088,6 +3100,8 @@ public inline fun FloatArray.filterIndexed(predicate: (Int, Float) -> Boolean): /** * Returns a list containing only elements matching the given [predicate]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun DoubleArray.filterIndexed(predicate: (Int, Double) -> Boolean): List { return filterIndexedTo(ArrayList(), predicate) @@ -3095,6 +3109,8 @@ public inline fun DoubleArray.filterIndexed(predicate: (Int, Double) -> Boolean) /** * Returns a list containing only elements matching the given [predicate]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun BooleanArray.filterIndexed(predicate: (Int, Boolean) -> Boolean): List { return filterIndexedTo(ArrayList(), predicate) @@ -3102,6 +3118,8 @@ public inline fun BooleanArray.filterIndexed(predicate: (Int, Boolean) -> Boolea /** * Returns a list containing only elements matching the given [predicate]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun CharArray.filterIndexed(predicate: (Int, Char) -> Boolean): List { return filterIndexedTo(ArrayList(), predicate) @@ -3109,6 +3127,8 @@ public inline fun CharArray.filterIndexed(predicate: (Int, Char) -> Boolean): Li /** * Appends all elements matching the given [predicate] to the given [destination]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun > Array.filterIndexedTo(destination: C, predicate: (Int, T) -> Boolean): C { forEachIndexed { index, element -> @@ -3119,6 +3139,8 @@ public inline fun > Array.filterIndexedTo( /** * Appends all elements matching the given [predicate] to the given [destination]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun > ByteArray.filterIndexedTo(destination: C, predicate: (Int, Byte) -> Boolean): C { forEachIndexed { index, element -> @@ -3129,6 +3151,8 @@ public inline fun > ByteArray.filterIndexedTo(des /** * Appends all elements matching the given [predicate] to the given [destination]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun > ShortArray.filterIndexedTo(destination: C, predicate: (Int, Short) -> Boolean): C { forEachIndexed { index, element -> @@ -3139,6 +3163,8 @@ public inline fun > ShortArray.filterIndexedTo(d /** * Appends all elements matching the given [predicate] to the given [destination]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun > IntArray.filterIndexedTo(destination: C, predicate: (Int, Int) -> Boolean): C { forEachIndexed { index, element -> @@ -3149,6 +3175,8 @@ public inline fun > IntArray.filterIndexedTo(desti /** * Appends all elements matching the given [predicate] to the given [destination]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun > LongArray.filterIndexedTo(destination: C, predicate: (Int, Long) -> Boolean): C { forEachIndexed { index, element -> @@ -3159,6 +3187,8 @@ public inline fun > LongArray.filterIndexedTo(des /** * Appends all elements matching the given [predicate] to the given [destination]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun > FloatArray.filterIndexedTo(destination: C, predicate: (Int, Float) -> Boolean): C { forEachIndexed { index, element -> @@ -3169,6 +3199,8 @@ public inline fun > FloatArray.filterIndexedTo(d /** * Appends all elements matching the given [predicate] to the given [destination]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun > DoubleArray.filterIndexedTo(destination: C, predicate: (Int, Double) -> Boolean): C { forEachIndexed { index, element -> @@ -3179,6 +3211,8 @@ public inline fun > DoubleArray.filterIndexedTo /** * Appends all elements matching the given [predicate] to the given [destination]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun > BooleanArray.filterIndexedTo(destination: C, predicate: (Int, Boolean) -> Boolean): C { forEachIndexed { index, element -> @@ -3189,6 +3223,8 @@ public inline fun > BooleanArray.filterIndexed /** * Appends all elements matching the given [predicate] to the given [destination]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun > CharArray.filterIndexedTo(destination: C, predicate: (Int, Char) -> Boolean): C { forEachIndexed { index, element -> @@ -7232,6 +7268,8 @@ public inline fun CharArray.map(transform: (Char) -> R): List { /** * Returns a list containing the results of applying the given [transform] function * to each element and its index in the original array. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun Array.mapIndexed(transform: (Int, T) -> R): List { return mapIndexedTo(ArrayList(size), transform) @@ -7240,6 +7278,8 @@ public inline fun Array.mapIndexed(transform: (Int, T) -> R): List /** * Returns a list containing the results of applying the given [transform] function * to each element and its index in the original array. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun ByteArray.mapIndexed(transform: (Int, Byte) -> R): List { return mapIndexedTo(ArrayList(size), transform) @@ -7248,6 +7288,8 @@ public inline fun ByteArray.mapIndexed(transform: (Int, Byte) -> R): List /** * Returns a list containing the results of applying the given [transform] function * to each element and its index in the original array. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun ShortArray.mapIndexed(transform: (Int, Short) -> R): List { return mapIndexedTo(ArrayList(size), transform) @@ -7256,6 +7298,8 @@ public inline fun ShortArray.mapIndexed(transform: (Int, Short) -> R): List< /** * Returns a list containing the results of applying the given [transform] function * to each element and its index in the original array. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun IntArray.mapIndexed(transform: (Int, Int) -> R): List { return mapIndexedTo(ArrayList(size), transform) @@ -7264,6 +7308,8 @@ public inline fun IntArray.mapIndexed(transform: (Int, Int) -> R): List { /** * Returns a list containing the results of applying the given [transform] function * to each element and its index in the original array. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun LongArray.mapIndexed(transform: (Int, Long) -> R): List { return mapIndexedTo(ArrayList(size), transform) @@ -7272,6 +7318,8 @@ public inline fun LongArray.mapIndexed(transform: (Int, Long) -> R): List /** * Returns a list containing the results of applying the given [transform] function * to each element and its index in the original array. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun FloatArray.mapIndexed(transform: (Int, Float) -> R): List { return mapIndexedTo(ArrayList(size), transform) @@ -7280,6 +7328,8 @@ public inline fun FloatArray.mapIndexed(transform: (Int, Float) -> R): List< /** * Returns a list containing the results of applying the given [transform] function * to each element and its index in the original array. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun DoubleArray.mapIndexed(transform: (Int, Double) -> R): List { return mapIndexedTo(ArrayList(size), transform) @@ -7288,6 +7338,8 @@ public inline fun DoubleArray.mapIndexed(transform: (Int, Double) -> R): Lis /** * Returns a list containing the results of applying the given [transform] function * to each element and its index in the original array. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun BooleanArray.mapIndexed(transform: (Int, Boolean) -> R): List { return mapIndexedTo(ArrayList(size), transform) @@ -7296,6 +7348,8 @@ public inline fun BooleanArray.mapIndexed(transform: (Int, Boolean) -> R): L /** * Returns a list containing the results of applying the given [transform] function * to each element and its index in the original array. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun CharArray.mapIndexed(transform: (Int, Char) -> R): List { return mapIndexedTo(ArrayList(size), transform) @@ -7304,6 +7358,8 @@ public inline fun CharArray.mapIndexed(transform: (Int, Char) -> R): List /** * Returns a list containing only the non-null results of applying the given [transform] function * to each element and its index in the original array. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun Array.mapIndexedNotNull(transform: (Int, T) -> R?): List { return mapIndexedNotNullTo(ArrayList(), transform) @@ -7312,6 +7368,8 @@ public inline fun Array.mapIndexedNotNull(transform: (Int, T /** * Applies the given [transform] function to each element and its index in the original array * and appends only the non-null results to the given [destination]. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun > Array.mapIndexedNotNullTo(destination: C, transform: (Int, T) -> R?): C { forEachIndexed { index, element -> transform(index, element)?.let { destination.add(it) } } @@ -7321,6 +7379,8 @@ public inline fun > Array.mapInde /** * Applies the given [transform] function to each element and its index in the original array * and appends the results to the given [destination]. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun > Array.mapIndexedTo(destination: C, transform: (Int, T) -> R): C { var index = 0 @@ -7332,6 +7392,8 @@ public inline fun > Array.mapIndexedTo( /** * Applies the given [transform] function to each element and its index in the original array * and appends the results to the given [destination]. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun > ByteArray.mapIndexedTo(destination: C, transform: (Int, Byte) -> R): C { var index = 0 @@ -7343,6 +7405,8 @@ public inline fun > ByteArray.mapIndexedTo(destin /** * Applies the given [transform] function to each element and its index in the original array * and appends the results to the given [destination]. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun > ShortArray.mapIndexedTo(destination: C, transform: (Int, Short) -> R): C { var index = 0 @@ -7354,6 +7418,8 @@ public inline fun > ShortArray.mapIndexedTo(desti /** * Applies the given [transform] function to each element and its index in the original array * and appends the results to the given [destination]. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun > IntArray.mapIndexedTo(destination: C, transform: (Int, Int) -> R): C { var index = 0 @@ -7365,6 +7431,8 @@ public inline fun > IntArray.mapIndexedTo(destina /** * Applies the given [transform] function to each element and its index in the original array * and appends the results to the given [destination]. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun > LongArray.mapIndexedTo(destination: C, transform: (Int, Long) -> R): C { var index = 0 @@ -7376,6 +7444,8 @@ public inline fun > LongArray.mapIndexedTo(destin /** * Applies the given [transform] function to each element and its index in the original array * and appends the results to the given [destination]. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun > FloatArray.mapIndexedTo(destination: C, transform: (Int, Float) -> R): C { var index = 0 @@ -7387,6 +7457,8 @@ public inline fun > FloatArray.mapIndexedTo(desti /** * Applies the given [transform] function to each element and its index in the original array * and appends the results to the given [destination]. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun > DoubleArray.mapIndexedTo(destination: C, transform: (Int, Double) -> R): C { var index = 0 @@ -7398,6 +7470,8 @@ public inline fun > DoubleArray.mapIndexedTo(dest /** * Applies the given [transform] function to each element and its index in the original array * and appends the results to the given [destination]. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun > BooleanArray.mapIndexedTo(destination: C, transform: (Int, Boolean) -> R): C { var index = 0 @@ -7409,6 +7483,8 @@ public inline fun > BooleanArray.mapIndexedTo(des /** * Applies the given [transform] function to each element and its index in the original array * and appends the results to the given [destination]. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun > CharArray.mapIndexedTo(destination: C, transform: (Int, Char) -> R): C { var index = 0 @@ -8580,6 +8656,8 @@ public inline fun CharArray.fold(initial: R, operation: (R, Char) -> R): R { /** * 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. + * @param [operation] function that takes the index of an element, current accumulator value + * and the element itself, and calculates the next accumulator value. */ public inline fun Array.foldIndexed(initial: R, operation: (Int, R, T) -> R): R { var index = 0 @@ -8591,6 +8669,8 @@ public inline fun Array.foldIndexed(initial: R, operation: (Int, R /** * 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. + * @param [operation] function that takes the index of an element, current accumulator value + * and the element itself, and calculates the next accumulator value. */ public inline fun ByteArray.foldIndexed(initial: R, operation: (Int, R, Byte) -> R): R { var index = 0 @@ -8602,6 +8682,8 @@ public inline fun ByteArray.foldIndexed(initial: R, operation: (Int, R, Byte /** * 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. + * @param [operation] function that takes the index of an element, current accumulator value + * and the element itself, and calculates the next accumulator value. */ public inline fun ShortArray.foldIndexed(initial: R, operation: (Int, R, Short) -> R): R { var index = 0 @@ -8613,6 +8695,8 @@ public inline fun ShortArray.foldIndexed(initial: R, operation: (Int, R, Sho /** * 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. + * @param [operation] function that takes the index of an element, current accumulator value + * and the element itself, and calculates the next accumulator value. */ public inline fun IntArray.foldIndexed(initial: R, operation: (Int, R, Int) -> R): R { var index = 0 @@ -8624,6 +8708,8 @@ public inline fun IntArray.foldIndexed(initial: R, operation: (Int, R, 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. + * @param [operation] function that takes the index of an element, current accumulator value + * and the element itself, and calculates the next accumulator value. */ public inline fun LongArray.foldIndexed(initial: R, operation: (Int, R, Long) -> R): R { var index = 0 @@ -8635,6 +8721,8 @@ public inline fun LongArray.foldIndexed(initial: R, operation: (Int, R, Long /** * 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. + * @param [operation] function that takes the index of an element, current accumulator value + * and the element itself, and calculates the next accumulator value. */ public inline fun FloatArray.foldIndexed(initial: R, operation: (Int, R, Float) -> R): R { var index = 0 @@ -8646,6 +8734,8 @@ public inline fun FloatArray.foldIndexed(initial: R, operation: (Int, R, Flo /** * 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. + * @param [operation] function that takes the index of an element, current accumulator value + * and the element itself, and calculates the next accumulator value. */ public inline fun DoubleArray.foldIndexed(initial: R, operation: (Int, R, Double) -> R): R { var index = 0 @@ -8657,6 +8747,8 @@ public inline fun DoubleArray.foldIndexed(initial: R, operation: (Int, R, Do /** * 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. + * @param [operation] function that takes the index of an element, current accumulator value + * and the element itself, and calculates the next accumulator value. */ public inline fun BooleanArray.foldIndexed(initial: R, operation: (Int, R, Boolean) -> R): R { var index = 0 @@ -8668,6 +8760,8 @@ public inline fun BooleanArray.foldIndexed(initial: R, operation: (Int, R, B /** * 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. + * @param [operation] function that takes the index of an element, current accumulator value + * and the element itself, and calculates the next accumulator value. */ public inline fun CharArray.foldIndexed(initial: R, operation: (Int, R, Char) -> R): R { var index = 0 @@ -8787,6 +8881,8 @@ public inline fun CharArray.foldRight(initial: R, operation: (Char, R) -> R) /** * 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. + * @param [operation] function that takes the index of an element, the element itself + * and current accumulator value, and calculates the next accumulator value. */ public inline fun Array.foldRightIndexed(initial: R, operation: (Int, T, R) -> R): R { var index = lastIndex @@ -8801,6 +8897,8 @@ public inline fun Array.foldRightIndexed(initial: R, operation: (I /** * 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. + * @param [operation] function that takes the index of an element, the element itself + * and current accumulator value, and calculates the next accumulator value. */ public inline fun ByteArray.foldRightIndexed(initial: R, operation: (Int, Byte, R) -> R): R { var index = lastIndex @@ -8815,6 +8913,8 @@ public inline fun ByteArray.foldRightIndexed(initial: R, operation: (Int, By /** * 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. + * @param [operation] function that takes the index of an element, the element itself + * and current accumulator value, and calculates the next accumulator value. */ public inline fun ShortArray.foldRightIndexed(initial: R, operation: (Int, Short, R) -> R): R { var index = lastIndex @@ -8829,6 +8929,8 @@ public inline fun ShortArray.foldRightIndexed(initial: R, operation: (Int, S /** * 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. + * @param [operation] function that takes the index of an element, the element itself + * and current accumulator value, and calculates the next accumulator value. */ public inline fun IntArray.foldRightIndexed(initial: R, operation: (Int, Int, R) -> R): R { var index = lastIndex @@ -8843,6 +8945,8 @@ public inline fun IntArray.foldRightIndexed(initial: R, operation: (Int, Int /** * 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. + * @param [operation] function that takes the index of an element, the element itself + * and current accumulator value, and calculates the next accumulator value. */ public inline fun LongArray.foldRightIndexed(initial: R, operation: (Int, Long, R) -> R): R { var index = lastIndex @@ -8857,6 +8961,8 @@ public inline fun LongArray.foldRightIndexed(initial: R, operation: (Int, Lo /** * 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. + * @param [operation] function that takes the index of an element, the element itself + * and current accumulator value, and calculates the next accumulator value. */ public inline fun FloatArray.foldRightIndexed(initial: R, operation: (Int, Float, R) -> R): R { var index = lastIndex @@ -8871,6 +8977,8 @@ public inline fun FloatArray.foldRightIndexed(initial: R, operation: (Int, F /** * 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. + * @param [operation] function that takes the index of an element, the element itself + * and current accumulator value, and calculates the next accumulator value. */ public inline fun DoubleArray.foldRightIndexed(initial: R, operation: (Int, Double, R) -> R): R { var index = lastIndex @@ -8885,6 +8993,8 @@ public inline fun DoubleArray.foldRightIndexed(initial: R, operation: (Int, /** * 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. + * @param [operation] function that takes the index of an element, the element itself + * and current accumulator value, and calculates the next accumulator value. */ public inline fun BooleanArray.foldRightIndexed(initial: R, operation: (Int, Boolean, R) -> R): R { var index = lastIndex @@ -8899,6 +9009,8 @@ public inline fun BooleanArray.foldRightIndexed(initial: R, operation: (Int, /** * 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. + * @param [operation] function that takes the index of an element, the element itself + * and current accumulator value, and calculates the next accumulator value. */ public inline fun CharArray.foldRightIndexed(initial: R, operation: (Int, Char, R) -> R): R { var index = lastIndex @@ -8975,6 +9087,8 @@ public inline fun CharArray.forEach(action: (Char) -> Unit): Unit { /** * Performs the given [action] on each element, providing sequential index with the element. + * @param [action] function that takes the index of an element and the element itself + * and performs the desired action on the element. */ public inline fun Array.forEachIndexed(action: (Int, T) -> Unit): Unit { var index = 0 @@ -8983,6 +9097,8 @@ public inline fun Array.forEachIndexed(action: (Int, T) -> Unit): Uni /** * Performs the given [action] on each element, providing sequential index with the element. + * @param [action] function that takes the index of an element and the element itself + * and performs the desired action on the element. */ public inline fun ByteArray.forEachIndexed(action: (Int, Byte) -> Unit): Unit { var index = 0 @@ -8991,6 +9107,8 @@ public inline fun ByteArray.forEachIndexed(action: (Int, Byte) -> Unit): Unit { /** * Performs the given [action] on each element, providing sequential index with the element. + * @param [action] function that takes the index of an element and the element itself + * and performs the desired action on the element. */ public inline fun ShortArray.forEachIndexed(action: (Int, Short) -> Unit): Unit { var index = 0 @@ -8999,6 +9117,8 @@ public inline fun ShortArray.forEachIndexed(action: (Int, Short) -> Unit): Unit /** * Performs the given [action] on each element, providing sequential index with the element. + * @param [action] function that takes the index of an element and the element itself + * and performs the desired action on the element. */ public inline fun IntArray.forEachIndexed(action: (Int, Int) -> Unit): Unit { var index = 0 @@ -9007,6 +9127,8 @@ public inline fun IntArray.forEachIndexed(action: (Int, Int) -> Unit): Unit { /** * Performs the given [action] on each element, providing sequential index with the element. + * @param [action] function that takes the index of an element and the element itself + * and performs the desired action on the element. */ public inline fun LongArray.forEachIndexed(action: (Int, Long) -> Unit): Unit { var index = 0 @@ -9015,6 +9137,8 @@ public inline fun LongArray.forEachIndexed(action: (Int, Long) -> Unit): Unit { /** * Performs the given [action] on each element, providing sequential index with the element. + * @param [action] function that takes the index of an element and the element itself + * and performs the desired action on the element. */ public inline fun FloatArray.forEachIndexed(action: (Int, Float) -> Unit): Unit { var index = 0 @@ -9023,6 +9147,8 @@ public inline fun FloatArray.forEachIndexed(action: (Int, Float) -> Unit): Unit /** * Performs the given [action] on each element, providing sequential index with the element. + * @param [action] function that takes the index of an element and the element itself + * and performs the desired action on the element. */ public inline fun DoubleArray.forEachIndexed(action: (Int, Double) -> Unit): Unit { var index = 0 @@ -9031,6 +9157,8 @@ public inline fun DoubleArray.forEachIndexed(action: (Int, Double) -> Unit): Uni /** * Performs the given [action] on each element, providing sequential index with the element. + * @param [action] function that takes the index of an element and the element itself + * and performs the desired action on the element. */ public inline fun BooleanArray.forEachIndexed(action: (Int, Boolean) -> Unit): Unit { var index = 0 @@ -9039,6 +9167,8 @@ public inline fun BooleanArray.forEachIndexed(action: (Int, Boolean) -> Unit): U /** * Performs the given [action] on each element, providing sequential index with the element. + * @param [action] function that takes the index of an element and the element itself + * and performs the desired action on the element. */ public inline fun CharArray.forEachIndexed(action: (Int, Char) -> Unit): Unit { var index = 0 @@ -10075,6 +10205,8 @@ public inline fun CharArray.reduce(operation: (Char, Char) -> Char): Char { /** * 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. */ public inline fun Array.reduceIndexed(operation: (Int, S, T) -> S): S { if (isEmpty()) @@ -10089,6 +10221,8 @@ public inline fun Array.reduceIndexed(operation: (Int, S, T) -> /** * 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. */ public inline fun ByteArray.reduceIndexed(operation: (Int, Byte, Byte) -> Byte): Byte { if (isEmpty()) @@ -10103,6 +10237,8 @@ public inline fun ByteArray.reduceIndexed(operation: (Int, Byte, Byte) -> Byte): /** * 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. */ public inline fun ShortArray.reduceIndexed(operation: (Int, Short, Short) -> Short): Short { if (isEmpty()) @@ -10117,6 +10253,8 @@ public inline fun ShortArray.reduceIndexed(operation: (Int, Short, Short) -> Sho /** * 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. */ public inline fun IntArray.reduceIndexed(operation: (Int, Int, Int) -> Int): Int { if (isEmpty()) @@ -10131,6 +10269,8 @@ public inline fun IntArray.reduceIndexed(operation: (Int, Int, Int) -> Int): Int /** * 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. */ public inline fun LongArray.reduceIndexed(operation: (Int, Long, Long) -> Long): Long { if (isEmpty()) @@ -10145,6 +10285,8 @@ public inline fun LongArray.reduceIndexed(operation: (Int, Long, Long) -> Long): /** * 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. */ public inline fun FloatArray.reduceIndexed(operation: (Int, Float, Float) -> Float): Float { if (isEmpty()) @@ -10159,6 +10301,8 @@ public inline fun FloatArray.reduceIndexed(operation: (Int, Float, Float) -> Flo /** * 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. */ public inline fun DoubleArray.reduceIndexed(operation: (Int, Double, Double) -> Double): Double { if (isEmpty()) @@ -10173,6 +10317,8 @@ public inline fun DoubleArray.reduceIndexed(operation: (Int, Double, Double) -> /** * 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. */ public inline fun BooleanArray.reduceIndexed(operation: (Int, Boolean, Boolean) -> Boolean): Boolean { if (isEmpty()) @@ -10187,6 +10333,8 @@ public inline fun BooleanArray.reduceIndexed(operation: (Int, Boolean, Boolean) /** * 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. */ public inline fun CharArray.reduceIndexed(operation: (Int, Char, Char) -> Char): Char { if (isEmpty()) @@ -10318,6 +10466,8 @@ public inline fun CharArray.reduceRight(operation: (Char, Char) -> Char): Char { /** * Accumulates value starting with 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. */ public inline fun Array.reduceRightIndexed(operation: (Int, T, S) -> S): S { var index = lastIndex @@ -10333,6 +10483,8 @@ public inline fun Array.reduceRightIndexed(operation: (Int, T, /** * Accumulates value starting with 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. */ public inline fun ByteArray.reduceRightIndexed(operation: (Int, Byte, Byte) -> Byte): Byte { var index = lastIndex @@ -10348,6 +10500,8 @@ public inline fun ByteArray.reduceRightIndexed(operation: (Int, Byte, Byte) -> B /** * Accumulates value starting with 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. */ public inline fun ShortArray.reduceRightIndexed(operation: (Int, Short, Short) -> Short): Short { var index = lastIndex @@ -10363,6 +10517,8 @@ public inline fun ShortArray.reduceRightIndexed(operation: (Int, Short, Short) - /** * Accumulates value starting with 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. */ public inline fun IntArray.reduceRightIndexed(operation: (Int, Int, Int) -> Int): Int { var index = lastIndex @@ -10378,6 +10534,8 @@ public inline fun IntArray.reduceRightIndexed(operation: (Int, Int, Int) -> Int) /** * Accumulates value starting with 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. */ public inline fun LongArray.reduceRightIndexed(operation: (Int, Long, Long) -> Long): Long { var index = lastIndex @@ -10393,6 +10551,8 @@ public inline fun LongArray.reduceRightIndexed(operation: (Int, Long, Long) -> L /** * Accumulates value starting with 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. */ public inline fun FloatArray.reduceRightIndexed(operation: (Int, Float, Float) -> Float): Float { var index = lastIndex @@ -10408,6 +10568,8 @@ public inline fun FloatArray.reduceRightIndexed(operation: (Int, Float, Float) - /** * Accumulates value starting with 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. */ public inline fun DoubleArray.reduceRightIndexed(operation: (Int, Double, Double) -> Double): Double { var index = lastIndex @@ -10423,6 +10585,8 @@ public inline fun DoubleArray.reduceRightIndexed(operation: (Int, Double, Double /** * Accumulates value starting with 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. */ public inline fun BooleanArray.reduceRightIndexed(operation: (Int, Boolean, Boolean) -> Boolean): Boolean { var index = lastIndex @@ -10438,6 +10602,8 @@ public inline fun BooleanArray.reduceRightIndexed(operation: (Int, Boolean, Bool /** * Accumulates value starting with 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. */ public inline fun CharArray.reduceRightIndexed(operation: (Int, Char, Char) -> Char): Char { var index = lastIndex diff --git a/libraries/stdlib/src/generated/_Collections.kt b/libraries/stdlib/src/generated/_Collections.kt index 9931f24d5eb..a9cf105f2cb 100644 --- a/libraries/stdlib/src/generated/_Collections.kt +++ b/libraries/stdlib/src/generated/_Collections.kt @@ -621,6 +621,8 @@ public inline fun Iterable.filter(predicate: (T) -> Boolean): List { /** * Returns a list containing only elements matching the given [predicate]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun Iterable.filterIndexed(predicate: (Int, T) -> Boolean): List { return filterIndexedTo(ArrayList(), predicate) @@ -628,6 +630,8 @@ public inline fun Iterable.filterIndexed(predicate: (Int, T) -> Boolean): /** * Appends all elements matching the given [predicate] to the given [destination]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun > Iterable.filterIndexedTo(destination: C, predicate: (Int, T) -> Boolean): C { forEachIndexed { index, element -> @@ -1133,6 +1137,8 @@ public inline fun Iterable.map(transform: (T) -> R): List { /** * Returns a list containing the results of applying the given [transform] function * to each element and its index in the original collection. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE") public inline fun Iterable.mapIndexed(transform: (Int, T) -> R): List { @@ -1142,6 +1148,8 @@ public inline fun Iterable.mapIndexed(transform: (Int, T) -> R): List< /** * Returns a list containing only the non-null results of applying the given [transform] function * to each element and its index in the original collection. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun Iterable.mapIndexedNotNull(transform: (Int, T) -> R?): List { return mapIndexedNotNullTo(ArrayList(), transform) @@ -1150,6 +1158,8 @@ public inline fun Iterable.mapIndexedNotNull(transform: (Int, T) /** * Applies the given [transform] function to each element and its index in the original collection * and appends only the non-null results to the given [destination]. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun > Iterable.mapIndexedNotNullTo(destination: C, transform: (Int, T) -> R?): C { forEachIndexed { index, element -> transform(index, element)?.let { destination.add(it) } } @@ -1159,6 +1169,8 @@ public inline fun > Iterable.mapIndex /** * Applies the given [transform] function to each element and its index in the original collection * and appends the results to the given [destination]. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun > Iterable.mapIndexedTo(destination: C, transform: (Int, T) -> R): C { var index = 0 @@ -1324,6 +1336,8 @@ public inline fun Iterable.fold(initial: R, operation: (R, T) -> R): R /** * 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. + * @param [operation] function that takes the index of an element, current accumulator value + * and the element itself, and calculates the next accumulator value. */ public inline fun Iterable.foldIndexed(initial: R, operation: (Int, R, T) -> R): R { var index = 0 @@ -1347,6 +1361,8 @@ public inline fun List.foldRight(initial: R, operation: (T, R) -> 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. + * @param [operation] function that takes the index of an element, the element itself + * and current accumulator value, and calculates the next accumulator value. */ public inline fun List.foldRightIndexed(initial: R, operation: (Int, T, R) -> R): R { var index = lastIndex @@ -1368,6 +1384,8 @@ public inline fun Iterable.forEach(action: (T) -> Unit): Unit { /** * Performs the given [action] on each element, providing sequential index with the element. + * @param [action] function that takes the index of an element and the element itself + * and performs the desired action on the element. */ public inline fun Iterable.forEachIndexed(action: (Int, T) -> Unit): Unit { var index = 0 @@ -1500,6 +1518,8 @@ public inline fun Iterable.reduce(operation: (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. */ public inline fun Iterable.reduceIndexed(operation: (Int, S, T) -> S): S { val iterator = this.iterator() @@ -1528,6 +1548,8 @@ public inline fun List.reduceRight(operation: (T, S) -> S): S { /** * Accumulates value starting with 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. */ public inline fun List.reduceRightIndexed(operation: (Int, T, S) -> S): S { var index = lastIndex diff --git a/libraries/stdlib/src/generated/_Sequences.kt b/libraries/stdlib/src/generated/_Sequences.kt index 59e3df6666b..1c1c0e7dee4 100644 --- a/libraries/stdlib/src/generated/_Sequences.kt +++ b/libraries/stdlib/src/generated/_Sequences.kt @@ -312,6 +312,8 @@ public fun Sequence.filter(predicate: (T) -> Boolean): Sequence { /** * Returns a sequence containing only elements matching the given [predicate]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public fun Sequence.filterIndexed(predicate: (Int, T) -> Boolean): Sequence { // TODO: Rewrite with generalized MapFilterIndexingSequence @@ -320,6 +322,8 @@ public fun Sequence.filterIndexed(predicate: (Int, T) -> Boolean): Sequen /** * Appends all elements matching the given [predicate] to the given [destination]. + * @param [predicate] function that takes the index of an element and the element itself + * and returns the result of predicate evaluation on the element. */ public inline fun > Sequence.filterIndexedTo(destination: C, predicate: (Int, T) -> Boolean): C { forEachIndexed { index, element -> @@ -629,6 +633,8 @@ public fun Sequence.map(transform: (T) -> R): Sequence { /** * Returns a sequence containing the results of applying the given [transform] function * to each element and its index in the original sequence. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public fun Sequence.mapIndexed(transform: (Int, T) -> R): Sequence { return TransformingIndexedSequence(this, transform) @@ -637,6 +643,8 @@ public fun Sequence.mapIndexed(transform: (Int, T) -> R): Sequence /** * Returns a sequence containing only the non-null results of applying the given [transform] function * to each element and its index in the original sequence. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public fun Sequence.mapIndexedNotNull(transform: (Int, T) -> R?): Sequence { return TransformingIndexedSequence(this, transform).filterNotNull() @@ -645,6 +653,8 @@ public fun Sequence.mapIndexedNotNull(transform: (Int, T) -> R?) /** * Applies the given [transform] function to each element and its index in the original sequence * and appends only the non-null results to the given [destination]. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun > Sequence.mapIndexedNotNullTo(destination: C, transform: (Int, T) -> R?): C { forEachIndexed { index, element -> transform(index, element)?.let { destination.add(it) } } @@ -654,6 +664,8 @@ public inline fun > Sequence.mapIndex /** * Applies the given [transform] function to each element and its index in the original sequence * and appends the results to the given [destination]. + * @param [transform] function that takes the index of an element and the element itself + * and returns the result of the transform applied to the element. */ public inline fun > Sequence.mapIndexedTo(destination: C, transform: (Int, T) -> R): C { var index = 0 @@ -776,6 +788,8 @@ public inline fun Sequence.fold(initial: R, operation: (R, T) -> R): R /** * 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. + * @param [operation] function that takes the index of an element, current accumulator value + * and the element itself, and calculates the next accumulator value. */ public inline fun Sequence.foldIndexed(initial: R, operation: (Int, R, T) -> R): R { var index = 0 @@ -793,6 +807,8 @@ public inline fun Sequence.forEach(action: (T) -> Unit): Unit { /** * Performs the given [action] on each element, providing sequential index with the element. + * @param [action] function that takes the index of an element and the element itself + * and performs the desired action on the element. */ public inline fun Sequence.forEachIndexed(action: (Int, T) -> Unit): Unit { var index = 0 @@ -925,6 +941,8 @@ public inline fun Sequence.reduce(operation: (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. */ public inline fun Sequence.reduceIndexed(operation: (Int, S, T) -> S): S { val iterator = this.iterator() diff --git a/libraries/stdlib/src/generated/_Strings.kt b/libraries/stdlib/src/generated/_Strings.kt index 1a3c469e313..b4c0f1f1e77 100644 --- a/libraries/stdlib/src/generated/_Strings.kt +++ b/libraries/stdlib/src/generated/_Strings.kt @@ -306,6 +306,8 @@ public inline fun String.filter(predicate: (Char) -> Boolean): String { /** * Returns a char sequence containing only those characters from the original char sequence that match the given [predicate]. + * @param [predicate] function that takes the index of a character and the character itself + * and returns the result of predicate evaluation on the character. */ public inline fun CharSequence.filterIndexed(predicate: (Int, Char) -> Boolean): CharSequence { return filterIndexedTo(StringBuilder(), predicate) @@ -313,6 +315,8 @@ public inline fun CharSequence.filterIndexed(predicate: (Int, Char) -> Boolean): /** * Returns a string containing only those characters from the original string that match the given [predicate]. + * @param [predicate] function that takes the index of a character and the character itself + * and returns the result of predicate evaluation on the character. */ public inline fun String.filterIndexed(predicate: (Int, Char) -> Boolean): String { return filterIndexedTo(StringBuilder(), predicate).toString() @@ -320,6 +324,8 @@ public inline fun String.filterIndexed(predicate: (Int, Char) -> Boolean): Strin /** * Appends all characters matching the given [predicate] to the given [destination]. + * @param [predicate] function that takes the index of a character and the character itself + * and returns the result of predicate evaluation on the character. */ public inline fun CharSequence.filterIndexedTo(destination: C, predicate: (Int, Char) -> Boolean): C { forEachIndexed { index, element -> @@ -687,6 +693,8 @@ public inline fun CharSequence.map(transform: (Char) -> R): List { /** * Returns a list containing the results of applying the given [transform] function * to each character and its index in the original char sequence. + * @param [transform] function that takes the index of a character and the character itself + * and returns the result of the transform applied to the character. */ public inline fun CharSequence.mapIndexed(transform: (Int, Char) -> R): List { return mapIndexedTo(ArrayList(length), transform) @@ -695,6 +703,8 @@ public inline fun CharSequence.mapIndexed(transform: (Int, Char) -> R): List /** * Returns a list containing only the non-null results of applying the given [transform] function * to each character and its index in the original char sequence. + * @param [transform] function that takes the index of a character and the character itself + * and returns the result of the transform applied to the character. */ public inline fun CharSequence.mapIndexedNotNull(transform: (Int, Char) -> R?): List { return mapIndexedNotNullTo(ArrayList(), transform) @@ -703,6 +713,8 @@ public inline fun CharSequence.mapIndexedNotNull(transform: (Int, Char /** * Applies the given [transform] function to each character and its index in the original char sequence * and appends only the non-null results to the given [destination]. + * @param [transform] function that takes the index of a character and the character itself + * and returns the result of the transform applied to the character. */ public inline fun > CharSequence.mapIndexedNotNullTo(destination: C, transform: (Int, Char) -> R?): C { forEachIndexed { index, element -> transform(index, element)?.let { destination.add(it) } } @@ -712,6 +724,8 @@ public inline fun > CharSequence.mapIndexed /** * Applies the given [transform] function to each character and its index in the original char sequence * and appends the results to the given [destination]. + * @param [transform] function that takes the index of a character and the character itself + * and returns the result of the transform applied to the character. */ public inline fun > CharSequence.mapIndexedTo(destination: C, transform: (Int, Char) -> R): C { var index = 0 @@ -807,6 +821,8 @@ public inline fun CharSequence.fold(initial: R, operation: (R, Char) -> R): /** * 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. + * @param [operation] function that takes the index of a character, current accumulator value + * and the character itself, and calculates the next accumulator value. */ public inline fun CharSequence.foldIndexed(initial: R, operation: (Int, R, Char) -> R): R { var index = 0 @@ -830,6 +846,8 @@ public inline fun CharSequence.foldRight(initial: R, operation: (Char, R) -> /** * 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. + * @param [operation] function that takes the index of a character, the character itself + * and current accumulator value, and calculates the next accumulator value. */ public inline fun CharSequence.foldRightIndexed(initial: R, operation: (Int, Char, R) -> R): R { var index = lastIndex @@ -850,6 +868,8 @@ public inline fun CharSequence.forEach(action: (Char) -> Unit): Unit { /** * Performs the given [action] on each character, providing sequential index with the character. + * @param [action] function that takes the index of a character and the character itself + * and performs the desired action on the character. */ public inline fun CharSequence.forEachIndexed(action: (Int, Char) -> Unit): Unit { var index = 0 @@ -976,6 +996,8 @@ public inline fun CharSequence.reduce(operation: (Char, Char) -> Char): 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. + * @param [operation] function that takes the index of a character, current accumulator value + * and the character itself and calculates the next accumulator value. */ public inline fun CharSequence.reduceIndexed(operation: (Int, Char, Char) -> Char): Char { if (isEmpty()) @@ -1003,6 +1025,8 @@ public inline fun CharSequence.reduceRight(operation: (Char, Char) -> Char): Cha /** * Accumulates value starting with 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. */ public inline fun CharSequence.reduceRightIndexed(operation: (Int, Char, Char) -> Char): Char { var index = lastIndex diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt index f439631cbdc..c93af808dd9 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt @@ -360,6 +360,8 @@ fun aggregates(): List { """ Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each ${f.element} with its index in the original ${f.collection}. + @param [operation] function that takes the index of ${f.element.prefixWithArticle()}, current accumulator value + and the ${f.element} itself, and calculates the next accumulator value. """ } typeParam("R") @@ -382,6 +384,8 @@ fun aggregates(): List { """ Accumulates value starting with [initial] value and applying [operation] from right to left to each ${f.element} with its index in the original ${f.collection} and current accumulator value. + @param [operation] function that takes the index of ${f.element.prefixWithArticle()}, the ${f.element} itself + and current accumulator value, and calculates the next accumulator value. """ } typeParam("R") @@ -442,6 +446,8 @@ fun aggregates(): List { """ Accumulates value starting with the first ${f.element} and applying [operation] from left to right to current accumulator value and each ${f.element} with its index in the original ${f.collection}. + @param [operation] function that takes the index of ${f.element.prefixWithArticle()}, current accumulator value + and the ${f.element} itself and calculates the next accumulator value. """ } returns("T") @@ -467,6 +473,8 @@ fun aggregates(): List { """ Accumulates value starting with the first ${f.element} and applying [operation] from left to right to current accumulator value and each ${f.element} with its index in the original ${f.collection}. + @param [operation] function that takes the index of ${f.element.prefixWithArticle()}, current accumulator value + and the ${f.element} itself and calculates the next accumulator value. """ } typeParam("S") @@ -507,6 +515,8 @@ fun aggregates(): List { """ Accumulates value starting with last ${f.element} and applying [operation] from right to left to each ${f.element} with its index in the original ${f.collection} and current accumulator value. + @param [operation] function that takes the index of ${f.element.prefixWithArticle()}, the ${f.element} itself + and current accumulator value, and calculates the next accumulator value. """ } returns("T") @@ -534,6 +544,8 @@ fun aggregates(): List { """ Accumulates value starting with last ${f.element} and applying [operation] from right to left to each ${f.element} with its index in the original ${f.collection} and current accumulator value. + @param [operation] function that takes the index of ${f.element.prefixWithArticle()}, the ${f.element} itself + and current accumulator value, and calculates the next accumulator value. """ } typeParam("S") @@ -670,7 +682,12 @@ fun aggregates(): List { templates add f("forEachIndexed(action: (Int, T) -> Unit)") { inline(true) include(CharSequences) - doc { f -> "Performs the given [action] on each ${f.element}, providing sequential index with the ${f.element}." } + doc { f -> + """ + Performs the given [action] on each ${f.element}, providing sequential index with the ${f.element}. + @param [action] function that takes the index of ${f.element.prefixWithArticle()} and the ${f.element} itself + and performs the desired action on the ${f.element}. + """ } returns("Unit") body { """ diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt index 25e5e57670d..abffa760adb 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt @@ -406,7 +406,13 @@ fun filtering(): List { templates add f("filterIndexed(predicate: (Int, T) -> Boolean)") { inline(true) - doc { f -> "Returns a ${f.mapResult} containing only ${f.element.pluralize()} matching the given [predicate]." } + doc { f -> + """ + Returns a ${f.mapResult} containing only ${f.element.pluralize()} matching the given [predicate]. + @param [predicate] function that takes the index of ${f.element.prefixWithArticle()} and the ${f.element} itself + and returns the result of predicate evaluation on the ${f.element}. + """ + } returns("List") body { """ @@ -414,7 +420,13 @@ fun filtering(): List { """ } - doc(CharSequences, Strings) { f -> "Returns a ${f.collection} containing only those characters from the original ${f.collection} that match the given [predicate]." } + doc(CharSequences, Strings) { f -> + """ + Returns a ${f.collection} containing only those characters from the original ${f.collection} that match the given [predicate]. + @param [predicate] function that takes the index of ${f.element.prefixWithArticle()} and the ${f.element} itself + and returns the result of predicate evaluation on the ${f.element}. + """ + } returns(CharSequences, Strings) { "SELF" } body(CharSequences, Strings) { f -> """return filterIndexedTo(StringBuilder(), predicate)${toResult(f)}""" } @@ -434,7 +446,12 @@ fun filtering(): List { include(CharSequences) - doc { f -> "Appends all ${f.element.pluralize()} matching the given [predicate] to the given [destination]." } + doc { f -> + """ + Appends all ${f.element.pluralize()} matching the given [predicate] to the given [destination]. + @param [predicate] function that takes the index of ${f.element.prefixWithArticle()} and the ${f.element} itself + and returns the result of predicate evaluation on the ${f.element}. + """ } typeParam("C : TCollection") returns("C") diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt index e009f7a1191..7977992e8e2 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt @@ -30,6 +30,8 @@ fun mapping(): List { """ Returns a ${f.mapResult} containing the results of applying the given [transform] function to each ${f.element} and its index in the original ${f.collection}. + @param [transform] function that takes the index of ${f.element.prefixWithArticle()} and the ${f.element} itself + and returns the result of the transform applied to the ${f.element}. """ } typeParam("R") @@ -115,6 +117,8 @@ fun mapping(): List { """ Returns a ${f.mapResult} containing only the non-null results of applying the given [transform] function to each ${f.element} and its index in the original ${f.collection}. + @param [transform] function that takes the index of ${f.element.prefixWithArticle()} and the ${f.element} itself + and returns the result of the transform applied to the ${f.element}. """ } body { @@ -158,6 +162,8 @@ fun mapping(): List { """ Applies the given [transform] function to each ${f.element} and its index in the original ${f.collection} and appends the results to the given [destination]. + @param [transform] function that takes the index of ${f.element.prefixWithArticle()} and the ${f.element} itself + and returns the result of the transform applied to the ${f.element}. """ } typeParam("R") @@ -207,6 +213,8 @@ fun mapping(): List { """ Applies the given [transform] function to each ${f.element} and its index in the original ${f.collection} and appends only the non-null results to the given [destination]. + @param [transform] function that takes the index of ${f.element.prefixWithArticle()} and the ${f.element} itself + and returns the result of the transform applied to the ${f.element}. """ } body {