Unify withIndex docs wording

This commit is contained in:
Ilya Gorbunov
2019-07-30 22:58:08 +03:00
parent 2e445ebad6
commit 65b0a5f903
7 changed files with 39 additions and 19 deletions
@@ -9304,63 +9304,72 @@ public inline fun <R, C : MutableCollection<in R>> 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 <T> Array<out T>.withIndex(): Iterable<IndexedValue<T>> { public fun <T> Array<out T>.withIndex(): Iterable<IndexedValue<T>> {
return IndexingIterable { iterator() } 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<IndexedValue<Byte>> { public fun ByteArray.withIndex(): Iterable<IndexedValue<Byte>> {
return IndexingIterable { iterator() } 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<IndexedValue<Short>> { public fun ShortArray.withIndex(): Iterable<IndexedValue<Short>> {
return IndexingIterable { iterator() } 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<IndexedValue<Int>> { public fun IntArray.withIndex(): Iterable<IndexedValue<Int>> {
return IndexingIterable { iterator() } 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<IndexedValue<Long>> { public fun LongArray.withIndex(): Iterable<IndexedValue<Long>> {
return IndexingIterable { iterator() } 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<IndexedValue<Float>> { public fun FloatArray.withIndex(): Iterable<IndexedValue<Float>> {
return IndexingIterable { iterator() } 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<IndexedValue<Double>> { public fun DoubleArray.withIndex(): Iterable<IndexedValue<Double>> {
return IndexingIterable { iterator() } 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<IndexedValue<Boolean>> { public fun BooleanArray.withIndex(): Iterable<IndexedValue<Boolean>> {
return IndexingIterable { iterator() } 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<IndexedValue<Char>> { public fun CharArray.withIndex(): Iterable<IndexedValue<Char>> {
return IndexingIterable { iterator() } return IndexingIterable { iterator() }
@@ -1385,7 +1385,8 @@ public inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.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 <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> { public fun <T> Iterable<T>.withIndex(): Iterable<IndexedValue<T>> {
return IndexingIterable { iterator() } return IndexingIterable { iterator() }
@@ -947,7 +947,8 @@ public inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.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_. * The operation is _intermediate_ and _stateless_.
*/ */
@@ -907,7 +907,8 @@ public inline fun <R, C : MutableCollection<in R>> 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<IndexedValue<Char>> { public fun CharSequence.withIndex(): Iterable<IndexedValue<Char>> {
return IndexingIterable { iterator() } return IndexingIterable { iterator() }
@@ -4291,7 +4291,8 @@ public inline fun <R, C : MutableCollection<in R>> 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") @SinceKotlin("1.3")
@ExperimentalUnsignedTypes @ExperimentalUnsignedTypes
@@ -4300,7 +4301,8 @@ public fun UIntArray.withIndex(): Iterable<IndexedValue<UInt>> {
} }
/** /**
* 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") @SinceKotlin("1.3")
@ExperimentalUnsignedTypes @ExperimentalUnsignedTypes
@@ -4309,7 +4311,8 @@ public fun ULongArray.withIndex(): Iterable<IndexedValue<ULong>> {
} }
/** /**
* 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") @SinceKotlin("1.3")
@ExperimentalUnsignedTypes @ExperimentalUnsignedTypes
@@ -4318,7 +4321,8 @@ public fun UByteArray.withIndex(): Iterable<IndexedValue<UByte>> {
} }
/** /**
* 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") @SinceKotlin("1.3")
@ExperimentalUnsignedTypes @ExperimentalUnsignedTypes
@@ -17,8 +17,9 @@ package kotlin.collections
public inline operator fun <T> Iterator<T>.iterator(): Iterator<T> = this public inline operator fun <T> Iterator<T>.iterator(): Iterator<T> = this
/** /**
* Returns an [Iterator] wrapping each value produced by this [Iterator] with the [IndexedValue], * Returns an [Iterator] that wraps each element produced by the original iterator
* containing value and it's index. * into an [IndexedValue] containing the index of that element and the element itself.
*
* @sample samples.collections.Iterators.withIndexIterator * @sample samples.collections.Iterators.withIndexIterator
*/ */
public fun <T> Iterator<T>.withIndex(): Iterator<IndexedValue<T>> = IndexingIterator(this) public fun <T> Iterator<T>.withIndex(): Iterator<IndexedValue<T>> = IndexingIterator(this)
@@ -31,7 +31,10 @@ object Mapping : TemplateGroupBase() {
include(CharSequences, ArraysOfUnsigned) include(CharSequences, ArraysOfUnsigned)
} builder { } builder {
doc { 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<IndexedValue<T>>") returns("Iterable<IndexedValue<T>>")
body { body {