summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSean McDirmid <sean.mcdirmid@gmail.com>2007-08-07 09:05:01 +0000
committerSean McDirmid <sean.mcdirmid@gmail.com>2007-08-07 09:05:01 +0000
commita19af644d2a04ddaaa93252b33795debdcda7057 (patch)
treef3c021766b7ebf07239175c32779b7c47bc194a0 /src
parentfe133c86f413abc789164619221bf560b97531b1 (diff)
downloadscala-a19af644d2a04ddaaa93252b33795debdcda7057.tar.gz
scala-a19af644d2a04ddaaa93252b33795debdcda7057.tar.bz2
scala-a19af644d2a04ddaaa93252b33795debdcda7057.zip
Fixing indexOf bug.
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/Seq.scala16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/library/scala/Seq.scala b/src/library/scala/Seq.scala
index a076cbf2ef..b78c3f9123 100644
--- a/src/library/scala/Seq.scala
+++ b/src/library/scala/Seq.scala
@@ -412,19 +412,21 @@ trait Seq[+A] extends AnyRef with PartialFunction[Int, A] with Collection[A] {
/** @returns -1 if <code>that</code> not contained in this, otherwise the index where <code>that</code> is contained
* @see String.indexOf
*/
- def indexOf[B](that : Seq[B]) : Int = {
- val i = this.elements.counted
- var j = that.elements
+ def indexOf[B >: A](that : Seq[B]) : Int = {
+ val i = this.elements
var idx = 0
+ var j = that.elements
+ var jdx = -1
while (i.hasNext && j.hasNext) {
+ idx = idx + 1
if (i.next != j.next) {
j = that.elements
- idx = -1
- } else if (idx == -1) {
- idx = i.count - 1
+ jdx = -1
+ } else if (jdx == -1) {
+ jdx = idx - 1
}
}
- idx
+ jdx
}
/** Is <code>that</code> a slice in this?
*/