Minor: cleanup asSequence() documentation.

This commit is contained in:
Ilya Gorbunov
2015-11-29 05:25:09 +03:00
parent f596d9ac23
commit 6ca647aecd
6 changed files with 24 additions and 31 deletions
+9 -9
View File
@@ -10506,7 +10506,7 @@ public fun ShortArray.asIterable(): Iterable<Short> {
} }
/** /**
* Returns a sequence from the given collection. * Creates a [Sequence] instance that wraps the original array returning its elements when being iterated.
*/ */
public fun <T> Array<out T>.asSequence(): Sequence<T> { public fun <T> Array<out T>.asSequence(): Sequence<T> {
if (isEmpty()) return emptySequence() if (isEmpty()) return emptySequence()
@@ -10518,7 +10518,7 @@ public fun <T> Array<out T>.asSequence(): Sequence<T> {
} }
/** /**
* Returns a sequence from the given collection. * Creates a [Sequence] instance that wraps the original array returning its elements when being iterated.
*/ */
public fun BooleanArray.asSequence(): Sequence<Boolean> { public fun BooleanArray.asSequence(): Sequence<Boolean> {
if (isEmpty()) return emptySequence() if (isEmpty()) return emptySequence()
@@ -10530,7 +10530,7 @@ public fun BooleanArray.asSequence(): Sequence<Boolean> {
} }
/** /**
* Returns a sequence from the given collection. * Creates a [Sequence] instance that wraps the original array returning its elements when being iterated.
*/ */
public fun ByteArray.asSequence(): Sequence<Byte> { public fun ByteArray.asSequence(): Sequence<Byte> {
if (isEmpty()) return emptySequence() if (isEmpty()) return emptySequence()
@@ -10542,7 +10542,7 @@ public fun ByteArray.asSequence(): Sequence<Byte> {
} }
/** /**
* Returns a sequence from the given collection. * Creates a [Sequence] instance that wraps the original array returning its elements when being iterated.
*/ */
public fun CharArray.asSequence(): Sequence<Char> { public fun CharArray.asSequence(): Sequence<Char> {
if (isEmpty()) return emptySequence() if (isEmpty()) return emptySequence()
@@ -10554,7 +10554,7 @@ public fun CharArray.asSequence(): Sequence<Char> {
} }
/** /**
* Returns a sequence from the given collection. * Creates a [Sequence] instance that wraps the original array returning its elements when being iterated.
*/ */
public fun DoubleArray.asSequence(): Sequence<Double> { public fun DoubleArray.asSequence(): Sequence<Double> {
if (isEmpty()) return emptySequence() if (isEmpty()) return emptySequence()
@@ -10566,7 +10566,7 @@ public fun DoubleArray.asSequence(): Sequence<Double> {
} }
/** /**
* Returns a sequence from the given collection. * Creates a [Sequence] instance that wraps the original array returning its elements when being iterated.
*/ */
public fun FloatArray.asSequence(): Sequence<Float> { public fun FloatArray.asSequence(): Sequence<Float> {
if (isEmpty()) return emptySequence() if (isEmpty()) return emptySequence()
@@ -10578,7 +10578,7 @@ public fun FloatArray.asSequence(): Sequence<Float> {
} }
/** /**
* Returns a sequence from the given collection. * Creates a [Sequence] instance that wraps the original array returning its elements when being iterated.
*/ */
public fun IntArray.asSequence(): Sequence<Int> { public fun IntArray.asSequence(): Sequence<Int> {
if (isEmpty()) return emptySequence() if (isEmpty()) return emptySequence()
@@ -10590,7 +10590,7 @@ public fun IntArray.asSequence(): Sequence<Int> {
} }
/** /**
* Returns a sequence from the given collection. * Creates a [Sequence] instance that wraps the original array returning its elements when being iterated.
*/ */
public fun LongArray.asSequence(): Sequence<Long> { public fun LongArray.asSequence(): Sequence<Long> {
if (isEmpty()) return emptySequence() if (isEmpty()) return emptySequence()
@@ -10602,7 +10602,7 @@ public fun LongArray.asSequence(): Sequence<Long> {
} }
/** /**
* Returns a sequence from the given collection. * Creates a [Sequence] instance that wraps the original array returning its elements when being iterated.
*/ */
public fun ShortArray.asSequence(): Sequence<Short> { public fun ShortArray.asSequence(): Sequence<Short> {
if (isEmpty()) return emptySequence() if (isEmpty()) return emptySequence()
@@ -1769,7 +1769,7 @@ public fun <T> Iterable<T>.asIterable(): Iterable<T> {
} }
/** /**
* Returns a sequence from the given collection. * Creates a [Sequence] instance that wraps the original collection returning its elements when being iterated.
*/ */
public fun <T> Iterable<T>.asSequence(): Sequence<T> { public fun <T> Iterable<T>.asSequence(): Sequence<T> {
return object : Sequence<T> { return object : Sequence<T> {
+1 -1
View File
@@ -196,7 +196,7 @@ public fun <K, V> Map<K, V>.asIterable(): Iterable<Map.Entry<K, V>> {
} }
/** /**
* Returns a sequence from the given collection. * Creates a [Sequence] instance that wraps the original map returning its entrys when being iterated.
*/ */
public fun <K, V> Map<K, V>.asSequence(): Sequence<Map.Entry<K, V>> { public fun <K, V> Map<K, V>.asSequence(): Sequence<Map.Entry<K, V>> {
return object : Sequence<Map.Entry<K, V>> { return object : Sequence<Map.Entry<K, V>> {
+1 -1
View File
@@ -1085,7 +1085,7 @@ public fun <T> Sequence<T>.asIterable(): Iterable<T> {
} }
/** /**
* Returns a sequence from the given collection. * Returns this sequence as a [Sequence].
*/ */
public fun <T> Sequence<T>.asSequence(): Sequence<T> { public fun <T> Sequence<T>.asSequence(): Sequence<T> {
return this return this
+2 -2
View File
@@ -1618,7 +1618,7 @@ public fun CharSequence.asIterable(): Iterable<Char> {
} }
/** /**
* Returns a sequence from the given collection. * Creates a [Sequence] instance that wraps the original char sequence returning its characters when being iterated.
*/ */
public fun CharSequence.asSequence(): Sequence<Char> { public fun CharSequence.asSequence(): Sequence<Char> {
if (this is String && isEmpty()) return emptySequence() if (this is String && isEmpty()) return emptySequence()
@@ -1630,7 +1630,7 @@ public fun CharSequence.asSequence(): Sequence<Char> {
} }
/** /**
* Returns a sequence from the given collection. * Creates a [Sequence] instance that wraps the original string returning its characters when being iterated.
*/ */
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) @Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
public fun String.asSequence(): Sequence<Char> { public fun String.asSequence(): Sequence<Char> {
@@ -28,10 +28,15 @@ fun sequences(): List<GenericFunction> {
templates add f("asSequence()") { templates add f("asSequence()") {
include(Maps) include(Maps)
doc { "Returns a sequence from the given collection." } doc { f -> "Creates a [Sequence] instance that wraps the original ${f.collection} returning its ${f.element}s when being iterated." }
returns("Sequence<T>") returns("Sequence<T>")
body { body { f ->
""" """
${ when(f) {
ArraysOfObjects, ArraysOfPrimitives -> "if (isEmpty()) return emptySequence()"
CharSequences -> "if (this is String && isEmpty()) return emptySequence()"
else -> ""
}}
return object : Sequence<T> { return object : Sequence<T> {
override fun iterator(): Iterator<T> { override fun iterator(): Iterator<T> {
return this@asSequence.iterator() return this@asSequence.iterator()
@@ -40,16 +45,7 @@ fun sequences(): List<GenericFunction> {
""" """
} }
body(ArraysOfObjects, ArraysOfPrimitives) { // TODO: Drop special case
"""
if (isEmpty()) return emptySequence()
return object : Sequence<T> {
override fun iterator(): Iterator<T> {
return this@asSequence.iterator()
}
}
"""
}
deprecate(Strings) { forBinaryCompatibility } deprecate(Strings) { forBinaryCompatibility }
body(CharSequences, Strings) { body(CharSequences, Strings) {
@@ -63,11 +59,8 @@ fun sequences(): List<GenericFunction> {
""" """
} }
body(Sequences) { doc(Sequences) { "Returns this sequence as a [Sequence]."}
""" body(Sequences) { "return this" }
return this
"""
}
} }
return templates return templates