Rename sequence and iterator builder functions and their scope class

This introduces new functions instead of the existing sequence builders:
- `sequence` instead of `buildSequence`
- `iterator` instead of `buildIterator`
- `SequenceScope` instead of `SequenceBuilder`

The old functions were deprecated with error and made inline-only, and `SequenceBuilder` has been
made a deprecated typealias to `SequenceScope`.

Move sequence builders to `SequencesKt` facade class.

Replace sequence builder usages in stdlib and samples.

#KT-26678
This commit is contained in:
Ilya Gorbunov
2018-09-07 07:15:21 +03:00
parent 9c812c6e2b
commit aac96c476a
9 changed files with 56 additions and 46 deletions
@@ -1658,7 +1658,7 @@ public fun <T> Sequence<T>.zipWithNext(): Sequence<Pair<T, T>> {
*/
@SinceKotlin("1.2")
public fun <T, R> Sequence<T>.zipWithNext(transform: (a: T, b: T) -> R): Sequence<R> {
return buildSequence result@ {
return sequence result@ {
val iterator = iterator()
if (!iterator.hasNext()) return@result
var current = iterator.next()