Minor: cleanup asSequence() documentation.
This commit is contained in:
@@ -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> {
|
||||
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> {
|
||||
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> {
|
||||
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> {
|
||||
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> {
|
||||
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> {
|
||||
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> {
|
||||
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> {
|
||||
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> {
|
||||
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> {
|
||||
return object : Sequence<T> {
|
||||
|
||||
@@ -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>> {
|
||||
return object : Sequence<Map.Entry<K, V>> {
|
||||
|
||||
@@ -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> {
|
||||
return this
|
||||
|
||||
@@ -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> {
|
||||
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)
|
||||
public fun String.asSequence(): Sequence<Char> {
|
||||
|
||||
@@ -28,10 +28,15 @@ fun sequences(): List<GenericFunction> {
|
||||
|
||||
templates add f("asSequence()") {
|
||||
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>")
|
||||
body {
|
||||
body { f ->
|
||||
"""
|
||||
${ when(f) {
|
||||
ArraysOfObjects, ArraysOfPrimitives -> "if (isEmpty()) return emptySequence()"
|
||||
CharSequences -> "if (this is String && isEmpty()) return emptySequence()"
|
||||
else -> ""
|
||||
}}
|
||||
return object : Sequence<T> {
|
||||
override fun iterator(): Iterator<T> {
|
||||
return this@asSequence.iterator()
|
||||
@@ -40,16 +45,7 @@ fun sequences(): List<GenericFunction> {
|
||||
"""
|
||||
}
|
||||
|
||||
body(ArraysOfObjects, ArraysOfPrimitives) {
|
||||
"""
|
||||
if (isEmpty()) return emptySequence()
|
||||
return object : Sequence<T> {
|
||||
override fun iterator(): Iterator<T> {
|
||||
return this@asSequence.iterator()
|
||||
}
|
||||
}
|
||||
"""
|
||||
}
|
||||
// TODO: Drop special case
|
||||
|
||||
deprecate(Strings) { forBinaryCompatibility }
|
||||
body(CharSequences, Strings) {
|
||||
@@ -63,11 +59,8 @@ fun sequences(): List<GenericFunction> {
|
||||
"""
|
||||
}
|
||||
|
||||
body(Sequences) {
|
||||
"""
|
||||
return this
|
||||
"""
|
||||
}
|
||||
doc(Sequences) { "Returns this sequence as a [Sequence]."}
|
||||
body(Sequences) { "return this" }
|
||||
}
|
||||
|
||||
return templates
|
||||
|
||||
Reference in New Issue
Block a user