diff --git a/libraries/stdlib/common/src/generated/_Arrays.kt b/libraries/stdlib/common/src/generated/_Arrays.kt index 1830c89b596..2aae07f587d 100644 --- a/libraries/stdlib/common/src/generated/_Arrays.kt +++ b/libraries/stdlib/common/src/generated/_Arrays.kt @@ -9304,63 +9304,72 @@ public inline fun > CharArray.mapTo(destination: } /** - * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. + * Returns a lazy [Iterable] that wraps each element of the original array + * into an [IndexedValue] containing the index of that element and the element itself. */ public fun Array.withIndex(): Iterable> { return IndexingIterable { iterator() } } /** - * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. + * Returns a lazy [Iterable] that wraps each element of the original array + * into an [IndexedValue] containing the index of that element and the element itself. */ public fun ByteArray.withIndex(): Iterable> { return IndexingIterable { iterator() } } /** - * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. + * Returns a lazy [Iterable] that wraps each element of the original array + * into an [IndexedValue] containing the index of that element and the element itself. */ public fun ShortArray.withIndex(): Iterable> { return IndexingIterable { iterator() } } /** - * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. + * Returns a lazy [Iterable] that wraps each element of the original array + * into an [IndexedValue] containing the index of that element and the element itself. */ public fun IntArray.withIndex(): Iterable> { return IndexingIterable { iterator() } } /** - * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. + * Returns a lazy [Iterable] that wraps each element of the original array + * into an [IndexedValue] containing the index of that element and the element itself. */ public fun LongArray.withIndex(): Iterable> { return IndexingIterable { iterator() } } /** - * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. + * Returns a lazy [Iterable] that wraps each element of the original array + * into an [IndexedValue] containing the index of that element and the element itself. */ public fun FloatArray.withIndex(): Iterable> { return IndexingIterable { iterator() } } /** - * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. + * Returns a lazy [Iterable] that wraps each element of the original array + * into an [IndexedValue] containing the index of that element and the element itself. */ public fun DoubleArray.withIndex(): Iterable> { return IndexingIterable { iterator() } } /** - * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. + * Returns a lazy [Iterable] that wraps each element of the original array + * into an [IndexedValue] containing the index of that element and the element itself. */ public fun BooleanArray.withIndex(): Iterable> { return IndexingIterable { iterator() } } /** - * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. + * Returns a lazy [Iterable] that wraps each element of the original array + * into an [IndexedValue] containing the index of that element and the element itself. */ public fun CharArray.withIndex(): Iterable> { return IndexingIterable { iterator() } diff --git a/libraries/stdlib/common/src/generated/_Collections.kt b/libraries/stdlib/common/src/generated/_Collections.kt index f0e538723c7..a555bd6637a 100644 --- a/libraries/stdlib/common/src/generated/_Collections.kt +++ b/libraries/stdlib/common/src/generated/_Collections.kt @@ -1385,7 +1385,8 @@ public inline fun > Iterable.mapTo(destinat } /** - * Returns a lazy [Iterable] of [IndexedValue] for each element of the original collection. + * Returns a lazy [Iterable] that wraps each element of the original collection + * into an [IndexedValue] containing the index of that element and the element itself. */ public fun Iterable.withIndex(): Iterable> { return IndexingIterable { iterator() } diff --git a/libraries/stdlib/common/src/generated/_Sequences.kt b/libraries/stdlib/common/src/generated/_Sequences.kt index 310780c11a4..32f7ee41ff8 100644 --- a/libraries/stdlib/common/src/generated/_Sequences.kt +++ b/libraries/stdlib/common/src/generated/_Sequences.kt @@ -947,7 +947,8 @@ public inline fun > Sequence.mapTo(destinat } /** - * Returns a sequence of [IndexedValue] for each element of the original sequence. + * Returns a sequence that wraps each element of the original sequence + * into an [IndexedValue] containing the index of that element and the element itself. * * The operation is _intermediate_ and _stateless_. */ diff --git a/libraries/stdlib/common/src/generated/_Strings.kt b/libraries/stdlib/common/src/generated/_Strings.kt index 683878bd918..58462562c64 100644 --- a/libraries/stdlib/common/src/generated/_Strings.kt +++ b/libraries/stdlib/common/src/generated/_Strings.kt @@ -907,7 +907,8 @@ public inline fun > CharSequence.mapTo(destinatio } /** - * Returns a lazy [Iterable] of [IndexedValue] for each character of the original char sequence. + * Returns a lazy [Iterable] that wraps each character of the original char sequence + * into an [IndexedValue] containing the index of that character and the character itself. */ public fun CharSequence.withIndex(): Iterable> { return IndexingIterable { iterator() } diff --git a/libraries/stdlib/common/src/generated/_UArrays.kt b/libraries/stdlib/common/src/generated/_UArrays.kt index f20664f407a..d18f9bf4c60 100644 --- a/libraries/stdlib/common/src/generated/_UArrays.kt +++ b/libraries/stdlib/common/src/generated/_UArrays.kt @@ -4291,7 +4291,8 @@ public inline fun > UShortArray.mapTo(destination } /** - * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. + * Returns a lazy [Iterable] that wraps each element of the original array + * into an [IndexedValue] containing the index of that element and the element itself. */ @SinceKotlin("1.3") @ExperimentalUnsignedTypes @@ -4300,7 +4301,8 @@ public fun UIntArray.withIndex(): Iterable> { } /** - * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. + * Returns a lazy [Iterable] that wraps each element of the original array + * into an [IndexedValue] containing the index of that element and the element itself. */ @SinceKotlin("1.3") @ExperimentalUnsignedTypes @@ -4309,7 +4311,8 @@ public fun ULongArray.withIndex(): Iterable> { } /** - * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. + * Returns a lazy [Iterable] that wraps each element of the original array + * into an [IndexedValue] containing the index of that element and the element itself. */ @SinceKotlin("1.3") @ExperimentalUnsignedTypes @@ -4318,7 +4321,8 @@ public fun UByteArray.withIndex(): Iterable> { } /** - * Returns a lazy [Iterable] of [IndexedValue] for each element of the original array. + * Returns a lazy [Iterable] that wraps each element of the original array + * into an [IndexedValue] containing the index of that element and the element itself. */ @SinceKotlin("1.3") @ExperimentalUnsignedTypes diff --git a/libraries/stdlib/src/kotlin/collections/Iterators.kt b/libraries/stdlib/src/kotlin/collections/Iterators.kt index 528344596d8..3f6deb54178 100644 --- a/libraries/stdlib/src/kotlin/collections/Iterators.kt +++ b/libraries/stdlib/src/kotlin/collections/Iterators.kt @@ -17,8 +17,9 @@ package kotlin.collections public inline operator fun Iterator.iterator(): Iterator = this /** - * Returns an [Iterator] wrapping each value produced by this [Iterator] with the [IndexedValue], - * containing value and it's index. + * Returns an [Iterator] that wraps each element produced by the original iterator + * into an [IndexedValue] containing the index of that element and the element itself. + * * @sample samples.collections.Iterators.withIndexIterator */ public fun Iterator.withIndex(): Iterator> = IndexingIterator(this) diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt index 64d53433602..e74e70719c5 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt @@ -31,7 +31,10 @@ object Mapping : TemplateGroupBase() { include(CharSequences, ArraysOfUnsigned) } builder { doc { - "Returns a ${if (f == Sequences) f.mapResult else "lazy [Iterable]"} of [IndexedValue] for each ${f.element} of the original ${f.collection}." + """ + Returns a ${if (f == Sequences) f.mapResult else "lazy [Iterable]"} that wraps each ${f.element} of the original ${f.collection} + into an [IndexedValue] containing the index of that ${f.element} and the ${f.element} itself. + """ } returns("Iterable>") body {