summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorPhilipp Haller <hallerp@gmail.com>2009-09-22 16:14:46 +0000
committerPhilipp Haller <hallerp@gmail.com>2009-09-22 16:14:46 +0000
commiteaa7f5738dd74feeb510efd8f4831feb16e6ac06 (patch)
tree0bdccc7afa8272a4472f940c49161d80b52d1853 /src/library
parent35f61f4fa2c277d7c459b148ab0cf633b2800386 (diff)
downloadscala-eaa7f5738dd74feeb510efd8f4831feb16e6ac06.tar.gz
scala-eaa7f5738dd74feeb510efd8f4831feb16e6ac06.tar.bz2
scala-eaa7f5738dd74feeb510efd8f4831feb16e6ac06.zip
Finished re-integrating mutable collections.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/collection/generic/BufferTemplate.scala2
-rw-r--r--src/library/scala/collection/mutable/BufferProxy.scala2
-rw-r--r--src/library/scala/collection/mutable/PriorityQueueProxy.scala22
-rw-r--r--src/library/scala/collection/mutable/QueueProxy.scala22
-rw-r--r--src/library/scala/collection/mutable/StackProxy.scala43
-rw-r--r--src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala29
-rw-r--r--src/library/scala/collection/mutable/SynchronizedSet.scala5
7 files changed, 73 insertions, 52 deletions
diff --git a/src/library/scala/collection/generic/BufferTemplate.scala b/src/library/scala/collection/generic/BufferTemplate.scala
index ee494507bc..7ea5afb5c3 100644
--- a/src/library/scala/collection/generic/BufferTemplate.scala
+++ b/src/library/scala/collection/generic/BufferTemplate.scala
@@ -327,6 +327,8 @@ trait BufferTemplate[A, +This <: BufferTemplate[A, This] with Buffer[A]]
for (elem <- iter) -=(elem)
repr
}
+
+ @deprecated("Use toSequence instead") def readOnly: Sequence[A] = toSequence
}
diff --git a/src/library/scala/collection/mutable/BufferProxy.scala b/src/library/scala/collection/mutable/BufferProxy.scala
index 1c52751308..b401be7425 100644
--- a/src/library/scala/collection/mutable/BufferProxy.scala
+++ b/src/library/scala/collection/mutable/BufferProxy.scala
@@ -46,7 +46,7 @@ trait BufferProxy[A] extends Buffer[A] with Proxy {
*/
def +=(elem: A): this.type = { self.+=(elem); this }
-// override def readOnly = self.readOnly
+ override def readOnly: collection.Sequence[A] = self.readOnly
/** Appends a number of elements provided by an iterable object
* via its <code>iterator</code> method. The identity of the
diff --git a/src/library/scala/collection/mutable/PriorityQueueProxy.scala b/src/library/scala/collection/mutable/PriorityQueueProxy.scala
index ec5cbb8902..e673732ff0 100644
--- a/src/library/scala/collection/mutable/PriorityQueueProxy.scala
+++ b/src/library/scala/collection/mutable/PriorityQueueProxy.scala
@@ -10,11 +10,6 @@
package scala.collection.mutable
-// A dummy to fool ant until reintegration.
-abstract class PriorityQueueProxy
-
-/* TODO: Reintegrate
-
/** This class implements priority queues using a heap. The
* elements of the queue have to be ordered in terms of the
* <code>Ordered[T]</code> class.
@@ -22,8 +17,8 @@ abstract class PriorityQueueProxy
* @author Matthias Zenger
* @version 1.0, 03/05/2004
*/
-abstract class PriorityQueueProxy[A <% Ordered[A]] extends PriorityQueue[A]
- with RandomAccessSeqProxy[A]
+abstract class PriorityQueueProxy[A](implicit ord: Ordering[A]) extends PriorityQueue[A]
+ with Proxy
{
def self: PriorityQueue[A]
@@ -49,20 +44,26 @@ abstract class PriorityQueueProxy[A <% Ordered[A]] extends PriorityQueue[A]
*
* @param elem the element to insert
*/
- override def +=(elem: A): Unit = self += elem
+ override def +=(elem: A): this.type = { self += elem; this }
/** Adds all elements provided by an <code>Iterable</code> object
* into the priority queue.
*
* @param iter an iterable object
*/
- override def ++=(iter: collection.Iterable[A]): Unit = self ++= iter
+ def ++=(iter: collection.Iterable[A]): this.type = {
+ self ++= iter
+ this
+ }
/** Adds all elements provided by an iterator into the priority queue.
*
* @param it an iterator
*/
- override def ++=(it: Iterator[A]): Unit = self ++= it
+ override def ++=(it: Iterator[A]): this.type = {
+ self ++= it
+ this
+ }
/** Adds all elements to the queue.
*
@@ -101,4 +102,3 @@ abstract class PriorityQueueProxy[A <% Ordered[A]] extends PriorityQueue[A]
def self = PriorityQueueProxy.this.self.clone()
}
}
-*/
diff --git a/src/library/scala/collection/mutable/QueueProxy.scala b/src/library/scala/collection/mutable/QueueProxy.scala
index b6ea063706..3f88fc5b58 100644
--- a/src/library/scala/collection/mutable/QueueProxy.scala
+++ b/src/library/scala/collection/mutable/QueueProxy.scala
@@ -11,18 +11,13 @@
package scala.collection.mutable
-// A dummy to fool ant until reintegration.
-trait QueueProxy
-
-/* TODO: Reintegrate
-
/** <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.1, 03/05/2004
*/
-trait QueueProxy[A] extends Queue[A] with SeqProxy[A] {
+trait QueueProxy[A] extends Queue[A] with Proxy {
def self: Queue[A]
@@ -46,7 +41,7 @@ trait QueueProxy[A] extends Queue[A] with SeqProxy[A] {
*
* @param elem the element to insert
*/
- override def +=(elem: A): Unit = self += elem
+ override def +=(elem: A): this.type = { self += elem; this }
/** Adds all elements provided by an <code>Iterable</code> object
* at the end of the queue. The elements are prepended in the order they
@@ -54,7 +49,10 @@ trait QueueProxy[A] extends Queue[A] with SeqProxy[A] {
*
* @param iter an iterable object
*/
- override def ++=(iter: collection.Iterable[A]): Unit = self ++= iter
+ def ++=(iter: collection.Iterable[A]): this.type = {
+ self ++= iter
+ this
+ }
/** Adds all elements provided by an iterator
* at the end of the queue. The elements are prepended in the order they
@@ -62,7 +60,10 @@ trait QueueProxy[A] extends Queue[A] with SeqProxy[A] {
*
* @param iter an iterator
*/
- override def ++=(it: Iterator[A]): Unit = self ++= it
+ override def ++=(it: Iterator[A]): this.type = {
+ self ++= it
+ this
+ }
/** Adds all elements to the queue.
*
@@ -93,7 +94,7 @@ trait QueueProxy[A] extends Queue[A] with SeqProxy[A] {
*
* @return an iterator over all queue elements.
*/
- override def iteratoor: Iterator[A] = self.iterator
+ override def iterator: Iterator[A] = self.iterator
/** This method clones the queue.
*
@@ -103,4 +104,3 @@ trait QueueProxy[A] extends Queue[A] with SeqProxy[A] {
def self = QueueProxy.this.self.clone()
}
}
-*/
diff --git a/src/library/scala/collection/mutable/StackProxy.scala b/src/library/scala/collection/mutable/StackProxy.scala
index 8c86bc95a8..6161b3bc7e 100644
--- a/src/library/scala/collection/mutable/StackProxy.scala
+++ b/src/library/scala/collection/mutable/StackProxy.scala
@@ -11,18 +11,13 @@
package scala.collection.mutable
-// A dummy to fool ant until reintegration.
-trait StackProxy
-
-/* TODO: Reintegrate
-
/** A stack implements a data structure which allows to store and retrieve
* objects in a last-in-first-out (LIFO) fashion.
*
* @author Matthias Zenger
* @version 1.0, 10/05/2004
*/
-trait StackProxy[A] extends Stack[A] with SeqProxy[A] {
+trait StackProxy[A] extends Stack[A] with Proxy {
def self: Stack[A]
@@ -46,7 +41,20 @@ trait StackProxy[A] extends Stack[A] with SeqProxy[A] {
*
* @param elem the element to push onto the stack
*/
- override def +=(elem: A): Unit = self += elem
+ def +=(elem: A): this.type = {
+ self push elem
+ this
+ }
+
+ override def pushAll(elems: Iterator[A]): this.type = {
+ self pushAll elems
+ this
+ }
+
+ override def pushAll(elems: collection.Traversable[A]): this.type = {
+ self pushAll elems
+ this
+ }
/** Pushes all elements provided by an <code>Iterable</code> object
* on top of the stack. The elements are pushed in the order they
@@ -54,7 +62,10 @@ trait StackProxy[A] extends Stack[A] with SeqProxy[A] {
*
* @param iter an iterable object
*/
- override def ++=(iter: collection.Iterable[A]): Unit = self ++= iter
+ @deprecated("use pushAll") override def ++=(iter: collection.Iterable[A]): this.type = {
+ self ++= iter
+ this
+ }
/** Pushes all elements provided by an iterator
* on top of the stack. The elements are pushed in the order they
@@ -62,14 +73,15 @@ trait StackProxy[A] extends Stack[A] with SeqProxy[A] {
*
* @param iter an iterator
*/
- override def ++=(it: Iterator[A]): Unit = self ++= it
+ @deprecated("use pushAll") override def ++=(it: Iterator[A]): this.type = {
+ self ++= it
+ this
+ }
- /** Pushes a sequence of elements on top of the stack. The first element
- * is pushed first, etc.
- *
- * @param elems a sequence of elements
- */
- override def push(elems: A*): Unit = self ++= elems
+ override def push(elem1: A, elem2: A, elems: A*): this.type = {
+ self.push(elem1).push(elem2).pushAll(elems)
+ this
+ }
/** Returns the top element of the stack. This method will not remove
* the element from the stack. An error is signaled if there is no
@@ -113,4 +125,3 @@ trait StackProxy[A] extends Stack[A] with SeqProxy[A] {
def self = StackProxy.this.self.clone()
}
}
-*/
diff --git a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala
index 2025e2d16a..937d532614 100644
--- a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala
+++ b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala
@@ -11,11 +11,6 @@
package scala.collection.mutable
-// A dummy to fool ant until reintegration.
-class SynchronizedPriorityQueue
-
-/* TODO: Reintegrate
-
/** This class implements synchronized priority queues using a heap.
* The elements of the queue have to be ordered in terms of the
* <code>Ordered[T]</code> class.
@@ -23,7 +18,7 @@ class SynchronizedPriorityQueue
* @author Matthias Zenger
* @version 1.0, 03/05/2004
*/
-class SynchronizedPriorityQueue[A <% Ordered[A]] extends PriorityQueue[A] {
+class SynchronizedPriorityQueue[A](implicit ord: Ordering[A]) extends PriorityQueue[A] {
/** Checks if the queue is empty.
*
@@ -35,20 +30,35 @@ class SynchronizedPriorityQueue[A <% Ordered[A]] extends PriorityQueue[A] {
*
* @param elem the element to insert
*/
- override def +=(elem: A): Unit = synchronized { super.+=(elem) }
+ override def +=(elem: A): this.type = {
+ synchronized {
+ super.+=(elem)
+ }
+ this
+ }
/** Adds all elements provided by an <code>Iterable</code> object
* into the priority queue.
*
* @param iter an iterable object
*/
- override def ++=(iter: collection.Iterable[A]): Unit = synchronized { super.++=(iter) }
+ def ++=(iter: collection.Iterable[A]): this.type = {
+ synchronized {
+ super.++=(iter)
+ }
+ this
+ }
/** Adds all elements provided by an iterator into the priority queue.
*
* @param it an iterator
*/
- override def ++=(it: Iterator[A]): Unit = synchronized { super.++=(it) }
+ override def ++=(it: Iterator[A]): this.type = {
+ synchronized {
+ super.++=(it)
+ }
+ this
+ }
/** Adds all elements to the queue.
*
@@ -94,4 +104,3 @@ class SynchronizedPriorityQueue[A <% Ordered[A]] extends PriorityQueue[A] {
*/
override def toString(): String = synchronized { super.toString() }
}
-*/
diff --git a/src/library/scala/collection/mutable/SynchronizedSet.scala b/src/library/scala/collection/mutable/SynchronizedSet.scala
index e3ab544974..31e80c391c 100644
--- a/src/library/scala/collection/mutable/SynchronizedSet.scala
+++ b/src/library/scala/collection/mutable/SynchronizedSet.scala
@@ -7,10 +7,10 @@
\* */
// $Id$
-// !!! check whether we have all methods */
package scala.collection.mutable
+import scala.collection.script._
/** This class should be used as a mixin. It synchronizes the <code>Set</code>
* functions of the class into which it is mixed in.
@@ -97,11 +97,10 @@ trait SynchronizedSet[A] extends Set[A] {
super.toString
}
-/* TODO: Reintegrate
override def <<(cmd: Message[A]): Unit = synchronized {
super.<<(cmd)
}
-*/
+
override def clone(): Set[A] = synchronized {
super.clone()
}