summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/collection/Iterator.scala11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala
index de0ec5275f..32525d59a6 100644
--- a/src/library/scala/collection/Iterator.scala
+++ b/src/library/scala/collection/Iterator.scala
@@ -994,7 +994,8 @@ trait Iterator[+A] { self =>
}
/** Creates two new iterators that both iterate over the same elements
- * as this iterator (in the same order).
+ * as this iterator (in the same order). The duplicate iterators are
+ * considered equal if they are positioned at the same element.
*
* @return a pair of iterators
*/
@@ -1013,6 +1014,14 @@ trait Iterator[+A] { self =>
e
} else gap.dequeue
}
+ // to verify partnerhood we use reference equality on gap because
+ // type testing does not discriminate based on origin.
+ private def compareGap(queue: scala.collection.mutable.Queue[A]) = gap eq queue
+ override def hashCode = gap.hashCode
+ override def equals(other: Any) = other match {
+ case x: Partner => x.compareGap(gap) && gap.isEmpty
+ case _ => super.equals(other)
+ }
}
(new Partner, new Partner)
}