summaryrefslogtreecommitdiff
path: root/src/library/scalax/collection/immutable
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/scalax/collection/immutable')
-rw-r--r--src/library/scalax/collection/immutable/Iterable.scala1
-rw-r--r--src/library/scalax/collection/immutable/OrderedIterable.scala4
-rw-r--r--src/library/scalax/collection/immutable/Sequence.scala6
-rwxr-xr-xsrc/library/scalax/collection/immutable/Set.scala43
-rwxr-xr-xsrc/library/scalax/collection/immutable/Stream.scala3
-rw-r--r--src/library/scalax/collection/immutable/Vector.scala4
6 files changed, 56 insertions, 5 deletions
diff --git a/src/library/scalax/collection/immutable/Iterable.scala b/src/library/scalax/collection/immutable/Iterable.scala
index c299518d1b..07e1fed890 100644
--- a/src/library/scalax/collection/immutable/Iterable.scala
+++ b/src/library/scalax/collection/immutable/Iterable.scala
@@ -14,6 +14,7 @@ import generic.covariant
* @version 2.8
*/
trait Iterable[+A] extends collection.Iterable[A]
+ with covariant.IterableTemplate[Iterable, A]
object Iterable extends covariant.IterableFactory[Iterable] {
val empty: Iterable[Nothing] = Nil
diff --git a/src/library/scalax/collection/immutable/OrderedIterable.scala b/src/library/scalax/collection/immutable/OrderedIterable.scala
index 402244953d..1c3fb67fb2 100644
--- a/src/library/scalax/collection/immutable/OrderedIterable.scala
+++ b/src/library/scalax/collection/immutable/OrderedIterable.scala
@@ -13,7 +13,9 @@ import generic.covariant
* @owner Martin Odersky
* @version 2.8
*/
-trait OrderedIterable[+A] extends collection.OrderedIterable[A] with Iterable[A]
+trait OrderedIterable[+A] extends Iterable[A]
+ with covariant.OrderedIterableTemplate[OrderedIterable, A]
+ with collection.OrderedIterable[A]
object OrderedIterable extends covariant.IterableFactory[OrderedIterable] {
val empty: OrderedIterable[Nothing] = Nil
diff --git a/src/library/scalax/collection/immutable/Sequence.scala b/src/library/scalax/collection/immutable/Sequence.scala
index fdb9fadf04..10ae805106 100644
--- a/src/library/scalax/collection/immutable/Sequence.scala
+++ b/src/library/scalax/collection/immutable/Sequence.scala
@@ -9,11 +9,13 @@ import generic.covariant
* @note If a collection has a known <code>size</code>, it should also sub-type <code>SizedIterable</code>.
*
* @author Matthias Zenger
- * @autor Martin Odersky
+ * @autor Martin Oderskyter
* @owner Martin Odersky
* @version 2.8
*/
-trait Sequence[+A] extends collection.Sequence[A] with OrderedIterable[A]
+trait Sequence[+A] extends OrderedIterable[A]
+ with covariant.SequenceTemplate[Sequence, A]
+ with collection.Sequence[A]
object Sequence extends covariant.SequenceFactory[Sequence] {
val empty: Sequence[Nothing] = Nil
diff --git a/src/library/scalax/collection/immutable/Set.scala b/src/library/scalax/collection/immutable/Set.scala
new file mode 100755
index 0000000000..5b39aaa3a4
--- /dev/null
+++ b/src/library/scalax/collection/immutable/Set.scala
@@ -0,0 +1,43 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id: Set.scala 16893 2009-01-13 13:09:22Z cunei $
+
+
+package scalax.collection.immutable
+
+import collection.generic._
+
+object Set extends generic.SetFactory[Set] {
+ private val hashSeed = "Set".hashCode
+ def empty[A]: Set[A] = null // !!!
+}
+
+trait Set[A] extends OrderedIterable[A]
+ with collection.Set[A]
+ with SetTemplate[Set, A] {
+
+ /** Compares this set with another object and returns true, iff the
+ * other object is also a set which contains the same elements as
+ * this set.
+ *
+ * @param that the other object
+ * @note not necessarily run-time type safe.
+ * @return <code>true</code> iff this set and the other set
+ * contain the same elements.
+ */
+ override def equals(that: Any): Boolean = that match {
+ case other: Set[_] =>
+ this.size == other.size && subsetOf(other.asInstanceOf[Set[A]])
+ case _ =>
+ false
+ }
+
+ override def hashCode = (Set.hashSeed /: this)(_ * 41 + _.hashCode)
+
+}
diff --git a/src/library/scalax/collection/immutable/Stream.scala b/src/library/scalax/collection/immutable/Stream.scala
index 63333ff091..3581ac5b5d 100755
--- a/src/library/scalax/collection/immutable/Stream.scala
+++ b/src/library/scalax/collection/immutable/Stream.scala
@@ -416,7 +416,8 @@ import Stream._
* @author Martin Odersky, Matthias Zenger
* @version 1.1 08/08/03
*/
-abstract class Stream[+A] extends Sequence[A] with SequenceTemplate[Stream, A] {
+abstract class Stream[+A] extends Sequence[A]
+ with SequenceTemplate[Stream, A] {
self =>
import collection.{Iterable, OrderedIterable, Sequence, Vector}
diff --git a/src/library/scalax/collection/immutable/Vector.scala b/src/library/scalax/collection/immutable/Vector.scala
index 64cf512c90..3848304525 100644
--- a/src/library/scalax/collection/immutable/Vector.scala
+++ b/src/library/scalax/collection/immutable/Vector.scala
@@ -13,7 +13,9 @@ import generic.covariant
* @owner Martin Odersky
* @version 2.8
*/
-trait Vector[+A] extends collection.Vector[A] with Sequence[A]
+trait Vector[+A] extends Sequence[A]
+ with covariant.VectorTemplate[Vector, A]
+ with collection.Vector[A]
object Vector extends covariant.SequenceFactory[Vector] {
val empty: Vector[Nothing] = immutable.Vector.empty