summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/collection/mutable/Queue.scala19
-rw-r--r--sources/scala/collection/mutable/Stack.scala19
2 files changed, 30 insertions, 8 deletions
diff --git a/sources/scala/collection/mutable/Queue.scala b/sources/scala/collection/mutable/Queue.scala
index a53faca37c..6810a9910d 100644
--- a/sources/scala/collection/mutable/Queue.scala
+++ b/sources/scala/collection/mutable/Queue.scala
@@ -9,13 +9,14 @@
package scala.collection.mutable;
+
/** <code>Queue</code> objects implement data structures that allow to
* insert and retrieve elements in a first-in-first-out (FIFO) manner.
*
* @author Matthias Zenger
* @version 1.0, 08/07/2003
*/
-class Queue[A] with MutableList[A] with StructuralEquality[Queue[A]] {
+class Queue[A] with MutableList[A] {
/** Checks if the queue is empty.
*
@@ -74,11 +75,23 @@ class Queue[A] with MutableList[A] with StructuralEquality[Queue[A]] {
*
* @returns true, iff both queues contain the same sequence of elements.
*/
- override def ===[B >: Queue[A]](that: B) =
+ override def equals(that: Any): Boolean =
that.isInstanceOf[Queue[A]] &&
{ val other = that.asInstanceOf[Queue[A]];
elements.zip(other.elements).forall {
case Pair(thiselem, thatelem) => thiselem == thatelem;
}};
-}
+ /** The hashCode method always yields an error, since it is not
+ * safe to use mutable queues as keys in hash tables.
+ *
+ * @returns never.
+ */
+ override def hashCode(): Int = error("unsuitable as hash key");
+
+ /** Returns a textual representation of a queue as a string.
+ *
+ * @returns the string representation of this queue.
+ */
+ override def toString() = toList.mkString("Queue(", ", ", ")");
+}
diff --git a/sources/scala/collection/mutable/Stack.scala b/sources/scala/collection/mutable/Stack.scala
index 51e5e89c73..4851421767 100644
--- a/sources/scala/collection/mutable/Stack.scala
+++ b/sources/scala/collection/mutable/Stack.scala
@@ -4,10 +4,9 @@
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
+** $Id$
\* */
-// $Id$
-
package scala.collection.mutable;
@@ -17,7 +16,7 @@ package scala.collection.mutable;
* @author Matthias Zenger
* @version 1.0, 08/07/2003
*/
-class Stack[A] with MutableList[A] with StructuralEquality[Stack[A]] {
+class Stack[A] with MutableList[A] {
/** Checks if the stack is empty.
*
@@ -83,13 +82,23 @@ class Stack[A] with MutableList[A] with StructuralEquality[Stack[A]] {
*
* @returns true, iff both stacks contain the same sequence of elements.
*/
- override def ===[B >: Stack[A]](that: B) =
+ override def equals(that: Any): Boolean =
that.isInstanceOf[Stack[A]] &&
{ val other = that.asInstanceOf[Stack[A]];
elements.zip(other.elements).forall {
case Pair(thiselem, thatelem) => thiselem == thatelem;
}};
- override def toString() = toList.mkString("Stack(", ", ", ")");
+ /** The hashCode method always yields an error, since it is not
+ * safe to use mutable stacks as keys in hash tables.
+ *
+ * @returns never.
+ */
+ override def hashCode(): Int = error("unsuitable as hash key");
+ /** Returns a textual representation of a stack as a string.
+ *
+ * @returns the string representation of this stack.
+ */
+ override def toString() = toList.mkString("Stack(", ", ", ")");
}