Rename sequence() extension to asSequence()

This commit is contained in:
Ilya Gorbunov
2015-04-21 02:05:14 +03:00
parent 60347e87aa
commit 899a01e8c2
10 changed files with 216 additions and 80 deletions
@@ -8,12 +8,12 @@ fun sequences(): List<GenericFunction> {
templates add f("stream()") {
include(Maps)
exclude(Sequences)
deprecate { "Use sequence() instead" }
deprecate { "Use asSequence() instead" }
doc { "Returns a sequence from the given collection" }
returns("Stream<T>")
body {
"""
val sequence = sequence()
val sequence = asSequence()
return object : Stream<T> {
override fun iterator(): Iterator<T> {
return sequence.iterator()
@@ -25,6 +25,24 @@ fun sequences(): List<GenericFunction> {
}
templates add f("sequence()") {
include(Maps)
exclude(Sequences)
deprecate { "Use asSequence() instead" }
doc { "Returns a sequence from the given collection" }
returns("Sequence<T>")
body {
"""
return asSequence()
"""
}
body(Sequences) {
"""
return this
"""
}
}
templates add f("asSequence()") {
include(Maps)
exclude(Sequences)
doc { "Returns a sequence from the given collection" }
@@ -33,7 +51,7 @@ fun sequences(): List<GenericFunction> {
"""
return object : Sequence<T> {
override fun iterator(): Iterator<T> {
return this@sequence.iterator()
return this@asSequence.iterator()
}
}
"""
@@ -47,4 +65,5 @@ fun sequences(): List<GenericFunction> {
}
return templates
}
}