diff options
Diffstat (limited to 'src')
10 files changed, 103 insertions, 17 deletions
diff --git a/src/library/scala/Responder.scala b/src/library/scala/Responder.scala index f628b08b9e..32665a2bcf 100644 --- a/src/library/scala/Responder.scala +++ b/src/library/scala/Responder.scala @@ -67,6 +67,7 @@ object Responder { * @version 1.0 * @since 2.1 */ +@serializable abstract class Responder[+A] { def respond(k: A => Unit): Unit @@ -90,5 +91,7 @@ abstract class Responder[+A] { Responder.this.respond(x => if (p(x)) k(x) else ()) } } + + override def toString = "Responder" } diff --git a/src/library/scala/collection/immutable/NumericRange.scala b/src/library/scala/collection/immutable/NumericRange.scala index 67b097e65d..6c5f2ddc09 100644 --- a/src/library/scala/collection/immutable/NumericRange.scala +++ b/src/library/scala/collection/immutable/NumericRange.scala @@ -33,6 +33,7 @@ import generic._ * @author Paul Phillips * @version 2.8 */ +@serializable abstract class NumericRange[+T] (val start: T, val end: T, val step: T, val isInclusive: Boolean) (implicit num: Integral[T]) @@ -75,12 +76,12 @@ extends IndexedSeq[T] if (step > zero) { while (i < end) { f(i) - i = i + step + i += step } } else { while (i > end) { f(i) - i = i + step + i += step } } if (limitTest(i)) f(i) @@ -100,7 +101,7 @@ extends IndexedSeq[T] } def length: Int = toInt(genericLength) - override def isEmpty = + override def isEmpty: Boolean = if (step > zero) if (isInclusive) end < start else end <= start diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala index 831ea2c678..fca5de2640 100644 --- a/src/library/scala/collection/immutable/Range.scala +++ b/src/library/scala/collection/immutable/Range.scala @@ -25,6 +25,7 @@ package scala.collection.immutable * @version 2.8 * @since 2.5 */ +@serializable @SerialVersionUID(7618862778670199309L) class Range(val start: Int, val end: Int, val step: Int) extends IndexedSeq[Int] { require(step != 0) diff --git a/src/library/scala/collection/immutable/Set.scala b/src/library/scala/collection/immutable/Set.scala index 80f98aa679..15a6152e6c 100644 --- a/src/library/scala/collection/immutable/Set.scala +++ b/src/library/scala/collection/immutable/Set.scala @@ -57,7 +57,7 @@ object Set extends SetFactory[Set] { } /** An optimized representation for immutable sets of size 1 */ - @serializable + @serializable @SerialVersionUID(1233385750652442003L) class Set1[A](elem1: A) extends Set[A] { override def size: Int = 1 def contains(elem: A): Boolean = @@ -76,7 +76,7 @@ object Set extends SetFactory[Set] { } /** An optimized representation for immutable sets of size 2 */ - @serializable + @serializable @SerialVersionUID(-6443011234944830092L) class Set2[A](elem1: A, elem2: A) extends Set[A] { override def size: Int = 2 def contains(elem: A): Boolean = @@ -96,7 +96,7 @@ object Set extends SetFactory[Set] { } /** An optimized representation for immutable sets of size 3 */ - @serializable + @serializable @SerialVersionUID(-3590273538119220064L) class Set3[A](elem1: A, elem2: A, elem3: A) extends Set[A] { override def size: Int = 3 def contains(elem: A): Boolean = @@ -117,7 +117,7 @@ object Set extends SetFactory[Set] { } /** An optimized representation for immutable sets of size 4 */ - @serializable + @serializable @SerialVersionUID(-3622399588156184395L) class Set4[A](elem1: A, elem2: A, elem3: A, elem4: A) extends Set[A] { override def size: Int = 4 def contains(elem: A): Boolean = diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala index 6a57c3596d..9a6a4a3b4c 100644 --- a/src/library/scala/collection/immutable/Stream.scala +++ b/src/library/scala/collection/immutable/Stream.scala @@ -480,6 +480,7 @@ object Stream extends SeqFactory[Stream] { } /** A lazy cons cell, from which streams are built. */ + @serializable @SerialVersionUID(-602202424901551803L) final class Cons[+A](hd: A, tl: => Stream[A]) extends Stream[A] { override def isEmpty = false override def head = hd diff --git a/src/library/scala/collection/mutable/ArrayBuilder.scala b/src/library/scala/collection/mutable/ArrayBuilder.scala index 05ad865862..cdb01c9ded 100644 --- a/src/library/scala/collection/mutable/ArrayBuilder.scala +++ b/src/library/scala/collection/mutable/ArrayBuilder.scala @@ -19,6 +19,7 @@ import scala.reflect.ClassManifest * * @since 2.8 */ +@serializable abstract class ArrayBuilder[T] extends Builder[T, Array[T]] /** @@ -84,6 +85,13 @@ object ArrayBuilder { if (capacity != 0 && capacity == size) elems else mkArray(size) } + + override def equals(other: Any): Boolean = other match { + case x: ofRef[_] => (size == x.size) && (elems == x.elems) + case _ => false + } + + override def toString = "ArrayBuilder.ofRef" } class ofByte extends ArrayBuilder[Byte] { @@ -141,6 +149,13 @@ object ArrayBuilder { if (capacity != 0 && capacity == size) elems else mkArray(size) } + + override def equals(other: Any): Boolean = other match { + case x: ofByte => (size == x.size) && (elems == x.elems) + case _ => false + } + + override def toString = "ArrayBuilder.ofByte" } class ofShort extends ArrayBuilder[Short] { @@ -198,6 +213,13 @@ object ArrayBuilder { if (capacity != 0 && capacity == size) elems else mkArray(size) } + + override def equals(other: Any): Boolean = other match { + case x: ofShort => (size == x.size) && (elems == x.elems) + case _ => false + } + + override def toString = "ArrayBuilder.ofShort" } class ofChar extends ArrayBuilder[Char] { @@ -255,6 +277,13 @@ object ArrayBuilder { if (capacity != 0 && capacity == size) elems else mkArray(size) } + + override def equals(other: Any): Boolean = other match { + case x: ofChar => (size == x.size) && (elems == x.elems) + case _ => false + } + + override def toString = "ArrayBuilder.ofChar" } class ofInt extends ArrayBuilder[Int] { @@ -312,6 +341,13 @@ object ArrayBuilder { if (capacity != 0 && capacity == size) elems else mkArray(size) } + + override def equals(other: Any): Boolean = other match { + case x: ofInt => (size == x.size) && (elems == x.elems) + case _ => false + } + + override def toString = "ArrayBuilder.ofInt" } class ofLong extends ArrayBuilder[Long] { @@ -369,6 +405,13 @@ object ArrayBuilder { if (capacity != 0 && capacity == size) elems else mkArray(size) } + + override def equals(other: Any): Boolean = other match { + case x: ofLong => (size == x.size) && (elems == x.elems) + case _ => false + } + + override def toString = "ArrayBuilder.ofLong" } class ofFloat extends ArrayBuilder[Float] { @@ -426,6 +469,13 @@ object ArrayBuilder { if (capacity != 0 && capacity == size) elems else mkArray(size) } + + override def equals(other: Any): Boolean = other match { + case x: ofFloat => (size == x.size) && (elems == x.elems) + case _ => false + } + + override def toString = "ArrayBuilder.ofFloat" } class ofDouble extends ArrayBuilder[Double] { @@ -483,6 +533,13 @@ object ArrayBuilder { if (capacity != 0 && capacity == size) elems else mkArray(size) } + + override def equals(other: Any): Boolean = other match { + case x: ofDouble => (size == x.size) && (elems == x.elems) + case _ => false + } + + override def toString = "ArrayBuilder.ofDouble" } class ofBoolean extends ArrayBuilder[Boolean] { @@ -540,6 +597,13 @@ object ArrayBuilder { if (capacity != 0 && capacity == size) elems else mkArray(size) } + + override def equals(other: Any): Boolean = other match { + case x: ofBoolean => (size == x.size) && (elems == x.elems) + case _ => false + } + + override def toString = "ArrayBuilder.ofBoolean" } class ofUnit extends ArrayBuilder[Unit] { @@ -597,5 +661,12 @@ object ArrayBuilder { if (capacity != 0 && capacity == size) elems else mkArray(size) } + + override def equals(other: Any): Boolean = other match { + case x: ofUnit => (size == x.size) && (elems == x.elems) + case _ => false + } + + override def toString = "ArrayBuilder.ofUnit" } } diff --git a/src/library/scala/collection/mutable/ArrayStack.scala b/src/library/scala/collection/mutable/ArrayStack.scala index 0059d5ff6b..4cfebaf76d 100644 --- a/src/library/scala/collection/mutable/ArrayStack.scala +++ b/src/library/scala/collection/mutable/ArrayStack.scala @@ -35,7 +35,7 @@ private object Utils { * @author David MacIver * @since 2.7 */ -@cloneable +@cloneable @serializable @SerialVersionUID(8565219180626620510L) class ArrayStack[T] private(private var table : Array[AnyRef], private var index : Int) extends scala.collection.Seq[T] with Cloneable[ArrayStack[T]] { def this() = this(new Array[AnyRef](1), 0) diff --git a/src/library/scala/collection/mutable/DoubleLinkedList.scala b/src/library/scala/collection/mutable/DoubleLinkedList.scala index 6a4476d743..6767b5c7c2 100644 --- a/src/library/scala/collection/mutable/DoubleLinkedList.scala +++ b/src/library/scala/collection/mutable/DoubleLinkedList.scala @@ -4,7 +4,7 @@ ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** -* */ +\* */ // $Id$ @@ -14,7 +14,7 @@ package mutable import generic._ -/** This class implements single linked lists where both the head (<code>elem</code>) +/** This class implements double linked lists where both the head (<code>elem</code>) * and the tail (<code>next</code>) are mutable. * * @author Matthias Zenger @@ -22,12 +22,20 @@ import generic._ * @version 2.8 * @since 1 */ -@serializable @SerialVersionUID(419155950203746706L) -class DoubleLinkedList[A](_elem: A, _next: DoubleLinkedList[A]) extends LinearSeq[A] - with GenericTraversableTemplate[A, DoubleLinkedList] - with DoubleLinkedListLike[A, DoubleLinkedList[A]] { - elem = _elem - next = _next +@serializable @SerialVersionUID(-8144992287952814767L) +class DoubleLinkedList[A]() extends LinearSeq[A] + with GenericTraversableTemplate[A, DoubleLinkedList] + with DoubleLinkedListLike[A, DoubleLinkedList[A]] { + next = this + + def this(elem: A, next: DoubleLinkedList[A]) { + this() + if (next != null) { + this.elem = elem + this.next = next + } + } + override def companion: GenericCompanion[DoubleLinkedList] = DoubleLinkedList } diff --git a/src/library/scala/collection/mutable/LinkedList.scala b/src/library/scala/collection/mutable/LinkedList.scala index abd691ef5c..ca59a90efb 100644 --- a/src/library/scala/collection/mutable/LinkedList.scala +++ b/src/library/scala/collection/mutable/LinkedList.scala @@ -22,7 +22,7 @@ import generic._ * @version 2.8 * @since 1 */ -@serializable +@serializable @SerialVersionUID(-7308240733518833071L) class LinkedList[A]() extends LinearSeq[A] with GenericTraversableTemplate[A, LinkedList] with LinkedListLike[A, LinkedList[A]] { diff --git a/src/library/scala/xml/Document.scala b/src/library/scala/xml/Document.scala index 4ddcc2bf66..f9d8b579ea 100644 --- a/src/library/scala/xml/Document.scala +++ b/src/library/scala/xml/Document.scala @@ -19,6 +19,7 @@ package scala.xml * @author Burak Emir * @version 1.0, 26/04/2005 */ +@serializable @SerialVersionUID(-2289320563321795109L) class Document extends NodeSeq with pull.XMLEvent { /** An ordered list of child information items, in document |