diff options
author | Matthias Zenger <mzenger@gmail.com> | 2003-07-08 12:30:04 +0000 |
---|---|---|
committer | Matthias Zenger <mzenger@gmail.com> | 2003-07-08 12:30:04 +0000 |
commit | 6ad472567e124b1c6835e9e74666b224bd7958e2 (patch) | |
tree | 0d3b4cc1030d5fc9739e7202c3efcb3f95222b0e /sources | |
parent | 8eead5dedd7a391ecc658700dff0c503a098886c (diff) | |
download | scala-6ad472567e124b1c6835e9e74666b224bd7958e2.tar.gz scala-6ad472567e124b1c6835e9e74666b224bd7958e2.tar.bz2 scala-6ad472567e124b1c6835e9e74666b224bd7958e2.zip |
Fixed bugs to make the collection classes compile.
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scala/Predef.scala | 4 | ||||
-rw-r--r-- | sources/scala/collection/mutable/Buffer.scala | 6 | ||||
-rw-r--r-- | sources/scala/collection/mutable/MutableList.scala (renamed from sources/scala/collection/mutable/List.scala) | 3 | ||||
-rw-r--r-- | sources/scala/collection/mutable/Queue.scala | 4 | ||||
-rw-r--r-- | sources/scala/collection/mutable/Set.scala | 2 | ||||
-rw-r--r-- | sources/scala/collection/mutable/SingleLinkedList.scala | 2 | ||||
-rw-r--r-- | sources/scala/collection/mutable/Stack.scala | 2 | ||||
-rw-r--r-- | sources/scala/collection/mutable/SynchronizedSet.scala | 2 |
8 files changed, 13 insertions, 12 deletions
diff --git a/sources/scala/Predef.scala b/sources/scala/Predef.scala index ebe450a42b..218b5d926e 100644 --- a/sources/scala/Predef.scala +++ b/sources/scala/Predef.scala @@ -15,7 +15,8 @@ object Predef { def List[A](x: A*): List[A] = x as List[A]; val List = scala.List; - def Set[A](es: A*): MutableSet[A] = { +/* + def Set[A](es: A*): scala.Set[A] = { val set = new HashSet[A]; set.addSet(es); set; @@ -26,6 +27,7 @@ object Predef { map.putMap(mappings); map; } +*/ def error(x: String): All = new java.lang.RuntimeException(x).throw; diff --git a/sources/scala/collection/mutable/Buffer.scala b/sources/scala/collection/mutable/Buffer.scala index 654a4560fb..13ec8aa6eb 100644 --- a/sources/scala/collection/mutable/Buffer.scala +++ b/sources/scala/collection/mutable/Buffer.scala @@ -18,7 +18,7 @@ package scala.collection.mutable; * @author Matthias Zenger * @version 1.0, 08/07/2003 */ -class Buffer[A] with scala.collection.mutable.List[A] { +class Buffer[A] with MutableList[A] { def prepend(elem: A) = prependElem(elem); @@ -55,9 +55,7 @@ class Buffer[A] with scala.collection.mutable.List[A] { i = i - 1; } val old = elem.next; - elem.next = new LinkedList[A]; - elem.next.elem = newelem; - elem.next.next = old; + elem.next = new LinkedList[A](newelem, old); } } diff --git a/sources/scala/collection/mutable/List.scala b/sources/scala/collection/mutable/MutableList.scala index 1c8634c751..5e9b3d917d 100644 --- a/sources/scala/collection/mutable/List.scala +++ b/sources/scala/collection/mutable/MutableList.scala @@ -9,6 +9,7 @@ package scala.collection.mutable; + /** This class is used internally to represent mutable lists. It is the * basis for the implementation of the classes <code>Buffer</code>, * <code>Stack</code>, and <code>Queue</code>. @@ -16,7 +17,7 @@ package scala.collection.mutable; * @author Matthias Zenger * @version 1.0, 08/07/2003 */ -class List[A] with Seq[A] with PartialFunction[Int, A] { +class MutableList[A] with Seq[A] with PartialFunction[Int, A] { protected var first: LinkedList[A] = null; protected var last: LinkedList[A] = null; diff --git a/sources/scala/collection/mutable/Queue.scala b/sources/scala/collection/mutable/Queue.scala index 91c6d8b3c7..b25b4cdf72 100644 --- a/sources/scala/collection/mutable/Queue.scala +++ b/sources/scala/collection/mutable/Queue.scala @@ -15,7 +15,7 @@ package scala.collection.mutable; * @author Matthias Zenger * @version 1.0, 08/07/2003 */ -class Queue[A] with scala.collection.mutable.List[A] { +class Queue[A] with MutableList[A] { /** Checks if the queue is empty. * @@ -63,7 +63,7 @@ class Queue[A] with scala.collection.mutable.List[A] { * * @returns the first element. */ - def first: A = first.elem; + def front: A = first.elem; /** Removes all elements from the queue. After this operation is completed, * the queue will be empty. diff --git a/sources/scala/collection/mutable/Set.scala b/sources/scala/collection/mutable/Set.scala index 688130b156..5c0e1bb6da 100644 --- a/sources/scala/collection/mutable/Set.scala +++ b/sources/scala/collection/mutable/Set.scala @@ -37,7 +37,7 @@ trait Set[A] with scala.collection.Set[A] { def removeSet(that: Iterable[A]): Unit = that.elements.foreach(elem => remove(elem)); - def intersect(that: scala.collection.Set[A]): Unit = filter(that.contains); + def intersect(that: Set[A]): Unit = filter(that.contains); def clear: Unit; diff --git a/sources/scala/collection/mutable/SingleLinkedList.scala b/sources/scala/collection/mutable/SingleLinkedList.scala index edeb0db261..c7926a28e4 100644 --- a/sources/scala/collection/mutable/SingleLinkedList.scala +++ b/sources/scala/collection/mutable/SingleLinkedList.scala @@ -36,7 +36,7 @@ abstract class SingleLinkedList[A, This <: SingleLinkedList[A, This]]: This with def apply(n: Int): A = { if (n == 0) elem - else if (next == null) null + else if (next == null) error("unknown element") else next.apply(n - 1); } diff --git a/sources/scala/collection/mutable/Stack.scala b/sources/scala/collection/mutable/Stack.scala index 6b19a3dd3c..dca34693ce 100644 --- a/sources/scala/collection/mutable/Stack.scala +++ b/sources/scala/collection/mutable/Stack.scala @@ -16,7 +16,7 @@ package scala.collection.mutable; * @author Matthias Zenger * @version 1.0, 08/07/2003 */ -class Stack[A] with scala.collection.mutable.List[A] with Iterable[A] { +class Stack[A] with MutableList[A] { /** Checks if the stack is empty. * diff --git a/sources/scala/collection/mutable/SynchronizedSet.scala b/sources/scala/collection/mutable/SynchronizedSet.scala index a13f6ec288..ce38dcc38d 100644 --- a/sources/scala/collection/mutable/SynchronizedSet.scala +++ b/sources/scala/collection/mutable/SynchronizedSet.scala @@ -62,7 +62,7 @@ trait SynchronizedSet[A] extends scala.collection.mutable.Set[A] with Monitor { super.clear; } - override def subsetOf(that: Set[A]) = synchronized { + override def subsetOf(that: scala.collection.Set[A]) = synchronized { super.subsetOf(that); } |