File tree 1 file changed +3
-5
lines changed
src/main/scala/scala/collection/decorators
1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -95,24 +95,22 @@ class IteratorDecorator[A](val `this`: Iterator[A]) extends AnyVal {
95
95
*/
96
96
def groupUntilChanged [K ](f : A => K ): Iterator [Iterable [A ]] =
97
97
new AbstractIterator [Seq [A ]] {
98
- private var hd : Option [A ] = readHead ()
98
+ private var hd : Option [A ] = `this`.nextOption ()
99
99
override def hasNext : Boolean = hd.isDefined
100
100
101
101
override def next (): Seq [A ] = {
102
102
hd match {
103
103
case None => Iterator .empty.next()
104
104
case Some (head) =>
105
105
val key = f(head)
106
- hd = readHead ()
106
+ hd = `this`.nextOption ()
107
107
var seq = mutable.Buffer (head)
108
108
while (hd.exists(el => f(el) == key)) {
109
109
seq = seq ++ hd
110
- hd = readHead ()
110
+ hd = `this`.nextOption ()
111
111
}
112
112
seq.toVector
113
113
}
114
114
}
115
-
116
- private def readHead () = if (`this`.hasNext) Some (`this`.next) else None
117
115
}
118
116
}
You can’t perform that action at this time.
0 commit comments