diff options
author | stenman <stenman@epfl.ch> | 2004-01-28 12:07:07 +0000 |
---|---|---|
committer | stenman <stenman@epfl.ch> | 2004-01-28 12:07:07 +0000 |
commit | 4c01efeee52bcdf62241e051ea499928a6a66ee7 (patch) | |
tree | 23e3c5be0665edcb879d164cf6ab1707edfa02f6 /sources | |
parent | 0134764630b0817a1485094c9f0e17f867e2a835 (diff) | |
download | scala-4c01efeee52bcdf62241e051ea499928a6a66ee7.tar.gz scala-4c01efeee52bcdf62241e051ea499928a6a66ee7.tar.bz2 scala-4c01efeee52bcdf62241e051ea499928a6a66ee7.zip |
Bugfix: Added hashCode() method.
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scala/collection/immutable/Queue.scala | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/sources/scala/collection/immutable/Queue.scala b/sources/scala/collection/immutable/Queue.scala index 7a220777c0..6368f71928 100644 --- a/sources/scala/collection/immutable/Queue.scala +++ b/sources/scala/collection/immutable/Queue.scala @@ -97,16 +97,14 @@ class Queue[+A](elem: A*) extends Seq[A] { var newOut:List[A] = Nil; var newIn:List[A] = Nil; if (out.isEmpty) { - newOut = in.reverse; - newIn = Nil; - } else { - newOut = out; - newIn = in; - } - if (newOut.isEmpty) - error("queue empty"); - else - Pair(newOut.head, mkQueue(newIn, newOut.tail)); + newOut = in.reverse; + newIn = Nil; + } else { + newOut = out; + newIn = in; + } + if (newOut.isEmpty) error("queue empty"); + else Pair(newOut.head, mkQueue(newIn, newOut.tail)); } /** Returns the first element in the queue, or throws an error if there @@ -168,4 +166,11 @@ class Queue[+A](elem: A*) extends Seq[A] { case _ => false; /* o is not a queue: not equal to this. */ } + + override def hashCode():Int = + if (isEmpty) 0 + else { + val q:Pair[A,Queue[A]] = dequeue; + q._1.hashCode()+q._2.hashCode(); + } } |