summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/collection/mutable/ArrayBuffer.scala236
-rw-r--r--src/library/scala/collection/mutable/BitSet.scala52
-rw-r--r--src/library/scala/collection/mutable/Buffer.scala408
-rw-r--r--src/library/scala/collection/mutable/BufferProxy.scala256
-rw-r--r--src/library/scala/collection/mutable/DefaultMapModel.scala44
-rw-r--r--src/library/scala/collection/mutable/DoubleLinkedList.scala52
-rw-r--r--src/library/scala/collection/mutable/History.scala24
-rw-r--r--src/library/scala/collection/mutable/ImmutableMapAdaptor.scala38
-rw-r--r--src/library/scala/collection/mutable/ImmutableSetAdaptor.scala24
-rw-r--r--src/library/scala/collection/mutable/JavaMapAdaptor.scala66
-rw-r--r--src/library/scala/collection/mutable/JavaSetAdaptor.scala34
-rw-r--r--src/library/scala/collection/mutable/LinkedList.scala11
-rw-r--r--src/library/scala/collection/mutable/ListBuffer.scala34
-rw-r--r--src/library/scala/collection/mutable/Location.scala12
-rw-r--r--src/library/scala/collection/mutable/Map.scala60
-rw-r--r--src/library/scala/collection/mutable/MapProxy.scala36
-rw-r--r--src/library/scala/collection/mutable/Message.scala36
-rw-r--r--src/library/scala/collection/mutable/MultiMap.scala40
-rw-r--r--src/library/scala/collection/mutable/MutableList.scala91
-rw-r--r--src/library/scala/collection/mutable/ObservableBuffer.scala88
-rw-r--r--src/library/scala/collection/mutable/ObservableMap.scala51
-rw-r--r--src/library/scala/collection/mutable/ObservableSet.scala26
-rw-r--r--src/library/scala/collection/mutable/PriorityQueue.scala298
-rw-r--r--src/library/scala/collection/mutable/PriorityQueueProxy.scala30
-rw-r--r--src/library/scala/collection/mutable/Publisher.scala31
-rw-r--r--src/library/scala/collection/mutable/Queue.scala330
-rw-r--r--src/library/scala/collection/mutable/QueueProxy.scala156
-rw-r--r--src/library/scala/collection/mutable/ResizableArray.scala86
-rw-r--r--src/library/scala/collection/mutable/RevertableHistory.scala16
-rw-r--r--src/library/scala/collection/mutable/Scriptable.scala4
-rw-r--r--src/library/scala/collection/mutable/Set.scala189
-rw-r--r--src/library/scala/collection/mutable/SetProxy.scala34
-rw-r--r--src/library/scala/collection/mutable/SingleLinkedList.scala56
-rw-r--r--src/library/scala/collection/mutable/Stack.scala213
-rw-r--r--src/library/scala/collection/mutable/StackProxy.scala177
-rw-r--r--src/library/scala/collection/mutable/Subscriber.scala4
-rw-r--r--src/library/scala/collection/mutable/SynchronizedBuffer.scala338
-rw-r--r--src/library/scala/collection/mutable/SynchronizedMap.scala146
-rw-r--r--src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala152
-rw-r--r--src/library/scala/collection/mutable/SynchronizedQueue.scala144
-rw-r--r--src/library/scala/collection/mutable/SynchronizedSet.scala128
-rw-r--r--src/library/scala/collection/mutable/SynchronizedStack.scala176
-rw-r--r--src/library/scala/collection/mutable/Undoable.scala4
43 files changed, 2226 insertions, 2205 deletions
diff --git a/src/library/scala/collection/mutable/ArrayBuffer.scala b/src/library/scala/collection/mutable/ArrayBuffer.scala
index 41ab8395a8..f33256782c 100644
--- a/src/library/scala/collection/mutable/ArrayBuffer.scala
+++ b/src/library/scala/collection/mutable/ArrayBuffer.scala
@@ -9,10 +9,10 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
-import Predef._;
+import Predef._
/** An implementation of the Buffer class using an array to
* represent the assembled sequence internally.
@@ -23,123 +23,121 @@ import Predef._;
[serializable]
class ArrayBuffer[A] extends Buffer[A] with ResizableArray[A] {
- /** Append a single element to this buffer and return
- * the identity of the buffer.
- *
- * @param elem the element to append.
- */
- def +=(elem: A): Unit = {
- ensureSize(size+1);
- array(size) = elem;
- size = size + 1;
+ /** Append a single element to this buffer and return
+ * the identity of the buffer.
+ *
+ * @param elem the element to append.
+ */
+ def +=(elem: A): Unit = {
+ ensureSize(size+1)
+ array(size) = elem
+ size = size + 1
+ }
+
+ /** Appends a number of elements provided by an iterable object
+ * via its <code>elements</code> method. The identity of the
+ * buffer is returned.
+ *
+ * @param iter the iterable object.
+ */
+ override def ++(iter: Iterable[A]): Buffer[A] = { insertAll(size, iter); this }
+
+ /** Prepend a single element to this buffer and return
+ * the identity of the buffer.
+ *
+ * @param elem the element to append.
+ */
+ def +:(elem: A): Buffer[A] = {
+ ensureSize(size+1)
+ copy(0, 1, size)
+ array(0) = elem
+ size = size + 1
+ this
+ }
+
+ /** Prepends a number of elements provided by an iterable object
+ * via its <code>elements</code> method. The identity of the
+ * buffer is returned.
+ *
+ * @param iter the iterable object.
+ */
+ override def ++:(iter: Iterable[A]): Buffer[A] = { insertAll(0, iter); this }
+
+ /** Inserts new elements at the index <code>n</code>. Opposed to method
+ * <code>update</code>, this method will not replace an element with a
+ * one. Instead, it will insert a new element at index <code>n</code>.
+ *
+ * @param n the index where a new element will be inserted.
+ * @param iter the iterable object providing all elements to insert.
+ */
+ def insertAll(n: Int, iter: Iterable[A]): Unit = {
+ if ((n < 0) || (n > size))
+ error("cannot insert element " + n + " in ListBuffer")
+ val xs = iter.elements.toList
+ val len = xs.length
+ ensureSize(size + len)
+ copy(n, n + len, size - n)
+ xs.copyToArray(array, n)
+ size = size + len
+ }
+
+ /** Replace element at index <code>n</code> with the new element
+ * <code>newelem</code>.
+ *
+ * @param n the index of the element to replace.
+ * @param newelem the new element.
+ */
+ def update(n: Int, newelem: A): Unit =
+ if ((n < 0) || (n >= size))
+ error("cannot update element " + n + " in ArrayBuffer")
+ else {
+ val res = array(n)
+ array(n) = newelem
+ res
}
- /** Appends a number of elements provided by an iterable object
- * via its <code>elements</code> method. The identity of the
- * buffer is returned.
- *
- * @param iter the iterable object.
- */
- override def ++(iter: Iterable[A]): Buffer[A] = { insertAll(size, iter); this }
-
- /** Prepend a single element to this buffer and return
- * the identity of the buffer.
- *
- * @param elem the element to append.
- */
- def +:(elem: A): Buffer[A] = {
- ensureSize(size+1);
- copy(0, 1, size);
- array(0) = elem;
- size = size + 1;
- this
- }
-
- /** Prepends a number of elements provided by an iterable object
- * via its <code>elements</code> method. The identity of the
- * buffer is returned.
- *
- * @param iter the iterable object.
- */
- override def ++:(iter: Iterable[A]): Buffer[A] = { insertAll(0, iter); this }
-
- /** Inserts new elements at the index <code>n</code>. Opposed to method
- * <code>update</code>, this method will not replace an element with a
- * one. Instead, it will insert a new element at index <code>n</code>.
- *
- * @param n the index where a new element will be inserted.
- * @param iter the iterable object providing all elements to insert.
- */
- def insertAll(n: Int, iter: Iterable[A]): Unit = {
- if ((n < 0) || (n > size))
- error("cannot insert element " + n + " in ListBuffer");
- val xs = iter.elements.toList;
- val len = xs.length;
- ensureSize(size+len);
- copy(n, n + len, size - n);
- xs.copyToArray(array, n);
- size = size + len;
- }
-
- /** Replace element at index <code>n</code> with the new element
- * <code>newelem</code>.
- *
- * @param n the index of the element to replace.
- * @param newelem the new element.
- */
- def update(n: Int, newelem: A): Unit = {
- if ((n < 0) || (n >= size))
- error("cannot update element " + n + " in ArrayBuffer");
- else {
- val res = array(n)
- array(n) = newelem
- res
- }
- }
-
- /** Removes the element on a given index position.
- *
- * @param n the index which refers to the element to delete.
- */
- def remove(n: Int): A = {
- if ((n < 0) || (n >= size))
- error("cannot remove element " + n + " in Buffer");
- val res = array(n);
- copy(n + 1, n, size - n - 1);
- size = size - 1;
- res
- }
-
- /** Clears the buffer contents.
- */
- def clear: Unit = {
- size = 0;
- }
-
- /** Return a clone of this buffer.
- *
- * @return an <code>ArrayBuffer</code> with the same elements.
- */
- override def clone(): Buffer[A] = {
- val res = new ArrayBuffer[A];
- res ++= this;
- res
- }
-
- /** Checks if two buffers are structurally identical.
- *
- * @return true, iff both buffers contain the same sequence of elements.
- */
- override def equals(obj: Any): Boolean = obj match {
- case that: ArrayBuffer[A] =>
- ( this.length == that.length &&
- elements.zip(that.elements).forall {
- case Pair(thiselem, thatelem) => thiselem == thatelem;
- } )
- case _ => false
- }
-
- /** Defines the prefix of the string representation.
- */
- override protected def stringPrefix: String = "ArrayBuffer";
+ /** Removes the element on a given index position.
+ *
+ * @param n the index which refers to the element to delete.
+ */
+ def remove(n: Int): A = {
+ if ((n < 0) || (n >= size))
+ error("cannot remove element " + n + " in Buffer")
+ val res = array(n)
+ copy(n + 1, n, size - n - 1)
+ size = size - 1
+ res
+ }
+
+ /** Clears the buffer contents.
+ */
+ def clear: Unit = { size = 0 }
+
+ /** Return a clone of this buffer.
+ *
+ * @return an <code>ArrayBuffer</code> with the same elements.
+ */
+ override def clone(): Buffer[A] = {
+ val res = new ArrayBuffer[A]
+ res ++= this
+ res
+ }
+
+ /** Checks if two buffers are structurally identical.
+ *
+ * @return true, iff both buffers contain the same sequence of elements.
+ */
+ override def equals(obj: Any): Boolean = obj match {
+ case that: ArrayBuffer[A] =>
+ this.length == that.length &&
+ elements.zip(that.elements).forall {
+ case Pair(thiselem, thatelem) => thiselem == thatelem
+ }
+ case _ =>
+ false
+ }
+
+ /** Defines the prefix of the string representation.
+ */
+ override protected def stringPrefix: String = "ArrayBuffer"
}
diff --git a/src/library/scala/collection/mutable/BitSet.scala b/src/library/scala/collection/mutable/BitSet.scala
index 27285ed461..d8dc877e57 100644
--- a/src/library/scala/collection/mutable/BitSet.scala
+++ b/src/library/scala/collection/mutable/BitSet.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/**
@@ -24,7 +24,7 @@ package scala.collection.mutable;
[serializable]
class BitSet(initSize: Int) extends collection.BitSet with Set[Int] {
- import scala.runtime.compat.Platform.arraycopy;
+ import scala.runtime.compat.Platform.arraycopy
/** default constructor, initial size of 512 bits */
def this() = this(0);
@@ -33,15 +33,15 @@ class BitSet(initSize: Int) extends collection.BitSet with Set[Int] {
def ensureCapacity(n: Int): Unit =
if (capacity < n) {
if (nbits(arr.length) < n) {
- val newn = memsize(n);
- var newsize = if (arr.length == 0) newn else arr.length * 2;
+ val newn = memsize(n)
+ var newsize = if (arr.length == 0) newn else arr.length * 2
while (newn > newsize)
newsize = newsize * 2;
- val newarr = new Array[Int](newsize);
- arraycopy(arr, 0, newarr, 0, arr.length);
- arr = newarr;
+ val newarr = new Array[Int](newsize)
+ arraycopy(arr, 0, newarr, 0, arr.length)
+ arr = newarr
}
- capacity = n;
+ capacity = n
}
/**
@@ -49,44 +49,44 @@ class BitSet(initSize: Int) extends collection.BitSet with Set[Int] {
* No restriction on <code>i</code>
*/
def +=(i: Int): Unit = {
- ensureCapacity(i+1);
- val oldInt = arr(offset(i));
- val newInt = oldInt | mask(i);
+ ensureCapacity(i+1)
+ val oldInt = arr(offset(i))
+ val newInt = oldInt | mask(i)
if (oldInt != newInt) {
- arr(offset(i)) = newInt;
- size = size + 1;
+ arr(offset(i)) = newInt
+ size = size + 1
}
}
/** Clears <code>i<sup>th</sup></code> bit */
def -=(i: Int): Unit = {
if (i >= capacity) return;
- val oldInt = arr(offset(i));
- val newInt = oldInt & ~mask(i);
+ val oldInt = arr(offset(i))
+ val newInt = oldInt & ~mask(i)
if (oldInt != newInt) {
- arr(offset(i)) = newInt;
- size = size - 1;
+ arr(offset(i)) = newInt
+ size = size - 1
}
}
def clear: Unit = {
- java.util.Arrays.fill(arr, 0);
- size = 0;
+ java.util.Arrays.fill(arr, 0)
+ size = 0
}
def toImmutable: collection.immutable.BitSet =
- new immutable.BitSet(size, capacity, arr, true);
+ new immutable.BitSet(size, capacity, arr, true)
override def clone(): BitSet = new BitSet(capacity) {
- arraycopy(BitSet.this.arr, 0, arr, 0, arr.length);
- size = BitSet.this.size;
- capacity = BitSet.this.capacity;
+ arraycopy(BitSet.this.arr, 0, arr, 0, arr.length)
+ size = BitSet.this.size
+ capacity = BitSet.this.capacity
}
- var size: Int = 0;
+ var size: Int = 0
- var capacity: Int = initSize;
+ var capacity: Int = initSize
- protected var arr: Array[Int] = new Array[Int](memsize(initSize));
+ protected var arr: Array[Int] = new Array[Int](memsize(initSize))
}
diff --git a/src/library/scala/collection/mutable/Buffer.scala b/src/library/scala/collection/mutable/Buffer.scala
index 5cec902cff..31c7bd95c0 100644
--- a/src/library/scala/collection/mutable/Buffer.scala
+++ b/src/library/scala/collection/mutable/Buffer.scala
@@ -9,10 +9,10 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
-import Predef._;
+import Predef._
/** Buffers are used to create sequences of elements incrementally by
* appending, prepending, or inserting new elements. It is also
@@ -28,208 +28,210 @@ trait Buffer[A] extends AnyRef
with Scriptable[Message[Pair[Location, A]]]
{
- /** Append a single element to this buffer and return
- * the identity of the buffer.
- *
- * @param elem the element to append.
- */
- def +(elem: A): Buffer[A] = {
- this += elem;
- this
+ /** Append a single element to this buffer and return
+ * the identity of the buffer.
+ *
+ * @param elem the element to append.
+ */
+ def +(elem: A): Buffer[A] = {
+ this += elem
+ this
+ }
+
+ /** Append a single element to this buffer.
+ *
+ * @param elem the element to append.
+ */
+ def +=(elem: A): Unit
+
+ /** Appends a number of elements provided by an iterable object
+ * via its <code>elements</code> method. The identity of the
+ * buffer is returned.
+ *
+ * @param iter the iterable object.
+ * @return the updated buffer.
+ */
+ def ++(elems: Iterable[A]): Buffer[A] = this ++ elems.elements
+
+ /** Appends a number of elements provided by an iterable object
+ * via its <code>elements</code> method. The identity of the
+ * buffer is returned.
+ *
+ * @param iter the iterable object.
+ * @return the updated buffer.
+ */
+ def ++(iter: Iterator[A]): Buffer[A] = {
+ iter.foreach(e => this += e)
+ this
+ }
+
+ /** Appends a number of elements provided by an iterable object
+ * via its <code>elements</code> method.
+ *
+ * @param iter the iterable object.
+ */
+ def ++=(elems: Iterable[A]): Unit = this ++ elems.elements
+
+ /** Appends a number of elements provided by an iterable object
+ * via its <code>elements</code> method.
+ *
+ * @param iter the iterable object.
+ */
+ def ++=(it: Iterator[A]): Unit = this ++ it
+
+ /** Appends a sequence of elements to this buffer.
+ *
+ * @param elems the elements to append.
+ */
+ def append(elems: A*): Unit = this ++ elems
+
+ /** Appends a number of elements provided by an iterable object
+ * via its <code>elements</code> method.
+ *
+ * @param iter the iterable object.
+ */
+ def appendAll(iter: Iterable[A]): Unit = this ++ iter
+
+ /** Prepend a single element to this buffer and return
+ * the identity of the buffer.
+ *
+ * @param elem the element to append.
+ */
+ def +:(elem: A): Buffer[A]
+
+ /** Removes a single element from this buffer, at its first occurrence.
+ * If the list does not contain that element, it is unchanged
+ *
+ * @param x the element to remove.
+ */
+ def -= (x: A): unit = {
+ val i = indexOf(x)
+ if(i != -1) remove(i)
+ }
+
+ /** Prepends a number of elements provided by an iterable object
+ * via its <code>elements</code> method. The identity of the
+ * buffer is returned.
+ *
+ * @param iter the iterable object.
+ */
+ def ++:(iter: Iterable[A]): Buffer[A] = {
+ iter.elements.toList.reverse.foreach(e => e +: this)
+ this
+ }
+
+ /** Prepend an element to this list.
+ *
+ * @param elem the element to prepend.
+ */
+ def prepend(elems: A*): Unit = elems ++: this
+
+ /** Prepends a number of elements provided by an iterable object
+ * via its <code>elements</code> method. The identity of the
+ * buffer is returned.
+ *
+ * @param iter the iterable object.
+ */
+ def prependAll(elems: Iterable[A]): Unit = elems ++: this
+
+ /** Inserts new elements at the index <code>n</code>. Opposed to method
+ * <code>update</code>, this method will not replace an element with a
+ * one. Instead, it will insert the new elements at index <code>n</code>.
+ *
+ * @param n the index where a new element will be inserted.
+ * @param elems the new elements to insert.
+ */
+ def insert(n: Int, elems: A*): Unit = insertAll(n, elems)
+
+ /** Inserts new elements at the index <code>n</code>. Opposed to method
+ * <code>update</code>, this method will not replace an element with a
+ * one. Instead, it will insert a new element at index <code>n</code>.
+ *
+ * @param n the index where a new element will be inserted.
+ * @param iter the iterable object providing all elements to insert.
+ */
+ def insertAll(n: Int, iter: Iterable[A]): Unit
+
+ /** Replace element at index <code>n</code> with the new element
+ * <code>newelem</code>.
+ *
+ * @param n the index of the element to replace.
+ * @param newelem the new element.
+ */
+ def update(n: Int, newelem: A): Unit
+
+ /** Removes the element on a given index position.
+ *
+ * @param n the index which refers to the element to delete.
+ */
+ def remove(n: Int): A
+
+ /** Removes the first <code>n</code> elements.
+ *
+ * @param n the number of elements to remove from the beginning
+ * of this buffer.
+ */
+ def trimStart(n: Int): Unit = {
+ var i = n
+ while (i > 0) { remove(0); i = i - 1 }
+ }
+
+ /** Removes the last <code>n</code> elements.
+ *
+ * @param n the number of elements to remove from the end
+ * of this buffer.
+ */
+ def trimEnd(n: Int): Unit = {
+ var i = n
+ while (i > 0) { remove(length - 1); i = i - 1 }
+ }
+
+ /** Clears the buffer contents.
+ */
+ def clear: Unit
+
+ /** Send a message to this scriptable object.
+ *
+ * @param cmd the message to send.
+ */
+ def <<(cmd: Message[Pair[Location, A]]): Unit = cmd match {
+ case Include(Pair(l, elem)) => l match {
+ case Start => prepend(elem)
+ case End => append(elem)
+ case Index(n) => insert(n, elem)
+ case _ => error("message " + cmd + " not understood")
}
-
- /** Append a single element to this buffer.
- *
- * @param elem the element to append.
- */
- def +=(elem: A): Unit;
-
- /** Appends a number of elements provided by an iterable object
- * via its <code>elements</code> method. The identity of the
- * buffer is returned.
- *
- * @param iter the iterable object.
- */
- def ++(elems: Iterable[A]): Buffer[A] = this ++ elems.elements;
-
- /** Appends a number of elements provided by an iterable object
- * via its <code>elements</code> method. The identity of the
- * buffer is returned.
- *
- * @param iter the iterable object.
- */
- def ++(iter: Iterator[A]): Buffer[A] = {
- iter.foreach(e => this += e);
- this
- }
-
- /** Appends a number of elements provided by an iterable object
- * via its <code>elements</code> method.
- *
- * @param iter the iterable object.
- */
- def ++=(elems: Iterable[A]): Unit = this ++ elems.elements;
-
- /** Appends a number of elements provided by an iterable object
- * via its <code>elements</code> method.
- *
- * @param iter the iterable object.
- */
- def ++=(it: Iterator[A]): Unit = this ++ it;
-
- /** Appends a sequence of elements to this buffer.
- *
- * @param elems the elements to append.
- */
- def append(elems: A*): Unit = this ++ elems;
-
- /** Appends a number of elements provided by an iterable object
- * via its <code>elements</code> method.
- *
- * @param iter the iterable object.
- */
- def appendAll(iter: Iterable[A]): Unit = this ++ iter;
-
- /** Prepend a single element to this buffer and return
- * the identity of the buffer.
- *
- * @param elem the element to append.
- */
- def +:(elem: A): Buffer[A];
-
- /** Removes a single element from this buffer, at its first occurrence.
- * If the list does not contain that element, it is unchanged
- *
- * @param x the element to remove.
- */
- def -= (x: A): unit = {
- val i = indexOf(x)
- if(i != -1) remove(i)
+ case Update(Pair(l, elem)) => l match {
+ case Start => update(0, elem)
+ case End => update(length - 1, elem)
+ case Index(n) => update(n, elem)
+ case _ => error("message " + cmd + " not understood")
}
-
- /** Prepends a number of elements provided by an iterable object
- * via its <code>elements</code> method. The identity of the
- * buffer is returned.
- *
- * @param iter the iterable object.
- */
- def ++:(iter: Iterable[A]): Buffer[A] = {
- iter.elements.toList.reverse.foreach(e => e +: this);
- this
- }
-
- /** Prepend an element to this list.
- *
- * @param elem the element to prepend.
- */
- def prepend(elems: A*): Unit = elems ++: this;
-
- /** Prepends a number of elements provided by an iterable object
- * via its <code>elements</code> method. The identity of the
- * buffer is returned.
- *
- * @param iter the iterable object.
- */
- def prependAll(elems: Iterable[A]): Unit = elems ++: this;
-
- /** Inserts new elements at the index <code>n</code>. Opposed to method
- * <code>update</code>, this method will not replace an element with a
- * one. Instead, it will insert the new elements at index <code>n</code>.
- *
- * @param n the index where a new element will be inserted.
- * @param elems the new elements to insert.
- */
- def insert(n: Int, elems: A*): Unit = insertAll(n, elems);
-
- /** Inserts new elements at the index <code>n</code>. Opposed to method
- * <code>update</code>, this method will not replace an element with a
- * one. Instead, it will insert a new element at index <code>n</code>.
- *
- * @param n the index where a new element will be inserted.
- * @param iter the iterable object providing all elements to insert.
- */
- def insertAll(n: Int, iter: Iterable[A]): Unit;
-
- /** Replace element at index <code>n</code> with the new element
- * <code>newelem</code>.
- *
- * @param n the index of the element to replace.
- * @param newelem the new element.
- */
- def update(n: Int, newelem: A): Unit;
-
- /** Removes the element on a given index position.
- *
- * @param n the index which refers to the element to delete.
- */
- def remove(n: Int): A;
-
- /** Removes the first <code>n</code> elements.
- *
- * @param n the number of elements to remove from the beginning
- * of this buffer.
- */
- def trimStart(n: Int): Unit = {
- var i = n;
- while (i > 0) { remove(0); i = i - 1; }
+ case Remove(Pair(l, _)) => l match {
+ case Start => remove(0)
+ case End => remove(length - 1)
+ case Index(n) => remove(n)
+ case _ => error("message " + cmd + " not understood")
}
-
- /** Removes the last <code>n</code> elements.
- *
- * @param n the number of elements to remove from the end
- * of this buffer.
- */
- def trimEnd(n: Int): Unit = {
- var i = n;
- while (i > 0) { remove(length - 1); i = i - 1; }
- }
-
- /** Clears the buffer contents.
- */
- def clear: Unit;
-
- /** Send a message to this scriptable object.
- *
- * @param cmd the message to send.
- */
- def <<(cmd: Message[Pair[Location, A]]): Unit = cmd match {
- case Include(Pair(l, elem)) => l match {
- case Start => prepend(elem);
- case End => append(elem);
- case Index(n) => insert(n, elem);
- case _ => error("message " + cmd + " not understood");
- }
- case Update(Pair(l, elem)) => l match {
- case Start => update(0, elem);
- case End => update(length - 1, elem);
- case Index(n) => update(n, elem);
- case _ => error("message " + cmd + " not understood");
- }
- case Remove(Pair(l, _)) => l match {
- case Start => remove(0);
- case End => remove(length - 1);
- case Index(n) => remove(n);
- case _ => error("message " + cmd + " not understood");
- }
- case Reset() => clear;
- case s: Script[Pair[Location, A]] => s.elements foreach <<;
- case _ => error("message " + cmd + " not understood");
- }
-
- /** Return a clone of this buffer.
- *
- * @return a buffer with the same elements.
- */
- override def clone(): Buffer[A] = super.clone().asInstanceOf[Buffer[A]];
-
- /** The hashCode method always yields an error, since it is not
- * safe to use buffers as keys in hash tables.
- *
- * @return never.
- */
- override def hashCode(): Int = error("unsuitable as hash key");
-
- /** Defines the prefix of the string representation.
- */
- override protected def stringPrefix: String = "Buffer";
+ case Reset() => clear
+ case s: Script[Pair[Location, A]] => s.elements foreach <<
+ case _ => error("message " + cmd + " not understood")
+ }
+
+ /** Return a clone of this buffer.
+ *
+ * @return a buffer with the same elements.
+ */
+ override def clone(): Buffer[A] = super.clone().asInstanceOf[Buffer[A]]
+
+ /** The hashCode method always yields an error, since it is not
+ * safe to use buffers as keys in hash tables.
+ *
+ * @return never.
+ */
+ override def hashCode(): Int = error("unsuitable as hash key")
+
+ /** Defines the prefix of the string representation.
+ */
+ override protected def stringPrefix: String = "Buffer"
}
diff --git a/src/library/scala/collection/mutable/BufferProxy.scala b/src/library/scala/collection/mutable/BufferProxy.scala
index f2837f7200..86b80613fd 100644
--- a/src/library/scala/collection/mutable/BufferProxy.scala
+++ b/src/library/scala/collection/mutable/BufferProxy.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This is a simple proxy class for <code>scala.collection.mutable.Buffer</code>.
@@ -21,129 +21,133 @@ package scala.collection.mutable;
*/
trait BufferProxy[A] extends Buffer[A] with Proxy {
- def self: Buffer[A];
-
- def length: Int = self.length;
-
- def elements: Iterator[A] = self.elements;
-
- def apply(n: Int): A = self.apply(n);
-
- /** Append a single element to this buffer and return
- * the identity of the buffer.
- *
- * @param elem the element to append.
- */
- override def +(elem: A): Buffer[A] = self.+(elem);
-
- /** Append a single element to this buffer.
- *
- * @param elem the element to append.
- */
- def +=(elem: A): Unit = self.+=(elem);
-
- /** Appends a number of elements provided by an iterable object
- * via its <code>elements</code> method. The identity of the
- * buffer is returned.
- *
- * @param iter the iterable object.
- */
- override def ++(iter: Iterable[A]): Buffer[A] = self.++(iter);
-
- /** Appends a number of elements provided by an iterable object
- * via its <code>elements</code> method.
- *
- * @param iter the iterable object.
- */
- override def ++=(iter: Iterable[A]): Unit = self.++=(iter);
-
- /** Appends a sequence of elements to this buffer.
- *
- * @param elems the elements to append.
- */
- override def append(elems: A*): Unit = self.++=(elems);
-
- /** Appends a number of elements provided by an iterable object
- * via its <code>elements</code> method.
- *
- * @param iter the iterable object.
- */
- override def appendAll(iter: Iterable[A]): Unit = self.appendAll(iter);
-
- /** Prepend a single element to this buffer and return
- * the identity of the buffer.
- *
- * @param elem the element to append.
- */
- def +:(elem: A): Buffer[A] = self.+:(elem);
-
- /** Prepends a number of elements provided by an iterable object
- * via its <code>elements</code> method. The identity of the
- * buffer is returned.
- *
- * @param iter the iterable object.
- */
- override def ++:(iter: Iterable[A]): Buffer[A] = self.++:(iter);
-
- /** Prepend an element to this list.
- *
- * @param elem the element to prepend.
- */
- override def prepend(elems: A*): Unit = self.prependAll(elems);
-
- /** Prepends a number of elements provided by an iterable object
- * via its <code>elements</code> method. The identity of the
- * buffer is returned.
- *
- * @param iter the iterable object.
- */
- override def prependAll(elems: Iterable[A]): Unit = self.prependAll(elems);
-
- /** Inserts new elements at the index <code>n</code>. Opposed to method
- * <code>update</code>, this method will not replace an element with a
- * one. Instead, it will insert the new elements at index <code>n</code>.
- *
- * @param n the index where a new element will be inserted.
- * @param elems the new elements to insert.
- */
- override def insert(n: Int, elems: A*): Unit = self.insertAll(n, elems);
-
- /** Inserts new elements at the index <code>n</code>. Opposed to method
- * <code>update</code>, this method will not replace an element with a
- * one. Instead, it will insert a new element at index <code>n</code>.
- *
- * @param n the index where a new element will be inserted.
- * @param iter the iterable object providing all elements to insert.
- */
- def insertAll(n: Int, iter: Iterable[A]): Unit = self.insertAll(n, iter);
-
- /** Replace element at index <code>n</code> with the new element
- * <code>newelem</code>.
- *
- * @param n the index of the element to replace.
- * @param newelem the new element.
- */
- def update(n: Int, newelem: A): Unit = self.update(n, newelem);
-
- /** Removes the element on a given index position.
- *
- * @param n the index which refers to the element to delete.
- */
- def remove(n: Int): A = self.remove(n);
-
- /** Clears the buffer contents.
- */
- def clear: Unit = self.clear;
-
- /** Send a message to this scriptable object.
- *
- * @param cmd the message to send.
- */
- override def <<(cmd: Message[Pair[Location, A]]): Unit = self << cmd;
-
- /** Return a clone of this buffer.
- *
- * @return a <code>Buffer</code> with the same elements.
- */
- override def clone(): Buffer[A] = new BufferProxy[A] { def self = BufferProxy.this.self.clone() }
+ def self: Buffer[A]
+
+ def length: Int = self.length
+
+ def elements: Iterator[A] = self.elements
+
+ def apply(n: Int): A = self.apply(n)
+
+ /** Append a single element to this buffer and return
+ * the identity of the buffer.
+ *
+ * @param elem the element to append.
+ * @return the updated buffer.
+ */
+ override def +(elem: A): Buffer[A] = self.+(elem)
+
+ /** Append a single element to this buffer.
+ *
+ * @param elem the element to append.
+ */
+ def +=(elem: A): Unit = self.+=(elem)
+
+ /** Appends a number of elements provided by an iterable object
+ * via its <code>elements</code> method. The identity of the
+ * buffer is returned.
+ *
+ * @param iter the iterable object.
+ * @return the updated buffer.
+ */
+ override def ++(iter: Iterable[A]): Buffer[A] = self.++(iter)
+
+ /** Appends a number of elements provided by an iterable object
+ * via its <code>elements</code> method.
+ *
+ * @param iter the iterable object.
+ */
+ override def ++=(iter: Iterable[A]): Unit = self.++=(iter)
+
+ /** Appends a sequence of elements to this buffer.
+ *
+ * @param elems the elements to append.
+ */
+ override def append(elems: A*): Unit = self.++=(elems)
+
+ /** Appends a number of elements provided by an iterable object
+ * via its <code>elements</code> method.
+ *
+ * @param iter the iterable object.
+ */
+ override def appendAll(iter: Iterable[A]): Unit = self.appendAll(iter)
+
+ /** Prepend a single element to this buffer and return
+ * the identity of the buffer.
+ *
+ * @param elem the element to append.
+ */
+ def +:(elem: A): Buffer[A] = self.+:(elem)
+
+ /** Prepends a number of elements provided by an iterable object
+ * via its <code>elements</code> method. The identity of the
+ * buffer is returned.
+ *
+ * @param iter the iterable object.
+ */
+ override def ++:(iter: Iterable[A]): Buffer[A] = self.++:(iter)
+
+ /** Prepend an element to this list.
+ *
+ * @param elem the element to prepend.
+ */
+ override def prepend(elems: A*): Unit = self.prependAll(elems)
+
+ /** Prepends a number of elements provided by an iterable object
+ * via its <code>elements</code> method. The identity of the
+ * buffer is returned.
+ *
+ * @param iter the iterable object.
+ */
+ override def prependAll(elems: Iterable[A]): Unit = self.prependAll(elems)
+
+ /** Inserts new elements at the index <code>n</code>. Opposed to method
+ * <code>update</code>, this method will not replace an element with a
+ * one. Instead, it will insert the new elements at index <code>n</code>.
+ *
+ * @param n the index where a new element will be inserted.
+ * @param elems the new elements to insert.
+ */
+ override def insert(n: Int, elems: A*): Unit = self.insertAll(n, elems)
+
+ /** Inserts new elements at the index <code>n</code>. Opposed to method
+ * <code>update</code>, this method will not replace an element with a
+ * one. Instead, it will insert a new element at index <code>n</code>.
+ *
+ * @param n the index where a new element will be inserted.
+ * @param iter the iterable object providing all elements to insert.
+ */
+ def insertAll(n: Int, iter: Iterable[A]): Unit = self.insertAll(n, iter)
+
+ /** Replace element at index <code>n</code> with the new element
+ * <code>newelem</code>.
+ *
+ * @param n the index of the element to replace.
+ * @param newelem the new element.
+ */
+ def update(n: Int, newelem: A): Unit = self.update(n, newelem)
+
+ /** Removes the element on a given index position.
+ *
+ * @param n the index which refers to the element to delete.
+ */
+ def remove(n: Int): A = self.remove(n)
+
+ /** Clears the buffer contents.
+ */
+ def clear: Unit = self.clear
+
+ /** Send a message to this scriptable object.
+ *
+ * @param cmd the message to send.
+ */
+ override def <<(cmd: Message[Pair[Location, A]]): Unit = self << cmd
+
+ /** Return a clone of this buffer.
+ *
+ * @return a <code>Buffer</code> with the same elements.
+ */
+ override def clone(): Buffer[A] = new BufferProxy[A] {
+ def self = BufferProxy.this.self.clone()
+ }
}
diff --git a/src/library/scala/collection/mutable/DefaultMapModel.scala b/src/library/scala/collection/mutable/DefaultMapModel.scala
index de7da91eb2..2bcaa1ccbe 100644
--- a/src/library/scala/collection/mutable/DefaultMapModel.scala
+++ b/src/library/scala/collection/mutable/DefaultMapModel.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This class is used internally. It implements the mutable <code>Map</code>
* class in terms of three functions: <code>findEntry</code>,
@@ -20,35 +20,35 @@ package scala.collection.mutable;
*/
trait DefaultMapModel[A, B] extends AnyRef with Map[A, B] {
- protected type Entry = DefaultEntry[A,B];
+ protected type Entry = DefaultEntry[A,B]
- protected def findEntry(key: A): Option[Entry];
+ protected def findEntry(key: A): Option[Entry]
- protected def addEntry(e: Entry): Unit;
+ protected def addEntry(e: Entry): Unit
- protected def entries: Iterator[Entry];
+ protected def entries: Iterator[Entry]
- def get(key: A) = findEntry(key) match {
- case None => None
- case Some(e) => Some(e.value);
- }
+ def get(key: A) = findEntry(key) match {
+ case None => None
+ case Some(e) => Some(e.value);
+ }
- def update(key: A, value: B) = findEntry(key) match {
- case None => addEntry(new Entry(key, value));
- case Some(e) => e.value = value;
- }
+ def update(key: A, value: B) = findEntry(key) match {
+ case None => addEntry(new Entry(key, value));
+ case Some(e) => e.value = value;
+ }
- def elements = new Iterator[Pair[A, B]] {
- val iter = entries;
- def hasNext = iter.hasNext;
- def next = iter.next.toPair;
- }
+ def elements = new Iterator[Pair[A, B]] {
+ val iter = entries
+ def hasNext = iter.hasNext
+ def next = iter.next.toPair
+ }
}
[serializable]
protected class DefaultEntry[A,B](k: A, v: B) extends AnyRef {
- def key = k;
- var value = v;
- def toPair = Pair(k, value);
- override def toString() = k.toString() + " -> " + value;
+ def key = k
+ var value = v
+ def toPair = Pair(k, value)
+ override def toString() = k.toString() + " -> " + value
}
diff --git a/src/library/scala/collection/mutable/DoubleLinkedList.scala b/src/library/scala/collection/mutable/DoubleLinkedList.scala
index 3f5b276aee..f2916d39e9 100644
--- a/src/library/scala/collection/mutable/DoubleLinkedList.scala
+++ b/src/library/scala/collection/mutable/DoubleLinkedList.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This extensible class may be used as a basis for implementing double
@@ -25,29 +25,29 @@ abstract class DoubleLinkedList[A, This >: Null <: DoubleLinkedList[A, This]]
extends SingleLinkedList[A, This]
{
- var prev: This;
-
- override def append(that: This): Unit =
- if (that == null)
- ()
- else if (next == null) {
- next = that;
- that.prev = this;
- } else
- next.append(that);
-
- override def insert(that: This): Unit = if (that != null) {
- that.append(next);
- next = that;
- that.prev = this;
- }
-
- def remove: Unit = {
- if (next != null)
- next.prev = prev;
- if (prev != null)
- prev.next = next;
- prev = null;
- next = null;
- }
+ var prev: This
+
+ override def append(that: This): Unit =
+ if (that == null)
+ ()
+ else if (next == null) {
+ next = that
+ that.prev = this
+ } else
+ next.append(that)
+
+ override def insert(that: This): Unit = if (that != null) {
+ that.append(next)
+ next = that
+ that.prev = this
+ }
+
+ def remove: Unit = {
+ if (next != null)
+ next.prev = prev
+ if (prev != null)
+ prev.next = next
+ prev = null
+ next = null
+ }
}
diff --git a/src/library/scala/collection/mutable/History.scala b/src/library/scala/collection/mutable/History.scala
index 551b8dd391..85b081e0ea 100644
--- a/src/library/scala/collection/mutable/History.scala
+++ b/src/library/scala/collection/mutable/History.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** <code>History[A, B]</code> objects may subscribe to events of
@@ -23,22 +23,22 @@ package scala.collection.mutable;
[serializable]
class History[A, B] extends AnyRef with Subscriber[A, B] with Iterable[Pair[B, A]] {
- protected val log: Queue[Pair[B, A]] = new Queue[Pair[B, A]];
+ protected val log: Queue[Pair[B, A]] = new Queue[Pair[B, A]]
- val maxHistory: Int = 1000;
+ val maxHistory: Int = 1000
- def notify(pub: B, event: A): Unit = {
- if (log.length >= maxHistory) {
- val old = log.dequeue;
- }
- log.enqueue(Pair(pub, event));
+ def notify(pub: B, event: A): Unit = {
+ if (log.length >= maxHistory) {
+ val old = log.dequeue;
}
+ log.enqueue(Pair(pub, event))
+ }
- def elements: Iterator[Pair[B, A]] = log.elements;
+ def elements: Iterator[Pair[B, A]] = log.elements
- def events: Iterator[A] = log.elements.map { case Pair(_, e) => e }
+ def events: Iterator[A] = log.elements.map { case Pair(_, e) => e }
- def size: Int = log.length;
+ def size: Int = log.length
- def clear: Unit = log.clear;
+ def clear: Unit = log.clear
}
diff --git a/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala b/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala
index d3e37df238..16007865d1 100644
--- a/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala
+++ b/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This class can be used as an adaptor to create mutable maps from
@@ -26,39 +26,39 @@ class ImmutableMapAdaptor[A, B](protected var imap: immutable.Map[A, B])
extends Map[A, B]
{
- def size: Int = imap.size;
+ def size: Int = imap.size
- def get(key: A): Option[B] = imap.get(key);
+ def get(key: A): Option[B] = imap.get(key)
- override def isEmpty: Boolean = imap.isEmpty;
+ override def isEmpty: Boolean = imap.isEmpty
- override def apply(key: A): B = imap.apply(key);
+ override def apply(key: A): B = imap.apply(key)
- override def contains(key: A): Boolean = imap.contains(key);
+ override def contains(key: A): Boolean = imap.contains(key)
- override def isDefinedAt(key: A) = imap.isDefinedAt(key);
+ override def isDefinedAt(key: A) = imap.isDefinedAt(key)
- override def keys: Iterator[A] = imap.keys;
+ override def keys: Iterator[A] = imap.keys
- override def values: Iterator[B] = imap.values;
+ override def values: Iterator[B] = imap.values
- def elements: Iterator[Pair[A, B]] = imap.elements;
+ def elements: Iterator[Pair[A, B]] = imap.elements
- override def foreach(f: Pair[A, B] => Unit) = imap.foreach(f);
+ override def foreach(f: Pair[A, B] => Unit) = imap.foreach(f)
- override def toList: List[Pair[A, B]] = imap.toList;
+ override def toList: List[Pair[A, B]] = imap.toList
- override def toString() = imap.toString();
+ override def toString() = imap.toString()
- def update(key: A, value: B): Unit = { imap = imap.update(key, value); }
+ def update(key: A, value: B): Unit = { imap = imap.update(key, value) }
- def -=(key: A): Unit = { imap = imap - key; }
+ def -=(key: A): Unit = { imap = imap - key }
- override def clear: Unit = { imap = imap.empty; }
+ override def clear: Unit = { imap = imap.empty }
- override def map(f: Pair[A, B] => B): Unit = { imap = imap.map(f); }
+ override def map(f: Pair[A, B] => B): Unit = { imap = imap.map(f) }
- override def filter(p: Pair[A, B] => Boolean): Unit = { imap = imap.filter(p); }
+ override def filter(p: Pair[A, B] => Boolean): Unit = { imap = imap.filter(p) }
- override def mappingToString(p: Pair[A, B]) = imap.mappingToString(p);
+ override def mappingToString(p: Pair[A, B]) = imap.mappingToString(p)
}
diff --git a/src/library/scala/collection/mutable/ImmutableSetAdaptor.scala b/src/library/scala/collection/mutable/ImmutableSetAdaptor.scala
index b6f1cfd710..93323b750f 100644
--- a/src/library/scala/collection/mutable/ImmutableSetAdaptor.scala
+++ b/src/library/scala/collection/mutable/ImmutableSetAdaptor.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This class can be used as an adaptor to create mutable sets from
@@ -24,26 +24,26 @@ package scala.collection.mutable;
[serializable]
class ImmutableSetAdaptor[A](protected var set: immutable.Set[A]) extends Set[A] {
- def size: Int = set.size;
+ def size: Int = set.size
- override def isEmpty: Boolean = set.isEmpty;
+ override def isEmpty: Boolean = set.isEmpty
- def contains(elem: A): Boolean = set.contains(elem);
+ def contains(elem: A): Boolean = set.contains(elem)
- override def foreach(f: A => Unit): Unit = set.foreach(f);
+ override def foreach(f: A => Unit): Unit = set.foreach(f)
- override def exists(p: A => Boolean): Boolean = set.exists(p);
+ override def exists(p: A => Boolean): Boolean = set.exists(p)
- override def toList: List[A] = set.toList;
+ override def toList: List[A] = set.toList
- override def toString() = set.toString();
+ override def toString() = set.toString()
- def elements: Iterator[A] = set.elements;
+ def elements: Iterator[A] = set.elements
- def +=(elem: A): Unit = { set = set + elem; }
+ def +=(elem: A): Unit = { set = set + elem }
- def -=(elem: A): Unit = { set = set - elem; }
+ def -=(elem: A): Unit = { set = set - elem }
- def clear: Unit = { set = set.empty; }
+ def clear: Unit = { set = set.empty }
}
diff --git a/src/library/scala/collection/mutable/JavaMapAdaptor.scala b/src/library/scala/collection/mutable/JavaMapAdaptor.scala
index 9478b5c169..9131b25ecf 100644
--- a/src/library/scala/collection/mutable/JavaMapAdaptor.scala
+++ b/src/library/scala/collection/mutable/JavaMapAdaptor.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This class can be used as an adaptor to create mutable maps from
@@ -20,49 +20,49 @@ package scala.collection.mutable;
*/
class JavaMapAdaptor[A, B](jmap: java.util.Map) extends Map[A, B] {
- def size: Int = jmap.size();
+ def size: Int = jmap.size()
- def get(key: A): Option[B] =
- if (jmap.containsKey(key)) Some(jmap.get(key).asInstanceOf[B]) else None;
+ def get(key: A): Option[B] =
+ if (jmap.containsKey(key)) Some(jmap.get(key).asInstanceOf[B]) else None
- override def isEmpty: Boolean = jmap.isEmpty();
+ override def isEmpty: Boolean = jmap.isEmpty()
- override def apply(key: A): B = jmap.get(key).asInstanceOf[B];
+ override def apply(key: A): B = jmap.get(key).asInstanceOf[B]
- override def contains(key: A): Boolean = jmap.containsKey(key);
+ override def contains(key: A): Boolean = jmap.containsKey(key)
- override def isDefinedAt(key: A) = jmap.containsKey(key);
+ override def isDefinedAt(key: A) = jmap.containsKey(key)
- override def keys: Iterator[A] = new Iterator[A] {
- val iter = jmap.keySet().iterator();
- def hasNext = iter.hasNext();
- def next = iter.next().asInstanceOf[A];
- }
+ override def keys: Iterator[A] = new Iterator[A] {
+ val iter = jmap.keySet().iterator()
+ def hasNext = iter.hasNext()
+ def next = iter.next().asInstanceOf[A]
+ }
- override def values: Iterator[B] = new Iterator[B] {
- val iter = jmap.values().iterator();
- def hasNext = iter.hasNext();
- def next = iter.next().asInstanceOf[B];
- }
+ override def values: Iterator[B] = new Iterator[B] {
+ val iter = jmap.values().iterator()
+ def hasNext = iter.hasNext()
+ def next = iter.next().asInstanceOf[B]
+ }
- def elements: Iterator[Pair[A, B]] = new Iterator[Pair[A, B]] {
- val iter = jmap.keySet().iterator();
- def hasNext = iter.hasNext();
- def next = {
- val key = iter.next().asInstanceOf[A];
- Pair(key, apply(key))
- }
+ def elements: Iterator[Pair[A, B]] = new Iterator[Pair[A, B]] {
+ val iter = jmap.keySet().iterator()
+ def hasNext = iter.hasNext()
+ def next = {
+ val key = iter.next().asInstanceOf[A]
+ Pair(key, apply(key))
}
+ }
- def update(key: A, value: B): Unit = { val x = jmap.put(key, value); }
+ def update(key: A, value: B): Unit = { val x = jmap.put(key, value); }
- def -=(key: A): Unit = { val x = jmap.remove(key); }
+ def -=(key: A): Unit = { val x = jmap.remove(key); }
- override def clear: Unit = jmap.clear();
+ override def clear: Unit = jmap.clear()
- override def clone(): Map[A, B] = {
- val res = new HashMap[A, B];
- res ++= this;
- res
- }
+ override def clone(): Map[A, B] = {
+ val res = new HashMap[A, B]
+ res ++= this
+ res
+ }
}
diff --git a/src/library/scala/collection/mutable/JavaSetAdaptor.scala b/src/library/scala/collection/mutable/JavaSetAdaptor.scala
index 7b96f07ddd..31e12c598e 100644
--- a/src/library/scala/collection/mutable/JavaSetAdaptor.scala
+++ b/src/library/scala/collection/mutable/JavaSetAdaptor.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This class can be used as an adaptor to create mutable sets from
@@ -20,27 +20,27 @@ package scala.collection.mutable;
*/
class JavaSetAdaptor[A](jset: java.util.Set) extends Set[A] {
- def size: Int = jset.size();
+ def size: Int = jset.size()
- override def isEmpty: Boolean = jset.isEmpty();
+ override def isEmpty: Boolean = jset.isEmpty()
- def contains(elem: A): Boolean = jset.contains(elem);
+ def contains(elem: A): Boolean = jset.contains(elem)
- def elements: Iterator[A] = new Iterator[A] {
- val iter = jset.iterator();
- def hasNext = iter.hasNext();
- def next = iter.next().asInstanceOf[A];
- }
+ def elements: Iterator[A] = new Iterator[A] {
+ val iter = jset.iterator()
+ def hasNext = iter.hasNext()
+ def next = iter.next().asInstanceOf[A]
+ }
- def +=(elem: A): Unit = { val x = jset.add(elem); }
+ def +=(elem: A): Unit = { val x = jset.add(elem); }
- def -=(elem: A): Unit = { val x = jset.remove(elem); }
+ def -=(elem: A): Unit = { val x = jset.remove(elem); }
- def clear: Unit = jset.clear();
+ def clear: Unit = jset.clear()
- override def clone(): Set[A] = {
- val res = new HashSet[A];
- res ++= this;
- res;
- }
+ override def clone(): Set[A] = {
+ val res = new HashSet[A]
+ res ++= this
+ res
+ }
}
diff --git a/src/library/scala/collection/mutable/LinkedList.scala b/src/library/scala/collection/mutable/LinkedList.scala
index 905c2539a9..80bebc4775 100644
--- a/src/library/scala/collection/mutable/LinkedList.scala
+++ b/src/library/scala/collection/mutable/LinkedList.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This class implements single linked lists where both the head (<code>elem</code>)
* and the tail (<code>next</code>) are mutable.
@@ -22,12 +22,11 @@ class LinkedList[A](var elem: A, var next: LinkedList[A])
extends SingleLinkedList[A, LinkedList[A]]
{
- override def equals(obj: Any): Boolean = (
- obj.isInstanceOf[LinkedList[A]]
- && toList.equals((obj.asInstanceOf[LinkedList[A]]).toList)
- );
+ override def equals(obj: Any): Boolean =
+ obj.isInstanceOf[LinkedList[A]] &&
+ toList.equals((obj.asInstanceOf[LinkedList[A]]).toList)
- override protected def stringPrefix: String = "LinkedList";
+ override protected def stringPrefix: String = "LinkedList"
}
diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala
index 66c5dbae27..b031a4a9aa 100644
--- a/src/library/scala/collection/mutable/ListBuffer.scala
+++ b/src/library/scala/collection/mutable/ListBuffer.scala
@@ -9,17 +9,17 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
-import Predef._;
+import Predef._
/**
*/
final class ListBuffer[A] extends Buffer[A] {
- private var start: List[A] = Nil;
- private var last: ::[A] = _;
- private var exported: boolean = false;
+ private var start: List[A] = Nil
+ private var last: ::[A] = _
+ private var exported: boolean = false
/** Prepend a single element to this buffer.
*
@@ -66,9 +66,10 @@ final class ListBuffer[A] extends Buffer[A] {
else if (start.head == x) start = start.tail
else {
var cursor = start
- while (!cursor.tail.isEmpty && cursor.tail.head != x) { cursor = cursor.tail }
+ while (!cursor.tail.isEmpty && cursor.tail.head != x)
+ cursor = cursor.tail
if (!cursor.tail.isEmpty)
- cursor.asInstanceOf[scala.::[A]].tl = cursor.tail.tail
+ cursor.asInstanceOf[scala.::[A]].tl = cursor.tail.tail
}
}
@@ -109,7 +110,8 @@ final class ListBuffer[A] extends Buffer[A] {
*/
def length: int = start.length
- private def noElem(n: int): All = error("element " + n + " does not exist in buffer");
+ private def noElem(n: int): All =
+ error("element " + n + " does not exist in buffer")
/** Returns the <code>n</code>th element of this list. This method
* yields an error if the element does not exist.
@@ -156,7 +158,7 @@ final class ListBuffer[A] extends Buffer[A] {
*/
def insertAll(n: Int, iter: Iterable[A]): unit = try {
if (exported) copy()
- var elems = iter.elements.toList.reverse;
+ var elems = iter.elements.toList.reverse
if (n == 0) {
while (!elems.isEmpty) {
val newElem = new scala.:: (elems.head, start);
@@ -194,8 +196,8 @@ final class ListBuffer[A] extends Buffer[A] {
if (n == 0) {
start = start.tail
} else {
- var cursor = start;
- var i = 1;
+ var cursor = start
+ var i = 1
while (i < n) {
cursor = cursor.tail
i = i + 1
@@ -215,13 +217,13 @@ final class ListBuffer[A] extends Buffer[A] {
* buffer snapshot, use toList.elements
*/
override def elements = new Iterator[A] {
- var cursor: List[A] = null;
- def hasNext: Boolean = !start.isEmpty && cursor != last;
+ var cursor: List[A] = null
+ def hasNext: Boolean = !start.isEmpty && cursor != last
def next: A =
if (!hasNext) {
error("next on empty Iterator")
} else {
- if (cursor == null) cursor = start else cursor = cursor.tail;
+ if (cursor == null) cursor = start else cursor = cursor.tail
cursor.head
}
}
@@ -240,13 +242,13 @@ final class ListBuffer[A] extends Buffer[A] {
case that: ListBuffer[A] =>
(this.length == that.length &&
elements.zip(that.elements).forall {
- case Pair(thiselem, thatelem) => thiselem == thatelem;
+ case Pair(thiselem, thatelem) => thiselem == thatelem
})
case _ => false
}
/** Defines the prefix of the string representation.
*/
- override protected def stringPrefix: String = "ListBuffer";
+ override protected def stringPrefix: String = "ListBuffer"
}
diff --git a/src/library/scala/collection/mutable/Location.scala b/src/library/scala/collection/mutable/Location.scala
index deaeb3f20a..efa329f4f1 100644
--- a/src/library/scala/collection/mutable/Location.scala
+++ b/src/library/scala/collection/mutable/Location.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** Class <code>Location</code> describes locations in messages implemented
@@ -18,12 +18,12 @@ package scala.collection.mutable;
* @author Matthias Zenger
* @version 1.0, 10/05/2004
*/
-abstract class Location;
+abstract class Location
-case object NA extends Location;
+case object NA extends Location
-case object Start extends Location;
+case object Start extends Location
-case object End extends Location;
+case object End extends Location
-case class Index(n: Int) extends Location;
+case class Index(n: Int) extends Location
diff --git a/src/library/scala/collection/mutable/Map.scala b/src/library/scala/collection/mutable/Map.scala
index 0cd019aa44..78555a4e20 100644
--- a/src/library/scala/collection/mutable/Map.scala
+++ b/src/library/scala/collection/mutable/Map.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This class represents mutable maps. Concrete map implementations
* just have to provide functionality for the abstract methods in
@@ -32,7 +32,7 @@ trait Map[A, B] extends AnyRef
* @param key
* @param value
*/
- def update(key: A, value: B): Unit;
+ def update(key: A, value: B): Unit
/** This method defines syntactic sugar for adding or modifying
* mappings. It is typically used in the following way:
@@ -40,14 +40,14 @@ trait Map[A, B] extends AnyRef
* map += key -> value;
* </pre>
*/
- def +=(key: A): MapTo = new MapTo(key);
+ def +=(key: A): MapTo = new MapTo(key)
/** This method adds all the mappings provided by an iterator of
* parameter <code>map</code> to the map.
*
* @param map
*/
- def ++=(map: Iterable[Pair[A, B]]): Unit = ++=(map.elements);
+ def ++=(map: Iterable[Pair[A, B]]): Unit = ++=(map.elements)
/** This method adds all the mappings provided by an iterator of
* parameter <code>map</code> to the map.
@@ -55,7 +55,7 @@ trait Map[A, B] extends AnyRef
* @param it
*/
def ++=(it: Iterator[Pair[A, B]]): Unit = it foreach {
- case Pair(key, value) => update(key, value);
+ case Pair(key, value) => update(key, value)
}
/** <code>incl</code> can be used to add many mappings at the same time
@@ -65,39 +65,41 @@ trait Map[A, B] extends AnyRef
*
* @param mappings
*/
- def incl(mappings: Pair[A, B]*): Unit = ++=(mappings.elements);
+ def incl(mappings: Pair[A, B]*): Unit = ++=(mappings.elements)
/** This method removes a mapping from the given <code>key</code>.
* If the map does not contain a mapping for the given key, the
* method does nothing.
+ *
+ * @param key
*/
- def -=(key: A): Unit;
+ def -=(key: A): Unit
/** This method removes all the mappings for keys provided by an
* iterator over the elements of the <code>keys</code> object.
*
* @param keys
*/
- def --=(keys: Iterable[A]): Unit = --=(keys.elements);
+ def --=(keys: Iterable[A]): Unit = --=(keys.elements)
/** This method removes all the mappings for keys provided by an
* iterator over the elements of the <code>keys</code> object.
*
* @param it
*/
- def --=(it: Iterator[A]): Unit = it foreach -=;
+ def --=(it: Iterator[A]): Unit = it foreach -=
/** This method will remove all the mappings for the given sequence
* of keys from the map.
*
* @param keys
*/
- def excl(keys: A*): Unit = --=(keys.elements);
+ def excl(keys: A*): Unit = --=(keys.elements)
/** Removes all mappings from the map. After this operation is
* completed, the map is empty.
*/
- def clear: Unit = keys foreach -=;
+ def clear: Unit = keys foreach -=
/** This function transforms all the values of mappings contained
* in this map with function <code>f</code>.
@@ -105,7 +107,7 @@ trait Map[A, B] extends AnyRef
* @param f
*/
def map(f: Pair[A, B] => B): Unit = elements foreach {
- case kv @ Pair(key, _) => update(key, f(kv));
+ case kv @ Pair(key, _) => update(key, f(kv))
}
/** This method removes all the mappings for which the predicate
@@ -114,7 +116,7 @@ trait Map[A, B] extends AnyRef
* @param p
*/
def filter(p: Pair[A, B] => Boolean): Unit = toList foreach {
- case kv @ Pair(key, _) => if (!p(kv)) -=(key);
+ case kv @ Pair(key, _) => if (!p(kv)) -=(key)
}
/** Send a message to this scriptable object.
@@ -122,26 +124,26 @@ trait Map[A, B] extends AnyRef
* @param cmd the message to send.
*/
def <<(cmd: Message[Pair[A, B]]): Unit = cmd match {
- case Include(Pair(k, v)) => update(k, v);
- case Update(Pair(k, v)) => update(k, v);
- case Remove(Pair(k, _)) => this -= k;
- case Reset() => clear;
- case s: Script[Pair[A, B]] => s.elements foreach <<;
- case _ => error("message " + cmd + " not understood");
+ case Include(Pair(k, v)) => update(k, v)
+ case Update(Pair(k, v)) => update(k, v)
+ case Remove(Pair(k, _)) => this -= k
+ case Reset() => clear
+ case s: Script[Pair[A, B]] => s.elements foreach <<
+ case _ => error("message " + cmd + " not understood")
}
/** Return a clone of this map.
*
- * @return an map with the same elements.
+ * @return a map with the same elements.
*/
- override def clone(): Map[A, B] = super.clone().asInstanceOf[Map[A, B]];
+ override def clone(): Map[A, B] = super.clone().asInstanceOf[Map[A, B]]
/** The hashCode method always yields an error, since it is not
* safe to use mutable maps as keys in hash tables.
*
* @return never.
*/
- override def hashCode(): Int = error("unsuitable as hash key");
+ override def hashCode(): Int = error("unsuitable as hash key")
/** Returns a string representation of this map which shows
* all the mappings.
@@ -151,23 +153,23 @@ trait Map[A, B] extends AnyRef
"{}"
else
"{" + {
- val iter = elements;
- var res = mappingToString(iter.next);
+ val iter = elements
+ var res = mappingToString(iter.next)
while (iter.hasNext) {
- res = res + ", " + mappingToString(iter.next);
+ res = res + ", " + mappingToString(iter.next)
}
- res;
- } + "}";
+ res
+ } + "}"
/** This method controls how a mapping is represented in the string
* representation provided by method <code>toString</code>.
*
* @param p
*/
- def mappingToString(p: Pair[A, B]) = p._1.toString() + " -> " + p._2;
+ def mappingToString(p: Pair[A, B]) = p._1.toString() + " -> " + p._2
class MapTo(key: A) {
- def ->(value: B): Unit = update(key, value);
+ def ->(value: B): Unit = update(key, value)
}
}
diff --git a/src/library/scala/collection/mutable/MapProxy.scala b/src/library/scala/collection/mutable/MapProxy.scala
index 1b1c38e804..872ae4a48d 100644
--- a/src/library/scala/collection/mutable/MapProxy.scala
+++ b/src/library/scala/collection/mutable/MapProxy.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This is a simple wrapper class for <code>scala.collection.mutable.Map</code>.
@@ -21,35 +21,37 @@ package scala.collection.mutable;
*/
trait MapProxy[A, B] extends Map[A, B] with collection.MapProxy[A, B] {
- def self: Map[A, B];
+ def self: Map[A, B]
- def update(key: A, value: B): Unit = self.update(key, value);
+ def update(key: A, value: B): Unit = self.update(key, value)
- override def ++=(map: Iterable[Pair[A, B]]): Unit = self ++= map;
+ override def ++=(map: Iterable[Pair[A, B]]): Unit = self ++= map
- override def ++=(it: Iterator[Pair[A, B]]): Unit = self ++= it;
+ override def ++=(it: Iterator[Pair[A, B]]): Unit = self ++= it
- override def incl(mappings: Pair[A, B]*): Unit = self ++= mappings;
+ override def incl(mappings: Pair[A, B]*): Unit = self ++= mappings
- def -=(key: A): Unit = self -= key;
+ def -=(key: A): Unit = self -= key
- override def --=(keys: Iterable[A]): Unit = self --= keys;
+ override def --=(keys: Iterable[A]): Unit = self --= keys
- override def --=(it: Iterator[A]): Unit = self --= it;
+ override def --=(it: Iterator[A]): Unit = self --= it
- override def excl(keys: A*): Unit = self --= keys;
+ override def excl(keys: A*): Unit = self --= keys
- override def clear: Unit = self.clear;
+ override def clear: Unit = self.clear
- override def map(f: Pair[A, B] => B): Unit = self.map(f);
+ override def map(f: Pair[A, B] => B): Unit = self.map(f)
- override def filter(p: Pair[A, B] => Boolean): Unit = self.filter(p);
+ override def filter(p: Pair[A, B] => Boolean): Unit = self.filter(p)
- override def toString() = self.toString();
+ override def toString() = self.toString()
- override def mappingToString(p: Pair[A, B]) = self.mappingToString(p);
+ override def mappingToString(p: Pair[A, B]) = self.mappingToString(p)
- override def <<(cmd: Message[Pair[A, B]]): Unit = self << cmd;
+ override def <<(cmd: Message[Pair[A, B]]): Unit = self << cmd
- override def clone(): Map[A, B] = new MapProxy[A, B] { def self = MapProxy.this.self.clone() }
+ override def clone(): Map[A, B] = new MapProxy[A, B] {
+ def self = MapProxy.this.self.clone()
+ }
}
diff --git a/src/library/scala/collection/mutable/Message.scala b/src/library/scala/collection/mutable/Message.scala
index 732caadf7a..8c59ad2334 100644
--- a/src/library/scala/collection/mutable/Message.scala
+++ b/src/library/scala/collection/mutable/Message.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** Class <code>Message</code> represents messages that are issued by observable
@@ -21,7 +21,7 @@ package scala.collection.mutable;
* @author Matthias Zenger
* @version 1.0, 08/07/2003
*/
-trait Message[+A];
+trait Message[+A]
/** This observable update refers to inclusion operations that add new elements
* to collection classes.
@@ -29,7 +29,7 @@ trait Message[+A];
* @author Matthias Zenger
* @version 1.0, 08/07/2003
*/
-case class Include[+I](elem: I) extends Message[I];
+case class Include[+I](elem: I) extends Message[I]
/** This observable update refers to destructive modification operations
* of elements from collection classes.
@@ -37,7 +37,7 @@ case class Include[+I](elem: I) extends Message[I];
* @author Matthias Zenger
* @version 1.0, 08/07/2003
*/
-case class Update[+A](elem: A) extends Message[A];
+case class Update[+A](elem: A) extends Message[A]
/** This observable update refers to removal operations of elements
* from collection classes.
@@ -45,14 +45,14 @@ case class Update[+A](elem: A) extends Message[A];
* @author Matthias Zenger
* @version 1.0, 08/07/2003
*/
-case class Remove[+A](elem: A) extends Message[A];
+case class Remove[+A](elem: A) extends Message[A]
/** This command refers to reset operations.
*
* @author Matthias Zenger
* @version 1.0, 08/07/2003
*/
-case class Reset[+A]() extends Message[A];
+case class Reset[+A]() extends Message[A]
/** Objects of this class represent compound messages consisting
* of a sequence of other messages.
@@ -62,19 +62,19 @@ case class Reset[+A]() extends Message[A];
*/
class Script[A] extends ArrayBuffer[Message[A]] with Message[A] {
- override def toString(): String = {
- var res = "Script(";
- var it = elements;
- var i = 1;
- while (it.hasNext) {
- if (i > 1)
- res = res + ", ";
- res = res + "[" + i + "] " + it.next;
- i = i + 1;
- }
- res + ")";
+ override def toString(): String = {
+ var res = "Script("
+ var it = elements
+ var i = 1
+ while (it.hasNext) {
+ if (i > 1)
+ res = res + ", "
+ res = res + "[" + i + "] " + it.next
+ i = i + 1
}
+ res + ")"
+ }
override def hashCode(): Int =
- Predef.error("scripts are not suitable as hash keys");
+ Predef.error("scripts are not suitable as hash keys")
}
diff --git a/src/library/scala/collection/mutable/MultiMap.scala b/src/library/scala/collection/mutable/MultiMap.scala
index 17363a12e0..35628e7673 100644
--- a/src/library/scala/collection/mutable/MultiMap.scala
+++ b/src/library/scala/collection/mutable/MultiMap.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This class is typically used as a mixin. It turns maps which map <code>A</code>
@@ -20,22 +20,24 @@ package scala.collection.mutable;
* @version 1.0, 08/07/2003
*/
trait MultiMap[A, B] extends Map[A, Set[B]] {
- protected def makeSet: Set[B] = new HashSet[B];
-
- def add(key: A, value: B): Unit = get(key) match {
- case None => val set = makeSet;
- set += value;
- this(key) = set;
- case Some(set) => set += value;
- }
-
- def remove(key: A, value: B) = get(key) match {
- case None =>
- case Some(set) => set -= value;
- }
-
- def entryExists(key: A, p: B => Boolean): Boolean = get(key) match {
- case None => false
- case Some(set) => set exists p;
- }
+ protected def makeSet: Set[B] = new HashSet[B]
+
+ def add(key: A, value: B): Unit = get(key) match {
+ case None =>
+ val set = makeSet
+ set += value
+ this(key) = set
+ case Some(set) =>
+ set += value
+ }
+
+ def remove(key: A, value: B) = get(key) match {
+ case None =>
+ case Some(set) => set -= value
+ }
+
+ def entryExists(key: A, p: B => Boolean): Boolean = get(key) match {
+ case None => false
+ case Some(set) => set exists p
+ }
}
diff --git a/src/library/scala/collection/mutable/MutableList.scala b/src/library/scala/collection/mutable/MutableList.scala
index ae3965f534..69e778ab66 100644
--- a/src/library/scala/collection/mutable/MutableList.scala
+++ b/src/library/scala/collection/mutable/MutableList.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+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>,
@@ -20,59 +20,58 @@ package scala.collection.mutable;
*/
trait MutableList[A] extends Seq[A] with PartialFunction[Int, A] {
- protected var first: LinkedList[A] = null;
- protected var last: LinkedList[A] = null;
- protected var len: Int = 0;
+ protected var first: LinkedList[A] = null
+ protected var last: LinkedList[A] = null
+ protected var len: Int = 0
- /** Returns the length of this list.
- */
- def length: Int = len;
+ /** Returns the length of this list.
+ */
+ def length: Int = len
- /** Returns the <code>n</code>th element of this list. This method
- * yields an error if the element does not exist.
- */
- def apply(n: Int): A = get(n) match {
- case None => error("element not found")
- case Some(value) => value
- }
+ /** Returns the <code>n</code>th element of this list. This method
+ * yields an error if the element does not exist.
+ */
+ def apply(n: Int): A = get(n) match {
+ case None => error("element not found")
+ case Some(value) => value
+ }
- /** Returns the <code>n</code>th element of this list or <code>None</code>
- * if this element does not exist.
- */
- def get(n: Int): Option[A] = first.get(n);
+ /** Returns the <code>n</code>th element of this list or <code>None</code>
+ * if this element does not exist.
+ */
+ def get(n: Int): Option[A] = first.get(n)
- protected def prependElem(elem: A): Unit = {
- first = new LinkedList[A](elem, first);
- if (len == 0)
- last = first;
- len = len + 1;
- }
+ protected def prependElem(elem: A): Unit = {
+ first = new LinkedList[A](elem, first)
+ if (len == 0)
+ last = first
+ len = len + 1
+ }
- protected def appendElem(elem: A): Unit = {
- if (len == 0)
- prependElem(elem);
- else {
- last.next = new LinkedList[A](elem, null);
- last = last.next;
- len = len + 1;
- }
+ protected def appendElem(elem: A): Unit =
+ if (len == 0)
+ prependElem(elem)
+ else {
+ last.next = new LinkedList[A](elem, null)
+ last = last.next
+ len = len + 1
}
- protected def reset: Unit = {
- first = null;
- last = null;
- len = 0;
- }
+ protected def reset: Unit = {
+ first = null
+ last = null
+ len = 0
+ }
- /** Returns an iterator over all elements of this list.
- */
- def elements: Iterator[A] =
- if (first == null) Nil.elements else first.elements;
+ /** Returns an iterator over all elements of this list.
+ */
+ def elements: Iterator[A] =
+ if (first == null) Nil.elements else first.elements
- /** Returns an instance of <code>scala.List</code> containing the same
- * sequence of elements.
- */
- override def toList: List[A] = if (first == null) Nil else first.toList;
+ /** Returns an instance of <code>scala.List</code> containing the same
+ * sequence of elements.
+ */
+ override def toList: List[A] = if (first == null) Nil else first.toList
- override protected def stringPrefix: String = "MutableList";
+ override protected def stringPrefix: String = "MutableList"
}
diff --git a/src/library/scala/collection/mutable/ObservableBuffer.scala b/src/library/scala/collection/mutable/ObservableBuffer.scala
index 1440fe6845..8112630da6 100644
--- a/src/library/scala/collection/mutable/ObservableBuffer.scala
+++ b/src/library/scala/collection/mutable/ObservableBuffer.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This class is typically used as a mixin. It adds a subscription
@@ -26,53 +26,53 @@ trait ObservableBuffer[A, This <: ObservableBuffer[A, This]] requires This
with Undoable, This]
{
- abstract override def +(element: A): Buffer[A] = {
- super.+(element);
- publish(new Include(Pair(End, element)) with Undoable {
- def undo: Unit = trimEnd(1);
- });
- this
- }
+ abstract override def +(element: A): Buffer[A] = {
+ super.+(element)
+ publish(new Include(Pair(End, element)) with Undoable {
+ def undo: Unit = trimEnd(1)
+ })
+ this
+ }
- abstract override def +:(element: A): Buffer[A] = {
- super.+:(element);
- publish(new Include(Pair(Start, element)) with Undoable {
- def undo: Unit = trimStart(1);
- });
- this
- }
+ abstract override def +:(element: A): Buffer[A] = {
+ super.+:(element);
+ publish(new Include(Pair(Start, element)) with Undoable {
+ def undo: Unit = trimStart(1)
+ })
+ this
+ }
- abstract override def insertAll(n: Int, iter: Iterable[A]): Unit = {
- super.insertAll(n, iter);
- var i = n;
- val it = iter.elements;
- while (it.hasNext) {
- publish(new Include(Pair(Index(i), it.next)) with Undoable {
- def undo: Unit = remove(i);
- });
- i = i + 1;
- }
+ abstract override def insertAll(n: Int, iter: Iterable[A]): Unit = {
+ super.insertAll(n, iter)
+ var i = n
+ val it = iter.elements
+ while (it.hasNext) {
+ publish(new Include(Pair(Index(i), it.next)) with Undoable {
+ def undo: Unit = remove(i);
+ })
+ i = i + 1
}
+ }
- abstract override def update(n: Int, newelement: A): Unit = {
- val oldelement = apply(n);
- super.update(n, newelement);
- publish(new Update(Pair(Index(n), newelement)) with Undoable {
- def undo: Unit = update(n, oldelement);
- });
- }
+ abstract override def update(n: Int, newelement: A): Unit = {
+ val oldelement = apply(n)
+ super.update(n, newelement)
+ publish(new Update(Pair(Index(n), newelement)) with Undoable {
+ def undo: Unit = update(n, oldelement)
+ })
+ }
- abstract override def remove(n: Int): A = {
- val oldelement = apply(n);
- super.remove(n);
- publish(new Remove(Pair(Index(n), oldelement)) with Undoable {
- def undo: Unit = insert(n, oldelement);
- });
- oldelement
- }
+ abstract override def remove(n: Int): A = {
+ val oldelement = apply(n)
+ super.remove(n)
+ publish(new Remove(Pair(Index(n), oldelement)) with Undoable {
+ def undo: Unit = insert(n, oldelement)
+ })
+ oldelement
+ }
- abstract override def clear: Unit = {
- super.clear;
- publish(new Reset with Undoable { def undo: Unit = error("cannot undo"); });
- }
+ abstract override def clear: Unit = {
+ super.clear
+ publish(new Reset with Undoable { def undo: Unit = error("cannot undo") })
+ }
}
diff --git a/src/library/scala/collection/mutable/ObservableMap.scala b/src/library/scala/collection/mutable/ObservableMap.scala
index 5d58e4f2e8..da08fb95d7 100644
--- a/src/library/scala/collection/mutable/ObservableMap.scala
+++ b/src/library/scala/collection/mutable/ObservableMap.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This class is typically used as a mixin. It adds a subscription
@@ -26,27 +26,30 @@ trait ObservableMap[A, B, This <: ObservableMap[A, B, This]] requires This
with Undoable, This]
{
- abstract override def update(key: A, value: B): Unit = get(key) match {
- case None => super.update(key, value);
- publish(new Include(Pair(key, value)) with Undoable {
- def undo = -=(key);
- });
- case Some(old) => super.update(key, value);
- publish(new Update(Pair(key, value)) with Undoable {
- def undo = update(key, old);
- });
- }
-
- abstract override def -=(key: A): Unit = get(key) match {
- case None =>
- case Some(old) => super.-=(key);
- publish(new Remove(Pair(key, old)) with Undoable {
- def undo = update(key, old);
- });
- }
-
- abstract override def clear: Unit = {
- super.clear;
- publish(new Reset with Undoable { def undo: Unit = error("cannot undo"); });
- }
+ abstract override def update(key: A, value: B): Unit = get(key) match {
+ case None =>
+ super.update(key, value)
+ publish(new Include(Pair(key, value)) with Undoable {
+ def undo = -=(key)
+ })
+ case Some(old) =>
+ super.update(key, value)
+ publish(new Update(Pair(key, value)) with Undoable {
+ def undo = update(key, old)
+ })
+ }
+
+ abstract override def -=(key: A): Unit = get(key) match {
+ case None =>
+ case Some(old) =>
+ super.-=(key)
+ publish(new Remove(Pair(key, old)) with Undoable {
+ def undo = update(key, old)
+ })
+ }
+
+ abstract override def clear: Unit = {
+ super.clear
+ publish(new Reset with Undoable { def undo: Unit = error("cannot undo") })
+ }
}
diff --git a/src/library/scala/collection/mutable/ObservableSet.scala b/src/library/scala/collection/mutable/ObservableSet.scala
index b8338d634b..52b81b24d4 100644
--- a/src/library/scala/collection/mutable/ObservableSet.scala
+++ b/src/library/scala/collection/mutable/ObservableSet.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This class is typically used as a mixin. It adds a subscription
@@ -26,18 +26,18 @@ trait ObservableSet[A, This <: ObservableSet[A, This]] requires This
with Undoable, This]
{
- abstract override def +=(elem: A): Unit = if (!contains(elem)) {
- super.+=(elem);
- publish(new Include(elem) with Undoable { def undo = -=(elem); });
- }
+ abstract override def +=(elem: A): Unit = if (!contains(elem)) {
+ super.+=(elem)
+ publish(new Include(elem) with Undoable { def undo = -=(elem) })
+ }
- abstract override def -=(elem: A): Unit = if (contains(elem)) {
- super.-=(elem);
- publish(new Remove(elem) with Undoable { def undo = +=(elem); });
- }
+ abstract override def -=(elem: A): Unit = if (contains(elem)) {
+ super.-=(elem)
+ publish(new Remove(elem) with Undoable { def undo = +=(elem) })
+ }
- abstract override def clear: Unit = {
- super.clear;
- publish(new Reset with Undoable { def undo: Unit = error("cannot undo"); });
- }
+ abstract override def clear: Unit = {
+ super.clear
+ publish(new Reset with Undoable { def undo: Unit = error("cannot undo") })
+ }
}
diff --git a/src/library/scala/collection/mutable/PriorityQueue.scala b/src/library/scala/collection/mutable/PriorityQueue.scala
index caa7033e8d..b6cb527d52 100644
--- a/src/library/scala/collection/mutable/PriorityQueue.scala
+++ b/src/library/scala/collection/mutable/PriorityQueue.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This class implements priority queues using a heap. The
@@ -22,158 +22,154 @@ package scala.collection.mutable;
[serializable, cloneable]
class PriorityQueue[A <% Ordered[A]] extends ResizableArray[A] {
- size = size + 1; // we do not use array(0)
-
- protected def fixUp(as: Array[A], m: Int): Unit = {
- var k: Int = m;
- while ((k > 1) && (as(k / 2) < as(k))) {
- swap(k, k / 2);
- k = k / 2;
- }
- }
-
- protected def fixDown(as: Array[A], m: Int, n: Int): Unit = {
- var k: Int = m;
- var loop: Boolean = true;
- while (loop && (n >= 2 * k)) {
- var j = 2 * k;
- if ((j < n) && (as(j) < as(j + 1)))
- j = j + 1;
- if (!(as(k) < as(j)))
- loop = false;
- else {
- val h = as(k);
- as(k) = as(j);
- as(j) = h;
- k = j;
- }
- }
- }
+ size = size + 1 // we do not use array(0)
- /** Checks if the queue is empty.
- *
- * @return true, iff there is no element in the queue.
- */
- override def isEmpty: Boolean = size < 2;
-
- /** Inserts a single element into the priority queue.
- *
- * @param elem the element to insert
- */
- def +=(elem: A): Unit = {
- ensureSize(size+1);
- array(size) = elem;
- fixUp(array, size);
- size = size + 1;
+ protected def fixUp(as: Array[A], m: Int): Unit = {
+ var k: Int = m
+ while ((k > 1) && (as(k / 2) < as(k))) {
+ swap(k, k / 2)
+ k = k / 2
}
-
- /** Adds all elements provided by an <code>Iterable</code> object
- * into the priority queue.
- *
- * @param iter an iterable object
- */
- def ++=(iter: Iterable[A]): Unit = this ++= iter.elements;
-
- /** Adds all elements provided by an iterator into the priority queue.
- *
- * @param it an iterator
- */
- def ++=(it: Iterator[A]): Unit = it foreach { e => this += e };
-
- /** Adds all elements to the queue.
- *
- * @param elems the elements to add.
- */
- def enqueue(elems: A*): Unit = (this ++= elems);
-
- /** Returns the element with the highest priority in the queue,
- * and removes this element from the queue.
- *
- * @return the element with the highest priority.
- */
- def dequeue: A = {
- if (size > 1) {
- size = size - 1;
- swap(1, size);
- fixDown(array, 1, size - 1);
- array(size)
- } else
- error("no element to remove from heap");
- }
-
- /** Returns the element with the highest priority in the queue,
- * or throws an error if there is no element contained in the queue.
- *
- * @return the element with the highest priority.
- */
- def max: A = if (size > 1) array(1) else error("queue is empty");
-
- /** Removes all elements from the queue. After this operation is completed,
- * the queue will be empty.
- */
- def clear: Unit = {
- size = 1;
+ }
+
+ protected def fixDown(as: Array[A], m: Int, n: Int): Unit = {
+ var k: Int = m
+ var loop: Boolean = true
+ while (loop && (n >= 2 * k)) {
+ var j = 2 * k
+ if ((j < n) && (as(j) < as(j + 1)))
+ j = j + 1;
+ if (!(as(k) < as(j)))
+ loop = false
+ else {
+ val h = as(k)
+ as(k) = as(j)
+ as(j) = h
+ k = j
+ }
}
-
- /** Returns an iterator which yiels all the elements of the priority
- * queue in descending priority order.
- *
- * @return an iterator over all elements sorted in descending order.
- */
- override def elements: Iterator[A] = new Iterator[A] {
- val as: Array[A] = new Array[A](size);
- Array.copy(array, 0, as, 0, size);
- var i = size - 1;
- def hasNext: Boolean = i > 0;
- def next: A = {
- val res = as(1);
- as(1) = as(i);
- i = i - 1;
- fixDown(as, 1, i);
- res
- }
- }
-
- /** Checks if two queues are structurally identical.
- *
- * @return true, iff both queues contain the same sequence of elements.
- */
- override def equals(that: Any): Boolean = (
- that.isInstanceOf[PriorityQueue[A]] &&
- { val other = that.asInstanceOf[PriorityQueue[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.
- *
- * @return never.
- */
- override def hashCode(): Int = error("unsuitable as hash key");
-
- /** Returns a regular queue containing the same elements.
- */
- def toQueue: Queue[A] = {
- val res = new Queue[A];
- res ++= this;
- res
- }
-
- /** Returns a textual representation of a queue as a string.
- *
- * @return the string representation of this queue.
- */
- override def toString() = toList.mkString("PriorityQueue(", ", ", ")");
-
- /** This method clones the priority queue.
- *
- * @return a priority queue with the same elements.
- */
- override def clone(): PriorityQueue[A] = {
- val res = new PriorityQueue[A];
- res ++= this;
- res
+ }
+
+ /** Checks if the queue is empty.
+ *
+ * @return true, iff there is no element in the queue.
+ */
+ override def isEmpty: Boolean = size < 2
+
+ /** Inserts a single element into the priority queue.
+ *
+ * @param elem the element to insert
+ */
+ def +=(elem: A): Unit = {
+ ensureSize(size+1)
+ array(size) = elem
+ fixUp(array, size)
+ size = size + 1
+ }
+
+ /** Adds all elements provided by an <code>Iterable</code> object
+ * into the priority queue.
+ *
+ * @param iter an iterable object
+ */
+ def ++=(iter: Iterable[A]): Unit = this ++= iter.elements
+
+ /** Adds all elements provided by an iterator into the priority queue.
+ *
+ * @param it an iterator
+ */
+ def ++=(it: Iterator[A]): Unit = it foreach { e => this += e }
+
+ /** Adds all elements to the queue.
+ *
+ * @param elems the elements to add.
+ */
+ def enqueue(elems: A*): Unit = (this ++= elems)
+
+ /** Returns the element with the highest priority in the queue,
+ * and removes this element from the queue.
+ *
+ * @return the element with the highest priority.
+ */
+ def dequeue: A =
+ if (size > 1) {
+ size = size - 1
+ swap(1, size)
+ fixDown(array, 1, size - 1)
+ array(size)
+ } else
+ error("no element to remove from heap")
+
+ /** Returns the element with the highest priority in the queue,
+ * or throws an error if there is no element contained in the queue.
+ *
+ * @return the element with the highest priority.
+ */
+ def max: A = if (size > 1) array(1) else error("queue is empty")
+
+ /** Removes all elements from the queue. After this operation is completed,
+ * the queue will be empty.
+ */
+ def clear: Unit = { size = 1 }
+
+ /** Returns an iterator which yiels all the elements of the priority
+ * queue in descending priority order.
+ *
+ * @return an iterator over all elements sorted in descending order.
+ */
+ override def elements: Iterator[A] = new Iterator[A] {
+ val as: Array[A] = new Array[A](size)
+ Array.copy(array, 0, as, 0, size)
+ var i = size - 1
+ def hasNext: Boolean = i > 0
+ def next: A = {
+ val res = as(1)
+ as(1) = as(i)
+ i = i - 1
+ fixDown(as, 1, i)
+ res
}
+ }
+
+ /** Checks if two queues are structurally identical.
+ *
+ * @return true, iff both queues contain the same sequence of elements.
+ */
+ override def equals(that: Any): Boolean =
+ that.isInstanceOf[PriorityQueue[A]] &&
+ { val other = that.asInstanceOf[PriorityQueue[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.
+ *
+ * @return never.
+ */
+ override def hashCode(): Int = error("unsuitable as hash key")
+
+ /** Returns a regular queue containing the same elements.
+ */
+ def toQueue: Queue[A] = {
+ val res = new Queue[A]
+ res ++= this
+ res
+ }
+
+ /** Returns a textual representation of a queue as a string.
+ *
+ * @return the string representation of this queue.
+ */
+ override def toString() = toList.mkString("PriorityQueue(", ", ", ")")
+
+ /** This method clones the priority queue.
+ *
+ * @return a priority queue with the same elements.
+ */
+ override def clone(): PriorityQueue[A] = {
+ val res = new PriorityQueue[A]
+ res ++= this
+ res
+ }
}
diff --git a/src/library/scala/collection/mutable/PriorityQueueProxy.scala b/src/library/scala/collection/mutable/PriorityQueueProxy.scala
index 04340bd3b0..6bc810dc1e 100644
--- a/src/library/scala/collection/mutable/PriorityQueueProxy.scala
+++ b/src/library/scala/collection/mutable/PriorityQueueProxy.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This class implements priority queues using a heap. The
@@ -23,76 +23,78 @@ abstract class PriorityQueueProxy[A <% Ordered[A]] extends PriorityQueue[A]
with IterableProxy[A]
{
- def self: PriorityQueue[A];
+ def self: PriorityQueue[A]
/** Creates a new iterator over all elements contained in this
* object.
*
* @return the new iterator
*/
- override def elements: Iterator[A] = self.elements;
+ override def elements: Iterator[A] = self.elements
/** Returns the length of this priority queue.
*/
- override def length: Int = self.length;
+ override def length: Int = self.length
/** Checks if the queue is empty.
*
* @return true, iff there is no element in the queue.
*/
- override def isEmpty: Boolean = self.isEmpty;
+ override def isEmpty: Boolean = self.isEmpty
/** Inserts a single element into the priority queue.
*
* @param elem the element to insert
*/
- override def +=(elem: A): Unit = self += elem;
+ override def +=(elem: A): Unit = self += elem
/** Adds all elements provided by an <code>Iterable</code> object
* into the priority queue.
*
* @param iter an iterable object
*/
- override def ++=(iter: Iterable[A]): Unit = self ++= iter;
+ override def ++=(iter: Iterable[A]): Unit = self ++= iter
/** 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]): Unit = self ++= it
/** Adds all elements to the queue.
*
* @param elems the elements to add.
*/
- override def enqueue(elems: A*): Unit = self ++= elems;
+ override def enqueue(elems: A*): Unit = self ++= elems
/** Returns the element with the highest priority in the queue,
* and removes this element from the queue.
*
* @return the element with the highest priority.
*/
- override def dequeue: A = self.dequeue;
+ override def dequeue: A = self.dequeue
/** Returns the element with the highest priority in the queue,
* or throws an error if there is no element contained in the queue.
*
* @return the element with the highest priority.
*/
- override def max: A = self.max;
+ override def max: A = self.max
/** Removes all elements from the queue. After this operation is completed,
* the queue will be empty.
*/
- override def clear: Unit = self.clear;
+ override def clear: Unit = self.clear
/** Returns a regular queue containing the same elements.
*/
- override def toQueue: Queue[A] = self.toQueue;
+ override def toQueue: Queue[A] = self.toQueue
/** This method clones the priority queue.
*
* @return a priority queue with the same elements.
*/
- override def clone(): PriorityQueue[A] = new PriorityQueueProxy[A] { def self = PriorityQueueProxy.this.self.clone() }
+ override def clone(): PriorityQueue[A] = new PriorityQueueProxy[A] {
+ def self = PriorityQueueProxy.this.self.clone()
+ }
}
diff --git a/src/library/scala/collection/mutable/Publisher.scala b/src/library/scala/collection/mutable/Publisher.scala
index 602fd3213f..7e6e386fb8 100644
--- a/src/library/scala/collection/mutable/Publisher.scala
+++ b/src/library/scala/collection/mutable/Publisher.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** <code>Publisher[A,This]</code> objects publish events of type <code>A</code>
@@ -23,25 +23,26 @@ package scala.collection.mutable;
* @version 1.0, 08/07/2003
*/
trait Publisher[A, This <: Publisher[A, This]] requires This {
- private val filters = new HashMap[Subscriber[A, This],
- scala.collection.mutable.Set[A => Boolean]]
- with MultiMap[Subscriber[A, This], A => Boolean];
- private val suspended = new HashSet[Subscriber[A, This]];
+ private val filters = new HashMap[Subscriber[A, This],
+ scala.collection.mutable.Set[A => Boolean]]
+ with MultiMap[Subscriber[A, This], A => Boolean]
+ private val suspended = new HashSet[Subscriber[A, This]]
- def subscribe(sub: Subscriber[A, This]): Unit = subscribe(sub, (event => true));
+ def subscribe(sub: Subscriber[A, This]): Unit =
+ subscribe(sub, event => true)
- def subscribe(sub: Subscriber[A, This], filter: A => Boolean): Unit =
- filters.add(sub, filter);
+ def subscribe(sub: Subscriber[A, This], filter: A => Boolean): Unit =
+ filters.add(sub, filter)
- def suspendSubscription(sub: Subscriber[A, This]): Unit = suspended += sub;
+ def suspendSubscription(sub: Subscriber[A, This]): Unit = suspended += sub
- def activateSubscription(sub: Subscriber[A, This]): Unit = suspended -= sub;
+ def activateSubscription(sub: Subscriber[A, This]): Unit = suspended -= sub
- def removeSubscription(sub: Subscriber[A, This]): Unit = filters -= sub;
+ def removeSubscription(sub: Subscriber[A, This]): Unit = filters -= sub
- def removeSubscriptions: Unit = filters.clear;
+ def removeSubscriptions: Unit = filters.clear
- protected def publish(event: A): Unit =
- filters.keys.foreach(sub =>
- if (filters.entryExists(sub, (p => p(event)))) sub.notify(this, event));
+ protected def publish(event: A): Unit =
+ filters.keys.foreach(sub =>
+ if (filters.entryExists(sub, p => p(event))) sub.notify(this, event))
}
diff --git a/src/library/scala/collection/mutable/Queue.scala b/src/library/scala/collection/mutable/Queue.scala
index 3434041344..d1a769b7eb 100644
--- a/src/library/scala/collection/mutable/Queue.scala
+++ b/src/library/scala/collection/mutable/Queue.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** <code>Queue</code> objects implement data structures that allow to
@@ -21,176 +21,172 @@ package scala.collection.mutable;
[serializable, cloneable]
class Queue[A] extends MutableList[A] {
- /** Checks if the queue is empty.
- *
- * @return true, iff there is no element in the queue.
- */
- override def isEmpty: Boolean = (first == null);
-
- /** Inserts a single element at the end of the queue.
- *
- * @param elem the element to insert
- */
- def +=(elem: A): Unit = appendElem(elem);
-
- /** Adds all elements provided by an <code>Iterable</code> object
- * at the end of the queue. The elements are prepended in the order they
- * are given out by the iterator.
- *
- * @param iter an iterable object
- */
- def ++=(iter: Iterable[A]): Unit = this ++= iter.elements;
-
- /** Adds all elements provided by an iterator
- * at the end of the queue. The elements are prepended in the order they
- * are given out by the iterator.
- *
- * @param it an iterator
- */
- def ++=(it: Iterator[A]): Unit = it foreach appendElem;
-
- /** Adds all elements to the queue.
- *
- * @param elems the elements to add.
- */
- def enqueue(elems: A*): Unit = (this ++= elems);
-
- /** Returns the first element in the queue, and removes this element
- * from the queue.
- *
- * @return the first element of the queue.
- */
- def dequeue: A = {
- if (first == null)
- error("queue empty");
- else {
- val res = first.elem;
- first = first.next;
- if (first == null)
- last = null;
- len = len - 1;
- res;
- }
+ /** Checks if the queue is empty.
+ *
+ * @return true, iff there is no element in the queue.
+ */
+ override def isEmpty: Boolean = (first == null)
+
+ /** Inserts a single element at the end of the queue.
+ *
+ * @param elem the element to insert
+ */
+ def +=(elem: A): Unit = appendElem(elem)
+
+ /** Adds all elements provided by an <code>Iterable</code> object
+ * at the end of the queue. The elements are prepended in the order they
+ * are given out by the iterator.
+ *
+ * @param iter an iterable object
+ */
+ def ++=(iter: Iterable[A]): Unit = this ++= iter.elements
+
+ /** Adds all elements provided by an iterator
+ * at the end of the queue. The elements are prepended in the order they
+ * are given out by the iterator.
+ *
+ * @param it an iterator
+ */
+ def ++=(it: Iterator[A]): Unit = it foreach appendElem
+
+ /** Adds all elements to the queue.
+ *
+ * @param elems the elements to add.
+ */
+ def enqueue(elems: A*): Unit = (this ++= elems)
+
+ /** Returns the first element in the queue, and removes this element
+ * from the queue.
+ *
+ * @return the first element of the queue.
+ */
+ def dequeue: A =
+ if (first == null)
+ error("queue empty")
+ else {
+ val res = first.elem
+ first = first.next
+ if (first == null) last = null
+ len = len - 1
+ res
}
- /** Returns the first element in the queue which satisfies the
- * given predicate, and removes this element from the queue.
- *
- * @param p the predicate used for choosing the first element
- * @return the first element of the queue for which p yields true
- */
- def dequeueFirst(p: A => Boolean): Option[A] = {
- if (first == null)
- None
- else if (p(first.elem)) {
- val res: Option[A] = Some(first.elem);
- first = first.next;
- len = len - 1;
- if (first == null) {
- last = null;
- } else if (first.next == null) {
- last = first;
- }
- res
- } else
- extractFirst(first, p) match {
- case None => None
- case Some(cell) => Some(cell.elem)
- }
+ /** Returns the first element in the queue which satisfies the
+ * given predicate, and removes this element from the queue.
+ *
+ * @param p the predicate used for choosing the first element
+ * @return the first element of the queue for which p yields true
+ */
+ def dequeueFirst(p: A => Boolean): Option[A] =
+ if (first == null)
+ None
+ else if (p(first.elem)) {
+ val res: Option[A] = Some(first.elem)
+ first = first.next
+ len = len - 1
+ if (first == null) {
+ last = null
+ } else if (first.next == null) {
+ last = first
+ }
+ res
+ } else
+ extractFirst(first, p) match {
+ case None => None
+ case Some(cell) => Some(cell.elem)
+ }
+
+ /** Returns all elements in the queue which satisfy the
+ * given predicate, and removes those elements from the queue.
+ *
+ * @param p the predicate used for choosing elements
+ * @return a sequence of all elements in the queue for which
+ * p yields true.
+ */
+ def dequeueAll(p: A => Boolean): Seq[A] = {
+ val res = new ArrayBuffer[A]
+ if (first == null)
+ res
+ else {
+ while (p(first.elem)) {
+ res += first.elem
+ first = first.next
+ len = len - 1
+ if (first == null) {
+ last = null
+ } else if (first.next == null) {
+ last = first
+ }
+ }
+ var cell: Option[LinkedList[A]] = extractFirst(first, p)
+ while (!cell.isEmpty) {
+ res += cell.get.elem
+ cell = extractFirst(cell.get, p)
+ }
+ res
}
+ }
- /** Returns all elements in the queue which satisfy the
- * given predicate, and removes those elements from the queue.
- *
- * @param p the predicate used for choosing elements
- * @return a sequence of all elements in the queue for which
- * p yields true.
- */
- def dequeueAll(p: A => Boolean): Seq[A] = {
- val res = new ArrayBuffer[A];
- if (first == null)
- res;
- else {
- while (p(first.elem)) {
- res += first.elem;
- first = first.next;
- len = len - 1;
- if (first == null) {
- last = null;
- } else if (first.next == null) {
- last = first;
- }
- }
- var cell: Option[LinkedList[A]] = extractFirst(first, p);
- while (!cell.isEmpty) {
- res += cell.get.elem;
- cell = extractFirst(cell.get, p);
- }
- res
- }
+ private def extractFirst(start: LinkedList[A], p: A => Boolean): Option[LinkedList[A]] = {
+ var cell = start
+ while ((cell.next != null) && !p(cell.next.elem)) {
+ cell = cell.next
}
-
- private def extractFirst(start: LinkedList[A], p: A => Boolean): Option[LinkedList[A]] = {
- var cell = start;
- while ((cell.next != null) && !p(cell.next.elem)) {
- cell = cell.next;
- }
- if (cell.next == null)
- None
- else {
- val res: Option[LinkedList[A]] = Some(cell.next);
- cell.next = cell.next.next;
- if (cell.next == null)
- last = cell;
- len = len - 1;
- res
- }
- }
-
- /** Returns the first element in the queue, or throws an error if there
- * is no element contained in the queue.
- *
- * @return the first element.
- */
- def front: A = first.elem;
-
- /** Removes all elements from the queue. After this operation is completed,
- * the queue will be empty.
- */
- def clear: Unit = reset;
-
- /** Checks if two queues are structurally identical.
- *
- * @return true, iff both queues contain the same sequence of elements.
- */
- 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.
- *
- * @return never.
- */
- override def hashCode(): Int = error("unsuitable as hash key");
-
- /** Returns a textual representation of a queue as a string.
- *
- * @return the string representation of this queue.
- */
- override def toString() = toList.mkString("Queue(", ", ", ")");
-
- /** This method clones the queue.
- *
- * @return a queue with the same elements.
- */
- override def clone(): Queue[A] = {
- val res = new Queue[A];
- res ++= this;
- res
+ if (cell.next == null)
+ None
+ else {
+ val res: Option[LinkedList[A]] = Some(cell.next)
+ cell.next = cell.next.next
+ if (cell.next == null)
+ last = cell
+ len = len - 1
+ res
}
+ }
+
+ /** Returns the first element in the queue, or throws an error if there
+ * is no element contained in the queue.
+ *
+ * @return the first element.
+ */
+ def front: A = first.elem
+
+ /** Removes all elements from the queue. After this operation is completed,
+ * the queue will be empty.
+ */
+ def clear: Unit = reset
+
+ /** Checks if two queues are structurally identical.
+ *
+ * @return true, iff both queues contain the same sequence of elements.
+ */
+ 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.
+ *
+ * @return never.
+ */
+ override def hashCode(): Int = error("unsuitable as hash key")
+
+ /** Returns a textual representation of a queue as a string.
+ *
+ * @return the string representation of this queue.
+ */
+ override def toString() = toList.mkString("Queue(", ", ", ")")
+
+ /** This method clones the queue.
+ *
+ * @return a queue with the same elements.
+ */
+ override def clone(): Queue[A] = {
+ val res = new Queue[A]
+ res ++= this
+ res
+ }
}
diff --git a/src/library/scala/collection/mutable/QueueProxy.scala b/src/library/scala/collection/mutable/QueueProxy.scala
index 0b927cd5e1..21d3635241 100644
--- a/src/library/scala/collection/mutable/QueueProxy.scala
+++ b/src/library/scala/collection/mutable/QueueProxy.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** <code>Queue</code> objects implement data structures that allow to
@@ -20,80 +20,82 @@ package scala.collection.mutable;
*/
trait QueueProxy[A] extends Queue[A] with SeqProxy[A] {
- def self: Queue[A];
-
- /** Access element number <code>n</code>.
- *
- * @return the element at index <code>n</code>.
- */
- override def apply(n: Int): A = self.apply(n);
-
- /** Returns the length of this queue.
- */
- override def length: Int = self.length;
-
- /** Checks if the queue is empty.
- *
- * @return true, iff there is no element in the queue.
- */
- override def isEmpty: Boolean = self.isEmpty;
-
- /** Inserts a single element at the end of the queue.
- *
- * @param elem the element to insert
- */
- override def +=(elem: A): Unit = self += elem;
-
- /** Adds all elements provided by an <code>Iterable</code> object
- * at the end of the queue. The elements are prepended in the order they
- * are given out by the iterator.
- *
- * @param iter an iterable object
- */
- override def ++=(iter: Iterable[A]): Unit = self ++= iter;
-
- /** Adds all elements provided by an iterator
- * at the end of the queue. The elements are prepended in the order they
- * are given out by the iterator.
- *
- * @param iter an iterator
- */
- override def ++=(it: Iterator[A]): Unit = self ++= it;
-
- /** Adds all elements to the queue.
- *
- * @param elems the elements to add.
- */
- override def enqueue(elems: A*): Unit = self ++= elems;
-
- /** Returns the first element in the queue, and removes this element
- * from the queue.
- *
- * @return the first element of the queue.
- */
- override def dequeue: A = self.dequeue;
-
- /** Returns the first element in the queue, or throws an error if there
- * is no element contained in the queue.
- *
- * @return the first element.
- */
- override def front: A = self.front;
-
- /** Removes all elements from the queue. After this operation is completed,
- * the queue will be empty.
- */
- override def clear: Unit = self.clear;
-
- /** Returns an iterator over all elements on the queue.
- *
- * @return an iterator over all queue elements.
- */
- override def elements: Iterator[A] = self.elements;
-
- /** This method clones the queue.
- *
- * @return a queue with the same elements.
- */
- override def clone(): Queue[A] = new QueueProxy[A] { def self = QueueProxy.this.self.clone() }
+ def self: Queue[A]
+
+ /** Access element number <code>n</code>.
+ *
+ * @return the element at index <code>n</code>.
+ */
+ override def apply(n: Int): A = self.apply(n)
+
+ /** Returns the length of this queue.
+ */
+ override def length: Int = self.length
+
+ /** Checks if the queue is empty.
+ *
+ * @return true, iff there is no element in the queue.
+ */
+ override def isEmpty: Boolean = self.isEmpty
+
+ /** Inserts a single element at the end of the queue.
+ *
+ * @param elem the element to insert
+ */
+ override def +=(elem: A): Unit = self += elem
+
+ /** Adds all elements provided by an <code>Iterable</code> object
+ * at the end of the queue. The elements are prepended in the order they
+ * are given out by the iterator.
+ *
+ * @param iter an iterable object
+ */
+ override def ++=(iter: Iterable[A]): Unit = self ++= iter
+
+ /** Adds all elements provided by an iterator
+ * at the end of the queue. The elements are prepended in the order they
+ * are given out by the iterator.
+ *
+ * @param iter an iterator
+ */
+ override def ++=(it: Iterator[A]): Unit = self ++= it
+
+ /** Adds all elements to the queue.
+ *
+ * @param elems the elements to add.
+ */
+ override def enqueue(elems: A*): Unit = self ++= elems
+
+ /** Returns the first element in the queue, and removes this element
+ * from the queue.
+ *
+ * @return the first element of the queue.
+ */
+ override def dequeue: A = self.dequeue
+
+ /** Returns the first element in the queue, or throws an error if there
+ * is no element contained in the queue.
+ *
+ * @return the first element.
+ */
+ override def front: A = self.front
+
+ /** Removes all elements from the queue. After this operation is completed,
+ * the queue will be empty.
+ */
+ override def clear: Unit = self.clear
+
+ /** Returns an iterator over all elements on the queue.
+ *
+ * @return an iterator over all queue elements.
+ */
+ override def elements: Iterator[A] = self.elements
+
+ /** This method clones the queue.
+ *
+ * @return a queue with the same elements.
+ */
+ override def clone(): Queue[A] = new QueueProxy[A] {
+ def self = QueueProxy.this.self.clone()
+ }
}
diff --git a/src/library/scala/collection/mutable/ResizableArray.scala b/src/library/scala/collection/mutable/ResizableArray.scala
index 7ff15eb5cb..97599617ab 100644
--- a/src/library/scala/collection/mutable/ResizableArray.scala
+++ b/src/library/scala/collection/mutable/ResizableArray.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This class is used internally to implement data structures that
@@ -19,61 +19,59 @@ package scala.collection.mutable;
* @version 1.0, 03/05/2004
*/
trait ResizableArray[A] extends Seq[A] {
- import scala.runtime.compat.Platform.arraycopy;
+ import scala.runtime.compat.Platform.arraycopy
- protected val initialSize: Int = 16;
- protected var array: Array[A] = new Array[A](initialSize);
- protected var size: Int = 0;
+ protected val initialSize: Int = 16
+ protected var array: Array[A] = new Array[A](initialSize)
+ protected var size: Int = 0
//##########################################################################
// implement/override methods of Seq[A]
- /** Returns the length of this resizable array.
- */
- def length: Int = size;
+ /** Returns the length of this resizable array.
+ */
+ def length: Int = size
- def apply(i: Int) = array(i)
+ def apply(i: Int) = array(i)
- override def toArray[B >: A]: Array[B] = {
- val narr = new Array[B](size);
- arraycopy(array, 0, narr, 0, size);
- narr
- }
+ override def toArray[B >: A]: Array[B] = {
+ val narr = new Array[B](size)
+ arraycopy(array, 0, narr, 0, size)
+ narr
+ }
- /** Returns a new iterator over all elements of this resizable array.
- */
- def elements: Iterator[A] = new Iterator[A] {
- var i = 0;
- def hasNext: Boolean = i < size;
- def next: A = { i = i + 1; array(i - 1) }
- }
+ /** Returns a new iterator over all elements of this resizable array.
+ */
+ def elements: Iterator[A] = new Iterator[A] {
+ var i = 0
+ def hasNext: Boolean = i < size
+ def next: A = { i = i + 1; array(i - 1) }
+ }
//##########################################################################
- /** ensure that the internal array has at n cells */
- protected def ensureSize(n: Int): Unit = {
- if (n > array.length) {
- var newsize = array.length * 2;
- while( n > newsize )
- newsize = newsize * 2;
- val newar: Array[A] = new Array(newsize);
- arraycopy(array, 0, newar, 0, size);
- array = newar;
- }
+ /** ensure that the internal array has at n cells */
+ protected def ensureSize(n: Int): Unit =
+ if (n > array.length) {
+ var newsize = array.length * 2
+ while (n > newsize)
+ newsize = newsize * 2
+ val newar: Array[A] = new Array(newsize)
+ arraycopy(array, 0, newar, 0, size)
+ array = newar
}
- /** Swap two elements of this array.
- */
- protected def swap(a: Int, b: Int): Unit = {
- val h = array(a);
- array(a) = array(b);
- array(b) = h;
- }
-
- /** Move parts of the array.
- */
- protected def copy(m: Int, n: Int, len: Int) = {
- arraycopy(array, m, array, n, len);
- }
+ /** Swap two elements of this array.
+ */
+ protected def swap(a: Int, b: Int): Unit = {
+ val h = array(a)
+ array(a) = array(b)
+ array(b) = h
+ }
+
+ /** Move parts of the array.
+ */
+ protected def copy(m: Int, n: Int, len: Int) =
+ arraycopy(array, m, array, n, len)
}
diff --git a/src/library/scala/collection/mutable/RevertableHistory.scala b/src/library/scala/collection/mutable/RevertableHistory.scala
index c285d6c888..9ad19dedc7 100644
--- a/src/library/scala/collection/mutable/RevertableHistory.scala
+++ b/src/library/scala/collection/mutable/RevertableHistory.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** A revertable history is a <code>History</code> object which supports
@@ -23,11 +23,11 @@ package scala.collection.mutable;
[serializable]
class RevertableHistory[A <: Undoable, B] extends History[A, B] with Undoable {
- /** Rollback the full history.
- */
- def undo: Unit = {
- val old = log.toList.reverse;
- clear;
- old.foreach { case Pair(sub, event) => event.undo; }
- }
+ /** Rollback the full history.
+ */
+ def undo: Unit = {
+ val old = log.toList.reverse
+ clear
+ old.foreach { case Pair(sub, event) => event.undo }
+ }
}
diff --git a/src/library/scala/collection/mutable/Scriptable.scala b/src/library/scala/collection/mutable/Scriptable.scala
index 9a09606075..313450ce6d 100644
--- a/src/library/scala/collection/mutable/Scriptable.scala
+++ b/src/library/scala/collection/mutable/Scriptable.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** Classes that mix in the <code>Scriptable</code> class allow
@@ -22,5 +22,5 @@ trait Scriptable[A] {
/** Send a message to this scriptable object.
*/
- def <<(cmd: A): Unit;
+ def <<(cmd: A): Unit
}
diff --git a/src/library/scala/collection/mutable/Set.scala b/src/library/scala/collection/mutable/Set.scala
index 0e3eeed654..86b6268dcd 100644
--- a/src/library/scala/collection/mutable/Set.scala
+++ b/src/library/scala/collection/mutable/Set.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This class represents mutable sets. Concrete set implementations
* just have to provide functionality for the abstract methods in
@@ -24,91 +24,104 @@ trait Set[A] extends AnyRef with collection.Set[A]
with Scriptable[Message[A]]
{
- /** This method allows one to add or remove an element <code>elem</code>
- * from this set depending on the value of parameter <code>included</code>.
- * Typically, one would use the following syntax:
- * <pre>set(elem) = true</pre>
- */
- def update(elem: A, included: Boolean): Unit =
- if (included) +=(elem) else -=(elem);
-
- /** This method adds a new element to the set.
- */
- def +=(elem: A): Unit;
-
- /** This method will add all the elements provided by an iterator
- * of the iterable object <code>that</code> to the set.
- */
- def ++=(that: Iterable[A]): Unit = ++=(that.elements);
-
- /** This method will add all the elements provided by an iterator
- * of the iterable object <code>that</code> to the set.
- */
- def ++=(it: Iterator[A]): Unit = it foreach +=;
-
- /** <code>incl</code> can be used to add many elements to the set
- * at the same time.
- */
- def incl(elems: A*): Unit = ++=(elems.elements);
-
- /** <code>-=</code> can be used to remove a single element from
- * a set.
- */
- def -=(elem: A): Unit;
-
- /** This method removes all the elements provided by the
- * the iterable object <code>that</code> from the set.
- */
- def --=(that: Iterable[A]): Unit = --=(that.elements);
-
- /** This method removes all the elements provided by an iterator
- * <code>it</code> from the set.
- */
- def --=(it: Iterator[A]): Unit = it foreach -=;
-
- /** <code>excl</code> removes many elements from the set.
- */
- def excl(elems: A*): Unit = --=(elems.elements);
-
- /** This method computes an intersection with set <code>that</code>.
- * It removes all the elements that are not present in <code>that</code>.
- */
- def intersect(that: Set[A]): Unit = filter(that.contains);
-
- /** Method <code>filter</code> removes all elements from the set for
- * which the predicate <code>p</code> yields the value <code>false</code>.
- */
- def filter(p: A => Boolean): Unit = toList.foreach {
- elem => if (!p(elem)) -=(elem);
- }
-
- /** Removes all elements from the set. After this operation is completed,
- * the set will be empty.
- */
- def clear: Unit;
-
- /** Send a message to this scriptable object.
- *
- * @param cmd the message to send.
- */
- def <<(cmd: Message[A]): Unit = cmd match {
- case Include(elem) => this += elem;
- case Remove(elem) => this -= elem;
- case Reset() => clear;
- case s: Script[A] => s.elements foreach <<;
- case _ => error("message " + cmd + " not understood");
- }
-
- /** Return a clone of this set.
- *
- * @return a set with the same elements.
- */
- override def clone(): Set[A] = super.clone().asInstanceOf[Set[A]];
-
- /** The hashCode method always yields an error, since it is not
- * safe to use mutable stacks as keys in hash tables.
- *
- * @return never.
- */
- override def hashCode(): Int = error("unsuitable as hash key");
+ /** This method allows one to add or remove an element <code>elem</code>
+ * from this set depending on the value of parameter <code>included</code>.
+ * Typically, one would use the following syntax:
+ * <pre>set(elem) = true</pre>
+ *
+ * @param elem ...
+ * @param included ...
+ */
+ def update(elem: A, included: Boolean): Unit =
+ if (included) +=(elem) else -=(elem)
+
+ /** This method adds a new element to the set.
+ *
+ * @param elem ...
+ */
+ def +=(elem: A): Unit
+
+ /** This method will add all the elements provided by an iterator
+ * of the iterable object <code>that</code> to the set.
+ *
+ * @param that ...
+ */
+ def ++=(that: Iterable[A]): Unit = ++=(that.elements);
+
+ /** This method will add all the elements provided by an iterator
+ * of the iterable object <code>that</code> to the set.
+ *
+ * @param it ...
+ */
+ def ++=(it: Iterator[A]): Unit = it foreach +=
+
+ /** <code>incl</code> can be used to add many elements to the set
+ * at the same time.
+ *
+ * @param elems ...
+ */
+ def incl(elems: A*): Unit = ++=(elems.elements)
+
+ /** <code>-=</code> can be used to remove a single element from
+ * a set.
+ */
+ def -=(elem: A): Unit
+
+ /** This method removes all the elements provided by the
+ * the iterable object <code>that</code> from the set.
+ */
+ def --=(that: Iterable[A]): Unit = --=(that.elements)
+
+ /** This method removes all the elements provided by an iterator
+ * <code>it</code> from the set.
+ */
+ def --=(it: Iterator[A]): Unit = it foreach -=
+
+ /** <code>excl</code> removes many elements from the set.
+ */
+ def excl(elems: A*): Unit = --=(elems.elements)
+
+ /** This method computes an intersection with set <code>that</code>.
+ * It removes all the elements that are not present in <code>that</code>.
+ *
+ * @param that ...
+ */
+ def intersect(that: Set[A]): Unit = filter(that.contains)
+
+ /** Method <code>filter</code> removes all elements from the set for
+ * which the predicate <code>p</code> yields the value <code>false</code>.
+ */
+ def filter(p: A => Boolean): Unit = toList.foreach {
+ elem => if (!p(elem)) -=(elem)
+ }
+
+ /** Removes all elements from the set. After this operation is completed,
+ * the set will be empty.
+ */
+ def clear: Unit
+
+ /** Send a message to this scriptable object.
+ *
+ * @param cmd the message to send.
+ */
+ def <<(cmd: Message[A]): Unit = cmd match {
+ case Include(elem) => this += elem
+ case Remove(elem) => this -= elem
+ case Reset() => clear
+ case s: Script[A] => s.elements foreach <<
+ case _ => error("message " + cmd + " not understood")
+ }
+
+ /** Return a clone of this set.
+ *
+ * @return a set with the same elements.
+ */
+ override def clone(): Set[A] = super.clone().asInstanceOf[Set[A]]
+
+ /** The hashCode method always yields an error, since it is not
+ * safe to use mutable stacks as keys in hash tables.
+ *
+ * @return never.
+ */
+ override def hashCode(): Int = error("unsuitable as hash key")
}
diff --git a/src/library/scala/collection/mutable/SetProxy.scala b/src/library/scala/collection/mutable/SetProxy.scala
index e3745b6371..8356b4b0ba 100644
--- a/src/library/scala/collection/mutable/SetProxy.scala
+++ b/src/library/scala/collection/mutable/SetProxy.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This is a simple wrapper class for <code>scala.collection.mutable.Set</code>.
@@ -21,33 +21,35 @@ package scala.collection.mutable;
*/
trait SetProxy[A] extends Set[A] with collection.SetProxy[A] {
- def self: Set[A];
+ def self: Set[A]
- override def update(elem: A, included: Boolean): Unit = self(elem) = included;
+ override def update(elem: A, included: Boolean): Unit = self(elem) = included
- def +=(elem: A): Unit = self += elem;
+ def +=(elem: A): Unit = self += elem
- override def ++=(that: Iterable[A]): Unit = self ++= that;
+ override def ++=(that: Iterable[A]): Unit = self ++= that
- override def ++=(it: Iterator[A]): Unit = self ++= it;
+ override def ++=(it: Iterator[A]): Unit = self ++= it
- override def incl(elems: A*): Unit = self ++= elems;
+ override def incl(elems: A*): Unit = self ++= elems
- def -=(elem: A): Unit = self -= elem;
+ def -=(elem: A): Unit = self -= elem
- override def --=(that: Iterable[A]): Unit = self --= that;
+ override def --=(that: Iterable[A]): Unit = self --= that
- override def --=(it: Iterator[A]): Unit = self --= it;
+ override def --=(it: Iterator[A]): Unit = self --= it
- override def excl(elems: A*): Unit = self --= elems;
+ override def excl(elems: A*): Unit = self --= elems
- override def intersect(that: Set[A]): Unit = self.intersect(that);
+ override def intersect(that: Set[A]): Unit = self.intersect(that)
- def clear: Unit = self.clear;
+ def clear: Unit = self.clear
- override def filter(p: A => Boolean): Unit = self.filter(p);
+ override def filter(p: A => Boolean): Unit = self.filter(p)
- override def <<(cmd: Message[A]): Unit = self << cmd;
+ override def <<(cmd: Message[A]): Unit = self << cmd
- override def clone(): Set[A] = new SetProxy[A] { def self = SetProxy.this.self.clone() }
+ override def clone(): Set[A] = new SetProxy[A] {
+ def self = SetProxy.this.self.clone()
+ }
}
diff --git a/src/library/scala/collection/mutable/SingleLinkedList.scala b/src/library/scala/collection/mutable/SingleLinkedList.scala
index 7569dfd49d..d25de421ef 100644
--- a/src/library/scala/collection/mutable/SingleLinkedList.scala
+++ b/src/library/scala/collection/mutable/SingleLinkedList.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This extensible class may be used as a basis for implementing linked
* list. Type variable <code>A</code> refers to the element type of the
@@ -24,42 +24,40 @@ abstract class SingleLinkedList[A, This >: Null <: SingleLinkedList[A, This]]
extends AnyRef with Seq[A]
{
- var elem: A;
+ var elem: A
- var next: This;
+ var next: This
- def length: Int = 1 + (if (next == null) 0 else next.length);
+ def length: Int = 1 + (if (next == null) 0 else next.length)
- def append(that: This): Unit =
- if (next == null) { next = that; } else next.append(that);
+ def append(that: This): Unit =
+ if (next == null) next = that else next.append(that)
- def insert(that: This): Unit = if (that != null) {
- that.append(next);
- next = that;
- }
+ def insert(that: This): Unit = if (that != null) {
+ that.append(next)
+ next = that
+ }
- def apply(n: Int): A = {
- if (n == 0) elem
- else if (next == null) error("unknown element")
- else next.apply(n - 1);
- }
+ def apply(n: Int): A =
+ if (n == 0) elem
+ else if (next == null) error("unknown element")
+ else next.apply(n - 1)
- def get(n: Int): Option[A] = {
- if (n == 0) Some(elem)
- else if (next == null) None
- else next.get(n - 1);
- }
+ def get(n: Int): Option[A] =
+ if (n == 0) Some(elem)
+ else if (next == null) None
+ else next.get(n - 1)
- def elements: Iterator[A] = new Iterator[A] {
- var elems = SingleLinkedList.this;
- def hasNext = (elems != null);
- def next = {
- val res = elems.elem;
- elems = elems.next;
- res;
- }
+ def elements: Iterator[A] = new Iterator[A] {
+ var elems = SingleLinkedList.this
+ def hasNext = (elems != null)
+ def next = {
+ val res = elems.elem
+ elems = elems.next
+ res;
}
+ }
- override def toList: List[A] = elements toList;
+ override def toList: List[A] = elements toList
}
diff --git a/src/library/scala/collection/mutable/Stack.scala b/src/library/scala/collection/mutable/Stack.scala
index 99e425bda4..c33f85d447 100644
--- a/src/library/scala/collection/mutable/Stack.scala
+++ b/src/library/scala/collection/mutable/Stack.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** A stack implements a data structure which allows to store and retrieve
* objects in a last-in-first-out (LIFO) fashion.
@@ -20,110 +20,109 @@ package scala.collection.mutable;
[serializable, cloneable]
class Stack[A] extends MutableList[A] {
- /** Checks if the stack is empty.
- *
- * @return true, iff there is no element on the stack
- */
- override def isEmpty: Boolean = (first == null);
-
- /** Pushes a single element on top of the stack.
- *
- * @param elem the element to push onto the stack
- */
- def +=(elem: A): Unit = prependElem(elem);
-
- /** Pushes all elements provided by an <code>Iterable</code> object
- * on top of the stack. The elements are pushed in the order they
- * are given out by the iterator.
- *
- * @param iter an iterable object
- */
- def ++=(iter: Iterable[A]): Unit = this ++= iter.elements;
-
- /** Pushes all elements provided by an iterator
- * on top of the stack. The elements are pushed in the order they
- * are given out by the iterator.
- *
- * @param iter an iterator
- */
- def ++=(it: Iterator[A]): Unit = it foreach { e => prependElem(e) };
-
- /** Pushes a sequence of elements on top of the stack. The first element
- * is pushed first, etc.
- *
- * @param elems a sequence of elements
- */
- def push(elems: A*): Unit = (this ++= elems);
-
- /** 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
- * element on the stack.
- *
- * @return the top element
- */
- def top: A = if (first == null) error("stack empty"); else first.elem;
-
- /** Removes the top element from the stack.
- */
- def pop: A =
- if (first != null) {
- val res = first.elem;
- first = first.next;
- len = len - 1;
- res
- } else
- error("stack empty");
-
- /**
- * Removes all elements from the stack. After this operation completed,
- * the stack will be empty.
- */
- def clear: Unit = reset;
-
- /** Returns an iterator over all elements on the stack. This iterator
- * is stable with respect to state changes in the stack object; i.e.
- * such changes will not be reflected in the iterator. The iterator
- * issues elements in the order they were inserted into the stack
- * (FIFO order).
- *
- * @return an iterator over all stack elements.
- */
- override def elements: Iterator[A] = toList.elements;
-
- /** Creates a list of all stack elements in FIFO order.
- *
- * @return the created list.
- */
- override def toList: List[A] = super[MutableList].toList.reverse;
-
- /** Checks if two stacks are structurally identical.
- *
- * @return true, iff both stacks contain the same sequence of elements.
- */
- 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;
- }}
- );
-
- /** The hashCode method always yields an error, since it is not
- * safe to use mutable stacks as keys in hash tables.
- *
- * @return never.
- */
- override def hashCode(): Int = error("unsuitable as hash key");
-
- /** This method clones the stack.
- *
- * @return a stack with the same elements.
- */
- override def clone(): Stack[A] = {
- val res = new Stack[A];
- res ++= this;
- res
- }
-
- override protected def stringPrefix: String = "Stack"
+ /** Checks if the stack is empty.
+ *
+ * @return true, iff there is no element on the stack
+ */
+ override def isEmpty: Boolean = (first == null)
+
+ /** Pushes a single element on top of the stack.
+ *
+ * @param elem the element to push onto the stack
+ */
+ def +=(elem: A): Unit = prependElem(elem)
+
+ /** Pushes all elements provided by an <code>Iterable</code> object
+ * on top of the stack. The elements are pushed in the order they
+ * are given out by the iterator.
+ *
+ * @param iter an iterable object
+ */
+ def ++=(iter: Iterable[A]): Unit = this ++= iter.elements
+
+ /** Pushes all elements provided by an iterator
+ * on top of the stack. The elements are pushed in the order they
+ * are given out by the iterator.
+ *
+ * @param iter an iterator
+ */
+ def ++=(it: Iterator[A]): Unit = it foreach { e => prependElem(e) }
+
+ /** Pushes a sequence of elements on top of the stack. The first element
+ * is pushed first, etc.
+ *
+ * @param elems a sequence of elements
+ */
+ def push(elems: A*): Unit = (this ++= elems)
+
+ /** 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
+ * element on the stack.
+ *
+ * @return the top element
+ */
+ def top: A = if (first == null) error("stack empty") else first.elem
+
+ /** Removes the top element from the stack.
+ */
+ def pop: A =
+ if (first != null) {
+ val res = first.elem
+ first = first.next
+ len = len - 1;
+ res
+ } else
+ error("stack empty")
+
+ /**
+ * Removes all elements from the stack. After this operation completed,
+ * the stack will be empty.
+ */
+ def clear: Unit = reset
+
+ /** Returns an iterator over all elements on the stack. This iterator
+ * is stable with respect to state changes in the stack object; i.e.
+ * such changes will not be reflected in the iterator. The iterator
+ * issues elements in the order they were inserted into the stack
+ * (FIFO order).
+ *
+ * @return an iterator over all stack elements.
+ */
+ override def elements: Iterator[A] = toList.elements
+
+ /** Creates a list of all stack elements in FIFO order.
+ *
+ * @return the created list.
+ */
+ override def toList: List[A] = super[MutableList].toList.reverse
+
+ /** Checks if two stacks are structurally identical.
+ *
+ * @return true, iff both stacks contain the same sequence of elements.
+ */
+ 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
+ }}
+
+ /** The hashCode method always yields an error, since it is not
+ * safe to use mutable stacks as keys in hash tables.
+ *
+ * @return never.
+ */
+ override def hashCode(): Int = error("unsuitable as hash key")
+
+ /** This method clones the stack.
+ *
+ * @return a stack with the same elements.
+ */
+ override def clone(): Stack[A] = {
+ val res = new Stack[A]
+ res ++= this
+ res
+ }
+
+ override protected def stringPrefix: String = "Stack"
}
diff --git a/src/library/scala/collection/mutable/StackProxy.scala b/src/library/scala/collection/mutable/StackProxy.scala
index 10fd038887..f48d186b50 100644
--- a/src/library/scala/collection/mutable/StackProxy.scala
+++ b/src/library/scala/collection/mutable/StackProxy.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** A stack implements a data structure which allows to store and retrieve
@@ -20,91 +20,92 @@ package scala.collection.mutable;
*/
trait StackProxy[A] extends Stack[A] with SeqProxy[A] {
- def self: Stack[A];
-
- /** Access element number <code>n</code>.
- *
- * @return the element at index <code>n</code>.
- */
- override def apply(n: Int): A = self.apply(n);
-
- /** Returns the length of this stack.
- */
- override def length: Int = self.length;
-
- /** Checks if the stack is empty.
- *
- * @return true, iff there is no element on the stack
- */
- override def isEmpty: Boolean = self.isEmpty;
-
- /** Pushes a single element on top of the stack.
- *
- * @param elem the element to push onto the stack
- */
- override def +=(elem: A): Unit = self += elem;
-
- /** Pushes all elements provided by an <code>Iterable</code> object
- * on top of the stack. The elements are pushed in the order they
- * are given out by the iterator.
- *
- * @param iter an iterable object
- */
- override def ++=(iter: Iterable[A]): Unit = self ++= iter;
-
-
- /** Pushes all elements provided by an iterator
- * on top of the stack. The elements are pushed in the order they
- * are given out by the iterator.
- *
- * @param iter an iterator
- */
- override def ++=(it: Iterator[A]): Unit = self ++= it;
-
- /** 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;
-
- /** 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
- * element on the stack.
- *
- * @return the top element
- */
- override def top: A = self.top;
-
- /** Removes the top element from the stack.
- */
- override def pop: A = self.pop;
-
- /**
- * Removes all elements from the stack. After this operation completed,
- * the stack will be empty.
- */
- override def clear: Unit = self.clear;
-
- /** Returns an iterator over all elements on the stack. This iterator
- * is stable with respect to state changes in the stack object; i.e.
- * such changes will not be reflected in the iterator. The iterator
- * issues elements in the order they were inserted into the stack
- * (FIFO order).
- *
- * @return an iterator over all stack elements.
- */
- override def elements: Iterator[A] = self.elements;
-
- /** Creates a list of all stack elements in FIFO order.
- *
- * @return the created list.
- */
- override def toList: List[A] = self.toList;
-
- /** This method clones the stack.
- *
- * @return a stack with the same elements.
- */
- override def clone(): Stack[A] = new StackProxy[A] { def self = StackProxy.this.self.clone() }
+ def self: Stack[A]
+
+ /** Access element number <code>n</code>.
+ *
+ * @return the element at index <code>n</code>.
+ */
+ override def apply(n: Int): A = self.apply(n)
+
+ /** Returns the length of this stack.
+ */
+ override def length: Int = self.length
+
+ /** Checks if the stack is empty.
+ *
+ * @return true, iff there is no element on the stack
+ */
+ override def isEmpty: Boolean = self.isEmpty
+
+ /** Pushes a single element on top of the stack.
+ *
+ * @param elem the element to push onto the stack
+ */
+ override def +=(elem: A): Unit = self += elem
+
+ /** Pushes all elements provided by an <code>Iterable</code> object
+ * on top of the stack. The elements are pushed in the order they
+ * are given out by the iterator.
+ *
+ * @param iter an iterable object
+ */
+ override def ++=(iter: Iterable[A]): Unit = self ++= iter
+
+ /** Pushes all elements provided by an iterator
+ * on top of the stack. The elements are pushed in the order they
+ * are given out by the iterator.
+ *
+ * @param iter an iterator
+ */
+ override def ++=(it: Iterator[A]): Unit = self ++= it
+
+ /** 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
+
+ /** 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
+ * element on the stack.
+ *
+ * @return the top element
+ */
+ override def top: A = self.top
+
+ /** Removes the top element from the stack.
+ */
+ override def pop: A = self.pop
+
+ /**
+ * Removes all elements from the stack. After this operation completed,
+ * the stack will be empty.
+ */
+ override def clear: Unit = self.clear
+
+ /** Returns an iterator over all elements on the stack. This iterator
+ * is stable with respect to state changes in the stack object; i.e.
+ * such changes will not be reflected in the iterator. The iterator
+ * issues elements in the order they were inserted into the stack
+ * (FIFO order).
+ *
+ * @return an iterator over all stack elements.
+ */
+ override def elements: Iterator[A] = self.elements
+
+ /** Creates a list of all stack elements in FIFO order.
+ *
+ * @return the created list.
+ */
+ override def toList: List[A] = self.toList
+
+ /** This method clones the stack.
+ *
+ * @return a stack with the same elements.
+ */
+ override def clone(): Stack[A] = new StackProxy[A] {
+ def self = StackProxy.this.self.clone()
+ }
}
diff --git a/src/library/scala/collection/mutable/Subscriber.scala b/src/library/scala/collection/mutable/Subscriber.scala
index 8cd7e0af05..330a5a2c22 100644
--- a/src/library/scala/collection/mutable/Subscriber.scala
+++ b/src/library/scala/collection/mutable/Subscriber.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** <code>Subscriber[A, B]</code> objects may subscribe to events of
@@ -20,5 +20,5 @@ package scala.collection.mutable;
* @version 1.0, 08/07/2003
*/
trait Subscriber[-A, -B] {
- def notify(pub: B, event: A): Unit;
+ def notify(pub: B, event: A): Unit
}
diff --git a/src/library/scala/collection/mutable/SynchronizedBuffer.scala b/src/library/scala/collection/mutable/SynchronizedBuffer.scala
index 6a7defb413..fc37575bac 100644
--- a/src/library/scala/collection/mutable/SynchronizedBuffer.scala
+++ b/src/library/scala/collection/mutable/SynchronizedBuffer.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This class should be used as a mixin. It synchronizes the <code>Buffer</code>
@@ -20,172 +20,172 @@ package scala.collection.mutable;
*/
trait SynchronizedBuffer[A] extends Buffer[A] {
- abstract override def length: Int = synchronized {
- super.length;
- }
-
- abstract override def elements: Iterator[A] = synchronized {
- super.elements;
- }
-
- abstract override def apply(n: Int): A = synchronized {
- super.apply(n);
- }
-
- /** Append a single element to this buffer and return
- * the identity of the buffer.
- *
- * @param elem the element to append.
- */
- override def +(elem: A): Buffer[A] = synchronized {
- super.+(elem);
- }
-
- /** Append a single element to this buffer.
- *
- * @param elem the element to append.
- */
- abstract override def +=(elem: A): Unit = synchronized {
- super.+=(elem);
- }
-
- /** Appends a number of elements provided by an iterable object
- * via its <code>elements</code> method. The identity of the
- * buffer is returned.
- *
- * @param iter the iterable object.
- */
- override def ++(iter: Iterable[A]): Buffer[A] = synchronized {
- super.++(iter);
- }
-
- /** Appends a number of elements provided by an iterable object
- * via its <code>elements</code> method.
- *
- * @param iter the iterable object.
- */
- override def ++=(iter: Iterable[A]): Unit = synchronized {
- super.++=(iter);
- }
-
- /** Appends a sequence of elements to this buffer.
- *
- * @param elems the elements to append.
- */
- override def append(elems: A*): Unit = synchronized {
- super.++=(elems);
- }
-
- /** Appends a number of elements provided by an iterable object
- * via its <code>elements</code> method.
- *
- * @param iter the iterable object.
- */
- override def appendAll(iter: Iterable[A]): Unit = synchronized {
- super.appendAll(iter);
- }
-
- /** Prepend a single element to this buffer and return
- * the identity of the buffer.
- *
- * @param elem the element to append.
- */
- abstract override def +:(elem: A): Buffer[A] = synchronized {
- super.+:(elem);
- }
-
- /** Prepends a number of elements provided by an iterable object
- * via its <code>elements</code> method. The identity of the
- * buffer is returned.
- *
- * @param iter the iterable object.
- */
- override def ++:(iter: Iterable[A]): Buffer[A] = synchronized {
- super.++:(iter);
- }
-
- /** Prepend an element to this list.
- *
- * @param elem the element to prepend.
- */
- override def prepend(elems: A*): Unit = synchronized {
- super.prependAll(elems);
- }
-
- /** Prepends a number of elements provided by an iterable object
- * via its <code>elements</code> method. The identity of the
- * buffer is returned.
- *
- * @param iter the iterable object.
- */
- override def prependAll(elems: Iterable[A]): Unit = synchronized {
- super.prependAll(elems);
- }
-
- /** Inserts new elements at the index <code>n</code>. Opposed to method
- * <code>update</code>, this method will not replace an element with a
- * one. Instead, it will insert the new elements at index <code>n</code>.
- *
- * @param n the index where a new element will be inserted.
- * @param elems the new elements to insert.
- */
- override def insert(n: Int, elems: A*): Unit = synchronized {
- super.insertAll(n, elems);
- }
-
- /** Inserts new elements at the index <code>n</code>. Opposed to method
- * <code>update</code>, this method will not replace an element with a
- * one. Instead, it will insert a new element at index <code>n</code>.
- *
- * @param n the index where a new element will be inserted.
- * @param iter the iterable object providing all elements to insert.
- */
- abstract override def insertAll(n: Int, iter: Iterable[A]): Unit = synchronized {
- super.insertAll(n, iter);
- }
-
- /** Replace element at index <code>n</code> with the new element
- * <code>newelem</code>.
- *
- * @param n the index of the element to replace.
- * @param newelem the new element.
- */
- abstract override def update(n: Int, newelem: A): Unit = synchronized {
- super.update(n, newelem);
- }
-
- /** Removes the element on a given index position.
- *
- * @param n the index which refers to the element to delete.
- */
- abstract override def remove(n: Int): A = synchronized {
- super.remove(n);
- }
-
- /** Clears the buffer contents.
- */
- abstract override def clear: Unit = synchronized {
- super.clear;
- }
-
- override def <<(cmd: Message[Pair[Location, A]]): Unit = synchronized {
- super.<<(cmd);
- }
-
- /** Return a clone of this buffer.
- *
- * @return an <code>ArrayBuffer</code> with the same elements.
- */
- override def clone(): Buffer[A] = synchronized {
- super.clone();
- }
-
- /** The hashCode method always yields an error, since it is not
- * safe to use buffers as keys in hash tables.
- *
- * @return never.
- */
- override def hashCode(): Int = synchronized {
- super.hashCode();
- }
+ abstract override def length: Int = synchronized {
+ super.length
+ }
+
+ abstract override def elements: Iterator[A] = synchronized {
+ super.elements
+ }
+
+ abstract override def apply(n: Int): A = synchronized {
+ super.apply(n)
+ }
+
+ /** Append a single element to this buffer and return
+ * the identity of the buffer.
+ *
+ * @param elem the element to append.
+ */
+ override def +(elem: A): Buffer[A] = synchronized {
+ super.+(elem)
+ }
+
+ /** Append a single element to this buffer.
+ *
+ * @param elem the element to append.
+ */
+ abstract override def +=(elem: A): Unit = synchronized {
+ super.+=(elem)
+ }
+
+ /** Appends a number of elements provided by an iterable object
+ * via its <code>elements</code> method. The identity of the
+ * buffer is returned.
+ *
+ * @param iter the iterable object.
+ */
+ override def ++(iter: Iterable[A]): Buffer[A] = synchronized {
+ super.++(iter)
+ }
+
+ /** Appends a number of elements provided by an iterable object
+ * via its <code>elements</code> method.
+ *
+ * @param iter the iterable object.
+ */
+ override def ++=(iter: Iterable[A]): Unit = synchronized {
+ super.++=(iter)
+ }
+
+ /** Appends a sequence of elements to this buffer.
+ *
+ * @param elems the elements to append.
+ */
+ override def append(elems: A*): Unit = synchronized {
+ super.++=(elems)
+ }
+
+ /** Appends a number of elements provided by an iterable object
+ * via its <code>elements</code> method.
+ *
+ * @param iter the iterable object.
+ */
+ override def appendAll(iter: Iterable[A]): Unit = synchronized {
+ super.appendAll(iter)
+ }
+
+ /** Prepend a single element to this buffer and return
+ * the identity of the buffer.
+ *
+ * @param elem the element to append.
+ */
+ abstract override def +:(elem: A): Buffer[A] = synchronized {
+ super.+:(elem)
+ }
+
+ /** Prepends a number of elements provided by an iterable object
+ * via its <code>elements</code> method. The identity of the
+ * buffer is returned.
+ *
+ * @param iter the iterable object.
+ */
+ override def ++:(iter: Iterable[A]): Buffer[A] = synchronized {
+ super.++:(iter)
+ }
+
+ /** Prepend an element to this list.
+ *
+ * @param elem the element to prepend.
+ */
+ override def prepend(elems: A*): Unit = synchronized {
+ super.prependAll(elems)
+ }
+
+ /** Prepends a number of elements provided by an iterable object
+ * via its <code>elements</code> method. The identity of the
+ * buffer is returned.
+ *
+ * @param iter the iterable object.
+ */
+ override def prependAll(elems: Iterable[A]): Unit = synchronized {
+ super.prependAll(elems)
+ }
+
+ /** Inserts new elements at the index <code>n</code>. Opposed to method
+ * <code>update</code>, this method will not replace an element with a
+ * one. Instead, it will insert the new elements at index <code>n</code>.
+ *
+ * @param n the index where a new element will be inserted.
+ * @param elems the new elements to insert.
+ */
+ override def insert(n: Int, elems: A*): Unit = synchronized {
+ super.insertAll(n, elems)
+ }
+
+ /** Inserts new elements at the index <code>n</code>. Opposed to method
+ * <code>update</code>, this method will not replace an element with a
+ * one. Instead, it will insert a new element at index <code>n</code>.
+ *
+ * @param n the index where a new element will be inserted.
+ * @param iter the iterable object providing all elements to insert.
+ */
+ abstract override def insertAll(n: Int, iter: Iterable[A]): Unit = synchronized {
+ super.insertAll(n, iter)
+ }
+
+ /** Replace element at index <code>n</code> with the new element
+ * <code>newelem</code>.
+ *
+ * @param n the index of the element to replace.
+ * @param newelem the new element.
+ */
+ abstract override def update(n: Int, newelem: A): Unit = synchronized {
+ super.update(n, newelem)
+ }
+
+ /** Removes the element on a given index position.
+ *
+ * @param n the index which refers to the element to delete.
+ */
+ abstract override def remove(n: Int): A = synchronized {
+ super.remove(n)
+ }
+
+ /** Clears the buffer contents.
+ */
+ abstract override def clear: Unit = synchronized {
+ super.clear
+ }
+
+ override def <<(cmd: Message[Pair[Location, A]]): Unit = synchronized {
+ super.<<(cmd)
+ }
+
+ /** Return a clone of this buffer.
+ *
+ * @return an <code>ArrayBuffer</code> with the same elements.
+ */
+ override def clone(): Buffer[A] = synchronized {
+ super.clone()
+ }
+
+ /** The hashCode method always yields an error, since it is not
+ * safe to use buffers as keys in hash tables.
+ *
+ * @return never.
+ */
+ override def hashCode(): Int = synchronized {
+ super.hashCode()
+ }
}
diff --git a/src/library/scala/collection/mutable/SynchronizedMap.scala b/src/library/scala/collection/mutable/SynchronizedMap.scala
index b024e36eeb..d6b2fa65ef 100644
--- a/src/library/scala/collection/mutable/SynchronizedMap.scala
+++ b/src/library/scala/collection/mutable/SynchronizedMap.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This class should be used as a mixin. It synchronizes the <code>Map</code>
@@ -20,99 +20,99 @@ package scala.collection.mutable;
*/
trait SynchronizedMap[A, B] extends Map[A, B] {
- abstract override def size: Int = synchronized {
- super.size;
- }
+ abstract override def size: Int = synchronized {
+ super.size
+ }
- abstract override def get(key: A): Option[B] = synchronized {
- super.get(key);
- }
+ abstract override def get(key: A): Option[B] = synchronized {
+ super.get(key)
+ }
- override def isEmpty: Boolean = synchronized {
- super.isEmpty;
- }
+ override def isEmpty: Boolean = synchronized {
+ super.isEmpty
+ }
- override def apply(key: A): B = synchronized {
- super.apply(key);
- }
+ override def apply(key: A): B = synchronized {
+ super.apply(key)
+ }
- override def contains(key: A): Boolean = synchronized {
- super.contains(key);
- }
+ override def contains(key: A): Boolean = synchronized {
+ super.contains(key)
+ }
- override def isDefinedAt(key: A) = synchronized {
- super.isDefinedAt(key);
- }
+ override def isDefinedAt(key: A) = synchronized {
+ super.isDefinedAt(key)
+ }
- override def keys: Iterator[A] = synchronized {
- super.keys;
- }
+ override def keys: Iterator[A] = synchronized {
+ super.keys
+ }
- override def values: Iterator[B] = synchronized {
- super.values;
- }
+ override def values: Iterator[B] = synchronized {
+ super.values
+ }
- override def foreach(f: Pair[A, B] => Unit) = synchronized {
- super.foreach(f);
- }
+ override def foreach(f: Pair[A, B] => Unit) = synchronized {
+ super.foreach(f)
+ }
- override def toList: List[Pair[A, B]] = synchronized {
- super.toList;
- }
+ override def toList: List[Pair[A, B]] = synchronized {
+ super.toList
+ }
- abstract override def update(key: A, value: B): Unit = synchronized {
- super.update(key, value);
- }
+ abstract override def update(key: A, value: B): Unit = synchronized {
+ super.update(key, value)
+ }
- override def ++=(map: Iterable[Pair[A, B]]): Unit = synchronized {
- super.++=(map);
- }
+ override def ++=(map: Iterable[Pair[A, B]]): Unit = synchronized {
+ super.++=(map)
+ }
- override def ++=(it: Iterator[Pair[A, B]]): Unit = synchronized {
- super.++=(it);
- }
+ override def ++=(it: Iterator[Pair[A, B]]): Unit = synchronized {
+ super.++=(it)
+ }
- override def incl(mappings: Pair[A, B]*): Unit = synchronized {
- super.++=(mappings);
- }
+ override def incl(mappings: Pair[A, B]*): Unit = synchronized {
+ super.++=(mappings)
+ }
- abstract override def -=(key: A): Unit = synchronized {
- super.-=(key);
- }
+ abstract override def -=(key: A): Unit = synchronized {
+ super.-=(key)
+ }
- override def --=(keys: Iterable[A]): Unit = synchronized {
- super.--=(keys);
- }
+ override def --=(keys: Iterable[A]): Unit = synchronized {
+ super.--=(keys)
+ }
- override def --=(it: Iterator[A]): Unit = synchronized {
- super.--=(it);
- }
+ override def --=(it: Iterator[A]): Unit = synchronized {
+ super.--=(it)
+ }
- override def excl(keys: A*): Unit = synchronized {
- super.--=(keys);
- }
+ override def excl(keys: A*): Unit = synchronized {
+ super.--=(keys)
+ }
- override def clear: Unit = synchronized {
- super.clear;
- }
+ override def clear: Unit = synchronized {
+ super.clear
+ }
- override def map(f: Pair[A, B] => B): Unit = synchronized {
- super.map(f);
- }
+ override def map(f: Pair[A, B] => B): Unit = synchronized {
+ super.map(f)
+ }
- override def filter(p: Pair[A, B] => Boolean): Unit = synchronized {
- super.filter(p);
- }
+ override def filter(p: Pair[A, B] => Boolean): Unit = synchronized {
+ super.filter(p)
+ }
- override def toString() = synchronized {
- super.toString();
- }
+ override def toString() = synchronized {
+ super.toString()
+ }
- override def <<(cmd: Message[Pair[A, B]]): Unit = synchronized {
- super.<<(cmd);
- }
+ override def <<(cmd: Message[Pair[A, B]]): Unit = synchronized {
+ super.<<(cmd)
+ }
- override def clone(): Map[A, B] = synchronized {
- super.clone();
- }
+ override def clone(): Map[A, B] = synchronized {
+ super.clone()
+ }
}
diff --git a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala
index 361cb7f38c..b4a8ebde19 100644
--- a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala
+++ b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This class implements synchronized priority queues using a heap.
@@ -21,79 +21,79 @@ package scala.collection.mutable;
*/
class SynchronizedPriorityQueue[A <% Ordered[A]] extends PriorityQueue[A] {
- /** Checks if the queue is empty.
- *
- * @return true, iff there is no element in the queue.
- */
- override def isEmpty: Boolean = synchronized { super.isEmpty; }
-
- /** Inserts a single element into the priority queue.
- *
- * @param elem the element to insert
- */
- override def +=(elem: A): Unit = synchronized { super.+=(elem); }
-
- /** Adds all elements provided by an <code>Iterable</code> object
- * into the priority queue.
- *
- * @param iter an iterable object
- */
- override def ++=(iter: Iterable[A]): Unit = synchronized { super.++=(iter); }
-
- /** Adds all elements provided by an iterator into the priority queue.
- *
- * @param it an iterator
- */
- override def ++=(it: Iterator[A]): Unit = synchronized { super.++=(it); }
-
- /** Adds all elements to the queue.
- *
- * @param elems the elements to add.
- */
- override def enqueue(elems: A*): Unit = synchronized { super.++=(elems); }
-
- /** Returns the element with the highest priority in the queue,
- * and removes this element from the queue.
- *
- * @return the element with the highest priority.
- */
- override def dequeue: A = synchronized { super.dequeue; }
-
- /** Returns the element with the highest priority in the queue,
- * or throws an error if there is no element contained in the queue.
- *
- * @return the element with the highest priority.
- */
- override def max: A = synchronized { super.max; }
-
- /** Removes all elements from the queue. After this operation is completed,
- * the queue will be empty.
- */
- override def clear: Unit = synchronized { super.clear; }
-
- /** Returns an iterator which yiels all the elements of the priority
- * queue in descending priority order.
- *
- * @return an iterator over all elements sorted in descending order.
- */
- override def elements: Iterator[A] = synchronized { super.elements; }
-
- /** Checks if two queues are structurally identical.
- *
- * @return true, iff both queues contain the same sequence of elements.
- */
- override def equals(that: Any): Boolean = synchronized { super.equals(that); }
-
- /** The hashCode method always yields an error, since it is not
- * safe to use mutable queues as keys in hash tables.
- *
- * @return never.
- */
- override def hashCode(): Int = synchronized { super.hashCode(); }
-
- /** Returns a textual representation of a queue as a string.
- *
- * @return the string representation of this queue.
- */
- override def toString(): String = synchronized { super.toString(); }
+ /** Checks if the queue is empty.
+ *
+ * @return true, iff there is no element in the queue.
+ */
+ override def isEmpty: Boolean = synchronized { super.isEmpty }
+
+ /** Inserts a single element into the priority queue.
+ *
+ * @param elem the element to insert
+ */
+ override def +=(elem: A): Unit = synchronized { super.+=(elem) }
+
+ /** Adds all elements provided by an <code>Iterable</code> object
+ * into the priority queue.
+ *
+ * @param iter an iterable object
+ */
+ override def ++=(iter: Iterable[A]): Unit = synchronized { super.++=(iter) }
+
+ /** Adds all elements provided by an iterator into the priority queue.
+ *
+ * @param it an iterator
+ */
+ override def ++=(it: Iterator[A]): Unit = synchronized { super.++=(it) }
+
+ /** Adds all elements to the queue.
+ *
+ * @param elems the elements to add.
+ */
+ override def enqueue(elems: A*): Unit = synchronized { super.++=(elems) }
+
+ /** Returns the element with the highest priority in the queue,
+ * and removes this element from the queue.
+ *
+ * @return the element with the highest priority.
+ */
+ override def dequeue: A = synchronized { super.dequeue }
+
+ /** Returns the element with the highest priority in the queue,
+ * or throws an error if there is no element contained in the queue.
+ *
+ * @return the element with the highest priority.
+ */
+ override def max: A = synchronized { super.max }
+
+ /** Removes all elements from the queue. After this operation is completed,
+ * the queue will be empty.
+ */
+ override def clear: Unit = synchronized { super.clear }
+
+ /** Returns an iterator which yiels all the elements of the priority
+ * queue in descending priority order.
+ *
+ * @return an iterator over all elements sorted in descending order.
+ */
+ override def elements: Iterator[A] = synchronized { super.elements }
+
+ /** Checks if two queues are structurally identical.
+ *
+ * @return true, iff both queues contain the same sequence of elements.
+ */
+ override def equals(that: Any): Boolean = synchronized { super.equals(that) }
+
+ /** The hashCode method always yields an error, since it is not
+ * safe to use mutable queues as keys in hash tables.
+ *
+ * @return never.
+ */
+ override def hashCode(): Int = synchronized { super.hashCode() }
+
+ /** Returns a textual representation of a queue as a string.
+ *
+ * @return the string representation of this queue.
+ */
+ override def toString(): String = synchronized { super.toString() }
}
diff --git a/src/library/scala/collection/mutable/SynchronizedQueue.scala b/src/library/scala/collection/mutable/SynchronizedQueue.scala
index f7625c2cc4..dece14cd5b 100644
--- a/src/library/scala/collection/mutable/SynchronizedQueue.scala
+++ b/src/library/scala/collection/mutable/SynchronizedQueue.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This is a synchronized version of the <code>Queue[T]</code> class. It
@@ -21,75 +21,75 @@ package scala.collection.mutable;
*/
class SynchronizedQueue[A] extends Queue[A] {
- /** Checks if the queue is empty.
- *
- * @return true, iff there is no element in the queue.
- */
- override def isEmpty: Boolean = synchronized { super.isEmpty; }
-
- /** Inserts a single element at the end of the queue.
- *
- * @param elem the element to insert
- */
- override def +=(elem: A): Unit = synchronized { super.+=(elem); }
-
- /** Adds all elements provided by an <code>Iterable</code> object
- * at the end of the queue. The elements are prepended in the order they
- * are given out by the iterator.
- *
- * @param iter an iterable object
- */
- override def ++=(iter: Iterable[A]): Unit = synchronized { super.++=(iter); }
-
- /** Adds all elements provided by an iterator
- * at the end of the queue. The elements are prepended in the order they
- * are given out by the iterator.
- *
- * @param it an iterator
- */
- override def ++=(it: Iterator[A]): Unit = synchronized { super.++=(it); }
-
- /** Adds all elements to the queue.
- *
- * @param elems the elements to add.
- */
- override def enqueue(elems: A*): Unit = synchronized { super.++=(elems); }
-
- /** Returns the first element in the queue, and removes this element
- * from the queue.
- *
- * @return the first element of the queue.
- */
- override def dequeue: A = synchronized { super.dequeue; }
-
- /** Returns the first element in the queue, or throws an error if there
- * is no element contained in the queue.
- *
- * @return the first element.
- */
- override def front: A = synchronized { super.front; }
-
- /** Removes all elements from the queue. After this operation is completed,
- * the queue will be empty.
- */
- override def clear: Unit = synchronized { super.clear; }
-
- /** Checks if two queues are structurally identical.
- *
- * @return true, iff both queues contain the same sequence of elements.
- */
- override def equals(that: Any): Boolean = synchronized { super.equals(that); }
-
- /** The hashCode method always yields an error, since it is not
- * safe to use mutable queues as keys in hash tables.
- *
- * @return never.
- */
- override def hashCode(): Int = synchronized { super.hashCode(); }
-
- /** Returns a textual representation of a queue as a string.
- *
- * @return the string representation of this queue.
- */
- override def toString() = synchronized { super.toString(); }
+ /** Checks if the queue is empty.
+ *
+ * @return true, iff there is no element in the queue.
+ */
+ override def isEmpty: Boolean = synchronized { super.isEmpty }
+
+ /** Inserts a single element at the end of the queue.
+ *
+ * @param elem the element to insert
+ */
+ override def +=(elem: A): Unit = synchronized { super.+=(elem) }
+
+ /** Adds all elements provided by an <code>Iterable</code> object
+ * at the end of the queue. The elements are prepended in the order they
+ * are given out by the iterator.
+ *
+ * @param iter an iterable object
+ */
+ override def ++=(iter: Iterable[A]): Unit = synchronized { super.++=(iter) }
+
+ /** Adds all elements provided by an iterator
+ * at the end of the queue. The elements are prepended in the order they
+ * are given out by the iterator.
+ *
+ * @param it an iterator
+ */
+ override def ++=(it: Iterator[A]): Unit = synchronized { super.++=(it) }
+
+ /** Adds all elements to the queue.
+ *
+ * @param elems the elements to add.
+ */
+ override def enqueue(elems: A*): Unit = synchronized { super.++=(elems) }
+
+ /** Returns the first element in the queue, and removes this element
+ * from the queue.
+ *
+ * @return the first element of the queue.
+ */
+ override def dequeue: A = synchronized { super.dequeue }
+
+ /** Returns the first element in the queue, or throws an error if there
+ * is no element contained in the queue.
+ *
+ * @return the first element.
+ */
+ override def front: A = synchronized { super.front }
+
+ /** Removes all elements from the queue. After this operation is completed,
+ * the queue will be empty.
+ */
+ override def clear: Unit = synchronized { super.clear }
+
+ /** Checks if two queues are structurally identical.
+ *
+ * @return true, iff both queues contain the same sequence of elements.
+ */
+ override def equals(that: Any): Boolean = synchronized { super.equals(that) }
+
+ /** The hashCode method always yields an error, since it is not
+ * safe to use mutable queues as keys in hash tables.
+ *
+ * @return never.
+ */
+ override def hashCode(): Int = synchronized { super.hashCode() }
+
+ /** Returns a textual representation of a queue as a string.
+ *
+ * @return the string representation of this queue.
+ */
+ override def toString() = synchronized { super.toString() }
}
diff --git a/src/library/scala/collection/mutable/SynchronizedSet.scala b/src/library/scala/collection/mutable/SynchronizedSet.scala
index 06eedd15f7..fc222e6121 100644
--- a/src/library/scala/collection/mutable/SynchronizedSet.scala
+++ b/src/library/scala/collection/mutable/SynchronizedSet.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This class should be used as a mixin. It synchronizes the <code>Set</code>
@@ -20,87 +20,87 @@ package scala.collection.mutable;
*/
trait SynchronizedSet[A] extends Set[A] {
- abstract override def size: Int = synchronized {
- super.size
- }
+ abstract override def size: Int = synchronized {
+ super.size
+ }
- override def isEmpty: Boolean = synchronized {
- super.isEmpty
- }
+ override def isEmpty: Boolean = synchronized {
+ super.isEmpty
+ }
- abstract override def contains(elem: A) = synchronized {
- super.contains(elem);
- }
+ abstract override def contains(elem: A) = synchronized {
+ super.contains(elem)
+ }
- abstract override def update(elem: A, included: Boolean): Unit = synchronized {
- super.update(elem, included);
- }
+ abstract override def update(elem: A, included: Boolean): Unit = synchronized {
+ super.update(elem, included)
+ }
- abstract override def +=(elem: A): Unit = synchronized {
- super.+=(elem);
- }
+ abstract override def +=(elem: A): Unit = synchronized {
+ super.+=(elem)
+ }
- override def ++=(that: Iterable[A]) = synchronized {
- super.++=(that);
- }
+ override def ++=(that: Iterable[A]) = synchronized {
+ super.++=(that)
+ }
- override def ++=(it: Iterator[A]) = synchronized {
- super.++=(it);
- }
+ override def ++=(it: Iterator[A]) = synchronized {
+ super.++=(it)
+ }
- override def incl(elems: A*): Unit = synchronized {
- super.++=(elems);
- }
+ override def incl(elems: A*): Unit = synchronized {
+ super.++=(elems)
+ }
- abstract override def -=(elem: A): Unit = synchronized {
- super.-=(elem);
- }
+ abstract override def -=(elem: A): Unit = synchronized {
+ super.-=(elem)
+ }
- override def --=(that: Iterable[A]) = synchronized {
- super.--=(that);
- }
+ override def --=(that: Iterable[A]) = synchronized {
+ super.--=(that)
+ }
- override def --=(it: Iterator[A]) = synchronized {
- super.--=(it);
- }
+ override def --=(it: Iterator[A]) = synchronized {
+ super.--=(it)
+ }
- override def excl(elems: A*): Unit = synchronized {
- super.--=(elems);
- }
+ override def excl(elems: A*): Unit = synchronized {
+ super.--=(elems)
+ }
- override def intersect(that: Set[A]) = synchronized {
- super.intersect(that);
- }
+ override def intersect(that: Set[A]) = synchronized {
+ super.intersect(that)
+ }
- abstract override def clear: Unit = synchronized {
- super.clear;
- }
+ abstract override def clear: Unit = synchronized {
+ super.clear
+ }
- override def subsetOf(that: scala.collection.Set[A]) = synchronized {
- super.subsetOf(that);
- }
+ override def subsetOf(that: scala.collection.Set[A]) = synchronized {
+ super.subsetOf(that)
+ }
- override def foreach(f: A => Unit) = synchronized {
- super.foreach(f);
- }
+ override def foreach(f: A => Unit) = synchronized {
+ super.foreach(f)
+ }
- override def filter(p: A => Boolean) = synchronized {
- super.filter(p);
- }
+ override def filter(p: A => Boolean) = synchronized {
+ super.filter(p)
+ }
- override def toList: List[A] = synchronized {
- super.toList;
- }
+ override def toList: List[A] = synchronized {
+ super.toList
+ }
- override def toString() = synchronized {
- super.toString();
- }
+ override def toString() = synchronized {
+ super.toString()
+ }
- override def <<(cmd: Message[A]): Unit = synchronized {
- super.<<(cmd);
- }
+ override def <<(cmd: Message[A]): Unit = synchronized {
+ super.<<(cmd)
+ }
- override def clone(): Set[A] = synchronized {
- super.clone();
- }
+ override def clone(): Set[A] = synchronized {
+ super.clone()
+ }
}
diff --git a/src/library/scala/collection/mutable/SynchronizedStack.scala b/src/library/scala/collection/mutable/SynchronizedStack.scala
index d2e2d44735..6b774f2dd2 100644
--- a/src/library/scala/collection/mutable/SynchronizedStack.scala
+++ b/src/library/scala/collection/mutable/SynchronizedStack.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** This is a synchronized version of the <code>Stack[T]</code> class. It
@@ -21,91 +21,91 @@ package scala.collection.mutable;
*/
class SynchronizedStack[A] extends Stack[A] {
- /** Checks if the stack is empty.
- *
- * @return true, iff there is no element on the stack
- */
- override def isEmpty: Boolean = synchronized { super.isEmpty }
-
- /** Pushes a single element on top of the stack.
- *
- * @param elem the element to push onto the stack
- */
- override def +=(elem: A): Unit = synchronized { super.+=(elem); }
-
- /** Pushes all elements provided by an <code>Iterable</code> object
- * on top of the stack. The elements are pushed in the order they
- * are given out by the iterator.
- *
- * @param iter an iterable object
- */
- override def ++=(iter: Iterable[A]): Unit = synchronized { super.++=(iter); }
-
- /** Pushes all elements provided by an iterator
- * on top of the stack. The elements are pushed in the order they
- * are given out by the iterator.
- *
- * @param iter an iterator
- */
- override def ++=(it: Iterator[A]): Unit = synchronized { super.++=(it); }
-
- /** 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 = synchronized { super.++=(elems); }
-
- /** 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
- * element on the stack.
- *
- * @return the top element
- */
- override def top: A = synchronized { super.top; }
-
- /** Removes the top element from the stack.
- */
- override def pop: A = synchronized { super.pop; }
-
- /**
- * Removes all elements from the stack. After this operation completed,
- * the stack will be empty.
- */
- override def clear: Unit = synchronized { super.clear; }
-
- /** Returns an iterator over all elements on the stack. This iterator
- * is stable with respect to state changes in the stack object; i.e.
- * such changes will not be reflected in the iterator. The iterator
- * issues elements in the order they were inserted into the stack
- * (FIFO order).
- *
- * @return an iterator over all stack elements.
- */
- override def elements: Iterator[A] = synchronized { super.elements; }
-
- /** Creates a list of all stack elements in FIFO order.
- *
- * @return the created list.
- */
- override def toList: List[A] = synchronized { super.toList; }
-
- /** Checks if two stacks are structurally identical.
- *
- * @return true, iff both stacks contain the same sequence of elements.
- */
- override def equals(that: Any): Boolean = synchronized { super.equals(that); }
-
- /** The hashCode method always yields an error, since it is not
- * safe to use mutable stacks as keys in hash tables.
- *
- * @return never.
- */
- override def hashCode(): Int = synchronized { super.hashCode(); }
-
- /** Returns a textual representation of a stack as a string.
- *
- * @return the string representation of this stack.
- */
- override def toString() = synchronized { super.toString(); }
+ /** Checks if the stack is empty.
+ *
+ * @return true, iff there is no element on the stack
+ */
+ override def isEmpty: Boolean = synchronized { super.isEmpty }
+
+ /** Pushes a single element on top of the stack.
+ *
+ * @param elem the element to push onto the stack
+ */
+ override def +=(elem: A): Unit = synchronized { super.+=(elem) }
+
+ /** Pushes all elements provided by an <code>Iterable</code> object
+ * on top of the stack. The elements are pushed in the order they
+ * are given out by the iterator.
+ *
+ * @param iter an iterable object
+ */
+ override def ++=(iter: Iterable[A]): Unit = synchronized { super.++=(iter) }
+
+ /** Pushes all elements provided by an iterator
+ * on top of the stack. The elements are pushed in the order they
+ * are given out by the iterator.
+ *
+ * @param iter an iterator
+ */
+ override def ++=(it: Iterator[A]): Unit = synchronized { super.++=(it) }
+
+ /** 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 = synchronized { super.++=(elems) }
+
+ /** 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
+ * element on the stack.
+ *
+ * @return the top element
+ */
+ override def top: A = synchronized { super.top }
+
+ /** Removes the top element from the stack.
+ */
+ override def pop: A = synchronized { super.pop }
+
+ /**
+ * Removes all elements from the stack. After this operation completed,
+ * the stack will be empty.
+ */
+ override def clear: Unit = synchronized { super.clear }
+
+ /** Returns an iterator over all elements on the stack. This iterator
+ * is stable with respect to state changes in the stack object; i.e.
+ * such changes will not be reflected in the iterator. The iterator
+ * issues elements in the order they were inserted into the stack
+ * (FIFO order).
+ *
+ * @return an iterator over all stack elements.
+ */
+ override def elements: Iterator[A] = synchronized { super.elements }
+
+ /** Creates a list of all stack elements in FIFO order.
+ *
+ * @return the created list.
+ */
+ override def toList: List[A] = synchronized { super.toList }
+
+ /** Checks if two stacks are structurally identical.
+ *
+ * @return true, iff both stacks contain the same sequence of elements.
+ */
+ override def equals(that: Any): Boolean = synchronized { super.equals(that) }
+
+ /** The hashCode method always yields an error, since it is not
+ * safe to use mutable stacks as keys in hash tables.
+ *
+ * @return never.
+ */
+ override def hashCode(): Int = synchronized { super.hashCode() }
+
+ /** Returns a textual representation of a stack as a string.
+ *
+ * @return the string representation of this stack.
+ */
+ override def toString() = synchronized { super.toString() }
}
diff --git a/src/library/scala/collection/mutable/Undoable.scala b/src/library/scala/collection/mutable/Undoable.scala
index f8d355c558..302273595a 100644
--- a/src/library/scala/collection/mutable/Undoable.scala
+++ b/src/library/scala/collection/mutable/Undoable.scala
@@ -9,7 +9,7 @@
// $Id$
-package scala.collection.mutable;
+package scala.collection.mutable
/** Classes that mix in the <code>Undoable</code> class provide an operation
@@ -22,5 +22,5 @@ trait Undoable {
/** Undo the last operation.
*/
- def undo: Unit;
+ def undo: Unit
}