Skip to content

Commit 2614aa8

Browse files
authored
Merge pull request scala#6735 from xuwei-k/AbstractIterator
use AbstractIterator instead of Iterator
2 parents a8d355a + f81a0a9 commit 2614aa8

File tree

7 files changed

+13
-12
lines changed

7 files changed

+13
-12
lines changed

src/library/scala/collection/ArrayOps.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ object ArrayOps {
104104
def withFilter(q: A => Boolean): WithFilter[A] = new WithFilter[A](a => p(a) && q(a), xs)
105105
}
106106

107-
private class ArrayIterator[A](private[this] val xs: Array[A]) extends Iterator[A] {
107+
private class ArrayIterator[A](private[this] val xs: Array[A]) extends AbstractIterator[A] {
108108
private[this] var pos = 0
109109
def hasNext: Boolean = pos < xs.length
110110
def next(): A = try {
@@ -114,7 +114,7 @@ object ArrayOps {
114114
} catch { case _: ArrayIndexOutOfBoundsException => throw new NoSuchElementException }
115115
}
116116

117-
private class ReverseIterator[A](private[this] val xs: Array[A]) extends Iterator[A] {
117+
private class ReverseIterator[A](private[this] val xs: Array[A]) extends AbstractIterator[A] {
118118
private[this] var pos = xs.length-1
119119
def hasNext: Boolean = pos >= 0
120120
def next(): A = try {
@@ -124,7 +124,7 @@ object ArrayOps {
124124
} catch { case _: ArrayIndexOutOfBoundsException => throw new NoSuchElementException }
125125
}
126126

127-
private class GroupedIterator[A](xs: Array[A], groupSize: Int) extends Iterator[Array[A]] {
127+
private class GroupedIterator[A](xs: Array[A], groupSize: Int) extends AbstractIterator[Array[A]] {
128128
private[this] var pos = 0
129129
def hasNext: Boolean = pos < xs.length
130130
def next(): Array[A] = {

src/library/scala/collection/Seq.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ trait SeqOps[+A, +CC[_], +C] extends Any
454454
if (n < 0 || n > size) Iterator.empty
455455
else new CombinationsItr(n)
456456

457-
private class PermutationsItr extends Iterator[C] {
457+
private class PermutationsItr extends AbstractIterator[C] {
458458
private[this] val (elms, idxs) = init()
459459
private[this] var _hasNext = true
460460

@@ -503,7 +503,7 @@ trait SeqOps[+A, +CC[_], +C] extends Any
503503
}
504504
}
505505

506-
private class CombinationsItr(n: Int) extends Iterator[C] {
506+
private class CombinationsItr(n: Int) extends AbstractIterator[C] {
507507
// generating all nums such that:
508508
// (1) nums(0) + .. + nums(length-1) = n
509509
// (2) 0 <= nums(i) <= cnts(i), where 0 <= i <= cnts.length-1

src/library/scala/collection/Set.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ trait SetOps[A, +CC[_], +C <: SetOps[A, CC, C]]
100100
*
101101
* @author Eastsun
102102
*/
103-
private class SubsetsItr(elms: IndexedSeq[A], len: Int) extends Iterator[C] {
103+
private class SubsetsItr(elms: IndexedSeq[A], len: Int) extends AbstractIterator[C] {
104104
private[this] val idxs = Array.range(0, len+1)
105105
private[this] var _hasNext = true
106106
idxs(len) = elms.size

src/library/scala/collection/StringOps.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object StringOps {
1616
private final val CR = 0x0D
1717
private final val SU = 0x1A
1818

19-
private class StringIterator(private[this] val s: String) extends Iterator[Char] {
19+
private class StringIterator(private[this] val s: String) extends AbstractIterator[Char] {
2020
private[this] var pos = 0
2121
def hasNext: Boolean = pos < s.length
2222
def next(): Char = try {
@@ -26,7 +26,7 @@ object StringOps {
2626
} catch { case _: IndexOutOfBoundsException => Iterator.empty.next() }
2727
}
2828

29-
private class ReverseIterator(private[this] val s: String) extends Iterator[Char] {
29+
private class ReverseIterator(private[this] val s: String) extends AbstractIterator[Char] {
3030
private[this] var pos = s.length-1
3131
def hasNext: Boolean = pos >= 0
3232
def next(): Char = try {
@@ -36,7 +36,7 @@ object StringOps {
3636
} catch { case _: IndexOutOfBoundsException => Iterator.empty.next() }
3737
}
3838

39-
private class GroupedIterator(s: String, groupSize: Int) extends Iterator[String] {
39+
private class GroupedIterator(s: String, groupSize: Int) extends AbstractIterator[String] {
4040
private[this] var pos = 0
4141
def hasNext: Boolean = pos < s.length
4242
def next(): String = {

src/library/scala/collection/concurrent/TrieMap.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ object TrieMap extends MapFactory[TrieMap] {
998998
}
999999

10001000

1001-
private[collection] class TrieMapIterator[K, V](var level: Int, private var ct: TrieMap[K, V], mustInit: Boolean = true) extends Iterator[(K, V)] {
1001+
private[collection] class TrieMapIterator[K, V](var level: Int, private var ct: TrieMap[K, V], mustInit: Boolean = true) extends AbstractIterator[(K, V)] {
10021002
private val stack = new Array[Array[BasicNode]](7)
10031003
private val stackpos = new Array[Int](7)
10041004
private var depth = -1

src/library/scala/collection/immutable/RedBlackTree.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ private[collection] object RedBlackTree {
491491
def unapply[A, B](t: BlackTree[A, B]) = Some((t.key, t.value, t.left, t.right))
492492
}
493493

494-
private[this] abstract class TreeIterator[A, B, R](root: Tree[A, B], start: Option[A])(implicit ordering: Ordering[A]) extends Iterator[R] {
494+
private[this] abstract class TreeIterator[A, B, R](root: Tree[A, B], start: Option[A])(implicit ordering: Ordering[A]) extends AbstractIterator[R] {
495495
protected[this] def nextResult(tree: Tree[A, B]): R
496496

497497
override def hasNext: Boolean = lookahead ne null

src/library/scala/collection/mutable/RedBlackTree.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package scala
22
package collection.mutable
33

44
import scala.annotation.tailrec
5+
import collection.AbstractIterator
56
import collection.Iterator
67

78
import java.lang.String
@@ -471,7 +472,7 @@ private[collection] object RedBlackTree {
471472
new ValuesIterator(tree, start, end)
472473

473474
private[this] abstract class TreeIterator[A, B, R](tree: Tree[A, B], start: Option[A], end: Option[A])
474-
(implicit ord: Ordering[A]) extends Iterator[R] {
475+
(implicit ord: Ordering[A]) extends AbstractIterator[R] {
475476

476477
protected def nextResult(node: Node[A, B]): R
477478

0 commit comments

Comments
 (0)