summaryrefslogtreecommitdiff
path: root/src/library/scalax
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2009-05-08 16:33:15 +0000
committerMartin Odersky <odersky@gmail.com>2009-05-08 16:33:15 +0000
commit14a631a5fec42d04d0723355a0b93e482b5e4662 (patch)
treef639c2a22e89e193b9abea391993ecfd4d5326ee /src/library/scalax
parent2379eb4ebbd28c8892b50a1d9fa8a687099eea4d (diff)
downloadscala-14a631a5fec42d04d0723355a0b93e482b5e4662.tar.gz
scala-14a631a5fec42d04d0723355a0b93e482b5e4662.tar.bz2
scala-14a631a5fec42d04d0723355a0b93e482b5e4662.zip
massive new collections checkin.
Diffstat (limited to 'src/library/scalax')
-rwxr-xr-xsrc/library/scalax/Fractional.scala5
-rwxr-xr-xsrc/library/scalax/Integral.scala6
-rwxr-xr-xsrc/library/scalax/Numeric.scala79
-rwxr-xr-xsrc/library/scalax/Tuple2.scala97
-rwxr-xr-xsrc/library/scalax/collection/BufferedIterator.scala27
-rwxr-xr-xsrc/library/scalax/collection/Iterable.scala160
-rwxr-xr-xsrc/library/scalax/collection/Iterator.scala965
-rwxr-xr-xsrc/library/scalax/collection/Map.scala21
-rwxr-xr-xsrc/library/scalax/collection/OrderedIterable.scala41
-rwxr-xr-xsrc/library/scalax/collection/Sequence.scala47
-rw-r--r--src/library/scalax/collection/Set.scala24
-rw-r--r--src/library/scalax/collection/SizedIterable.scala38
-rwxr-xr-xsrc/library/scalax/collection/Vector.scala23
-rwxr-xr-xsrc/library/scalax/collection/generic/Addable.scala64
-rw-r--r--src/library/scalax/collection/generic/AddableBuilder.scala22
-rwxr-xr-xsrc/library/scalax/collection/generic/Builder.scala31
-rw-r--r--src/library/scalax/collection/generic/Cloneable.scala19
-rwxr-xr-xsrc/library/scalax/collection/generic/EmptyIterableFactory.scala17
-rwxr-xr-xsrc/library/scalax/collection/generic/Growable.scala58
-rwxr-xr-xsrc/library/scalax/collection/generic/IterableFactory.scala122
-rw-r--r--src/library/scalax/collection/generic/IterableForwarder.scala59
-rwxr-xr-xsrc/library/scalax/collection/generic/IterableTemplate.scala677
-rwxr-xr-xsrc/library/scalax/collection/generic/IterableView.scala112
-rwxr-xr-xsrc/library/scalax/collection/generic/LazyBuilder.scala24
-rwxr-xr-xsrc/library/scalax/collection/generic/MapFactory.scala9
-rwxr-xr-xsrc/library/scalax/collection/generic/MapTemplate.scala247
-rw-r--r--src/library/scalax/collection/generic/MapView.scala44
-rwxr-xr-xsrc/library/scalax/collection/generic/MutableVectorTemplate.scala56
-rwxr-xr-xsrc/library/scalax/collection/generic/MutableVectorView.scala97
-rwxr-xr-xsrc/library/scalax/collection/generic/OrderedIterableForwarder.scala37
-rwxr-xr-xsrc/library/scalax/collection/generic/OrderedIterableTemplate.scala161
-rwxr-xr-xsrc/library/scalax/collection/generic/OrderedIterableView.scala87
-rwxr-xr-xsrc/library/scalax/collection/generic/SequenceFactory.scala11
-rw-r--r--src/library/scalax/collection/generic/SequenceForwarder.scala50
-rwxr-xr-xsrc/library/scalax/collection/generic/SequenceTemplate.scala383
-rwxr-xr-xsrc/library/scalax/collection/generic/SequenceView.scala131
-rw-r--r--src/library/scalax/collection/generic/SetFactory.scala11
-rwxr-xr-xsrc/library/scalax/collection/generic/SetTemplate.scala148
-rwxr-xr-xsrc/library/scalax/collection/generic/Shrinkable.scala54
-rwxr-xr-xsrc/library/scalax/collection/generic/Subtractable.scala64
-rw-r--r--src/library/scalax/collection/generic/VectorTemplate.scala266
-rwxr-xr-xsrc/library/scalax/collection/generic/covartest/IterableFactory.scala108
-rwxr-xr-xsrc/library/scalax/collection/generic/covartest/IterableForwarder.scala59
-rwxr-xr-xsrc/library/scalax/collection/generic/covartest/IterableTemplate.scala677
-rwxr-xr-xsrc/library/scalax/collection/generic/covartest/IterableView.scala112
-rwxr-xr-xsrc/library/scalax/collection/generic/covartest/OrderedIterableForwarder.scala37
-rwxr-xr-xsrc/library/scalax/collection/generic/covartest/OrderedIterableTemplate.scala161
-rwxr-xr-xsrc/library/scalax/collection/generic/covartest/SequenceFactory.scala11
-rw-r--r--src/library/scalax/collection/generic/covartest/SequenceForwarder.scala50
-rwxr-xr-xsrc/library/scalax/collection/generic/covartest/SequenceTemplate.scala382
-rwxr-xr-xsrc/library/scalax/collection/generic/covartest/SequenceView.scala131
-rw-r--r--src/library/scalax/collection/generic/covartest/VectorTemplate.scala264
-rw-r--r--src/library/scalax/collection/immutable/DefaultSet.scala45
-rw-r--r--src/library/scalax/collection/immutable/EmptyMap.scala34
-rwxr-xr-xsrc/library/scalax/collection/immutable/EmptySet.scala38
-rw-r--r--src/library/scalax/collection/immutable/HashMap.scala164
-rw-r--r--src/library/scalax/collection/immutable/HashSet.scala138
-rw-r--r--src/library/scalax/collection/immutable/Iterable.scala24
-rw-r--r--src/library/scalax/collection/immutable/List.scala952
-rwxr-xr-xsrc/library/scalax/collection/immutable/Map.scala66
-rwxr-xr-xsrc/library/scalax/collection/immutable/Map1.scala39
-rw-r--r--src/library/scalax/collection/immutable/Map2.scala44
-rw-r--r--src/library/scalax/collection/immutable/Map3.scala47
-rw-r--r--src/library/scalax/collection/immutable/Map4.scala50
-rw-r--r--src/library/scalax/collection/immutable/OrderedIterable.scala26
-rw-r--r--src/library/scalax/collection/immutable/Sequence.scala25
-rwxr-xr-xsrc/library/scalax/collection/immutable/Set.scala45
-rwxr-xr-xsrc/library/scalax/collection/immutable/Set1.scala46
-rwxr-xr-xsrc/library/scalax/collection/immutable/Set2.scala47
-rwxr-xr-xsrc/library/scalax/collection/immutable/Set3.scala48
-rwxr-xr-xsrc/library/scalax/collection/immutable/Set4.scala49
-rwxr-xr-xsrc/library/scalax/collection/immutable/Stream.scala794
-rw-r--r--src/library/scalax/collection/immutable/Vector.scala25
-rwxr-xr-xsrc/library/scalax/collection/mutable/Array.scala410
-rw-r--r--src/library/scalax/collection/mutable/ArrayBuffer.scala140
-rw-r--r--src/library/scalax/collection/mutable/Buffer.scala274
-rw-r--r--src/library/scalax/collection/mutable/DefaultEntry.scala16
-rw-r--r--src/library/scalax/collection/mutable/DefaultMapModel.scala44
-rw-r--r--src/library/scalax/collection/mutable/FlatHashTable.scala164
-rw-r--r--src/library/scalax/collection/mutable/HashMap.scala43
-rw-r--r--src/library/scalax/collection/mutable/HashSet.scala48
-rw-r--r--src/library/scalax/collection/mutable/HashTable.scala172
-rwxr-xr-xsrc/library/scalax/collection/mutable/Iterable.scala32
-rw-r--r--src/library/scalax/collection/mutable/ListBuffer.scala314
-rwxr-xr-xsrc/library/scalax/collection/mutable/Map.scala73
-rwxr-xr-xsrc/library/scalax/collection/mutable/OrderedIterable.scala22
-rw-r--r--src/library/scalax/collection/mutable/ResizableArray.scala108
-rwxr-xr-xsrc/library/scalax/collection/mutable/Sequence.scala23
-rw-r--r--src/library/scalax/collection/mutable/Set.scala119
-rwxr-xr-xsrc/library/scalax/collection/mutable/StringBuilder.scala942
-rw-r--r--src/library/scalax/collection/mutable/Vector.scala21
-rw-r--r--src/library/scalax/runtime/Boxed.scala18
-rwxr-xr-xsrc/library/scalax/runtime/BoxedAnyArray.scala239
-rwxr-xr-xsrc/library/scalax/runtime/BoxedArray.scala138
-rwxr-xr-xsrc/library/scalax/runtime/BoxedBooleanArray.scala25
-rwxr-xr-xsrc/library/scalax/runtime/BoxedByteArray.scala25
-rwxr-xr-xsrc/library/scalax/runtime/BoxedCharArray.scala25
-rwxr-xr-xsrc/library/scalax/runtime/BoxedDoubleArray.scala25
-rwxr-xr-xsrc/library/scalax/runtime/BoxedFloatArray.scala25
-rwxr-xr-xsrc/library/scalax/runtime/BoxedIntArray.scala25
-rwxr-xr-xsrc/library/scalax/runtime/BoxedLongArray.scala25
-rwxr-xr-xsrc/library/scalax/runtime/BoxedShortArray.scala25
-rw-r--r--src/library/scalax/runtime/BoxedString.scala195
-rwxr-xr-xsrc/library/scalax/runtime/ScalaRunTime.scala152
-rw-r--r--src/library/scalax/runtime/StringVector.scala54
-rwxr-xr-xsrc/library/scalax/util/control/Breaks.scala24
-rw-r--r--src/library/scalax/util/control/TailRec.scala24
107 files changed, 0 insertions, 13341 deletions
diff --git a/src/library/scalax/Fractional.scala b/src/library/scalax/Fractional.scala
deleted file mode 100755
index b29a903519..0000000000
--- a/src/library/scalax/Fractional.scala
+++ /dev/null
@@ -1,5 +0,0 @@
-package scalax
-
-trait Fractional[T] extends Numeric[T] {
- def div(x: T, y: T): T
-}
diff --git a/src/library/scalax/Integral.scala b/src/library/scalax/Integral.scala
deleted file mode 100755
index 2e80b1bb7b..0000000000
--- a/src/library/scalax/Integral.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-package scalax
-
-trait Integral[T] extends Numeric[T] {
- def quot(x: T, y: T): T
- def rem(x: T, y: T): T
-}
diff --git a/src/library/scalax/Numeric.scala b/src/library/scalax/Numeric.scala
deleted file mode 100755
index 6e61851dc5..0000000000
--- a/src/library/scalax/Numeric.scala
+++ /dev/null
@@ -1,79 +0,0 @@
-package scalax
-
-object Numeric {
- implicit object IntIsIntegral extends Integral[Int] {
- def plus(x: Int, y: Int): Int = x + y
- def minus(x: Int, y: Int): Int = x - y
- def times(x: Int, y: Int): Int = x * y
- def quot(x: Int, y: Int): Int = x / y
- def rem(x: Int, y: Int): Int = x % y
- def negate(x: Int): Int = -x
- def abs(x: Int): Int = if (x < 0) -x else x
- def signum(x: Int): Int = if (x < 0) -1 else if (x > 0) 1 else 0
- def fromInt(x: Int): Int = x
- def toInt(x: Int): Int = x
- def toLong(x: Int): Long = x
- def toFloat(x: Int): Float = x
- def toDouble(x: Int): Double = x
- }
- implicit object LongIsIntegral extends Integral[Long] {
- def plus(x: Long, y: Long): Long = x + y
- def minus(x: Long, y: Long): Long = x - y
- def times(x: Long, y: Long): Long = x * y
- def quot(x: Long, y: Long): Long = x / y
- def rem(x: Long, y: Long): Long = x % y
- def negate(x: Long): Long = -x
- def abs(x: Long): Long = if (x < 0) -x else x
- def signum(x: Long): Long = if (x < 0) -1 else if (x > 0) 1 else 0
- def fromInt(x: Int): Long = x
- def toInt(x: Long): Int = x.toInt
- def toLong(x: Long): Long = x
- def toFloat(x: Long): Float = x
- def toDouble(x: Long): Double = x
- }
- implicit object FloatIsFractional extends Fractional[Float] {
- def plus(x: Float, y: Float): Float = x + y
- def minus(x: Float, y: Float): Float = x - y
- def times(x: Float, y: Float): Float = x * y
- def div(x: Float, y: Float): Float = x / y
- def negate(x: Float): Float = -x
- def abs(x: Float): Float = if (x < 0) -x else x
- def signum(x: Float): Float = if (x < 0) -1 else if (x > 0) 1 else 0
- def fromInt(x: Int): Float = x
- def toInt(x: Float): Int = x.toInt
- def toLong(x: Float): Long = x.toLong
- def toFloat(x: Float): Float = x
- def toDouble(x: Float): Double = x
- }
- implicit object DoubleIsFractional extends Fractional[Double] {
- def plus(x: Double, y: Double): Double = x + y
- def minus(x: Double, y: Double): Double = x - y
- def times(x: Double, y: Double): Double = x * y
- def div(x: Double, y: Double): Double = x / y
- def negate(x: Double): Double = -x
- def abs(x: Double): Double = if (x < 0) -x else x
- def signum(x: Double): Double = if (x < 0) -1 else if (x > 0) 1 else 0
- def fromInt(x: Int): Double = x
- def toInt(x: Double): Int = x.toInt
- def toLong(x: Double): Long = x.toLong
- def toFloat(x: Double): Float = x.toFloat
- def toDouble(x: Double): Double = x
- }
-}
-
-
-trait Numeric[T] {
- def plus(x: T, y: T): T
- def minus(x: T, y: T): T
- def times(x: T, y: T): T
- def negate(x: T): T
- def abs(x: T): T
- def signum(x: T): T
- def fromInt(x: Int): T
- def toInt(x: T): Int
- def toLong(x: T): Long
- def toFloat(x: T): Float
- def toDouble(x: T): Double
- def zero = fromInt(0)
- def one = fromInt(1)
-}
diff --git a/src/library/scalax/Tuple2.scala b/src/library/scalax/Tuple2.scala
deleted file mode 100755
index 4adb9e471b..0000000000
--- a/src/library/scalax/Tuple2.scala
+++ /dev/null
@@ -1,97 +0,0 @@
-
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Tuple2.scala 14794 2008-04-23 08:15:17Z washburn $
-
-// generated by genprod on Wed Apr 23 10:06:16 CEST 2008 (with extra methods)
-
-package scalax
-
-import annotation.unchecked.uncheckedVariance
-
-object Tuple2 {
-
- import collection._
- import collection.generic._
-
- class IterableOps[CC[+B] <: Iterable[B] with IterableTemplate[CC, B @uncheckedVariance], A1, A2](tuple: (CC[A1], Iterable[A2])) {
- def zip: CC[(A1, A2)] = {
- val elems1 = tuple._1.elements
- val elems2 = tuple._2.elements
- val b = tuple._1.newBuilder[(A1, A2)]
- while (elems1.hasNext && elems2.hasNext)
- b += ((elems1.next, elems2.next))
- b.result
- }
- def map[B](f: (A1, A2) => B): CC[B] = {
- val elems1 = tuple._1.elements
- val elems2 = tuple._2.elements
- val b = tuple._1.newBuilder[B]
- while (elems1.hasNext && elems2.hasNext)
- b += f(elems1.next, elems2.next)
- b.result
- }
- def flatMap[B](f: (A1, A2) => CC[B]): CC[B] = {
- val elems1 = tuple._1.elements
- val elems2 = tuple._2.elements
- val b = tuple._1.newBuilder[B]
- while (elems1.hasNext && elems2.hasNext)
- b ++= f(elems1.next, elems2.next)
- b.result
- }
- def foreach(f: (A1, A2) => Unit) {
- val elems1 = tuple._1.elements
- val elems2 = tuple._2.elements
- while (elems1.hasNext && elems2.hasNext)
- f(elems1.next, elems2.next)
- }
- def forall(p: (A1, A2) => Boolean): Boolean = {
- val elems1 = tuple._1.elements
- val elems2 = tuple._2.elements
- while (elems1.hasNext && elems2.hasNext)
- if (!p(elems1.next, elems2.next)) return false
- true
- }
- def exists(p: (A1, A2) => Boolean): Boolean = {
- val elems1 = tuple._1.elements
- val elems2 = tuple._2.elements
- while (elems1.hasNext && elems2.hasNext)
- if (p(elems1.next, elems2.next)) return true
- false
- }
- }
- implicit def tupleOfIterableWrapper[CC[+B] <: Iterable[B] with IterableTemplate[CC, B], A1, A2](tuple: (CC[A1], Iterable[A2])) =
- new IterableOps[CC, A1, A2](tuple)
-
-
-/* A more general version which will probably not work.
- implicit def tupleOfIterableWrapper[CC[+B] <: Iterable[B] with IterableTemplate[CC, B], A1, A2, B1 <: CC[A1]](tuple: B1, Iterable[A2]) =
- new IterableOps[CC, A1, A2](tuple)
-*/
-
- // Adriaan: If you drop the type parameters it will infer the wrong types.
- tupleOfIterableWrapper[collection.immutable.List, Int, Int]((collection.immutable.Nil, collection.immutable.Nil)) forall (_ + _ < 10)
-}
-
-/** Tuple2 is the canonical representation of a @see Product2
- *
- */
-case class Tuple2[+T1, +T2](_1:T1, _2:T2)
- extends Product2[T1, T2] {
-
- override def toString() = {
- val sb = new StringBuilder
- sb.append('(').append(_1).append(',').append(_2).append(')')
- sb.toString
- }
-
- /** Swap the elements of the tuple */
- def swap: Tuple2[T2,T1] = Tuple2(_2, _1)
-
-}
diff --git a/src/library/scalax/collection/BufferedIterator.scala b/src/library/scalax/collection/BufferedIterator.scala
deleted file mode 100755
index dbe4fd36d1..0000000000
--- a/src/library/scalax/collection/BufferedIterator.scala
+++ /dev/null
@@ -1,27 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: BufferedIterator.scala 12641 2007-08-22 16:01:57Z mcdirmid $
-
-
-package scalax.collection
-
-/** Buffered iterators are iterators which allow to inspect the next
- * element without discarding it.
- *
- * @author Martin Odersky
- * @version 2.8
- */
-trait BufferedIterator[+A] extends Iterator[A] {
-
- /** Returns current element of iterator without advancing beyond it.
- */
- def head: A
-
- override def buffered: this.type = this
-}
diff --git a/src/library/scalax/collection/Iterable.scala b/src/library/scalax/collection/Iterable.scala
deleted file mode 100755
index 3dc181707c..0000000000
--- a/src/library/scalax/collection/Iterable.scala
+++ /dev/null
@@ -1,160 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
-
-
-package scalax.collection
-
-import generic._
-import collection.immutable.{List, Nil, ::}
-import annotation.unchecked.uncheckedVariance
-
-/** Collection classes mixing in this class provide a method
- * <code>elements</code> which returns an iterator over all the
- * elements contained in the collection.
- *
- * @note If a collection has a known <code>size</code>, it should also sub-type <code>SizedIterable</code>.
- *
- * @author Matthias Zenger
- * @autor Martin Odersky
- * @owner Martin Odersky
- * @version 2.8
- */
-trait Iterable[+A] extends IterableTemplate[Iterable, A @uncheckedVariance] { self =>
-
- /** Creates a view of this iterable @see Iterable.View
- def view: View[Iterable, A] = new View[Iterable, A] { // !!! Martin: We should maybe infer the type parameters here?
- val origin: self.type = self
- val elements: Iterator[A] = self.elements
- }
- */
-}
-
-/** Various utilities for instances of <a href="Iterable.html">Iterable</a>.
- *
- * @author Matthias Zenger
- * @author Martin Odersky
- * @version 2.8
- */
-object Iterable extends IterableFactory[Iterable] with EmptyIterableFactory[Iterable] {
-
- /** The empty iterable */
- val empty: Iterable[Nothing] = Nil
-
- class ComparableIterableOps[A](seq: Iterable[A], cmp: Ordering[A]) {
- def min: A = {
- require(!seq.isEmpty, "min(<empty>)")
- var acc = seq.elements.next
- for (x <- seq)
- if (cmp.lt(x, acc)) acc = x
- acc
- }
- def max: A = {
- require(!seq.isEmpty, "max(<empty>)")
- var acc = seq.elements.next
- for (x <- seq)
- if (cmp.gt(x, acc)) acc = x
- acc
- }
- }
-
- class NumericIterableOps[A](seq: Iterable[A], num: Numeric[A]) {
- def sum: A = {
- var acc = num.zero
- for (x <- seq) acc = num.plus(acc, x)
- acc
- }
- def product: A = {
- var acc = num.one
- for (x <- seq) acc = num.times(acc, x)
- acc
- }
- }
-
- class IterableIterableOps[C[+B] <: Iterable[B] with IterableTemplate[C, B @uncheckedVariance], A](self: C[C[A]]) {
- def flatten: C[A] = {
- val b: generic.Builder[C, A] = self.newBuilder[A]
- for (xs <- self)
- b ++= xs
- b.result
- }
-
- def transpose: C[C[A]] = {
- val bs: scala.Array[generic.Builder[C, A]] = self.head.map(_ => self.newBuilder[A]).toArray
- for (xs <- self) {
- var i = 0
- for (x <- xs) {
- bs(i) += x
- i += 1
- }
- }
- val bb = self.newBuilder[C[A]]
- for (b <- bs) bb += b.result
- bb.result
- }
- }
-
-
- class PairIterableOps[C[+B] <: Iterable[B], A1, A2](self: C[(A1, A2)]) {
- def unzip: (C[A1], C[A2]) = {
- val as = self.newBuilder[A1].asInstanceOf[Builder[C, A1]]
- val bs = self.newBuilder[A2].asInstanceOf[Builder[C, A2]]
- for ((a, b) <- self) {
- as += a
- bs += b
- }
- (as.result, bs.result)
- }
- }
-
- implicit def comparableIterableWrapper[A](seq: Iterable[A])(implicit cmp: Ordering[A]) =
- new ComparableIterableOps(seq, cmp)
- implicit def numericIterableWrapper[A](seq: Iterable[A])(implicit num: Numeric[A]) =
- new NumericIterableOps(seq, num)
- implicit def iterableIterableWrapper[C[+B] <: Iterable[B] with IterableTemplate[C, B], A](seq: C[C[A]]) =
- new IterableIterableOps[C, A](seq)
- implicit def pairIterableWrapper[C[+B] <: Iterable[B], A1, A2](seq: C[(A1, A2)]) =
- new PairIterableOps[C, A1, A2](seq)
-
- type View[A] = IterableView[UC, A] forSome { type UC[B] <: Iterable[B] }
-
- /** @deprecated use View instead
- */
- @deprecated type Projection[A] = View[A]
-
- /** The minimum element of a non-empty sequence of ordered elements
- * @deprecated use seq.min instead
- */
- @deprecated def min[A <% Ordered[A]](seq: Iterable[A]): A = {
- val xs = seq.elements
- if (!xs.hasNext) throw new IllegalArgumentException("min(<empty>)")
- var min = xs.next
- while (xs.hasNext) {
- val x = xs.next
- if (x < min) min = x
- }
- min
- }
-
- /** The maximum element of a non-empty sequence of ordered elements
- * @deprecated use seq.max iConstead
- */
- @deprecated def max[A <% Ordered[A]](seq: Iterable[A]): A = {
- val xs = seq.elements
- if (!xs.hasNext) throw new IllegalArgumentException("max(<empty>)")
- var max = xs.next
- while (xs.hasNext) {
- val x = xs.next
- if (max < x) max = x
- }
- max
- }
-
-}
-
diff --git a/src/library/scalax/collection/Iterator.scala b/src/library/scalax/collection/Iterator.scala
deleted file mode 100755
index 48eda407aa..0000000000
--- a/src/library/scalax/collection/Iterator.scala
+++ /dev/null
@@ -1,965 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Iterator.scala 15939 2008-08-26 14:33:17Z stepancheg $
-
-
-package scalax.collection
-
-import mutable.{Buffer, ArrayBuffer, ListBuffer}
-import immutable.{List, Nil, ::, Stream}
-
-/** The <code>Iterator</code> object provides various functions for
- * creating specialized iterators.
- *
- * @author Martin Odersky
- * @author Matthias Zenger
- * @version 2.8
- */
-object Iterator {
-
- val empty = new Iterator[Nothing] {
- def hasNext: Boolean = false
- def next(): Nothing = throw new NoSuchElementException("next on empty iterator")
- }
-
- /**
- * @param elem the element
- * @return the iterator with one single element
- * @note Equivalent, but more efficient than Iterator(x)
- */
- def single[A](elem: A) = new Iterator[A] {
- private var hasnext = true
- def hasNext: Boolean = hasnext
- def next(): A =
- if (hasnext) { hasnext = false; elem }
- else empty.next()
- }
-
- def apply[A](args: A*): Iterator[A] = args.asInstanceOf[Iterable[A]].elements // !@!
-
- /** Concatenate all the argument iterators into a single iterator.
- *
- * @param xss the lists that are to be concatenated
- * @return the concatenation of all the lists
- */
- def concat[A](xss: Iterator[A]*): Iterator[A] =
- xss.asInstanceOf[Iterable[Iterator[A]]].elements.flatten // !@!
-
- /** An iterator that returns the same element a number of times
- * @param len The number of elements returned
- * @param elem The element returned each time
- */
- def fill[A](len: Int, elem: => A) = new Iterator[A] {
- private var i = 0
- def hasNext: Boolean = i < len
- def next(): A =
- if (hasNext) { i += 1; elem }
- else empty.next()
- }
-
- /** An iterator that returns values of a function <code>f(0), ..., f(n-1)</code>,
- * for given `f` and `n`.
- */
- def tabulate[A](n: Int)(f: Int => A) = new Iterator[A] {
- private var i = 0
- def hasNext: Boolean = i < n
- def next(): A =
- if (hasNext) { val result = f(i); i += 1; result }
- else empty.next()
- }
-
- /** Nn iterator with elements
- * <code>e<sub>n+1</sub> = e<sub>n</sub> + 1</code>
- * where <code>e<sub>0</sub> = start</code>
- * and <code>e<sub>i</sub> &lt; end</code>. However,
- * if <code>start &ge; end</code>, then it will return an empty range.
- *
- * @param start the start value of the iterator
- * @param end the end value of the iterator
- * @return the iterator with values in range <code>[start;end)</code>.
- */
- def range(start: Int, end: Int): Iterator[Int] = range(start, end, 1)
-
- /** Create an iterator with elements
- * <code>e<sub>n+1</sub> = e<sub>n</sub> + step</code>
- * where <code>e<sub>0</sub> = start</code>
- * and elements are in the range between <code>start</code> (inclusive)
- * and <code>end</code> (exclusive)
- *
- * @param start the start value of the iterator
- * @param end the end value of the iterator
- * @param step the increment value of the iterator (must be positive or negative)
- * @return the iterator with values in range <code>[start;end)</code>.
- */
- def range(start: Int, end: Int, step: Int) = new Iterator[Int] {
- private var i = start
- def hasNext: Boolean = (step <= 0 || i < end) && (step >= 0 || i > end)
- def next(): Int =
- if (hasNext) { val result = i; i += step; result }
- else empty.next()
- }
-
- /** An iterator that repeatedly applies a given function to a start value.
- *
- * @param start the start value of the iteratpr
- * @param len the number of elements returned by the iterator
- * @param f the function that's repeatedly applied
- * @return the iterator returning values <code>(start, f(start), f(f(start)), ..., f<sup>len-1</sup>(start))</code>
- */
- def iterate(start: Int, len: Int)(f: Int => Int) = new Iterator[Int] {
- private var acc = start
- private var i = 0
- def hasNext: Boolean = i < len
- def next(): Int =
- if (hasNext) { val result = f(acc); i += 1; result }
- else empty.next()
- }
-
- /** An infinite iterator that repeatedly applies a given function to a start value.
- *
- * @param start the start value of the iteratpr
- * @param f the function that's repeatedly applied
- * @return the iterator returning values <code>(start, f(start), f(f(start)), ..., f<sup>len-1</sup>(start))</code>
- */
- def iterate(start: Int)(f: Int => Int) = new Iterator[Int] {
- private var acc = start
- private var i = 0
- def hasNext: Boolean = true
- def next(): Int = { val result = f(acc); i += 1; result }
- }
-
- /** Create an iterator with elements
- * <code>e<sub>n+1</sub> = e<sub>n</sub> + 1</code>
- * where <code>e<sub>0</sub> = start</code>.
- *
- * @param start the start value of the iterator
- * @return the iterator starting at value <code>start</code>.
- */
- def from(start: Int): Iterator[Int] = from(start, 1)
-
- /** Create an iterator with elements
- * <code>e<sub>n+1</sub> = e<sub>n</sub> + step</code>
- * where <code>e<sub>0</sub> = start</code>.
- *
- * @param start the start value of the iterator
- * @param step the increment value of the iterator
- * @return the iterator starting at value <code>start</code>.
- */
- def from(start: Int, step: Int): Iterator[Int] = new Iterator[Int] {
- private var i = 0
- def hasNext: Boolean = true
- def next(): Int = { val result = i; i += 1; result }
- }
-
- class IteratorIteratorOps[A](its: Iterator[Iterator[A]]) {
- /** Create an iterator that is the concantenation of all iterators
- * returned by a given iterator of iterators.
- * @param its The iterator which returns on each call to next
- * a new iterator whose elements are to be concatenated to the result.
- */
- def flatten: Iterator[A] = new Iterator[A] {
- private var it = its.next
- def hasNext: Boolean = if (it.hasNext) { it = its.next; hasNext } else false
- def next(): A = if (hasNext) it.next else empty.next()
- }
- }
-
- implicit def iteratorIteratorWrapper[A](its: Iterator[Iterator[A]]): IteratorIteratorOps[A] =
- new IteratorIteratorOps[A](its)
-
- /** @deprecated use `xs.elements`, or `Iterator(x1, ..., xn)` instead
- */
- @deprecated def fromValues[a](xs: a*) = xs.elements
-
- /**
- * @param xs the array of elements
- * @see also: Vector.elements and slice
- * @deprecated use `xs.elements` instead
- */
- @deprecated def fromArray[a](xs: Array[a]): Iterator[a] =
- fromArray(xs, 0, xs.length)
-
- /**
- * @param xs the array of elements
- * @param start the start index
- * @param length the length
- * @see also: Vector.elements and slice
- * @deprecated use `xs.slice(start, start + length).elements` instead
- */
- @deprecated def fromArray[a](xs: Array[a], start: Int, length: Int): Iterator[a] =
- xs.slice(start, start + length).elements.asInstanceOf[Iterator[a]] // !@!
-
- /**
- * @param str the given string
- * @return the iterator on <code>str</code>
- * @deprecated replaced by <code>str.elements</code>
- */
- @deprecated def fromString(str: String): Iterator[Char] =
- str.elements.asInstanceOf[Iterator[Char]] // !@!
-
- /**
- * @param n the product arity
- * @return the iterator on <code>Product&lt;n&gt;</code>.
- * @deprecated use product.productElements instead
- */
- @deprecated def fromProduct(n: Product): Iterator[Any] = new Iterator[Any] {
- private var c: Int = 0
- private val cmax = n.productArity
- def hasNext = c < cmax
- def next() = { val a = n productElement c; c += 1; a }
- }
-
- /** Create an iterator with elements
- * <code>e<sub>n+1</sub> = step(e<sub>n</sub>)</code>
- * where <code>e<sub>0</sub> = start</code>
- * and elements are in the range between <code>start</code> (inclusive)
- * and <code>end</code> (exclusive)
- *
- * @param start the start value of the iterator
- * @param end the end value of the iterator
- * @param step the increment function of the iterator, must be monotonically increasing or decreasing
- * @return the iterator with values in range <code>[start;end)</code>.
- * @deprecated use Iterator.iterate(start, end - start)(step) instead
- */
- @deprecated def range(start: Int, end: Int, step: Int => Int) = new Iterator[Int] {
- private val up = step(start) > start
- private val down = step(start) < start
- private var i = start
- def hasNext: Boolean = (!up || i < end) && (!down || i > end)
- def next(): Int =
- if (hasNext) { val j = i; i = step(i); j }
- else empty.next()
- }
-
- /** Create an iterator with elements
- * <code>e<sub>n+1</sub> = step(e<sub>n</sub>)</code>
- * where <code>e<sub>0</sub> = start</code>.
- *
- * @param start the start value of the iterator
- * @param step the increment function of the iterator
- * @return the iterator starting at value <code>start</code>.
- * @deprecated use iterate(start)(step) instead
- */
- @deprecated def from(start: Int, step: Int => Int): Iterator[Int] = new Iterator[Int] {
- private var i = start
- override def hasNext: Boolean = true
- def next(): Int = { val j = i; i = step(i); j }
- }
-
- /** Create an iterator that is the concantenation of all iterators
- * returned by a given iterator of iterators.
- * @param its The iterator which returns on each call to next
- * a new iterator whose elements are to be concatenated to the result.
- * @deprecated use its.flatten instead
- */
- @deprecated def flatten[T](its: Iterator[Iterator[T]]): Iterator[T] = new Iterator[T] {
- private var it = its.next
- def hasNext: Boolean = {
- while (!it.hasNext && its.hasNext) it = its.next
- it.hasNext
- }
- def next(): T =
- if (hasNext) it.next
- else empty.next()
- }
-}
-
-import Iterator.empty
-
-/** Iterators are data structures that allow to iterate over a sequence
- * of elements. They have a <code>hasNext</code> method for checking
- * if there is a next element available, and a <code>next</code> method
- * which returns the next element and discards it from the iterator.
- *
- * @author Martin Odersky, Matthias Zenger
- * @version 2.8
- */
-trait Iterator[+A] {
-self =>
-
- /** Does this iterator provide another element?
- */
- def hasNext: Boolean
-
- /** Returns the next element.
- */
- def next(): A
-
- /** Returns a new iterator that iterates only over the first <code>n</code>
- * elements.
- *
- * @param n the number of elements to take
- * @return the new iterator
- */
- def take(n: Int): Iterator[A] = new Iterator[A] {
- private var remaining = n
- def hasNext = remaining > 0 && self.hasNext
- def next(): A =
- if (hasNext) { remaining -= 1; self.next }
- else throw new NoSuchElementException("next on empty iterator")
- }
-
- /** Removes the first <code>n</code> elements from this iterator.
- *
- * @param n the number of elements to drop
- * @return the new iterator
- */
- def drop(n: Int): Iterator[A] =
- if (n > 0 && hasNext) { next(); drop(n - 1) } else this
-
- /** A sub-iterator of <code>until - from elements
- * starting at index <code>from</code>
- *
- * @param from The index of the first element of the slice
- * @param until The index of the element following the slice
- */
- def slice(from: Int, until: Int): Iterator[A] = drop(from).take(until - from)
-
- /** Returns a new iterator that maps all elements of this iterator
- * to new elements using function <code>f</code>.
- */
- def map[B](f: A => B): Iterator[B] = new Iterator[B] {
- def hasNext = self.hasNext
- def next() = f(self.next())
- }
-
- /** Returns a new iterator that first yields the elements of this
- * iterator followed by the elements provided by iterator <code>that</code>.
- * @deprecated use <code>++</code>
- */
- def append[B >: A](that: Iterator[B]) = new Iterator[B] {
- def hasNext = self.hasNext || that.hasNext
- def next() = (if (self.hasNext) self else that).next()
- }
-
- /** Returns a new iterator that first yields the elements of this
- * iterator followed by the elements provided by iterator <code>that</code>.
- */
- def ++[B >: A](that: => Iterator[B]) = new Iterator[B] {
- // optimize a little bit to prevent n log n behavior.
- var cur : Iterator[B] = self
- def hasNext = cur.hasNext || (cur eq self) && { cur = that; hasNext }
- def next() = { hasNext; cur.next }
- }
-
- /** Applies the given function <code>f</code> to each element of
- * this iterator, then concatenates the results.
- *
- * @param f the function to apply on each element.
- * @return an iterator over <code>f(a<sub>0</sub>), ... ,
- * f(a<sub>n</sub>)</code> if this iterator yields the
- * elements <code>a<sub>0</sub>, ..., a<sub>n</sub></code>.
- */
- def flatMap[B](f: A => Iterator[B]): Iterator[B] = new Iterator[B] {
- private var cur: Iterator[B] = empty
- def hasNext: Boolean =
- cur.hasNext || self.hasNext && { cur = f(self.next); hasNext }
- def next(): B = (if (hasNext) cur else empty).next()
- }
-
- /** Returns an iterator over all the elements of this iterator that
- * satisfy the predicate <code>p</code>. The order of the elements
- * is preserved.
- *
- * @param p the predicate used to filter the iterator.
- * @return the elements of this iterator satisfying <code>p</code>.
- */
- def filter(p: A => Boolean): Iterator[A] = {
- val self = buffered
- new Iterator[A] {
- private def skip() = while (self.hasNext && !p(self.head)) self.next()
- def hasNext = { skip(); self.hasNext }
- def next() = { skip(); self.next() }
- }
- }
-
- /** Returns an iterator over the longest prefix of this iterator such that
- * all elements of the result satisfy the predicate <code>p</code>.
- * The order of the elements is preserved.
- *
- * The behavior of <code>this</code> iterator is undefined after this method invocation.
- *
- * @param p the predicate used to filter the iterator.
- * @return the longest prefix of this iterator satisfying <code>p</code>.
- */
- def takeWhile(p: A => Boolean): Iterator[A] = {
- val self = buffered
- new Iterator[A] {
- def hasNext = { self.hasNext && p(self.head) }
- def next() = (if (hasNext) self else empty).next()
- }
- }
-
- /** Partitions this iterator in two iterators according to a predicate.
- *
- * @param p the predicate on which to partition
- * @return a pair of iterators: the iterator that satisfies the predicate
- * <code>p</code> and the iterator that does not.
- * The relative order of the elements in the resulting iterators
- * is the same as in the original iterator.
- */
- def partition(p: A => Boolean): (Iterator[A], Iterator[A]) = {
- val self = buffered
- class PartitionIterator(p: A => Boolean) extends Iterator[A] {
- var other: PartitionIterator = _
- val lookahead = new scala.collection.mutable.Queue[A]
- def skip() =
- while (self.hasNext && !p(self.head)) {
- other.lookahead += self.next
- }
- def hasNext = !lookahead.isEmpty || self.hasNext
- def next() = if (lookahead.isEmpty) self.next() else lookahead.dequeue()
- }
- val l = new PartitionIterator(p)
- val r = new PartitionIterator(!p(_))
- l.other = r
- r.other = l
- (l, r)
- }
-
- /** Skips longest sequence of elements of this iterator which satisfy given
- * predicate <code>p</code>, and returns an iterator of the remaining elements.
- *
- * The behavior of <code>this</code> iterator is undefined after this method invocation.
- *
- * @param p the predicate used to skip elements.
- * @return an iterator consisting of the remaining elements
- */
- def dropWhile(p: A => Boolean): Iterator[A] = {
- val self = buffered
- new Iterator[A] {
- var dropped = false
- private def skip() =
- if (!dropped) {
- while (self.hasNext && p(self.head)) self.next()
- dropped = true
- }
- def hasNext = { skip(); self.hasNext }
- def next() = { skip(); self.next() }
- }
- }
-
- /** Return an iterator formed from this iterator and the specified iterator
- * <code>that</code> by associating each element of the former with
- * the element at the same position in the latter.
- * If one of the two iterators is longer than the other, its remaining elements are ignored.
- *
- * @return an iterator yielding <code>{a<sub>0</sub>,b<sub>0</sub>},
- * {a<sub>1</sub>,b<sub>1</sub>}, ...</code> where
- * <code>a<sub>i</sub></code> are the elements from this iterator
- * and <code>b<sub>i</sub></code> are the elements from iterator
- * <code>that</code>.
- */
- def zip[B](that: Iterator[B]) = new Iterator[(A, B)] {
- def hasNext = self.hasNext && that.hasNext
- def next = (self.next, that.next)
- }
-
- /** Return an iterator that pairs each element of this iterator
- * with its index, counting from 0.
- *
- * @return an iterator yielding <code>{a<sub>0</sub>,0},
- * {a<sub>1</sub>,1}...</code> where <code>a<sub>i</sub></code>
- * are the elements from this iterator.
- */
- def zipWithIndex = new Iterator[(A, Int)] {
- var idx = 0
- def hasNext = self.hasNext
- def next = {
- val ret = (self.next, idx)
- idx += 1
- ret
- }
- }
-
- /** Returns an iterator formed from this iterator and the specified iterator
- * <code>that</code> by associating each element of the former with
- * the element at the same position in the latter.
- *
- * @param that iterator <code>that</code> may have a different length
- * as the self iterator.
- * @param thisElem element <code>thisElem</code> is used to fill up the
- * resulting iterator if the self iterator is shorter than
- * <code>that</code>
- * @param thatElem element <code>thatElem</code> is used to fill up the
- * resulting iterator if <code>that</code> is shorter than
- * the self iterator
- * @return <code>Iterator((a<sub>0</sub>,b<sub>0</sub>), ...,
- * (a<sub>n</sub>,b<sub>n</sub>), (elem,b<sub>n+1</sub>),
- * ..., {elem,b<sub>m</sub>})</code>
- * when <code>[a<sub>0</sub>, ..., a<sub>n</sub>] zip
- * [b<sub>0</sub>, ..., b<sub>m</sub>]</code> is
- * invoked where <code>m &gt; n</code>.
- */
- def zipAll[B, A1 >: A, B1 >: B](that: Iterator[B], thisElem: A1, thatElem: B1) = new Iterator[(A1, B1)] {
- def hasNext = self.hasNext || that.hasNext
- def next(): (A1, B1) =
- if (self.hasNext) {
- if (that.hasNext) (self.next(), that.next())
- else (self.next(), thatElem)
- } else {
- if (that.hasNext) (thisElem, that.next())
- else empty.next()
- }
- }
-
- /** Apply a function <code>f</code> to all elements of this
- * iterable object.
- *
- * @param f a function that is applied to every element.
- */
- def foreach(f: A => Unit) { while (hasNext) f(next()) }
-
- /** Apply a predicate <code>p</code> to all elements of this
- * iterable object and return <code>true</code> iff the predicate yields
- * <code>true</code> for all elements.
- *
- * @param p the predicate
- * @return <code>true</code> iff the predicate yields <code>true</code>
- * for all elements.
- */
- def forall(p: A => Boolean): Boolean = {
- var res = true
- while (res && hasNext) res = p(next())
- res
- }
-
- /** Apply a predicate <code>p</code> to all elements of this
- * iterable object and return true, iff there is at least one
- * element for which <code>p</code> yields <code>true</code>.
- *
- * @param p the predicate
- * @return <code>true</code> iff the predicate yields <code>true</code>
- * for at least one element.
- */
- def exists(p: A => Boolean): Boolean = {
- var res = false
- while (!res && hasNext) res = p(next())
- res
- }
-
- /** Tests if the given value <code>elem</code> is a member of this iterator.
- *
- * @param elem element whose membership has to be tested.
- * @return <code>true</code> iff there is an element of this iterator which
- * is equal (w.r.t. <code>==</code>) to <code>elem</code>.
- */
- def contains(elem: Any): Boolean = exists { _ == elem }
-
- /** Find and return the first element of the iterable object satisfying a
- * predicate, if any.
- *
- * @param p the predicate
- * @return the first element in the iterable object satisfying
- * <code>p</code>, or <code>None</code> if none exists.
- */
- def find(p: A => Boolean): Option[A] = {
- var res: Option[A] = None
- while (res.isEmpty && hasNext) {
- val e = next()
- if (p(e)) res = Some(e)
- }
- res
- }
-
- /** Returns index of the first element satisying a predicate, or -1.
- *
- * @note may not terminate for infinite-sized collections.
- * @param p the predicate
- * @return the index of the first element satisfying <code>p</code>,
- * or -1 if such an element does not exist
- */
- def indexWhere(p: A => Boolean): Int = {
- var i = 0
- var found = false
- while (!found && hasNext) {
- if (p(next())) {
- found = true
- } else {
- i += 1
- }
- }
- if (found) i else -1
- }
-
- /** Returns index of the first element satisying a predicate, or -1.
- *
- * @deprecated use `indexWhere` instead
- */
- @deprecated def findIndexOf(p: A => Boolean): Int = indexWhere(p)
-
- /** Returns the index of the first occurence of the specified
- * object in this iterable object.
- *
- * @note may not terminate for infinite-sized collections.
- * @param elem element to search for.
- * @return the index in this sequence of the first occurence of the
- * specified element, or -1 if the sequence does not contain
- * this element.
- */
- def indexOf[B >: A](elem: B): Int = {
- var i = 0
- var found = false
- while (!found && hasNext) {
- if (next() == elem) {
- found = true
- } else {
- i += 1
- }
- }
- if (found) i else -1
- }
-
- /** Combines the elements of this iterator together using the binary
- * operator <code>op</code>, from left to right, and starting with
- * the value <code>z</code>.
- *
- * @return <code>op(... (op(op(z,a<sub>0</sub>),a<sub>1</sub>) ...),
- * a<sub>n</sub>)</code> if the iterator yields elements
- * <code>a<sub>0</sub>, a<sub>1</sub>, ..., a<sub>n</sub></code>.
- */
- def foldLeft[B](z: B)(op: (B, A) => B): B = {
- var acc = z
- while (hasNext) acc = op(acc, next())
- acc
- }
-
- /** Combines the elements of this iterator together using the binary
- * operator <code>op</code>, from right to left, and starting with
- * the value <code>z</code>.
- *
- * @return <code>a<sub>0</sub> op (... op (a<sub>n</sub> op z)...)</code>
- * if the iterator yields elements <code>a<sub>0</sub>, a<sub>1</sub>, ...,
- * a<sub>n</sub></code>.
- */
- def foldRight[B](z: B)(op: (A, B) => B): B = {
- def fold(z: B): B = if (hasNext) op(next(), fold(z)) else z
- fold(z)
- }
-
- /** Similar to <code>foldLeft</code> but can be used as
- * an operator with the order of iterator and zero arguments reversed.
- * That is, <code>z /: xs</code> is the same as <code>xs foldLeft z</code>.
- *
- * @param z the left argument of the first application of <code>op</code>
- * (evaluation occurs from left to right).
- * @param op the applied operator.
- * @return the result value
- * @see <code><a href="#foldLeft">foldLeft</a></code>.
- */
- def /:[B](z: B)(op: (B, A) => B): B = foldLeft(z)(op)
-
- /** An alias for <code>foldRight</code>.
- * That is, <code>xs :\ z</code> is the same as <code>xs foldRight z</code>.
- *
- * @param z the right argument of the first application of <code>op</code>
- * (evaluation occurs from right to left).
- * @param op the applied operator.
- * @return the result value.
- * @see <code><a href="#foldRight">foldRight</a></code>.
- */
- def :\[B](z: B)(op: (A, B) => B): B = foldRight(z)(op)
-
- /** Combines the elements of this iterator together using the binary
- * operator <code>op</code>, from left to right
- * @param op The operator to apply
- * @return <code>op(... op(a<sub>0</sub>,a<sub>1</sub>), ..., a<sub>n</sub>)</code>
- if the iterator yields elements
- * <code>a<sub>0</sub>, a<sub>1</sub>, ..., a<sub>n</sub></code>.
- * @throws Predef.UnsupportedOperationException if the iterator is empty.
- */
- def reduceLeft[B >: A](op: (B, A) => B): B = {
- if (hasNext) foldLeft[B](next())(op)
- else throw new UnsupportedOperationException("empty.reduceLeft")
- }
-
- /** Combines the elements of this iterator together using the binary
- * operator <code>op</code>, from right to left
- * @param op The operator to apply
- *
- * @return <code>a<sub>0</sub> op (... op (a<sub>n-1</sub> op a<sub>n</sub>)...)</code>
- * if the iterator yields elements <code>a<sub>0</sub>, a<sub>1</sub>, ...,
- * a<sub>n</sub></code>.
-
- * @throws Predef.UnsupportedOperationException if the iterator is empty.
- */
- def reduceRight[B >: A](op: (A, B) => B): B = {
- if (!hasNext) throw new UnsupportedOperationException("empty.reduceRight")
- foldRight[B](next())(op)
- }
-
- /** Returns a buffered iterator from this iterator.
- */
- def buffered = new BufferedIterator[A] {
- private var hd: A = _
- private var hdDefined: Boolean = false
-
- def head: A = {
- if (!hdDefined) {
- hd = next()
- hdDefined = true
- }
- hd
- }
-
- def hasNext =
- hdDefined || self.hasNext
-
- def next =
- if (hdDefined) {
- hdDefined = false
- hd
- } else self.next
- }
-
- def length: Int = {
- var i = 0
- while (hasNext) {
- next(); i += 1
- }
- i
- }
-
- /** Returns a counted iterator from this iterator.
- * @deprecated use @see zipWithIndex in Iterator
- */
- def counted = new CountedIterator[A] {
- private var cnt = -1
- def count = cnt
- def hasNext: Boolean = self.hasNext
- def next(): A = { cnt += 1; self.next }
- }
-
- /** Creates two new iterators that both iterate over the same elements
- * than this iterator (in the same order).
- *
- * @return a pair of iterators
- */
- def duplicate: (Iterator[A], Iterator[A]) = {
- var xs: List[A] = Nil
- var ahead: Iterator[A] = null
- class Partner extends Iterator[A] {
- var ys: List[A] = Nil
- def hasNext: Boolean = self.synchronized (
- ((this == ahead) && self.hasNext) ||
- ((this != ahead) && (!xs.isEmpty || !ys.isEmpty || self.hasNext))
- )
- def next(): A = self.synchronized {
- if (this == ahead) {
- val e = self.next()
- xs = e :: xs; e
- } else {
- if (ys.isEmpty) {
- ys = xs.reverse
- xs = Nil
- }
- ys match {
- case Nil =>
- val e = self.next()
- ahead = this
- xs = e :: xs; e
- case z :: zs =>
- ys = zs; z
- }
- }
- }
- }
- ahead = new Partner
- (ahead, new Partner)
- }
-
- def patch[B >: A](from: Int, ps: Sequence[B], replaced: Int) = new Iterator[B] {
- private val plen = ps.length
- private var origElems = self
- private val patchElems = ps.elements
- private var i = 0
- def hasNext: Boolean =
- if (i < from) origElems.hasNext
- else patchElems.hasNext || origElems.hasNext
- def next(): B = {
- val result: B =
- if (i < from || i >= from + plen) origElems.next()
- else patchElems.next()
- i += 1
- if (i == from) origElems = origElems drop replaced
- result
- }
- }
-
- /** Fills the given array <code>xs</code> with at most `len` elements of
- * this iterator starting at position `start`.
- * Copying will stop once either the end of the current iterable is reached or
- * `len` elements have been copied.
- *
- * @param xs the array to fill.
- * @param start starting index.
- * @param len number of elements to copy
- * @pre the array must be large enough to hold all elements.
- */
- def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit = {
- var i = start
- val end = start + len
- while (hasNext && i < end) {
- xs(i) = next()
- i += 1
- }
- }
-
- /** Fills the given array <code>xs</code> with the elements of
- * this iterator starting at position <code>start</code>
- * until either the end of the current iterator or the end of array `xs` is reached.
- *
- * @param xs the array to fill.
- * @param start starting index.
- * @pre the array must be large enough to hold all elements.
- */
- def copyToArray[B >: A](xs: Array[B], start: Int): Unit =
- copyToArray(xs, start, xs.length - start)
-
- /** Fills the given array <code>xs</code> with the elements of
- * this iterator starting at position <code>0</code>
- * until either the end of the current iterator or the end of array `xs` is reached.
- *
- * @param xs the array to fill.
- * @pre the array must be large enough to hold all elements.
- */
- def copyToArray[B >: A](xs: Array[B]): Unit = copyToArray(xs, 0, xs.length)
-
- /** Fills the given array <code>xs</code> with the elements of
- * this sequence starting at position <code>start</code>. Like <code>copyToArray</code>,
- * but designed to accomodate IO stream operations.
- *
- * @param xs the array to fill.
- * @param start the starting index.
- * @param sz the maximum number of elements to be read.
- * @pre the array must be large enough to hold <code>sz</code> elements.
- * @deprecated use copyToArray instead
- */
- @deprecated def readInto[B >: A](xs: Array[B], start: Int, sz: Int) {
- var i = start
- while (hasNext && i - start < sz) {
- xs(i) = next
- i += 1
- }
- }
- @deprecated def readInto[B >: A](xs: Array[B], start: Int) {
- readInto(xs, start, xs.length - start)
- }
- @deprecated def readInto[B >: A](xs: Array[B]) {
- readInto(xs, 0, xs.length)
- }
-
- /** Copy all elements to a buffer
- * @param The buffer to which elements are copied
- */
- def copyToBuffer[B >: A](dest: Buffer[B]) {
- while (hasNext) dest += next
- }
-
- /** Transform this iterator into a list of all elements.
- *
- * @return a list which enumerates all elements of this iterator.
- */
- def toList: List[A] = {
- val res = new ListBuffer[A]
- while (hasNext) res += next
- res.toList
- }
-
- /**
- * Create a stream which contains all the elements of this iterator.
- */
- def toStream: Stream[A] =
- if (hasNext) Stream.cons(next, toStream) else Stream.empty
-
- /**
- * Create a sequence which contains all the elements of this iterator.
- */
- def toSequence: Sequence[A] = {
- val buffer = new ArrayBuffer[A]
- this copyToBuffer buffer
- buffer.readOnly
- }
-
- /** Collect elements into a seq.
- *
- * @return a sequence which enumerates all elements of this iterator.
- * @deprecated use toSequence instead
- */
- @deprecated def collect: Sequence[A] = toSequence
-
- /** Returns a string representation of the elements in this iterator. The resulting string
- * begins with the string <code>start</code> and is finished by the string
- * <code>end</code>. Inside, the string representations of elements (w.r.t.
- * the method <code>toString()</code>) are separated by the string
- * <code>sep</code>.
- * <p/>
- * Ex: <br/>
- * <code>List(1, 2, 3).mkString("(", "; ", ")") = "(1; 2; 3)"</code>
- *
- * @param start starting string.
- * @param sep separator string.
- * @param end ending string.
- * @return a string representation of this iterable object.
- */
- def mkString(start: String, sep: String, end: String): String = {
- val buf = new StringBuilder
- addString(buf, start, sep, end).toString
- }
-
- /** Returns a string representation of this iterable object. The string
- * representations of elements (w.r.t. the method <code>toString()</code>)
- * are separated by the string <code>sep</code>.
- *
- * @param sep separator string.
- * @return a string representation of this iterable object.
- */
- def mkString(sep: String): String = this.mkString("", sep, "")
-
- /** Returns a string representation of this iterable object. The string
- * representations of elements (w.r.t. the method <code>toString()</code>)
- * are separated by a comma.
- *
- * @return a string representation of this iterable object.
- */
- def mkString: String =
- mkString("")
-
- /** Write all elements of this iterator into given string builder.
- * The written text begins with the string <code>start</code> and is finished by the string
- * <code>end</code>. Inside, the string representations of elements (w.r.t.
- * the method <code>toString()</code>) are separated by the string
- * <code>sep</code>.
- */
- def addString(buf: StringBuilder, start: String, sep: String, end: String): StringBuilder = {
- buf.append(start)
- val elems = this
- if (elems.hasNext) buf.append(elems.next)
- while (elems.hasNext) {
- buf.append(sep); buf.append(elems.next)
- }
- buf.append(end)
- }
-
- /** Write all elements of this iterator into given string builder.
- * The string representations of elements (w.r.t. the method <code>toString()</code>)
- * are separated by the string <code>sep</code>.
- */
- def addString(buf: StringBuilder, sep: String): StringBuilder =
- addString(buf, "", sep, "")
-
- /** Write all elements of this string into given string builder without using
- * any separator between consecutive elements.
- */
- def addString(buf: StringBuilder): StringBuilder =
- addString(buf, "", "", "")
-
- override def toString = (if (hasNext) "non-empty" else "empty")+" iterator"
-
-}
diff --git a/src/library/scalax/collection/Map.scala b/src/library/scalax/collection/Map.scala
deleted file mode 100755
index 602da06bb0..0000000000
--- a/src/library/scalax/collection/Map.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Map.scala 16884 2009-01-09 16:52:09Z cunei $
-
-
-package scalax.collection
-
-import generic._
-
-trait Map[A, B] extends MapTemplate[A, B, Map]
-
-/* Factory object for `Map` class */
-object Map extends MapFactory[Map] {
- def empty[A, B]: Map[A, B] = new immutable.EmptyMap[A, B]
-}
diff --git a/src/library/scalax/collection/OrderedIterable.scala b/src/library/scalax/collection/OrderedIterable.scala
deleted file mode 100755
index 9a0b77e575..0000000000
--- a/src/library/scalax/collection/OrderedIterable.scala
+++ /dev/null
@@ -1,41 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
-
-
-package scalax.collection
-
-import generic._
-import immutable.Nil
-import annotation.unchecked.uncheckedVariance
-
-/** An ordered collection is a collection with a fixed sequence of elements
- * which is the same in every run.
- *
- * for any two ordered collections c1 and c2.
- * Ordered collections support
- * - operations that form subsequences: take, takeWhile, drop, dropWhile,
- * - zip, unzip
- *
- * @author Martin Odersky
- * @version 2.8
- */
-trait OrderedIterable[+A] extends Iterable[A] with OrderedIterableTemplate[OrderedIterable, A @uncheckedVariance]
-
-/** Various utilities for instances of <a href="Iterable.html">Iterable</a>.
- *
- * @author Matthias Zenger
- * @author Martin Odersky
- * @version 2.8
- */
-object OrderedIterable extends IterableFactory[OrderedIterable] with EmptyIterableFactory[OrderedIterable] {
-
- val empty: OrderedIterable[Nothing] = Nil
-
-}
diff --git a/src/library/scalax/collection/Sequence.scala b/src/library/scalax/collection/Sequence.scala
deleted file mode 100755
index 48081c99e8..0000000000
--- a/src/library/scalax/collection/Sequence.scala
+++ /dev/null
@@ -1,47 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Sequence.scala 16092 2008-09-12 10:37:06Z nielsen $
-
-
-package scalax.collection
-
-import generic._
-import immutable.Nil
-import annotation.unchecked.uncheckedVariance
-
-/** Class <code>Sequence[A]</code> represents finite sequences of elements
- * of type <code>A</code>.
- *
- * @author Martin Odersky
- * @author Matthias Zenger
- * @version 1.0, 16/07/2003
- */
-trait Sequence[+A] extends OrderedIterable[A] with SizedIterable[A] with SequenceTemplate[Sequence, A @uncheckedVariance]
-
-object Sequence extends SequenceFactory[Sequence] with EmptyIterableFactory[Sequence] {
-
- /** The empty sequence */
- val empty : Sequence[Nothing] = immutable.Nil
-
- type View[+UC[B] <: Sequence[B], A] = SequenceView[UC, A]
-
- /** @deprecated use View instead
- */
- @deprecated type Projection[A] = View[C, A] forSome { type C[+B] <: Sequence[B] }
-
- /** @deprecated use Sequence(value) instead */
- @deprecated def singleton[A](value: A) = Sequence(value)
-
- /** Builds a singleton sequence.
- *
- * @deprecated use <code>Sequence(x)</code> instead.
- */
- @deprecated def single[A](x: A) = singleton(x)
-}
-
diff --git a/src/library/scalax/collection/Set.scala b/src/library/scalax/collection/Set.scala
deleted file mode 100644
index a7234d0261..0000000000
--- a/src/library/scalax/collection/Set.scala
+++ /dev/null
@@ -1,24 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
-
-package scalax.collection
-
-import generic._
-
-trait Set[A] extends SetTemplate[Set, A]
-
-/* Factory object for `Set` class */
-object Set extends IterableFactory[Set] {
- /** The empty set */
- def apply[A](args: A*): Set[A] = null // !!!
-
-}
-
-
diff --git a/src/library/scalax/collection/SizedIterable.scala b/src/library/scalax/collection/SizedIterable.scala
deleted file mode 100644
index 4463c268b9..0000000000
--- a/src/library/scalax/collection/SizedIterable.scala
+++ /dev/null
@@ -1,38 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Collection.scala 12340 2007-07-17 15:29:47Z mcdirmid $
-
-
-package scalax.collection
-
-/** Variant of <code>Iterable</code> which also demands
- * implementation of a `size` method.
- * Basically, this trait just adds size to Iterable,
- * and provides an optimized implementation of toArray based on it.
- *
- * @author Martin Odersky
- * @version 2.8
- */
-trait SizedIterable[+A] extends Iterable[A] {
-
- /** Returns the number of elements in this collection.
- *
- * @return number of collection elements.
- */
- def size : Int
-
- /** Converts this iterable to a fresh Array with <code>size</code> elements.
- */
- override def toArray[B >: A]: Array[B] = {
- val result = new Array[B](size)
- copyToArray(result, 0)
- result
- }
-}
-
diff --git a/src/library/scalax/collection/Vector.scala b/src/library/scalax/collection/Vector.scala
deleted file mode 100755
index 8224a8630b..0000000000
--- a/src/library/scalax/collection/Vector.scala
+++ /dev/null
@@ -1,23 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2006-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Vector.scala 15437 2008-06-25 16:22:45Z stepancheg $
-
-package scalax.collection
-
-import generic._
-import mutable.ArrayBuffer
-import annotation.unchecked.uncheckedVariance
-
-trait Vector[+A] extends Sequence[A] with VectorTemplate[Vector, A @uncheckedVariance]
-
-object Vector extends SequenceFactory[Vector] with EmptyIterableFactory[Vector] {
-
- /** The empty sequence */
- val empty : Vector[Nothing] = null // !!! todo: insert good immutable vector implementation here.
-}
diff --git a/src/library/scalax/collection/generic/Addable.scala b/src/library/scalax/collection/generic/Addable.scala
deleted file mode 100755
index 40a4f60e6e..0000000000
--- a/src/library/scalax/collection/generic/Addable.scala
+++ /dev/null
@@ -1,64 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
-
-package scalax.collection.generic
-
-/** This class represents collections that can be augmented using a += operator.
- *
- * @autor Martin Odersky
- * @owner Martin Odersky
- * @version 2.8
- */
-trait Addable[+C <: Addable[C, A], A] {
-
- protected def thisCC: C
-
- /** Adds a single element to this collection and returns
- * either the collection itself (if it is mutable), or a new collection
- * with the added element.
- *
- * @param elem the element to add.
- */
- def +(elem: A): C
-
- /** Adds two or more elements to this collection and returns
- * either the collection itself (if it is mutable), or a new collection
- * with the added elements.
- *
- * @param elem1 the first element to add.
- * @param elem2 the second element to add.
- * @param elems the remaining elements to add.
- */
- def +(elem1: A, elem2: A, elems: A*): C =
- thisCC + elem1 + elem2 ++ elems.asInstanceOf[Iterable[A]] // !@!
-
- /** Adds a number of elements provided by an iterable object
- * via its <code>elements</code> method and returns
- * either the collection itself (if it is mutable), or a new collection
- * with the added elements.
- *
- * @param iter the iterable object.
- */
- def ++(iter: Iterable[A]): C = (thisCC /: iter) (_ + _)
-
- /** Adds a number of elements provided by an iterator
- * via its <code>elements</code> method and returns
- * either the collection itself (if it is mutable), or a new collection
- * with the added elements.
- *
- * @param iter the iterator
- */
- def ++(iter: Iterator[A]): C = (thisCC /: iter) (_ + _)
-
-}
-
-
-
-
diff --git a/src/library/scalax/collection/generic/AddableBuilder.scala b/src/library/scalax/collection/generic/AddableBuilder.scala
deleted file mode 100644
index b1f3e4e522..0000000000
--- a/src/library/scalax/collection/generic/AddableBuilder.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: ListBuffer.scala 14378 2008-03-13 11:39:05Z dragos $
-
-package scalax.collection.generic
-
-import collection.mutable.ListBuffer
-import collection.immutable.{List, Nil, ::}
-
-class AddableBuilder[CC[B] <: Iterable[B] with Addable[CC[B], B], A](empty: CC[A]) extends Builder[CC, A] {
- protected var elems: CC[A] = empty
- def +=(x: A) { elems = elems + x }
- def elements: Iterator[A] = elems.elements
- def clear() { elems = empty }
- def result: CC[A] = elems
-}
diff --git a/src/library/scalax/collection/generic/Builder.scala b/src/library/scalax/collection/generic/Builder.scala
deleted file mode 100755
index 155ca553fa..0000000000
--- a/src/library/scalax/collection/generic/Builder.scala
+++ /dev/null
@@ -1,31 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: ListBuffer.scala 14378 2008-03-13 11:39:05Z dragos $
-
-package scalax.collection.generic
-
-import generic._
-
-trait Builder[+CC[B], A] extends Growable[A] {
- def +=(x: A)
- def elements: Iterator[A]
- def result: CC[A]
-
- def mapResult[DD[B]](f: CC[A] => DD[A]) =
- new Builder[DD, A] with Proxy {
- val self = Builder.this
- def +=(x: A) = self += x
- def elements: Iterator[A] = self.elements
- def clear() = self.clear()
- override def ++=(xs: Iterator[A]) = self ++= xs
- override def ++=(xs: collection.Iterable[A]) = self ++= xs
- def result: DD[A] = f(Builder.this.result)
- }
-}
-
diff --git a/src/library/scalax/collection/generic/Cloneable.scala b/src/library/scalax/collection/generic/Cloneable.scala
deleted file mode 100644
index acf9a16686..0000000000
--- a/src/library/scalax/collection/generic/Cloneable.scala
+++ /dev/null
@@ -1,19 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: CloneableCollection.scala 16893 2009-01-13 13:09:22Z cunei $
-
-
-package scalax.collection.generic
-
-/** A trait for cloneable collections.
- */
-@cloneable
-trait Cloneable[A <: AnyRef] {
- override def clone(): A = super.clone().asInstanceOf[A]
-}
diff --git a/src/library/scalax/collection/generic/EmptyIterableFactory.scala b/src/library/scalax/collection/generic/EmptyIterableFactory.scala
deleted file mode 100755
index 7f110d13d2..0000000000
--- a/src/library/scalax/collection/generic/EmptyIterableFactory.scala
+++ /dev/null
@@ -1,17 +0,0 @@
-package scalax.collection.generic
-
-import annotation.unchecked.uncheckedVariance
-
-trait EmptyIterableFactory[CC[+A] <: Iterable[A] with IterableTemplate[CC, A @uncheckedVariance]] extends IterableFactory[CC] {
-
- /** The empty collection of type CC */
- val empty: CC[Nothing]
-
- /** An override of newBuilder, to work off the empty object */
- override protected def newBuilder[A]: Builder[CC, A] =
- empty.newBuilder[A]
-
- /** Create CC collection of specified elements */
- override def apply[A](args: A*): CC[A] =
- empty ++ args.asInstanceOf[Iterable[A]]
-}
diff --git a/src/library/scalax/collection/generic/Growable.scala b/src/library/scalax/collection/generic/Growable.scala
deleted file mode 100755
index 960384f9d0..0000000000
--- a/src/library/scalax/collection/generic/Growable.scala
+++ /dev/null
@@ -1,58 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
-
-package scalax.collection.generic
-
-/** This class represents collections that can be augmented using a += operator.
- *
- * @autor Martin Odersky
- * @owner Martin Odersky
- * @version 2.8
- */
-trait Growable[A] {
-
- /** Adds a single element to this collection.
- *
- * @param elem the element to add.
- */
- def +=(elem: A): Unit
-
- /** Adds two or more elements to this collection.
- *
- * @param elem1 the first element to add.
- * @param elem2 the second element to add.
- * @param elems the remaining elements to add.
- */
- def +=(elem1: A, elem2: A, elems: A*) {
- this += elem1
- this += elem2
- this ++= elems.asInstanceOf[Iterable[A]] // !@!
- }
-
- /** Adds a number of elements provided by an iterator to this collection.
- *
- * @param iter the iterator.
- */
- def ++=(iter: collection.Iterator[A]) { iter foreach += }
-
- /** Adds a number of elements provided by an iterable object to this collection.
- *
- * @param iter the iterable object.
- */
- def ++=(iter: collection.Iterable[A]) { iter foreach += }
-
- /** Clears the collection contents.
- */
- def clear()
-}
-
-
-
-
diff --git a/src/library/scalax/collection/generic/IterableFactory.scala b/src/library/scalax/collection/generic/IterableFactory.scala
deleted file mode 100755
index 0cf9c8ac95..0000000000
--- a/src/library/scalax/collection/generic/IterableFactory.scala
+++ /dev/null
@@ -1,122 +0,0 @@
-package scalax.collection.generic
-
-trait IterableFactory[CC[A] <: Iterable[A]] {
-
- /** Create CC collection of specified elements */
- def apply[A](args: A*): CC[A]
-
- protected def newBuilder[A]: Builder[CC, A] =
- apply().newBuilder[A].asInstanceOf[Builder[CC, A]]
-
- // can't have an empty here because it is defined in subclass EmptyIterableFactory with type
- // CC[Nothing]. This type does not make sense for immutable iterables.
-
- /** Concatenate all the argument lists into a single list.
- *
- * @param xss the lists that are to be concatenated
- * @return the concatenation of all the lists
- */
- def concat[A](xss: CC[A]*): CC[A] = {
- val b = newBuilder[A]
- for (xs <- xss) b ++= xs
- b.result
- }
-
- /** An iterable that contains the same element a number of times
- * @param n The number of elements returned
- * @param elem The element returned each time
- */
- def fill[A](n: Int)(elem: => A): CC[A] = {
- val b = newBuilder[A]
- var i = 0
- while (i < n) {
- b += elem
- i += 1
- }
- b.result
- }
-
- def fill[A](n1: Int, n2: Int)(elem: => A): CC[CC[A]] =
- tabulate(n1)(_ => fill(n2)(elem))
-
- def fill[A](n1: Int, n2: Int, n3: Int)(elem: => A): CC[CC[CC[A]]] =
- tabulate(n1)(_ => fill(n2, n3)(elem))
-
- def fill[A](n1: Int, n2: Int, n3: Int, n4: Int)(elem: => A): CC[CC[CC[CC[A]]]] =
- tabulate(n1)(_ => fill(n2, n3, n4)(elem))
-
- def fill[A](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(elem: => A): CC[CC[CC[CC[CC[A]]]]] =
- tabulate(n1)(_ => fill(n2, n3, n4, n5)(elem))
-
- def tabulate[A](n: Int)(f: Int => A): CC[A] = {
- val b = newBuilder[A]
- var i = 0
- while (i < n) {
- b += f(i)
- i += 1
- }
- b.result
- }
-
- def tabulate[A](n1: Int, n2: Int)(f: (Int, Int) => A): CC[CC[A]] =
- tabulate(n1)(i1 => tabulate(n2)(f(i1, _)))
-
- def tabulate[A](n1: Int, n2: Int, n3: Int)(f: (Int, Int, Int) => A): CC[CC[CC[A]]] =
- tabulate(n1)(i1 => tabulate(n2, n3)(f(i1, _, _)))
-
- def tabulate[A](n1: Int, n2: Int, n3: Int, n4: Int)(f: (Int, Int, Int, Int) => A): CC[CC[CC[CC[A]]]] =
- tabulate(n1)(i1 => tabulate(n2, n3, n4)(f(i1, _, _, _)))
-
- def tabulate[A](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(f: (Int, Int, Int, Int, Int) => A): CC[CC[CC[CC[CC[A]]]]] =
- tabulate(n1)(i1 => tabulate(n2, n3, n4, n5)(f(i1, _, _, _, _)))
-
- /** Create a sequence of increasing integers in a range.
- *
- * @param from the start value of the sequence
- * @param end the end value of the sequence
- * @return the sorted list of all from `from` (inclusive)
- * up to, but exclusding, `end`.
- */
- def range[A](start: Int, end: Int): CC[Int] = range(start, end, 1)
-
- /** Create a sequence of increasing integers in a range.
- *
- * @param from the start value of the sequence
- * @param end the end value of the sequence
- * @param step the increment value of successive elements
- * @return a list of values <code>from + n * step</code> for
- * increasing n. If `step > 0` the sequence terminates
- * with the largest value less than `end`. If `step < 0`
- * the sequence terminates with the smallest value greater than `end`.
- * If `step == 0`, an IllegalArgumentException is thrown.
- */
- def range(start: Int, end: Int, step: Int): CC[Int] = {
- if (step == 0) throw new IllegalArgumentException("zero step")
- val b = newBuilder[Int]
- var i = start
- while ((step <= 0 || i < end) && (step >= 0 || i > end)) {
- b += i
- i += step
- }
- b.result
- }
-
- /** Create a sequence by repeatedly applying a given function to a start value.
- *
- * @param start the start value of the sequence
- * @param len the length of the sequence
- * @param f the function that's repeatedly applied
- * @return the sequence with elements <code>(start, f(start), f(f(start)), ..., f<sup>len-1</sup>(start))</code>
- */
- def iterate(start: Int, len: Int)(f: Int => Int): CC[Int] = {
- val b = newBuilder[Int]
- var acc = start
- var i = 0
- while (i < len) {
- b += acc
- acc = f(acc)
- i += 1
- }
- b.result
- }
-}
diff --git a/src/library/scalax/collection/generic/IterableForwarder.scala b/src/library/scalax/collection/generic/IterableForwarder.scala
deleted file mode 100644
index e38f030414..0000000000
--- a/src/library/scalax/collection/generic/IterableForwarder.scala
+++ /dev/null
@@ -1,59 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: IterableProxy.scala 15458 2008-06-28 20:23:22Z stepancheg $
-
-
-package scalax.collection.generic
-
-import collection.mutable.Buffer
-import collection.immutable.{List, Stream}
-
-/** This trait implements a forwarder for iterable objects. It forwards
- * all calls to a different iterable object, except for
- *
- * - toString, hashCode, equals, stringPrefix
- * - newBuilder, view
- * - all calls creating a new iterable objetc of the same kind
- *
- * The above methods are forwarded by subclass IterableProxy
- *
- * @author Martin Odersky
- * @version 2.8
- */
-trait IterableForwarder[+A] extends Iterable[A] {
-
- /** The iterable object to which calls are forwarded */
- protected def underlying: Iterable[A]
-
- // Iterable delegates
- // Iterable methods could be printed by cat IterableTemplate.scala | sed -n '/trait Iterable/,$ p' | egrep '^ (override )?def'
-
- override def elements = underlying.elements
- override def isEmpty = underlying.isEmpty
- override def hasDefiniteSize = underlying.hasDefiniteSize
- override def foreach(f: A => Unit) = underlying.foreach(f)
- override def forall(p: A => Boolean): Boolean = underlying.forall(p)
- override def exists(p: A => Boolean): Boolean = underlying.exists(p)
- override def count(p: A => Boolean): Int = underlying.count(p)
- override def find(p: A => Boolean): Option[A] = underlying.find(p)
- override def foldLeft[B](z: B)(op: (B, A) => B): B = underlying.foldLeft(z)(op)
- override def foldRight[B](z: B)(op: (A, B) => B): B = underlying.foldRight(z)(op)
- override def reduceLeft[B >: A](op: (B, A) => B): B = underlying.reduceLeft(op)
- override def reduceRight[B >: A](op: (A, B) => B): B = underlying.reduceRight(op)
- override def copyToBuffer[B >: A](dest: Buffer[B]) = underlying.copyToBuffer(dest)
- override def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) = underlying.copyToArray(xs, start, len)
- override def toArray[B >: A]: Array[B] = underlying.toArray
- override def toList: List[A] = underlying.toList
- override def toSequence: Sequence[A] = underlying.toSequence
- override def toStream: Stream[A] = underlying.toStream
- override def mkString(start: String, sep: String, end: String): String = underlying.mkString(start, sep, end)
- override def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder = underlying.addString(b, start, sep, end)
-
- override def head: A = underlying.head
-}
diff --git a/src/library/scalax/collection/generic/IterableTemplate.scala b/src/library/scalax/collection/generic/IterableTemplate.scala
deleted file mode 100755
index cc562c308a..0000000000
--- a/src/library/scalax/collection/generic/IterableTemplate.scala
+++ /dev/null
@@ -1,677 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
-
-
-package scalax.collection.generic
-
-import scalax.collection.mutable.{Buffer, ArrayBuffer, ListBuffer}
-import scalax.collection.immutable.{List, Nil, ::, Stream}
-import util.control.Breaks._
-import Iterable._
-
-/** Collection classes mixing in this class provide a method
- * <code>elements</code> which returns an iterator over all the
- * elements contained in the collection.
- *
- * @note If a collection has a known <code>size</code>, it should also sub-type <code>Collection</code>.
- * Only potentially unbounded collections should directly sub-class <code>Iterable</code>.
- * @author Matthias Zenger
- * @author Martin Odersky
- * @version 2.8
- */
-trait IterableTemplate[+CC[/*+*/B] <: IterableTemplate[CC, B] with Iterable[B], /*+*/A] { self/*: CC[A]*/ =>
-
- /** The template itself seen as an instance of `CC[A]`.
- * @note: It would be logical to have a self type `CC[A]` instead, then we would not need
- * this method. Unfortunately, tyis runs afoul some pecularities in Scala's member resolution
- * algorithm: If the self type is a CC, then Iterable is one of its supertypes. Iterable
- * defines a number of concrete methods such as newBuilder which are abstract here.
- * The newBuilder method in Iterable[A] has type Builder[Iterable, A]. Because Scala
- * prefers concrete over abstract members, it is this newBuilder which is chosen, instead of
- * the abstract newBuilder in class IterableTemplate of type Builder[CC, A].
- * Even for concrete methods we have a problem because the last mixin in the parents of CC is
- * Iterable, not IterableTemplate. So resolution picks the version in Iterable, which returns
- * again an Iterable, not a CC, as would be required.
- * These problems would be avoided if Scala computed the type of a member as the glb of the types
- * all members in the class and its superclasses types.
- * I think overall this would be a better design.
- */
- protected[this] def thisCC: CC[A] = this.asInstanceOf[CC[A]]
-
- /** Creates a new iterator over all elements contained in this
- * object.
- *
- * @return the new iterator
- */
- def elements: Iterator[A]
-
- /** Create a new builder for this IterableType
- */
- def newBuilder[B]: Builder[CC, B]
-
- /** Create a new builder for this IterableType
- * with a hint what that its size should be size `sizeHint`
- */
- def newBuilder[B](sizeHint: Int): Builder[CC, B] = newBuilder[B]
-
- /** Is this collection empty? */
- def isEmpty: Boolean = !elements.hasNext
-
- /** returns true iff this collection has a bound size.
- * Many APIs in this trait will not work on collections of
- * unbound sizes.
- */
- def hasDefiniteSize = true
-
- /** Create a new iterable of type CC which contains all elements of this iterable
- * followed by all elements of Iterable `that'
- */
- def ++[B >: A](that: Iterable[B]): CC[B] = {
- val b: Builder[CC, B] = (this: IterableTemplate[CC, A]).newBuilder[B]
- b ++= thisCC
- b ++= that
- b.result
- }
-
- /** Create a new iterable of type CC which contains all elements of this iterable
- * followed by all elements of Iterator `that'
- */
- def ++[B >: A](that: Iterator[B]): CC[B] = {
- val b = newBuilder[B]
- b ++= thisCC
- b ++= that
- b.result
- }
-
- /** Returns the iterable resulting from applying the given function
- * <code>f</code> to each element of this iterable.
- *
- * @param f function to apply to each element.
- * @return <code>f(a<sub>0</sub>), ..., f(a<sub>n</sub>)</code> if this
- * iterable is <code>a<sub>0</sub>, ..., a<sub>n</sub></code>.
- */
- def map[B](f: A => B): CC[B] = {
- val b = newBuilder[B]
- for (x <- this) b += f(x)
- b.result
- }
-
- /** Applies the given function <code>f</code> to each element of
- * this iterable, then concatenates the results.
- *
- * @param f the function to apply on each element.
- * @return <code>f(a<sub>0</sub>) ::: ... ::: f(a<sub>n</sub>)</code> if
- * this iterable is <code>a<sub>0</sub>, ..., a<sub>n</sub></code>.
- */
- def flatMap[B](f: A => Iterable[B]): CC[B] = {
- val b = newBuilder[B]
- for (x <- this) b ++= f(x)
- b.result
- }
-
- /** Returns all the elements of this iterable that satisfy the
- * predicate <code>p</code>. The order of the elements is preserved.
- * @param p the predicate used to filter the iterable.
- * @return the elements of this iterable satisfying <code>p</code>.
- */
- def filter(p: A => Boolean): CC[A] = {
- val b = newBuilder[A]
- for (x <- this)
- if (p(x)) b += x
- b.result
- }
-
- /** Removes all elements of the iterable which satisfy the predicate
- * <code>p</code>. This is like <code>filter</code> with the
- * predicate inversed.
- *
- * @param p the predicate to use to test elements
- * @return the iterable without all elements which satisfy <code>p</code>
- */
- def remove(p: A => Boolean): CC[A] = filter(!p(_))
-
- /** Partitions this iterable in two iterables according to a predicate.
- *
- * @param p the predicate on which to partition
- * @return a pair of iterables: the iterable that satisfies the predicate
- * <code>p</code> and the iterable that does not.
- * The relative order of the elements in the resulting iterables
- * is the same as in the original iterable.
- */
- def partition(p: A => Boolean): (CC[A], CC[A]) = {
- val l, r = newBuilder[A]
- for (x <- this) (if (p(x)) l else r) += x
- (l.result, r.result)
- }
-
- /** Apply a function <code>f</code> to all elements of this
- * iterable object.
- *
- * @note Will not terminate for infinite-sized collections.
- * @param f a function that is applied to every element.
- * Note this function underlies the implementation of most other bulk operations.
- * It should be overridden in concrete collectionc classes with efficient implementations.
- */
- def foreach(f: A => Unit): Unit = elements.foreach(f)
-
- /** Return true iff the given predicate `p` yields true for all elements
- * of this iterable.
- *
- * @note May not terminate for infinite-sized collections.
- * @param p the predicate
- */
- def forall(p: A => Boolean): Boolean = {
- var result = true
- breakable {
- for (x <- this)
- if (!p(x)) { result = false; break }
- }
- result
- }
-
- /** Return true iff there is an element in this iterable for which the
- * given predicate `p` yields true.
- *
- * @note May not terminate for infinite-sized collections.
- * @param p the predicate
- */
- def exists(p: A => Boolean): Boolean = {
- var result = false
- breakable {
- for (x <- this)
- if (p(x)) { result = true; break }
- }
- result
- }
-
- /** Count the number of elements in the iterable which satisfy a predicate.
- *
- * @param p the predicate for which to count
- * @return the number of elements satisfying the predicate <code>p</code>.
- */
- def count(p: A => Boolean): Int = {
- var cnt = 0
- for (x <- this) {
- if (p(x)) cnt += 1
- }
- cnt
- }
-
- /** Find and return the first element of the iterable object satisfying a
- * predicate, if any.
- *
- * @note may not terminate for infinite-sized collections.
- * @note Might return different results for different runs, unless this iterable is ordered, or
- * the operator is associative and commutative.
- * @param p the predicate
- * @return an option containing the first element in the iterable object
- * satisfying <code>p</code>, or <code>None</code> if none exists.
- */
- def find(p: A => Boolean): Option[A] = {
- var result: Option[A] = None
- breakable {
- for (x <- this)
- if (p(x)) { result = Some(x); break }
- }
- result
- }
-
- /** Combines the elements of this iterable object together using the binary
- * function <code>f</code>, from left to right, and starting with
- * the value <code>z</code>.
- *
- * @note Will not terminate for infinite-sized collections.
- * @note Might return different results for different runs, unless this iterable is ordered, or
- * the operator is associative and commutative.
- * @return <code>f(... (f(f(z, a<sub>0</sub>), a<sub>1</sub>) ...),
- * a<sub>n</sub>)</code> if the iterable is
- * <code>[a<sub>0</sub>, a<sub>1</sub>, ..., a<sub>n</sub>]</code>.
- */
- def foldLeft[B](z: B)(op: (B, A) => B): B = {
- var result = z
- for (x <- this)
- result = op(result, x)
- result
- }
-
- /** Combines the elements of this iterable together using the binary
- * function <code>f</code>, from right to left, and starting with
- * the value <code>z</code>.
- *
- * @note Will not terminate for infinite-sized collections.
- * @note Might return different results for different runs, unless this iterable is ordered, or
- * the operator is associative and commutative.
- * @return <code>f(a<sub>0</sub>, f(a<sub>1</sub>, f(..., f(a<sub>n</sub>, z)...)))</code>
- * if the iterable is <code>[a<sub>0</sub>, a1, ..., a<sub>n</sub>]</code>.
- */
- def foldRight[B](z: B)(op: (A, B) => B): B = elements.foldRight(z)(op)
-
- /** Similar to <code>foldLeft</code> but can be used as
- * an operator with the order of iterable and zero arguments reversed.
- * That is, <code>z /: xs</code> is the same as <code>xs foldLeft z</code>
- * @note Will not terminate for infinite-sized collections.
- * @note Might return different results for different runs, unless this iterable is ordered, or
- * the operator is associative and commutative.
- */
- def /: [B](z: B)(op: (B, A) => B): B = foldLeft(z)(op)
-
- /** An alias for <code>foldRight</code>.
- * That is, <code>xs :\ z</code> is the same as <code>xs foldRight z</code>
- * @note Will not terminate for infinite-sized collections.
- * @note Might return different results for different runs, unless this iterable is ordered, or
- * the operator is associative and commutative.
- */
- def :\ [B](z: B)(op: (A, B) => B): B = foldRight(z)(op)
-
- /** Combines the elements of this iterable object together using the binary
- * operator <code>op</code>, from left to right
- * @note Will not terminate for infinite-sized collections.
- * @note Might return different results for different runs, unless this iterable is ordered, or
- * the operator is associative and commutative.
- * @param op The operator to apply
- * @return <code>op(... op(a<sub>0</sub>,a<sub>1</sub>), ..., a<sub>n</sub>)</code>
- if the iterable object has elements
- * <code>a<sub>0</sub>, a<sub>1</sub>, ..., a<sub>n</sub></code>.
- * @throws Predef.UnsupportedOperationException if the iterable object is empty.
- */
- def reduceLeft[B >: A](op: (B, A) => B): B = {
- if (isEmpty) throw new UnsupportedOperationException("empty.reduceLeft")
- var result: B = elements.next
- var first = true
- for (x <- this)
- if (first) first = false
- else result = op(result, x)
- result
- }
-
- /** Combines the elements of this iterable object together using the binary
- * operator <code>op</code>, from right to left
- * @note Will not terminate for infinite-sized collections.
- * @note Might return different results for different runs, unless this iterable is ordered, or
- * the operator is associative and commutative.
- * @param op The operator to apply
- *
- * @return <code>a<sub>0</sub> op (... op (a<sub>n-1</sub> op a<sub>n</sub>)...)</code>
- * if the iterable object has elements <code>a<sub>0</sub>, a<sub>1</sub>, ...,
- * a<sub>n</sub></code>.
- *
- * @throws Predef.UnsupportedOperationException if the iterator is empty.
- */
- def reduceRight[B >: A](op: (A, B) => B): B =
- elements.reduceRight(op)
-
- /** Returns an iterable formed from this iterable and the specified iterable
- * `other` by associating each element of the former with
- * the element at the same position in the latter.
- * If one of the two iterables is longer than the other, its remaining elements are ignored.
- */
- def zip[B](that: Iterable[B]): CC[(A, B)] = {
- val these = this.elements
- val those = that.elements
- val b = this.newBuilder[(A, B)]
- while (these.hasNext && those.hasNext)
- b += ((these.next, those.next))
- b.result
- }
-
- /** Returns a iterable formed from this iterable and the specified iterable
- * <code>that</code> by associating each element of the former with
- * the element at the same position in the latter.
- *
- * @param that iterable <code>that</code> may have a different length
- * as the self iterable.
- * @param thisElem element <code>thisElem</code> is used to fill up the
- * resulting iterable if the self iterable is shorter than
- * <code>that</code>
-b * @param thatElem element <code>thatElem</code> is used to fill up the
- * resulting iterable if <code>that</code> is shorter than
- * the self iterable
- * @return <code>Iterable((a<sub>0</sub>,b<sub>0</sub>), ...,
- * (a<sub>n</sub>,b<sub>n</sub>), (elem,b<sub>n+1</sub>),
- * ..., {elem,b<sub>m</sub>})</code>
- * when <code>[a<sub>0</sub>, ..., a<sub>n</sub>] zip
- * [b<sub>0</sub>, ..., b<sub>m</sub>]</code> is
- * invoked where <code>m &gt; n</code>.
- */
- def zipAll[B, A1 >: A, B1 >: B](that: Iterable[B], thisElem: A1, thatElem: B1): CC[(A1, B1)] = {
- val these = this.elements
- val those = that.elements
- val b = newBuilder[(A1, B1)]
- while (these.hasNext && those.hasNext)
- b += ((these.next, those.next))
- while (these.hasNext)
- b += ((these.next, thatElem))
- while (those.hasNext)
- b += ((thisElem, those.next))
- b.result
- }
-
- /** Zips this iterable with its indices. `s.zipWithIndex` is equivalent to
- * `s zip s.indices`, but is usually more efficient.
- */
- def zipWithIndex: CC[(A, Int)] = {
- val b = newBuilder[(A, Int)]
- var i = 0
- for (x <- this) {
- b += ((x, i))
- i +=1
- }
- b.result
- }
-
- /** Copy all elements to a given buffer
- * @note Will not terminate for infinite-sized collections.
- * @param dest The buffer to which elements are copied
- */
- def copyToBuffer[B >: A](dest: Buffer[B]) {
- for (x <- this) dest += x
- }
-
- /** Fills the given array <code>xs</code> with at most `len` elements of
- * this iterable starting at position `start`.
- * Copying will stop oce either the end of the current iterable is reached or
- * `len` elements have been copied.
- *
- * @note Will not terminate for infinite-sized collections.
- * @param xs the array to fill.
- * @param start starting index.
- * @param len number of elements to copy
- * @pre the array must be large enough to hold all elements.
- */
- def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
- var i = start
- val end = (start + len) min xs.length
- for (x <- this) {
- if (i < end) {
- xs(i) = x
- i += 1
- }
- }
- }
-
- /** Fills the given array <code>xs</code> with the elements of
- * this iterable starting at position <code>start</code>
- * until either the end of the current iterable or the end of array `xs` is reached.
- *
- * @note Will not terminate for infinite-sized collections.
- * @param xs the array to fill.
- * @param start starting index.
- * @pre the array must be large enough to hold all elements.
- */
- def copyToArray[B >: A](xs: Array[B], start: Int) {
- copyToArray(xs, start, xs.length - start)
- }
-
- /** Converts this collection to a fresh Array elements.
- * @note Will not terminate for infinite-sized collections.
- */
- def toArray[B >: A]: Array[B] = {
- var size = 0
- for (x <- this) size += 1
- val result = new Array[B](size)
- copyToArray(result, 0)
- result
- }
-
- /**
- * Create a fresh list with all the elements of this iterable object.
- * @note Will not terminate for infinite-sized collections.
- */
- def toList: List[A] = (new ListBuffer[A] ++ thisCC).toList
-
- /**
- * Returns a sequence containing all of the elements in this iterable object.
- * @note Will not terminate for infinite-sized collections.
- */
- def toSequence: Sequence[A] = toList
-
- /** @deprecated use toSequence instead
- */
- @deprecated def toSeq: Sequence[A] = toSequence
-
- /**
- * Create a stream which contains all the elements of this iterable object.
- * @note consider using <code>projection</code> for lazy behavior.
- */
- def toStream: Stream[A] = elements.toStream
-
- /** Sort the iterable according to the comparison function
- * <code>&lt;(e1: a, e2: a) =&gt; Boolean</code>,
- * which should be true iff <code>e1</code> is smaller than
- * <code>e2</code>.
- * The sort is stable. That is elements that are equal wrt `lt` appear in the
- * same order in the sorted iterable as in the original.
- *
- * @param lt the comparison function
- * @return a iterable sorted according to the comparison function
- * <code>&lt;(e1: a, e2: a) =&gt; Boolean</code>.
- * @ex <pre>
- * List("Steve", "Tom", "John", "Bob")
- * .sort((e1, e2) => (e1 compareTo e2) &lt; 0) =
- * List("Bob", "John", "Steve", "Tom")</pre>
- * !!!
- def sortWith(lt : (A,A) => Boolean): CC[A] = {
- val arr = toArray
- Array.sortWith(arr, lt)
- val b = newBuilder[A]
- for (x <- arr) b += x
- b.result
- }
- */
-
- /** Returns a string representation of this iterable object. The resulting string
- * begins with the string <code>start</code> and is finished by the string
- * <code>end</code>. Inside, the string representations of elements (w.r.t.
- * the method <code>toString()</code>) are separated by the string
- * <code>sep</code>.
- *
- * @ex <code>List(1, 2, 3).mkString("(", "; ", ")") = "(1; 2; 3)"</code>
- * @param start starting string.
- * @param sep separator string.
- * @param end ending string.
- * @return a string representation of this iterable object.
- */
- def mkString(start: String, sep: String, end: String): String =
- addString(new StringBuilder(), start, sep, end).toString
-
- /** Returns a string representation of this iterable object. The string
- * representations of elements (w.r.t. the method <code>toString()</code>)
- * are separated by the string <code>sep</code>.
- *
- * @param sep separator string.
- * @return a string representation of this iterable object.
- */
- def mkString(sep: String): String =
- addString(new StringBuilder(), sep).toString
-
- /** Converts a collection into a flat <code>String</code> by each element's toString method.
- */
- def mkString =
- addString(new StringBuilder()).toString
-
- /** Write all elements of this iterable into given string builder.
- * The written text begins with the string <code>start</code> and is finished by the string
- * <code>end</code>. Inside, the string representations of elements (w.r.t.
- * the method <code>toString()</code>) are separated by the string
- * <code>sep</code>.
- */
- def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder = {
- b append start
- var first = true
- for (x <- this) {
- if (first) first = false
- else b append sep
- b append x
- }
- b append end
- }
-
- /** Write all elements of this string into given string builder.
- * The string representations of elements (w.r.t. the method <code>toString()</code>)
- * are separated by the string <code>sep</code>.
- */
- def addString(b: StringBuilder, sep: String): StringBuilder = addString(b, "", sep, "")
-
- /** Write all elements of this string into given string builder without using
- * any separator between consecutive elements.
- */
- def addString(b: StringBuilder): StringBuilder = addString(b, "")
-
- /**
- * returns a projection that can be used to call non-strict <code>filter</code>,
- * <code>map</code>, and <code>flatMap</code> methods that build projections
- * of the collection.
- def projection : Iterable.Projection[A] = new Iterable.Projection[A] {
- def elements = Iterable.this.elements
- override def force = Iterable.this
- }
- */
-
- override def toString = mkString(stringPrefix + "(", ", ", ")")
-
- /** Defines the prefix of this object's <code>toString</code> representation.
- */
- def stringPrefix : String = {
- var string = this.getClass.getName
- val idx1 = string.lastIndexOf('.' : Int)
- if (idx1 != -1) string = string.substring(idx1 + 1)
- val idx2 = string.indexOf('$')
- if (idx2 != -1) string = string.substring(0, idx2)
- string
- }
-
- /** Creates a view of this iterable @see IterableView
- */
- def view: IterableView[CC, A] = new IterableView[CC, A] { // !!! Martin: We should maybe infer the type parameters here?
- val origin = thisCC
- val elements: Iterator[A] = self.elements
- }
-
-// The following methods return non-deterministic results, unless this iterable is an OrderedIterable
-
- /** The first element of this iterable.
- *
- * @note Might return different results for different runs, unless this iterable is ordered
- * @throws Predef.NoSuchElementException if the iterable is empty.
- */
- def head: A = if (isEmpty) throw new NoSuchElementException else elements.next
-
- /** @deprecated use head instead */
- @deprecated def first: A = head
-
- /** Returns as an option the first element of this iterable
- * or <code>None</code> if iterable is empty.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def headOption: Option[A] = if (isEmpty) None else Some(head)
-
- /** @deprecated use headOption instead
- * <code>None</code> if iterable is empty.
- */
- @deprecated def firstOption: Option[A] = headOption
-
- /** An iterable consisting of all elements of this iterable
- * except the first one.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def tail: CC[A] = drop(1)
-
- /** Return an iterable consisting only of the first <code>n</code>
- * elements of this iterable, or else the whole iterable, if it has less
- * than <code>n</code> elements.
- *
- * @param n the number of elements to take
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def take(n: Int): CC[A] = {
- val b = newBuilder[A]
- var i = 0
- breakable {
- for (x <- this) {
- b += x
- i += 1
- if (i == n) break
- }
- }
- b.result
- }
-
- /** Returns this iterable without its <code>n</code> first elements
- * If this iterable has less than <code>n</code> elements, the empty
- * iterable is returned.
- *
- * @param n the number of elements to drop
- * @return the new iterable
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def drop(n: Int): CC[A] = {
- val b = newBuilder[A]
- var i = 0
- for (x <- this) {
- if (i >= n) b += x
- i += 1
- }
- b.result
- }
-
- /** A sub-iterable starting at index `from`
- * and extending up to (but not including) index `until`.
- *
- * @note c.slice(from, to) is equivalent to (but possibly more efficient than)
- * c.drop(from).take(to - from)
- *
- * @param from The index of the first element of the returned subsequence
- * @param until The index of the element following the returned subsequence
- * @throws IndexOutOfBoundsException if <code>from &lt; 0</code>
- * or <code>length &lt; from + len<code>
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def slice(from: Int, until: Int): CC[A] = {
- val b = newBuilder[A]
- var i = 0
- breakable {
- for (x <- this) {
- if (i >= from) b += x
- i += 1
- if (i == until) break
- }
- }
- b.result
- }
-
- /** Split the iterable at a given point and return the two parts thus
- * created.
- *
- * @param n the position at which to split
- * @return a pair of iterables composed of the first <code>n</code>
- * elements, and the other elements.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def splitAt(n: Int): (CC[A], CC[A]) = {
- val l, r = newBuilder[A]
- var i = 0
- for (x <- this)
- (if (i < n) l else r) += x
- (l.result, r.result)
- }
-
- /** A sub-iterable view starting at index `from`
- * and extending up to (but not including) index `until`.
- *
- * @param from The index of the first element of the slice
- * @param until The index of the element following the slice
- * @note The difference between `view` and `slice` is that `view` produces
- * a view of the current iterable, whereas `slice` produces a new iterable.
- *
- * @note Might return different results for different runs, unless this iterable is ordered
- * @note view(from, to) is equivalent to view.slice(from, to)
- */
- def view(from: Int, until: Int): IterableView[CC, A] = view.slice(from, until)
-}
diff --git a/src/library/scalax/collection/generic/IterableView.scala b/src/library/scalax/collection/generic/IterableView.scala
deleted file mode 100755
index bb111e2252..0000000000
--- a/src/library/scalax/collection/generic/IterableView.scala
+++ /dev/null
@@ -1,112 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
-
-package scalax.collection.generic
-
-/** A non-strict projection of an iterable.
- * @author Sean McDirmid
- * @author Martin Odersky
- * @note this should really be a virtual class of SequenceFactory
- */
-trait IterableView[+UC[/*+*/B] <: Iterable[B], /*+*/A] extends Iterable[A] { self =>
-
- val origin: Iterable[_]
- def elements: Iterator[A]
-
- val underlying: Iterable[_] = origin match {
- case v: IterableView[t, _] => v.underlying
- case _ => origin
- }
-
- protected def isDelay = elements eq underlying.elements
-
- private[this] var forced: UC[A] = _
- private[this] var wasForced = false
-
- def force: UC[A] = {
- if (!wasForced) {
- forced = {
- val b = underlying.newBuilder[A]
- for (x <- elements)
- b += x
- b.result
- }.asInstanceOf[UC[A]]
- wasForced = true
- }
- forced
- }
-
- def newBuilder[A] = underlying.newBuilder[A]
-
- /** Builds a new view object. This method needs to be overridden in subclasses
- * which refine in IterableView type
- */
- protected def newView[B](elems: Iterator[B]) = new IterableView[UC, B] {
- val origin = if (self.isDelay) self.origin else self
- val elements = elems
- }
-
- /** Non-strict variant of @see IterableLike.++ */
- override def ++[B >: A](that: Iterator[B]): IterableView[UC, B] = newView(elements ++ that)
-
- /** Non-strict variant of @see IterableLike.++ */
- override def ++[B >: A](that: Iterable[B]): IterableView[UC, B] = newView(elements ++ that.elements)
-
- /** Non-strict variant of @see IterableLike.map */
- override def map[B](f: A => B): IterableView[UC, B] = newView(elements map f)
-
- /** Non-strict variant of @see IterableLike.flatMap */
- override def flatMap[B](f: A => Iterable[B]): IterableView[UC, B] = newView(elements flatMap (f(_).elements))
-
- /** Non-strict variant of @see IterableLike.filter */
- override def filter(p: A => Boolean): IterableView[UC, A] = newView(elements filter p)
-
- /** Non-strict variant of @see IterableLike.partition */
- override def partition(p: A => Boolean): (IterableView[UC, A], IterableView[UC, A]) = {
- val (li, ri) = elements partition p
- (newView(li), newView(ri))
- }
-
- /** Non-strict variant of @see IterableLike.zip */
- override def zip[B](other: Iterable[B]): IterableView[UC, (A, B)] = newView(elements zip other.elements)
-
- /** Non-strict variant of @see IterableLike.zipWithIndex */
- override def zipWithIndex: IterableView[UC, (A, Int)] = newView(elements.zipWithIndex)
-
- /* Non-strict variant of @see IterableLike.zipAll
- * This is not enabled because it can't be specialized in VectorView:
- * VectorView is not covariant, yet must maintain updatability. Impossible to do this
- * with this type signature.
- override def zipAll[B, A1 >: A, B1 >: B](that: Iterable[B], thisElem: A1, thatElem: B1): IterableView[UC, (A1, B1)] =
- newView(elements zipAll (that.elements, thisElem, thatElem))
- */
-
- /** Non-strict variant of @see Iterable.take */
- override def take(n: Int): IterableView[UC, A] = newView(elements take n)
-
- /** Non-strict variant of @see Iterable.drop */
- override def drop(n: Int): IterableView[UC, A] = newView(elements drop n)
-
- /** Non-strict variant of @see Iterable.splitAt */
- override def splitAt(n: Int): (IterableView[UC, A], IterableView[UC, A]) = (take(n), drop(n))
-
- /** Non-strict variant of @see Iterable.slice */
- override def slice(from: Int, until: Int): IterableView[UC, A] = newView(elements slice (from, until))
-
- /** The projection resulting from the concatenation of this projection with the <code>rest</code> projection.
- * @param rest The projection that gets appended to this projection
- * @deprecated Use ++ instead
- */
- @deprecated def append[B >: A](rest : => Iterable[B]): IterableView[UC, B] = this ++ rest.elements
-
- override def stringPrefix = origin.stringPrefix+"V"
-
-
-}
diff --git a/src/library/scalax/collection/generic/LazyBuilder.scala b/src/library/scalax/collection/generic/LazyBuilder.scala
deleted file mode 100755
index 74764351b6..0000000000
--- a/src/library/scalax/collection/generic/LazyBuilder.scala
+++ /dev/null
@@ -1,24 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: ListBuffer.scala 14378 2008-03-13 11:39:05Z dragos $
-
-package scalax.collection.generic
-
-import collection.mutable.ListBuffer
-import collection.immutable.{List, Nil, ::}
-
-abstract class LazyBuilder[+CC[B], A] extends Builder[CC, A] {
- protected var parts = new ListBuffer[Iterator[A]]
- def +=(x: A) = { parts += Iterator.single(x) }
- override def ++=(xs: Iterator[A]) { parts += xs }
- override def ++=(xs: Iterable[A]) { parts += xs.elements }
- def elements: Iterator[A] = Iterator.iteratorIteratorWrapper(parts.elements).flatten // !!! can remove the wrapper once new compiler is in starr
- def result: CC[A]
- def clear() { parts.clear() }
-}
diff --git a/src/library/scalax/collection/generic/MapFactory.scala b/src/library/scalax/collection/generic/MapFactory.scala
deleted file mode 100755
index d7413b8928..0000000000
--- a/src/library/scalax/collection/generic/MapFactory.scala
+++ /dev/null
@@ -1,9 +0,0 @@
-package scalax.collection.generic
-
-trait MapFactory[CC[A, B] <: MapTemplate[A, B, CC]] {
-
- def empty[A, B]: CC[A, B]
-
- def apply[A, B](elems: (A, B)*): CC[A, B] = empty[A, B] ++ elems.asInstanceOf[Iterable[(A, B)]] // !@!
-
-}
diff --git a/src/library/scalax/collection/generic/MapTemplate.scala b/src/library/scalax/collection/generic/MapTemplate.scala
deleted file mode 100755
index 6d1a9e3c93..0000000000
--- a/src/library/scalax/collection/generic/MapTemplate.scala
+++ /dev/null
@@ -1,247 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Map.scala 16884 2009-01-09 16:52:09Z cunei $
-
-
-package scalax.collection.generic
-
-import collection.immutable.Set
-import collection.mutable.ArrayBuffer
-import annotation.unchecked.uncheckedVariance
-
-/** <p>
-* A map is a collection that maps each key to one or zero values.
- * </p>
- * <p>
- * This trait provides a limited interface, only allowing reading of elements.
- * There are two extensions of this trait, in packages
- * <code><a href="mutable$content.html" target="contentFrame">
- * scala.collection.mutable</a></code>
- * and <code><a href="immutable$content.html" target="contentFrame">
- * scala.collection.immutable</a></code>, which provide functionality for
- * adding new key/value mappings to a map. The trait in the first package is
- * for maps that are modified destructively, whereas the trait in
- * the second package is for immutable maps which create a new map
- * when something is added or removed from them.
- * </p>
- *
- * @author Matthias Zenger
- * @author Martin Odersky
- * @version 1.2, 31/12/2006
- */
-trait MapTemplate[A, B, +CC[A1, B1] <: Map[A1, B1] with MapTemplate[A1, B1, CC]]
- extends PartialFunction[A, B]
- with SizedIterable[(A, B)]
- with Addable[CC[A, B], (A, B)]
- with Subtractable[CC[A, B], A] {
-self: CC[A, B] =>
-
- def newBuilder[B]: Builder[SizedIterable, B] = new ArrayBuffer[B]
-
- override def thisCC: CC[A, B] = this
-
- /** This method returns a new map instance of the same class
- * mapping keys of the same type to values of type <code>C</code>.
- */
- def empty[C]: CC[A, C]
-
- /** Compute the number of key-to-value mappings.
- *
- * @return the number of mappings
- */
- def size: Int
-
- /** Check if this map maps <code>key</code> to a value and return the
- * value if it exists.
- *
- * @param key the key of the mapping of interest
- * @return the value of the mapping, if it exists
- */
- def get(key: A): Option[B]
-
- /** Check if this map maps <code>key</code> to a value.
- * Return that value if it exists, otherwise return <code>default</code>.
- */
- def getOrElse[B2 >: B](key: A, default: => B2): B2 =
- get(key) match {
- case Some(v) => v
- case None => default
- }
-
- /** Is this an empty map?
- *
- * @return <code>true</code> iff the map is empty.
- */
- override def isEmpty: Boolean = size == 0
-
- /** Retrieve the value which is associated with the given key. This
- * method throws an exception if there is no mapping from the given
- * key to a value.
- *
- * @param key the key
- * @return the value associated with the given key.
- */
- def apply(key: A): B = get(key) match {
- case None => default(key)
- case Some(value) => value
- }
-
- /** Is the given key mapped to a value by this map?
- *
- * @param key the key
- * @return <code>true</code> iff there is a mapping for key in this map
- */
- def contains(key: A): Boolean = get(key) match {
- case None => false
- case Some(_) => true
- }
-
- /** Does this map contain a mapping from the given key to a value?
- *
- * @param key the key
- * @return <code>true</code> iff there is a mapping for key in this map
- */
- def isDefinedAt(key: A) = contains(key)
-
- /** Creates an iterator for all keys.
- *
- * @return an iterator over all keys.
- */
- def keys: Iterator[A] = new Iterator[A] {
- val iter = self.elements
- def hasNext = iter.hasNext
- def next = iter.next._1
- }
-
- /** @return the keys of this map as a set.
- */
- def keySet: Set[A] = new Set[A] {
- def size = self.size
- def contains(key : A) = self.contains(key)
- def elements = self.elements.map(_._1)
- def + (elem: A): Set[A] = immutable.Set[A]() ++ this + elem
- def - (elem: A): Set[A] = immutable.Set[A]() ++ this - elem
- override def newBuilder[B]: Builder[Set, B] = Set.newBuilder[B]
- }
-
- /** Creates an iterator for a contained values.
- *
- * @return an iterator over all values.
- */
- def values: Iterator[B] = new Iterator[B] {
- val iter = self.elements
- def hasNext = iter.hasNext
- def next = iter.next._2
- }
-
- /** Creates a string representation for this map.
- *
- * @return a string showing all mappings
- */
- override def toString() =
- elements.toList.map(kv => kv._1 + " -> " + kv._2).mkString(stringPrefix + "(", ", ", ")")
-
- /** The default value for the map, returned when a key is not found
- * The method implemented here yields an error,
- * but it might be overridden in subclasses.
- *
- * @param key the given key value
- * @throws Predef.NoSuchElementException
- */
- def default(key: A): B =
- throw new NoSuchElementException("key not found: " + key)
-
-/*
- override def view: Map.View[A,B] = new Map.View[A, B] {
- override def elements = self.elements
- override def size = self.size
- override def get(key: A): Option[B] = self.get(key)
- }
-*/
- def filterKeys(p: A => Boolean) = new MapView[CC, A, B] {
- val origin = self
- override def foreach(f: ((A, B)) => Unit): Unit = for (kv <- self) if (p(kv._1)) f(kv)
- def elements = self.elements.filter(kv => p(kv._1))
- def size = { var sz = 0; foreach(_ => sz += 1); sz }
- override def contains(key: A) = self.contains(key) && p(key)
- def get(key: A) = if (!p(key)) None else self.get(key)
- }
-
- def mapElements[C](f: B => C) = new MapView[CC, A,C] {
- val origin = self
- override def foreach(g: ((A, C)) => Unit): Unit = for ((k, v) <- self) g((k, f(v)))
- def elements = for ((k, v) <- self.elements) yield (k, f(v))
- def size = self.size
- override def contains(key: A) = self.contains(key)
- def get(key: A) = self.get(key).map(f)
- }
-
- /** Defines the prefix of this object's <code>toString</code> representation.
- */
- override def stringPrefix: String = "Map"
-
- /** Add a key/value pair to this map.
- * @param key the key
- * @param value the value
- * @return A new map with the new binding added to this map
- */
- def update (key: A, value: B): CC[A, B]
-
- /** Add a key/value pair to this map.
- * @param kv the key/value pair.
- * @return A new map with the new binding added to this map
- */
- def + (kv: (A, B)): CC[A, B] = update(kv._1, kv._2)
-
- /** Remove a key from this map
- * @param key the key to be removed
- * @return If the map does not contain a binding for <code>key</code>
- * it is returned unchanged. Otherwise, return a new map
- * without a binding for <code>key</code>
- */
- def - (key: A): CC[A, B]
-
- /** This function transforms all the values of mappings contained
- * in this map with function <code>f</code>.
- *
- * @param f A function over keys and values
- * @return the updated map
- */
- def transform[C](f: (A, B) => C): CC[A, C] = {
- var res = empty[C]
- for ((key, value) <- this) res += ((key, f(key, value)))
- res
- }
-
- /** Builds a new map with all key/value pairs of this map
- * for which the predicate <code>p</code> returns <code>true</code>.
- *
- * @param p A predicate over key-value pairs
- * @return the updated map
- */
- override def filter(p: ((A, B)) => Boolean): CC[A, B] = {
- var res = empty[B]
- for (kv <- this)
- if (p(kv)) res += kv
- res
- }
-
- /** Removes all the mappings for which the predicate
- * <code>p</code> returns <code>false</code>.
- *
- * @param p A predicate over key-value pairs
- * @return the updated map
- */
- override def remove(p: ((A, B)) => Boolean): CC[A, B] = {
- var res = this
- for (kv <- this)
- if (!p(kv)) res -= kv._1
- res
- }
-}
diff --git a/src/library/scalax/collection/generic/MapView.scala b/src/library/scalax/collection/generic/MapView.scala
deleted file mode 100644
index 924fd1173e..0000000000
--- a/src/library/scalax/collection/generic/MapView.scala
+++ /dev/null
@@ -1,44 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
-
-package scalax.collection.generic
-
-/** A non-strict view of a map.
- * @author Martin Odersky
- * @version 2.8
- */
-trait MapView[+UC[A1, B1] <: MapTemplate[A1, B1, UC] with Map[A1, B1], A, B] extends Map[A, B] { self =>
-
- val origin: Map[A, _]
-
- def empty[C] = origin.empty[C]
-
- def elements: Iterator[(A, B)]
-
- val underlying: Map[A, _] = origin match {
- case v: MapView[t, _, _] => v.underlying
- case _ => origin
- }
- private[this] var forced: UC[A, B] = _
- private[this] var wasForced = false
-
- def force: UC[A, B] = {
- if (!wasForced) {
- forced = underlying.empty[B].asInstanceOf[UC[A, B]] ++ elements
- wasForced = true
- }
- forced
- }
-
- def update (key: A, value: B): UC[A, B] = force update (key, value)
- def - (key: A): UC[A, B] = force - key
-}
-
-
diff --git a/src/library/scalax/collection/generic/MutableVectorTemplate.scala b/src/library/scalax/collection/generic/MutableVectorTemplate.scala
deleted file mode 100755
index 71c3f7bdf8..0000000000
--- a/src/library/scalax/collection/generic/MutableVectorTemplate.scala
+++ /dev/null
@@ -1,56 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2006-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Vector.scala 15437 2008-06-25 16:22:45Z stepancheg $
-
-package scalax.collection.generic
-
-import collection.mutable.Vector
-import collection.mutable.Vector._
-
-/** Sequences that support O(1) element access and O(1) length computation.
- * plus an update operation.
- * @author Sean McDirmid
- * @author Martin Odersky
- * @version 2.8
- */
-trait MutableVectorTemplate[+CC[B] <: MutableVectorTemplate[CC, B] with Vector[B], A] extends VectorTemplate[CC, A] {
-self =>
-
- def update(idx: Int, elem: A)
-
- /** Creates a view of this iterable @see OrderedIterable.View
- */
- override def view: MutableVectorView[CC, A] = new MutableVectorView[CC, A] { // !!! Martin: We should maybe infer the type parameters here?
- val origin: Vector[_] = thisCC
- val length: Int = self.length
- def apply(idx: Int): A = self.apply(idx)
- def update(idx: Int, elem: A) = self.update(idx, elem)
- }
-
- /** A sub-sequence view starting at index `from`
- * and extending up to (but not including) index `until`.
- *
- * @param from The index of the first element of the slice
- * @param until The index of the element following the slice
- * @note The difference between `view` and `slice` is that `view` produces
- * a view of the current sequence, whereas `slice` produces a new sequence.
- *
- * @note view(from, to) is equivalent to view.slice(from, to)
- */
- override def view(from: Int, until: Int): MutableVectorView[CC, A] = view.slice(from, until)
-
- def readOnly: collection.Vector[A] = new collection.Vector[A] { //!!! just use a VectorProxy?
- def length = self.length
- def apply(idx : Int) = self.apply(idx)
- def newBuilder[B]: Builder[collection.Vector, B] = self.newBuilder[B] //mapResult (_.readOnly)
- override def foreach(f: A => Unit) = self.foreach(f)
- override def stringPrefix = self.stringPrefix+"RO"
- }
-}
-
diff --git a/src/library/scalax/collection/generic/MutableVectorView.scala b/src/library/scalax/collection/generic/MutableVectorView.scala
deleted file mode 100755
index d445ba336e..0000000000
--- a/src/library/scalax/collection/generic/MutableVectorView.scala
+++ /dev/null
@@ -1,97 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Sequence.scala 16092 2008-09-12 10:37:06Z nielsen $
-
-
-package scalax.collection.generic
-
-import collection.mutable.Vector
-import collection.mutable.Vector._
-
-/** A non-strict projection of an iterable.
- * @author Sean McDirmid
- * @author Martin Odersky
- * @note this should really be a virtual class of SequenceFactory
- */
-trait MutableVectorView[+UC[B] <: Vector[B], A] extends SequenceView[UC, A] with Vector[A] {
-self =>
-
- /** refined from Iterable.View */
- val origin: Vector[_]
-
- override def newBuilder[A] = underlying.newBuilder[A].asInstanceOf[Builder[Vector, A]]
-
- trait Transformed[B] extends super.Transformed[B] with MutableVectorView[UC, B] {
- override val origin = self
- override def elements: Iterator[B] = new Elements(0, length)
- override protected def asCC = asInstanceOf[MutableVectorView[UC, B]]
- }
-
- class Appended(that: Vector[A]) extends super.Appended[A](that) with Transformed[A] {
- override def update(idx: Int, elem: A) {
- val ll = self.length
- if (idx < ll) self.update(idx, elem) else that.update(idx - ll, elem)
- }
- }
-
- class Sliced(from: Int, to: Int) extends super.Sliced(from, to) with Transformed[A] {
- override def update(idx: Int, elem: A) {
- if (idx >= 0 && idx < length) self.update(idx + from, elem)
- else throw new IndexOutOfBoundsException(idx.toString)
- }
- override def slice(from1: Int, to1: Int) =
- new self.Sliced(from + (from1 min length max 0) , to + (to1 min length max 0))
- }
-
- class Reversed extends super.Reversed with Transformed[A] {
- override def update(idx: Int, elem: A) {
- self.update(length - 1 - idx, elem)
- }
- }
-
- class Zipped[B](that: Vector[B]) extends super.Zipped[B](that) with Transformed[(A, B)] {
- override def update(idx: Int, elem: (A, B)) {
- self.update(idx, elem._1)
- that.update(idx, elem._2)
- }
- }
-
- def ++(that: Vector[A]): MutableVectorView[UC, A] =
- new Appended(that).asCC
-
- override def reverse: MutableVectorView[UC, A] =
- (new Reversed).asCC
-
- private def toVector[B](xs: Iterable[B]): Vector[B] = xs match {
- case ras: Vector[_] => ras.asInstanceOf[Vector[B]]
- case _ => Vector() ++ xs
- }
-
- override def zip[B](that: Iterable[B]): MutableVectorView[UC, (A, B)] =
- new Zipped(toVector(that)).asCC
-
- override def zipWithIndex: MutableVectorView[UC, (A, Int)] =
- zip((0 until length).asInstanceOf[Null]) // !@!
- override def take(n: Int): MutableVectorView[UC, A] =
- slice(0, n)
- override def drop(n: Int): MutableVectorView[UC, A] =
- slice(n, Math.MAX_INT)
- override def splitAt(n: Int): (MutableVectorView[UC, A], MutableVectorView[UC, A]) = (take(n), drop(n))
- override def slice(from: Int, until: Int): MutableVectorView[UC, A] =
- new Sliced(from, until).asCC
- override def takeWhile(p: A => Boolean): MutableVectorView[UC, A] =
- take(prefixLength(p))
- override def dropWhile(p: A => Boolean): MutableVectorView[UC, A] =
- drop(prefixLength(p))
- override def span(p: A => Boolean): (MutableVectorView[UC, A], MutableVectorView[UC, A]) = {
- val n = prefixLength(p)
- (take(n), drop(n))
- }
-}
-
diff --git a/src/library/scalax/collection/generic/OrderedIterableForwarder.scala b/src/library/scalax/collection/generic/OrderedIterableForwarder.scala
deleted file mode 100755
index 643f31d861..0000000000
--- a/src/library/scalax/collection/generic/OrderedIterableForwarder.scala
+++ /dev/null
@@ -1,37 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: IterableProxy.scala 15458 2008-06-28 20:23:22Z stepancheg $
-
-
-package scalax.collection.generic
-
-/** This trait implements a forwarder for iterable objects. It forwards
- * all calls to a different iterable object, except for
- *
- * - toString, hashCode, equals, stringPrefix
- * - newBuilder, view
- * - all calls creating a new iterable object of the same kind
- *
- * The above methods are forwarded by subclass IterableProxy
- *
- * @author Martin Odersky
- * @version 2.8
- */
-trait OrderedIterableForwarder[+A] extends OrderedIterable[A] with IterableForwarder[A] {
-
- /** The iterable object to which calls are forwarded */
- protected def underlying: OrderedIterable[A]
-
- // Iterable delegates
- // Iterable methods could be printed by cat IterableTemplate.scala | sed -n '/trait Iterable/,$ p' | egrep '^ (override )?def'
-
- override def last: A = underlying.last
- override def lastOption: Option[A] = underlying.lastOption
- override def sameElements[B >: A](that: OrderedIterable[B]): Boolean = underlying.sameElements(that)
-}
diff --git a/src/library/scalax/collection/generic/OrderedIterableTemplate.scala b/src/library/scalax/collection/generic/OrderedIterableTemplate.scala
deleted file mode 100755
index 501cbf6447..0000000000
--- a/src/library/scalax/collection/generic/OrderedIterableTemplate.scala
+++ /dev/null
@@ -1,161 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
-
-
-package scalax.collection.generic
-
-import OrderedIterable._
-
-import util.control.Breaks._
-
-/** Ordered iterables are iterables where the `elements` method always returns elements in the same
- * order (namely the order in which elements were appended to the iterable). In particular, one has
- * for every two ordered iterables `xs` and `ys`:
- *
- * `(xs ++ ys).elements = xs.elements ++ ys.elements
- */
-trait OrderedIterableTemplate[+CC[/*+*/B] <: OrderedIterableTemplate[CC, B] with OrderedIterable[B], /*+*/A]
- extends IterableTemplate[CC, A] {
-
- /** The last element of this iterable.
- *
- * @throws Predef.NoSuchElementException if the iterable is empty.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def last: A = {
- var lst = head
- for (x <- this)
- lst = x
- lst
- }
-
- /** Returns as an option the last element of this iterable or
- * <code>None</code> if iterable is empty.
- *
- * @return the last element as an option.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def lastOption: Option[A] = if (isEmpty) None else Some(last)
-
- /** An iterable consisting of all elements of this iterable except the last one.
- * @throws Predef.UnsupportedOperationException if the stream is empty.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def init: CC[A] = {
- if (isEmpty) throw new UnsupportedOperationException("empty.init")
- var lst = head
- val b = newBuilder[A]
- for (x <- this) {
- b += lst
- lst = x
- }
- b.result
- }
-
- /** Returns the rightmost <code>n</code> elements from this iterable.
- *
- * @param n the number of elements to take
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def takeRight(n: Int): CC[A] = {
- val b = newBuilder[A]
- val lead = elements drop n
- var go = false
- for (x <- this) {
- if (go) b += x
- else if (lead.hasNext) lead.next
- else go = true
- }
- b.result
- }
-
- /** Returns the iterable wihtout its rightmost <code>n</code> elements.
- *
- * @param n the number of elements to take
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def dropRight(n: Int): CC[A] = {
- val b = newBuilder[A]
- val lead = elements drop n
- breakable {
- for (x <- this) {
- if (!lead.hasNext) break
- lead.next
- b += x
- }
- }
- b.result
- }
-
- /** Returns the longest prefix of this iterable whose elements satisfy
- * the predicate <code>p</code>.
- *
- * @param p the test predicate.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def takeWhile(p: A => Boolean): CC[A] = {
- val b = newBuilder[A]
- breakable {
- for (x <- this) {
- if (!p(x)) break
- b += x
- }
- }
- b.result
- }
-
- /** Returns the longest suffix of this iterable whose first element
- * does not satisfy the predicate <code>p</code>.
- *
- * @param p the test predicate.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def dropWhile(p: A => Boolean): CC[A] = {
- val b = newBuilder[A]
- var go = false
- for (x <- this) {
- if (go) b += x
- else if (!p(x)) { go = true; b += x }
- }
- b.result
- }
-
- /** Returns a pair consisting of the longest prefix of the iterable whose
- * elements all satisfy the given predicate, and the rest of the iterable.
- *
- * @param p the test predicate
- * @return a pair consisting of the longest prefix of the iterable whose
- * elements all satisfy <code>p</code>, and the rest of the iterable.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def span(p: A => Boolean): (CC[A], CC[A]) = {
- val l, r = newBuilder[A]
- var toLeft = true
- for (x <- this) {
- toLeft = toLeft && p(x)
- (if (toLeft) l else r) += x
- }
- (l.result, r.result)
- }
-
- /** Checks if the other iterable object contains the same elements as this one.
- *
- * @note will not terminate for infinite-sized iterables.
- * @param that the other iterable
- * @return true, iff both iterables contain the same elements.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def sameElements[B >: A](that: OrderedIterable[B]): Boolean = {
- val these = this.elements
- val those = that.elements
- while (these.hasNext && those.hasNext && these.next() == those.next()) {}
- !these.hasNext && !those.hasNext
- }
-}
diff --git a/src/library/scalax/collection/generic/OrderedIterableView.scala b/src/library/scalax/collection/generic/OrderedIterableView.scala
deleted file mode 100755
index 9f0d981f54..0000000000
--- a/src/library/scalax/collection/generic/OrderedIterableView.scala
+++ /dev/null
@@ -1,87 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
-
-package scalax.collection.generic
-
-/** A non-strict projection of an iterable.
- * @author Sean McDirmid
- * @author Martin Odersky
- * @note this should really be a virtual class of SequenceFactory
- */
-trait OrderedIterableView[+UC[/*+*/B] <: Iterable[B], /*+*/A] extends IterableView[UC, A] with OrderedIterable[A] { self =>
-
- val origin: OrderedIterable[_]
-
- override def newBuilder[A] = underlying.newBuilder[A].asInstanceOf[Builder[OrderedIterable, A]]
-
- /** Builds a new view object. This method needs to be overridden in subclasses
- * which refine in IterableView type
- */
- protected override def newView[B](elems: Iterator[B]) = new OrderedIterableView[UC, B] {
- val origin = if (self.isDelay) self.origin else self
- val elements = elems
- }
-
- /** Non-strict variant of @see IterableLike.++ */
- override def ++[B >: A](that: Iterator[B]): OrderedIterableView[UC, B] = newView(elements ++ that)
-
- /** Non-strict variant of @see IterableLike.++ */
- override def ++[B >: A](that: Iterable[B]): OrderedIterableView[UC, B] = newView(elements ++ that.elements)
-
- /** Non-strict variant of @see IterableLike.map */
- override def map[B](f: A => B): OrderedIterableView[UC, B] = newView(elements map f)
-
- /** Non-strict variant of @see IterableLike.flatMap */
- override def flatMap[B](f: A => Iterable[B]): OrderedIterableView[UC, B] = newView(elements flatMap (f(_).elements))
-
- /** Non-strict variant of @see IterableLike.filter */
- override def filter(p: A => Boolean): OrderedIterableView[UC, A] = newView(elements filter p)
-
- /** Non-strict variant of @see IterableLike.partition */
- override def partition(p: A => Boolean): (OrderedIterableView[UC, A], OrderedIterableView[UC, A]) = {
- val (li, ri) = elements partition p
- (newView(li), newView(ri))
- }
-
- /** Non-strict variant of @see IterableLike.zip */
- override def zip[B](other: Iterable[B]): OrderedIterableView[UC, (A, B)] = newView(elements zip other.elements)
-
- /** Non-strict variant of @see IterableLike.zipWithIndex */
- override def zipWithIndex: OrderedIterableView[UC, (A, Int)] = newView(elements.zipWithIndex)
-
- /* Non-strict variant of @see IterableLike.zipAll
- * This is not enabled because it can't be specialized in VectorView:
- * VectorView is not covariant, yet must maintain updatability. Impossible to do this
- * with this type signature.
- override def zipAll[B, A1 >: A, B1 >: B](that: Iterable[B], thisElem: A1, thatElem: B1): OrderedIterableView[UC, (A1, B1)] =
- newView(elements zipAll (that.elements, thisElem, thatElem))
- */
-
- /** Non-strict variant of @see Iterable.take */
- override def take(n: Int): OrderedIterableView[UC, A] = newView(elements take n)
-
- /** Non-strict variant of @see Iterable.drop */
- override def drop(n: Int): OrderedIterableView[UC, A] = newView(elements drop n)
-
- /** Non-strict variant of @see Iterable.splitAt */
- override def splitAt(n: Int): (OrderedIterableView[UC, A], OrderedIterableView[UC, A]) = (take(n), drop(n))
-
- /** Non-strict variant of @see Iterable.slice */
- override def slice(from: Int, until: Int): OrderedIterableView[UC, A] = newView(elements slice (from, until))
-
- /** Non-strict variant of @see Iterable.takeWhile */
- override def takeWhile(p: A => Boolean): OrderedIterableView[UC, A] = newView(elements takeWhile p)
-
- /** Non-strict variant of @see Iterable.dropWhile */
- override def dropWhile(p: A => Boolean): OrderedIterableView[UC, A] = newView(elements dropWhile p)
-
- /** Non-strict variant of @see Iterable.span */
- override def span(p: A => Boolean): (OrderedIterableView[UC, A], OrderedIterableView[UC, A]) = (takeWhile(p), dropWhile(p))
-}
diff --git a/src/library/scalax/collection/generic/SequenceFactory.scala b/src/library/scalax/collection/generic/SequenceFactory.scala
deleted file mode 100755
index 26818c49c9..0000000000
--- a/src/library/scalax/collection/generic/SequenceFactory.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-package scalax.collection.generic
-
-trait SequenceFactory[CC[A] <: Sequence[A]] extends IterableFactory[CC] {
-
- /** This method is called in a pattern match { case Sequence(...) => }.
- *
- * @param x the selector value
- * @return sequence wrapped in an option, if this is a Sequence, otherwise none
- */
- def unapplySeq[A](x: CC[A]): Some[CC[A]] = Some(x)
-}
diff --git a/src/library/scalax/collection/generic/SequenceForwarder.scala b/src/library/scalax/collection/generic/SequenceForwarder.scala
deleted file mode 100644
index 63dca249b6..0000000000
--- a/src/library/scalax/collection/generic/SequenceForwarder.scala
+++ /dev/null
@@ -1,50 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: SeqProxy.scala 15458 2008-06-28 20:23:22Z stepancheg $
-
-
-package scalax.collection.generic
-
-/** This class implements a forwarder for sequences. It forwards
- * all calls to a different sequence object except for
- *
- * - toString, hashCode, equals, stringPrefix
- * - newBuilder, view, toSequence
- * - all calls creating a new iterable objetc of the same kind
- *
- * The above methods are forwarded by subclass SequenceProxy
- *
- * @author Martin Odersky
- * @version 2.8
- */
-trait SequenceForwarder[+A] extends Sequence[A] with IterableForwarder[A] {
-
- protected override def underlying: Sequence[A]
-
- // PartialFunction delegates
-
- override def apply(i: Int): A = underlying.apply(i)
- override def isDefinedAt(x: Int): Boolean = underlying.isDefinedAt(x)
-
- // Sequence delegates
- // Sequence methods could be printed by cat SequenceTemplate.scala | sed -n '/trait Seq/,$ p' | egrep '^ (override )?def'
-
- override def length: Int = underlying.length
- override def lengthCompare(l: Int) = underlying lengthCompare l
- override def segmentLength(p: A => Boolean, from: Int): Int = underlying.segmentLength(p, from)
- override def prefixLength(p: A => Boolean) = underlying.prefixLength(p)
- override def indexWhere(p: A => Boolean, from: Int): Int = underlying.indexWhere(p, from)
- override def indexOf[B >: A](elem: B, from: Int): Int = underlying.indexOf(elem, from)
- override def reversedElements: Iterator[A] = underlying.reversedElements
- override def startsWith[B](that: Sequence[B], offset: Int): Boolean = underlying.startsWith(that, offset)
- override def endsWith[B](that: Sequence[B]): Boolean = underlying.endsWith(that)
- override def indexOf[B >: A](that: Sequence[B]): Int = underlying.indexOf(that)
- override def contains(elem: Any): Boolean = underlying.contains(elem)
- override def indices: Range = underlying.indices
-}
diff --git a/src/library/scalax/collection/generic/SequenceTemplate.scala b/src/library/scalax/collection/generic/SequenceTemplate.scala
deleted file mode 100755
index 3407f63216..0000000000
--- a/src/library/scalax/collection/generic/SequenceTemplate.scala
+++ /dev/null
@@ -1,383 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Sequence.scala 16092 2008-09-12 10:37:06Z nielsen $
-
-
-package scalax.collection.generic
-
-import util.control.Breaks._
-import scalax.collection.immutable.{List, Nil, ::}
-
-import Sequence._
-
-trait SequenceTemplate[+CC[/*+*/B] <: SequenceTemplate[CC, B] with Sequence[B], /*+*/A] extends PartialFunction[Int, A] with OrderedIterableTemplate[CC, A] {
-self /*: CC[A]*/ =>
-
- /** Returns the length of the sequence.
- *
- * @return the sequence length.
- */
- def length: Int
-
- /** Result of comparing <code>length</code> with operand <code>len</code>.
- * returns <code>x</code> where
- * <code>x &lt; 0</code> iff <code>this.length &lt; len</code>
- * <code>x == 0</code> iff <code>this.length == len</code>
- * <code>x &gt; 0</code> iff <code>this.length &gt; len</code>.
- *
- * The method as implemented here does not call length directly; its running time
- * is O(length min len) instead of O(length). The method should be overwritten
- * if computing length is cheap.
- */
- def lengthCompare(len: Int): Int = {
- var i = 0
- breakable {
- for (_ <- this) {
- i += 1
- if (i > len) break
- }
- }
- i - len
- }
-
- /** Should always be <code>length</code> */
- def size = length
-
- /** Is this partial function defined for the index <code>x</code>?
- */
- def isDefinedAt(x: Int): Boolean = (x >= 0) && (x < length)
-
- /** Returns length of longest segment starting from a start index `from`
- * such that every element of the segment satisfies predicate `p`.
- * @note may not terminate for infinite-sized collections.
- * @param p the predicate
- * @param from the start index
- */
- def segmentLength(p: A => Boolean, from: Int): Int = {
- var result = 0
- var i = from
- breakable {
- for (x <- this) {
- if (i >= from && !p(x)) { result = i - from; break }
- else i += 1
- }
- }
- result
- }
-
- /** Returns length of longest prefix of this seqence
- * such that every element of the prefix satisfies predicate `p`.
- * @note may not terminate for infinite-sized collections.
- * @param p the predicate
- */
- def prefixLength(p: A => Boolean) = segmentLength(p, 0)
-
- /** Returns index of the first element satisfying a predicate, or -1, if none exists.
- *
- * @note may not terminate for infinite-sized collections.
- * @param p the predicate
- */
- def indexWhere(p: A => Boolean): Int = indexWhere(p, 0)
-
- /** Returns index of the first element starting from a start index
- * satisying a predicate, or -1, if none exists.
- *
- * @note may not terminate for infinite-sized collections.
- * @param p the predicate
- * @param from the start index
- */
- def indexWhere(p: A => Boolean, from: Int): Int = {
- var result = -1
- var i = from
- breakable {
- for (x <- this) {
- if (i >= from && p(x)) { result = i; break }
- else i += 1
- }
- }
- result
- }
-
- /** Returns index of the first element satisying a predicate, or -1.
- *
- * @deprecated Use `indexWhere` instead
- */
- @deprecated def findIndexOf(p: A => Boolean): Int = indexWhere(p)
-
- /** Returns the index of the first occurence of the specified
- * object in this iterable object.
- *
- * @note may not terminate for infinite-sized collections.
- * @param elem element to search for.
- * @return the index in this sequence of the first occurence of the
- * specified element, or -1 if the sequence does not contain
- * this element.
- */
- def indexOf[B >: A](elem: B): Int = indexOf(elem, 0)
-
- /** Returns the index of the first occurence of the specified
- * object in this iterable object, starting from a start index, or
- * -1, if none exists.
- *
- * @note may not terminate for infinite-sized collections.
- * @param elem element to search for.
- */
- def indexOf[B >: A](elem: B, from: Int): Int = indexWhere(elem ==, from)
-
- /** Returns the index of the last occurence of the specified element
- * in this sequence, or -1 if the sequence does not contain this element.
- *
- * @param elem element to search for.
- * @return the index in this sequence of the last occurence of the
- * specified element, or -1 if the sequence does not contain
- * this element.
- */
- def lastIndexOf[B >: A](elem: B): Int = lastIndexOf(elem, length - 1)
-
- /** Returns the index of the last
- * occurence of the specified element in this sequence
- * before or at a given end index,
- * or -1 if the sequence does not contain this element.
- *
- * @param elem element to search for.
- * @param end the end index
- */
- def lastIndexOf[B >: A](elem: B, end: Int): Int = {
- var i = end
- val it = reversedElements
- while (it.hasNext && it.next != elem) i -= 1
- i
- }
-
- /** Returns index of the last element satisying a predicate, or -1, if none exists.
- *
- * @param p the predicate
- * @return the index of the last element satisfying <code>p</code>,
- * or -1 if such an element does not exist
- */
- def lastIndexWhere(p: A => Boolean): Int = lastIndexWhere(p, length - 1)
-
- /** Returns index of the last element not exceeding a given end index
- * and satisying a predicate, or -1 if none exists.
- *
- * @param end the end index
- * @param p the predicate
- */
- def lastIndexWhere(p: A => Boolean, end: Int): Int = {
- var i = end
- val it = reversedElements
- while (it.hasNext && (i > end || !p(it.next))) i -= 1
- i
- }
-
- /** A sequence of type <code>C</code> consisting of all elements of
- * this sequence in reverse order.
- * @note the operation is implemented by building a new sequence
- * from <code>this(length - 1), ..., this(0)</code>
- * If random access is inefficient for the given sequence implementation,
- * this operation should be overridden.
- */
- def reverse: CC[A] = {
- var xs: List[A] = List()
- for (x <- this)
- xs = x :: xs
- val b = newBuilder[A]
- for (x <- xs)
- b += x
- b.result
- }
-
- /** The elements of this sequence in reversed order
- */
- def reversedElements: Iterator[A] = reverse.elements
-
- /**
- * Checks whether the argument sequence is contained at the
- * specified index within the receiver object.
- *
- * If the both the receiver object, <code>this</code> and
- * the argument, <code>that</code> are infinite sequences
- * this method may not terminate.
- *
- * @return true if <code>that</code> is contained in
- * <code>this</code>, at the specified index, otherwise false
- *
- * @see String.startsWith
- */
- def startsWith[B](that: Sequence[B], offset: Int): Boolean = {
- val i = elements.drop(offset)
- val j = that.elements
- while (j.hasNext && i.hasNext && i.next == j.next) {}
- !j.hasNext
- }
-
- /**
- * Check whether the receiver object starts with the argument sequence.
- *
- * @return true if <code>that</code> is a prefix of <code>this</code>,
- * otherwise false
- *
- * @see Sequence.startsWith
- */
- def startsWith[B](that: Sequence[B]): Boolean = startsWith(that, 0)
-
- /** @return true if this sequence end with that sequence
- * @see String.endsWith
- */
- def endsWith[B](that: Sequence[B]): Boolean = {
- val i = this.elements.drop(length - that.length)
- val j = that.elements
- while (i.hasNext && j.hasNext && i.next == j.next) ()
- !j.hasNext
- }
-
- /** @return -1 if <code>that</code> not contained in this, otherwise the
- * index where <code>that</code> is contained
- * @see String.indexOf
- */
- def indexOf[B >: A](that: Sequence[B]): Int = {
- var i = 0
- var s: Sequence[A] = thisCC
- while (!s.isEmpty && !(s startsWith that)) {
- i += 1
- s = s drop 1
- }
- if (!s.isEmpty || that.isEmpty) i else -1
- }
-
- /** Tests if the given value <code>elem</code> is a member of this
- * sequence.
- *
- * @param elem element whose membership has to be tested.
- * @return <code>true</code> iff there is an element of this sequence
- * which is equal (w.r.t. <code>==</code>) to <code>elem</code>.
- */
- def contains(elem: Any): Boolean = exists (_ == elem)
-
- /** Computes the union of this sequence and the given sequence
- * <code>that</code>.
- *
- * @param that the sequence of elements to add to the sequence.
- * @return an sequence containing the elements of this
- * sequence and those of the given sequence <code>that</code>
- * which are not contained in this sequence.
- */
- def union[B >: A](that: Sequence[B]): CC[B] = this ++ (that diff thisCC)
-
- /** Computes the difference between this sequence and the given sequence
- * <code>that</code>.
- *
- * @param that the sequence of elements to remove from this sequence.
- * @return this sequence without the elements of the given sequence
- * <code>that</code>.
- */
- def diff[B >: A](that: Sequence[B]): CC[A] = this remove (that contains _)
-
- /** Computes the intersection between this sequence and the given sequence
- * <code>that</code>.
- *
- * @param that the sequence to intersect.
- * @return the sequence of elements contained both in this sequence and
- * in the given sequence <code>that</code>.
- */
- def intersect[B >: A](that: Sequence[B]): CC[A] = this filter(that contains _)
-
- /** Builds a new sequence from this sequence in which any duplicates (wrt to ==) removed.
- * Among duplicate elements, only the first one is retained in the result sequence
- */
- def removeDuplicates: CC[A] = {
- val b = newBuilder[A]
- var seen = Set[A]()
- for (x <- this) {
- if (!(seen contains x)) {
- b += x
- seen += x
- }
- }
- b.result
- }
-
- /** Returns a new sequence of given length containing the elements of this sequence followed by zero
- * or more occurrences of given elements.
- */
- def padTo[B >: A](len: Int, elem: B): CC[B] = {
- var diff = len - length
- val b = newBuilder[B] //!!! drop [B] and get surprising results!
- b ++= thisCC
- while (diff > 0) {
- b += elem
- diff -=1
- }
- b.result
- }
-
- /**
- * Overridden for efficiency.
- *
- * @return the sequence itself
- */
- override def toSequence: Sequence[A] = thisCC
-
- /** Force toString from Iterable, not from Function */
- override def toString = super[OrderedIterableTemplate].toString
-
- def indices: Range = 0 until length
-
- /** Creates a view of this iterable @see OrderedIterable.View
- */
- override def view: SequenceView[CC, A] = new SequenceView[CC, A] { // !!! Martin: We should maybe infer the type parameters here?
- val origin: Sequence[_] = thisCC
- val elements: Iterator[A] = self.elements
- val length: Int = self.length
- def apply(idx: Int): A = self.apply(idx)
- }
-
- /** A sub-sequence view starting at index `from`
- * and extending up to (but not including) index `until`.
- *
- * @param from The index of the first element of the slice
- * @param until The index of the element following the slice
- * @note The difference between `view` and `slice` is that `view` produces
- * a view of the current sequence, whereas `slice` produces a new sequence.
- *
- * @note view(from, to) is equivalent to view.slice(from, to)
- */
- override def view(from: Int, until: Int): SequenceView[CC, A] = view.slice(from, until)
-
- /** Returns index of the last element satisying a predicate, or -1.
- * @deprecated use `lastIndexWhere` instead
- */
- @deprecated def findLastIndexOf(p: A => Boolean): Int = lastIndexWhere(p)
-
- /** A sub-sequence starting at index <code>from</code>
- * and extending up to the length of the current sequence
- *
- * @param from The index of the first element of the slice
- * @throws IndexOutOfBoundsException if <code>from &lt; 0</code>
- * @deprecated use <code>drop</code> instead
- */
- @deprecated def slice(from: Int): Sequence[A] = slice(from, length)
-
- /** @deprecated Should be replaced by
- *
- * <code>(s1, s2) forall { case (x, y) => f(x, y) }</code>
- */
- @deprecated def equalsWith[B](that: Sequence[B])(f: (A,B) => Boolean): Boolean = {
- val i = this.elements
- val j = that.elements
- while (i.hasNext && j.hasNext && f(i.next, j.next)) ()
- !i.hasNext && !j.hasNext
- }
-
- /** Is <code>that</code> a slice in this?
- * @deprecated Should be repaced by <code>indexOf(that) != -1</code>
- */
- @deprecated def containsSlice[B](that: Sequence[B]): Boolean = indexOf(that) != -1
-
-}
diff --git a/src/library/scalax/collection/generic/SequenceView.scala b/src/library/scalax/collection/generic/SequenceView.scala
deleted file mode 100755
index 4f70f8a9d8..0000000000
--- a/src/library/scalax/collection/generic/SequenceView.scala
+++ /dev/null
@@ -1,131 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Sequence.scala 16092 2008-09-12 10:37:06Z nielsen $
-
-
-package scalax.collection.generic
-
-import util.control.Breaks._
-import annotation.unchecked.uncheckedVariance
-
-import Sequence._
-
-/** A non-strict projection of an iterable.
- * @author Sean McDirmid
- * @author Martin Odersky
- * @note this should really be a virtual class of SequenceFactory
- */
-trait SequenceView[+UC[/*+*/B] <: Sequence[B], /*+*/A] extends IterableView[UC, A] with Sequence[A] {
-self =>
-
- /** refined from Iterable.View */
- val origin: Sequence[_]
-
- override def newBuilder[A] = underlying.newBuilder[A].asInstanceOf[Builder[Sequence, A]]
-
- trait Transformed[/*+*/B] extends SequenceView[UC, B] {
- val origin = self
- protected def asCC = asInstanceOf[SequenceView[UC, B]]
- }
-
- class Appended[/*+*/B >: A](that: Sequence[B]) extends Transformed[B] {
- override def elements: Iterator[B] = self.elements ++ that.elements
- override def length: Int = self.length + that.length
- override def apply(idx: Int): B = {
- val ll = self.length
- if (idx < ll) self.apply(idx) else that.apply(idx - ll)
- }
- override def stringPrefix = self.stringPrefix + "A"
- }
-
- class Sliced(from: Int, to: Int) extends Transformed[A] {
- override def elements: Iterator[A] = self.elements slice (from, to)
- override lazy val length: Int = ((to min self.length) - (from max 0) min 0)
- override def apply(idx: Int): A =
- if (idx >= 0 && idx < length) self.apply(idx + from)
- else throw new IndexOutOfBoundsException(idx.toString)
- override def stringPrefix = self.stringPrefix + "S"
- override def slice(from1: Int, to1: Int) =
- new self.Sliced(from + (from1 min length max 0) , to + (to1 min length max 0)).asInstanceOf[SequenceView[UC, A]]
- }
-
- class Mapped[/*+*/B](f: A => B) extends Transformed[B] {
- override def elements: Iterator[B] = self.elements map f
- override def length: Int = self.length
- override def apply(idx: Int): B = f(self.apply(idx))
- override def stringPrefix = self.stringPrefix + "M"
- }
-
- class Reversed extends Transformed[A] {
- override def elements: Iterator[A] = self.reversedElements
- override def length: Int = self.length
- override def apply(idx: Int): A = self.apply(length - 1 - idx)
- override def stringPrefix = super.stringPrefix+"R"
- }
-
- class Patched[/*+*/B >: A](from: Int, patch: Sequence[B], replaced: Int) extends Transformed[B] {
- val plen = patch.length
- override def elements: Iterator[B] = self.elements patch (from, patch, replaced)
- override def length: Int = self.length + plen - replaced
- override def apply(idx: Int): B =
- if (idx < from) self.apply(idx)
- else if (idx < from + plen) patch.apply(idx - from)
- else self.apply(idx - plen + replaced)
- override def stringPrefix = super.stringPrefix+"P"
- }
-
- class Zipped[/*+*/B](that: Sequence[B]) extends Transformed[(A, B)] {
- override def elements: Iterator[(A, B)] = self.elements zip that.elements
- override def length = self.length min that.length
- override def apply(idx: Int): (A, B) = (self.apply(idx), that.apply(idx))
- override def stringPrefix = super.stringPrefix+"Z"
- }
-
- override def ++[B >: A](that: Iterable[B]): SequenceView[UC, B] =
- new Appended[B](that.toSequence).asCC
- override def ++[B >: A](that: Iterator[B]): SequenceView[UC, B] =
- new Appended[B](that.toSequence).asCC
- override def map[B](f: A => B): SequenceView[UC, B] =
- new Mapped(f).asCC
- override def reverse: SequenceView[UC, A] =
- (new Reversed).asCC
- def patch[B >: A](from: Int, patch: Sequence[B], replaced: Int): SequenceView[UC, B] =
- if (0 <= from && from < length) new Patched(from, patch, replaced).asCC
- else throw new IndexOutOfBoundsException(from.toString)
- override def padTo[B >: A](len: Int, elem: B): SequenceView[UC, B] =
- patch(length, fill((len - length) max 0)(elem), 0)
- override def zip[B](that: Iterable[B]): SequenceView[UC, (A, B)] =
- new Zipped(that.toSequence).asCC
- override def zipWithIndex: SequenceView[UC, (A, Int)] =
- zip((0 until length).asInstanceOf[Null]) // !@!
- /*
- override def zipAll[B, A1 >: A, B1 >: B](that: Iterable[B], thisElem: A1, thatElem: B1): SequenceView[UC, (A1, B1)] = {
- val that1 = that.toSequence
- self.padTo(that1.length, thisElem) zip that1.padTo(this.length, thatElem)//.asInstanceOf[SequenceView[UC, (A1, B1)]]
- }*/
- override def take(n: Int): SequenceView[UC, A] =
- slice(0, n)
- override def drop(n: Int): SequenceView[UC, A] =
- slice(n, Math.MAX_INT)
- override def splitAt(n: Int): (SequenceView[UC, A], SequenceView[UC, A]) = (take(n), drop(n))
- override def slice(from: Int, until: Int): SequenceView[UC, A] =
- new Sliced(from, until).asCC
- override def takeWhile(p: A => Boolean): SequenceView[UC, A] =
- take(prefixLength(p))
- override def dropWhile(p: A => Boolean): SequenceView[UC, A] =
- drop(prefixLength(p))
- override def span(p: A => Boolean): (SequenceView[UC, A], SequenceView[UC, A]) = {
- val n = prefixLength(p)
- (take(n), drop(n))
- }
-
- // missing here because we can't do anything about them, so we fall back to default construction
- // if an IterableView via newView: flatMap, filter, partition
-}
-
diff --git a/src/library/scalax/collection/generic/SetFactory.scala b/src/library/scalax/collection/generic/SetFactory.scala
deleted file mode 100644
index 458d4bbade..0000000000
--- a/src/library/scalax/collection/generic/SetFactory.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-package scalax.collection.generic
-
-trait SetFactory[CC[A] <: SetTemplate[CC, A] with Set[A]] extends IterableFactory[CC] {
-
- def empty[A]: CC[A]
-
- def apply[A](elems: A*): CC[A] = empty[A] ++ elems.asInstanceOf[Iterable[A]] // !@!
-
- override def newBuilder[B]: Builder[CC, B] = new AddableBuilder[CC, B](empty)
-
-}
diff --git a/src/library/scalax/collection/generic/SetTemplate.scala b/src/library/scalax/collection/generic/SetTemplate.scala
deleted file mode 100755
index bd94f10fc0..0000000000
--- a/src/library/scalax/collection/generic/SetTemplate.scala
+++ /dev/null
@@ -1,148 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ 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.generic
-
-
-/** <p>
- * A set is a collection that includes at most one of any object.
- * </p>
- * <p>
- * This trait provides a limited interface, only allowing reading of elements.
- * There are two extensions of this trait, in packages
- * <code><a href="mutable$content.html" target="contentFrame">
- * scala.collection.mutable</a></code>
- * and <code><a href="immutable$content.html" target="contentFrame">
- * scala.collection.immutable</a></code>, which provide functionality for
- * adding and removing objects from the set. The trait in the first package is
- * for sets that are modified destructively, whereas the trait in
- * the second package is for immutable sets which create a new set
- * when something is added or removed to them.
- *
- * @author Matthias Zenger
- * @author Martin Odersky
- * @version 2.8
- */
-trait SetTemplate[+CC[B] <: SetTemplate[CC, B] with Set[B], A]
- extends (A => Boolean)
- with SizedIterable[A]
- with IterableTemplate[CC, A]
- with Addable[CC[A], A]
- with Subtractable[CC[A], A] {
-
- /** Returns the number of elements in this set.
- *
- * @return number of set elements.
- */
- def size: Int
-
- /** Creates a new set of this kind with given elements */
- def newBuilder[B]: Builder[CC, B]
-
- /** Checks if this set contains element <code>elem</code>.
- *
- * @param elem the element to check for membership.
- * @return <code>true</code> iff <code>elem</code> is contained in
- * this set.
- */
- def contains(elem: A): Boolean
-
- /** Create a new set with an additional element.
- */
- def + (elem: A): CC[A]
-
- /** Remove a single element from a set.
- * @param elem the element to be removed
- * @return a new set with the element removed.
- */
- def - (elem: A): CC[A]
-
- /** Checks if this set is empty.
- *
- * @return <code>true</code> iff there is no element in the set.
- */
- override def isEmpty: Boolean = size == 0
-
- /** This method allows sets to be interpreted as predicates.
- * It returns <code>true</code>, iff this set contains element
- * <code>elem</code>.
- *
- * @param elem the element to check for membership.
- * @return <code>true</code> iff <code>elem</code> is contained in
- * this set.
- */
- def apply(elem: A): Boolean = contains(elem)
-
- /** 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 the set to intersect with.
- */
- def intersect(that: Set[A]): CC[A] = filter(that.contains)
-
- /** This method is an alias for <code>intersect</code>.
- * It computes an intersection with set <code>that</code>.
- * It removes all the elements that are not present in <code>that</code>.
- *
- * @param that the set to intersect with
- */
- def ** (that: collection.Set[A]): CC[A] = intersect(that)
-
- /** Checks if this set is a subset of set <code>that</code>.
- *
- * @param that another set.
- * @return <code>true</code> iff the other set is a superset of
- * this set.
- * todo: rename to isSubsetOf
- */
- def subsetOf(that: Set[A]): Boolean = forall(that.contains)
-
-/* What a mess! We need to remove these methods, but can't without breaking
- * existing code. What to do?
-
- /** 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.
- * @deprecated equals is not stable for mutable sets.
- * If you wish object identity, use eq or cast this set of AnyRef and then use
- * equals. If you wish element comparisons, use `sameElements` instead.
- */
- @deprecated override def equals(that: Any): Boolean = that match {
- case other: Set[_] =>
- this.size == other.size && subsetOf(other.asInstanceOf[Set[A]])
- case _ =>
- false
- }
-
- /* @deprecated Since the previous hashCode is not stable for mutable sets,
- * the implementation of this method has been changed to
- * standard address-based hashCode from java.lang.Object.
- * If you relied on the old behavior, y
- * IT has been
- * if you intend to have object identity hashCode and wish the deprecated warning
- * to go away, cast this set to AnyRef before calling hashCode.
- */
- @deprecated override def hashCode() =
- (0 /: this)((hash, e) => hash + e.hashCode())
-*/
- /** Defines the prefix of this object's <code>toString</code> representation.
- */
- override def stringPrefix: String = "Set"
-
- /** Need to override string, so that it's not the Function1's string that gets mixed in.
- */
- override def toString = super[IterableTemplate].toString
-}
diff --git a/src/library/scalax/collection/generic/Shrinkable.scala b/src/library/scalax/collection/generic/Shrinkable.scala
deleted file mode 100755
index e6d3b085f3..0000000000
--- a/src/library/scalax/collection/generic/Shrinkable.scala
+++ /dev/null
@@ -1,54 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
-
-package scalax.collection.generic
-
-/** This class represents collections that can be reduced using a -= operator.
- *
- * @autor Martin Odersky
- * @owner Martin Odersky
- * @version 2.8
- */
-trait Shrinkable[A] {
-
- /** Removes a single element from this collection.
- *
- * @param elem the element to remove.
- */
- def -=(elem: A): Unit
-
- /** Removes two or more elements from this collection.
- *
- * @param elem1 the first element to remove.
- * @param elem2 the second element to remove.
- * @param elems the remaining elements to remove.
- */
- def -=(elem1: A, elem2: A, elems: A*) {
- this -= elem1
- this -= elem2
- this --= elems.asInstanceOf[Iterable[A]] // !@!
- }
-
- /** Removes a number of elements provided by an iterator from this collection.
- *
- * @param iter the iterator.
- */
- def --=(iter: collection.Iterator[A]) { iter foreach -= }
-
- /** Removes a number of elements provided by an iterable object from this collection.
- *
- * @param iter the iterable object.
- */
- def --=(iter: collection.Iterable[A]) { iter foreach -= }
-}
-
-
-
-
diff --git a/src/library/scalax/collection/generic/Subtractable.scala b/src/library/scalax/collection/generic/Subtractable.scala
deleted file mode 100755
index 93fe2f8190..0000000000
--- a/src/library/scalax/collection/generic/Subtractable.scala
+++ /dev/null
@@ -1,64 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
-
-package scalax.collection.generic
-
-/** This class represents collections that can be reduced using a -= operator.
- *
- * @autor Martin Odersky
- * @owner Martin Odersky
- * @version 2.8
- */
-trait Subtractable[+C <: Subtractable[C, A], A] {
-
- protected def thisCC: C
-
- /** Removes a single element from this collection and returns
- * either the collection itself (if it is mutable), or a new collection
- * with the removed element.
- *
- * @param elem the element to remove.
- */
- def -(elem: A): C
-
- /** Removes two or more elements from this collection and returns
- * either the collection itself (if it is mutable), or a new collection
- * with the removed elements.
- *
- * @param elem1 the first element to remove.
- * @param elem2 the second element to remove.
- * @param elems the remaining elements to remove.
- */
- def -(elem1: A, elem2: A, elems: A*): C =
- thisCC - elem1 - elem2 -- elems.asInstanceOf[Iterable[A]] // !@!
-
- /** Removes a number of elements provided by an iterable object
- * via its <code>elements</code> method and returns
- * either the collection itself (if it is mutable), or a new collection
- * with the removed elements.
- *
- * @param iter the iterable object.
- */
- def --(iter: Iterable[A]): C = (thisCC /: iter) (_ - _)
-
- /** Removes a number of elements provided by an iterator
- * via its <code>elements</code> method and returns
- * either the collection itself (if it is mutable), or a new collection
- * with the removed elements.
- *
- * @param iter the iterator
- */
- def --(iter: Iterator[A]): C = (thisCC /: iter) (_ - _)
-
-}
-
-
-
-
diff --git a/src/library/scalax/collection/generic/VectorTemplate.scala b/src/library/scalax/collection/generic/VectorTemplate.scala
deleted file mode 100644
index d97fd03aa4..0000000000
--- a/src/library/scalax/collection/generic/VectorTemplate.scala
+++ /dev/null
@@ -1,266 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2006-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Vector.scala 15437 2008-06-25 16:22:45Z stepancheg $
-
-package scalax.collection.generic
-
-import Vector._
-
-/** Sequences that support O(1) element access and O(1) length computation.
- * @author Sean McDirmid
- * @author Martin Odersky
- * @version 2.8
- */
-trait VectorTemplate[+CC[/*+*/B] <: VectorTemplate[CC, B] with Vector[B], /*+*/A] extends SequenceTemplate[CC, A] {
-self =>
-
- // Overridden methods from IterableTemplate
-
- /** The iterator returned by the elements method
- */
- protected class Elements(start: Int, end: Int) extends scalax.collection.BufferedIterator[A] {
- var i = start
- def hasNext: Boolean = i < end
- def next: A =
- if (i < end) {
- val x = self(i)
- i += 1
- x
- } else Iterator.empty.next
- def head =
- if (i < end) self(i) else Iterator.empty.next
- /** drop is overridden to enable fast searching in the middle of random access sequences */
- override def drop(n: Int): Iterator[A] =
- if (n > 0) new Elements(start + n, end) else this
- /** is overridden to be symmetric to drop */
- override def take(n: Int): Iterator[A] =
- if (n < 0) Iterator.empty.buffered
- else if (start + n < end) new Elements(start, start + n)
- else this
- }
-
- override def elements: Iterator[A] = new Elements(0, length)
-
- override def isEmpty: Boolean = { length == 0 }
-
- override def foreach(f: A => Unit): Unit = {
- var i = 0
- val len = length
- while (i < len) { f(this(i)); i += 1 }
- }
-
- override def forall(p: A => Boolean): Boolean = prefixLength(p(_)) == length
- override def exists(p: A => Boolean): Boolean = prefixLength(!p(_)) != length
-
- override def find(p: A => Boolean): Option[A] = {
- val i = prefixLength(!p(_))
- if (i < length) Some(this(i)) else None
- }
-
- private def foldl[B](start: Int, z: B, op: (B, A) => B): B = {
- var i = start
- val len = length
- var result = z
- while (i < len) {
- result = op(result, this(i))
- i += 1
- }
- result
- }
-
- private def foldr[B](start: Int, len: Int, z: B, op: (A, B) => B): B =
- if (start == len) z
- else op(this(start), foldr(start + 1, len, z, op))
-
- override def foldLeft[B](z: B)(op: (B, A) => B): B = foldl(0, z, op)
- override def foldRight[B](z: B)(op: (A, B) => B): B = foldr(0, length, z, op)
- override def reduceLeft[B >: A](op: (B, A) => B): B =
- if (length > 0) foldl(0, this(0), op) else super.reduceLeft(op)
- override def reduceRight[B >: A](op: (A, B) => B): B =
- if (length > 0) foldr(0, length - 1, this(length - 1), op) else super.reduceRight(op)
-
- override def zip[B](that: Iterable[B]): CC[(A, B)] = that match {
- case that: Vector[_] =>
- var i = 0
- val len = this.length min that.length
- val b = this.newBuilder[(A, B)](len)
- while (i < len) {
- b += ((this(i), that(i).asInstanceOf[B]))
- i += 1
- }
- b.result
- case _ =>
- super.zip(that)
- }
-
- override def zipAll[B, A1 >: A, B1 >: B](that: Iterable[B], thisElem: A1, thatElem: B1): CC[(A1, B1)] = that match {
- case that: Vector[_] =>
- var i = 0
- val thisLen = this.length
- val thatLen = that.length
- val len = thisLen min thatLen
- val b = this.newBuilder[(A1, B1)](thisLen max thatLen)
- while (i < len) {
- b += ((this(i), that(i).asInstanceOf[B]))
- i += 1
- }
- while (i < this.length) {
- b += ((this(i), thatElem))
- i += 1
- }
- while (i < that.length) {
- b += ((this(i), thatElem.asInstanceOf[B]))
- i += 1
- }
- b.result
- case _ =>
- super.zipAll(that, thisElem, thatElem)
- }
-
- override def zipWithIndex: CC[(A, Int)] = {
- val len = length
- val b = newBuilder[(A, Int)](len)
- var i = 0
- while (i < len) {
- b += ((this(i), i))
- i += 1
- }
- b.result
- }
-
- override def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
- var i = 0
- var j = start
- val end = length min len min (xs.length - start)
- while (i < end) {
- xs(j) = this(i)
- i += 1
- j += 1
- }
- }
-
- // Overridden methods from OrderedIterableTemplate
-
- override def head: A = if (isEmpty) throw new NoSuchElementException else this(0)
-
- override def slice(from: Int, until: Int): CC[A] = {
- var i = from max 0
- val end = until min length
- val b = newBuilder[A](end - i)
- while (i < end) {
- b += this(i)
- i += 1
- }
- b.result
- }
-
- override def take(n: Int): CC[A] = slice(0, n)
- override def drop(n: Int): CC[A] = slice(n, length)
- override def takeRight(n: Int): CC[A] = slice(length - n, length)
- override def dropRight(n: Int): CC[A] = slice(0, length - n)
- override def splitAt(n: Int): (CC[A], CC[A]) = (take(n), drop(n))
- override def takeWhile(p: A => Boolean): CC[A] = take(prefixLength(p))
- override def dropWhile(p: A => Boolean): CC[A] = drop(prefixLength(p))
- override def span(p: A => Boolean): (CC[A], CC[A]) = splitAt(prefixLength(p))
- override def last: A = if (length > 0) this(length - 1) else super.last
- override def init: CC[A] = if (length > 0) slice(0, length - 1) else super.init
-
- override def sameElements[B >: A](that: OrderedIterable[B]): Boolean = that match {
- case that: Vector[_] =>
- val len = length
- len == that.length && {
- var i = 0
- while (i < len && this(i) == that(i)) i += 1
- i == len
- }
- case _ =>
- super.sameElements(that)
- }
-
- // Overridden methods from Sequence
-
- override def lengthCompare(len: Int): Int = length - len
-
- private def negLength(n: Int) = if (n == length) -1 else n
-
- override def indexWhere(p: A => Boolean, from: Int): Int =
- negLength(from + segmentLength(!p(_), from))
-
- override def lastIndexWhere(p: A => Boolean, end: Int): Int = {
- var i = end
- while (i >= 0 && !p(this(i))) i -= 1
- i
- }
-
- override def lastIndexOf[B >: A](elem: B, end: Int): Int = lastIndexWhere(elem ==, end)
-
- override def reverse: CC[A] = {
- val b = newBuilder[A](length)
- var i = length
- while (0 < i) {
- i -= 1
- b += this(i)
- }
- b.result
- }
-
- override def reversedElements: Iterator[A] = new Iterator[A] {
- var i = length
- def hasNext: Boolean = 0 < i
- def next: A =
- if (0 < i) {
- i -= 1
- self(i)
- } else Iterator.empty.next
- }
-
- override def startsWith[B](that: Sequence[B], offset: Int): Boolean = that match {
- case that: Vector[_] =>
- var i = offset
- var j = 0
- val thisLen = length
- val thatLen = that.length
- while (i < thisLen && j < thatLen && this(i) == that(j)) {
- i += 1
- j += 1
- }
- j == thatLen
- case _ =>
- var i = offset
- val thisLen = length
- val thatElems = that.elements
- while (i < thisLen && thatElems.hasNext && this(i) == thatElems.next) {
- i += 1
- }
- !thatElems.hasNext
- }
-
- override def endsWith[B](that: Sequence[B]): Boolean = that match {
- case that: Vector[_] =>
- val thisLen = length
- val thatLen = that.length
- var i = thisLen - 1
- var j = thatLen - 1
- while (i >= 0 && j >= 0 && this(i) == that(j)) {
- i -= 1
- j -= 1
- }
- j == 0
- case _ =>
- super.endsWith(that)
- }
-
- override def indexOf[B >: A](that: Sequence[B]): Int = {
- var i = 0
- val last = length - that.length
- while (i <= last && !startsWith(that, i)) i += 1
- negLength(i)
- }
-}
-
diff --git a/src/library/scalax/collection/generic/covartest/IterableFactory.scala b/src/library/scalax/collection/generic/covartest/IterableFactory.scala
deleted file mode 100755
index d12da89987..0000000000
--- a/src/library/scalax/collection/generic/covartest/IterableFactory.scala
+++ /dev/null
@@ -1,108 +0,0 @@
-package scalax.collection.generic.covartest
-
-trait IterableFactory[CC[A] <: Iterable[A]] {
-
- /** Create CC collection of specified elements */
- def apply[A](args: A*): CC[A]
-
- protected def newBuilder[A]: Builder[CC, A] =
- apply().newBuilder[A].asInstanceOf[Builder[CC, A]]
-
- /** Concatenate all the argument lists into a single list.
- *
- * @param xss the lists that are to be concatenated
- * @return the concatenation of all the lists
- */
- def concat[A](xss: CC[A]*): CC[A] = {
- val b = newBuilder[A]
- for (xs <- xss) b ++= xs
- b.result
- }
-
- /** An iterable that contains the same element a number of times
- * @param n The number of elements returned
- * @param elem The element returned each time
- */
- def fill[A](n: Int, elem: => A): CC[A] = {
- val b = newBuilder[A]
- var i = 0
- while (i < n) {
- b += elem
- i += 1
- }
- b.result
- }
-
- def fill[A](n1: Int, n2: Int, elem: => A): CC[CC[A]] =
- tabulate(n1)(_ => fill(n2, elem))
-
- def fill[A](n1: Int, n2: Int, n3: Int, elem: => A): CC[CC[CC[A]]] =
- tabulate(n1)(_ => fill(n2, n3, elem))
-
- def tabulate[A](n: Int)(f: Int => A): CC[A] = {
- val b = newBuilder[A]
- var i = 0
- while (i < n) {
- b += f(i)
- i += 1
- }
- b.result
- }
-
- def tabulate[A](n1: Int, n2: Int)(f: (Int, Int) => A): CC[CC[A]] =
- tabulate(n1)(i1 => tabulate(n2)(i2 => f(i1, i2)))
-
- def tabulate[A](n1: Int, n2: Int, n3: Int)(f: (Int, Int, Int) => A): CC[CC[CC[A]]] =
- tabulate(n1)(i1 => tabulate(n2)(i2 => tabulate(n3)(i3 => f(i1, i2, i3))))
-// todo: go up to 5(?)
-
- /** Create a sequence of increasing integers in a range.
- *
- * @param from the start value of the sequence
- * @param end the end value of the sequence
- * @return the sorted list of all from `from` (inclusive)
- * up to, but exclusding, `end`.
- */
- def range[A](start: Int, end: Int): CC[Int] = range(start, end, 1)
-
- /** Create a sequence of increasing integers in a range.
- *
- * @param from the start value of the sequence
- * @param end the end value of the sequence
- * @param step the increment value of successive elements
- * @return a list of values <code>from + n * step</code> for
- * increasing n. If `step > 0` the sequence terminates
- * with the largest value less than `end`. If `step < 0`
- * the sequence terminates with the smallest value greater than `end`.
- * If `step == 0`, the sequence gors on infinitely (in that
- * case the `range` operation might not terminate.
- */
- def range(start: Int, end: Int, step: Int): CC[Int] = {
- val b = newBuilder[Int]
- var i = start
- while ((step <= 0 || i < end) && (step >= 0 || i > end)) {
- b += i
- i += step
- }
- b.result
- }
-
- /** Create a sequence by repeatedly applying a given function to a start value.
- *
- * @param start the start value of the sequence
- * @param len the length of the sequence
- * @param f the function that's repeatedly applied
- * @return the sequence with elements <code>(start, f(start), f(f(start)), ..., f<sup>len-1</sup>(start))</code>
- */
- def iterate(start: Int, len: Int)(f: Int => Int): CC[Int] = {
- val b = newBuilder[Int]
- var acc = start
- var i = 0
- while (i < len) {
- b += acc
- acc = f(acc)
- i += 1
- }
- b.result
- }
-}
diff --git a/src/library/scalax/collection/generic/covartest/IterableForwarder.scala b/src/library/scalax/collection/generic/covartest/IterableForwarder.scala
deleted file mode 100755
index 58290cfc68..0000000000
--- a/src/library/scalax/collection/generic/covartest/IterableForwarder.scala
+++ /dev/null
@@ -1,59 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: IterableProxy.scala 15458 2008-06-28 20:23:22Z stepancheg $
-
-
-package scalax.collection.generic.covartest
-
-import collection.mutable.Buffer
-import collection.immutable.{List, Stream}
-
-/** This trait implements a forwarder for iterable objects. It forwards
- * all calls to a different iterable object, except for
- *
- * - toString, hashCode, equals, stringPrefix
- * - newBuilder, view
- * - all calls creating a new iterable objetc of the same kind
- *
- * The above methods are forwarded by subclass IterableProxy
- *
- * @author Martin Odersky
- * @version 2.8
- */
-trait IterableForwarder[+A] extends Iterable[A] {
-
- /** The iterable object to which calls are forwarded */
- protected def underlying: Iterable[A]
-
- // Iterable delegates
- // Iterable methods could be printed by cat IterableTemplate.scala | sed -n '/trait Iterable/,$ p' | egrep '^ (override )?def'
-
- override def elements = underlying.elements
- override def isEmpty = underlying.isEmpty
- override def hasDefiniteSize = underlying.hasDefiniteSize
- override def foreach(f: A => Unit) = underlying.foreach(f)
- override def forall(p: A => Boolean): Boolean = underlying.forall(p)
- override def exists(p: A => Boolean): Boolean = underlying.exists(p)
- override def count(p: A => Boolean): Int = underlying.count(p)
- override def find(p: A => Boolean): Option[A] = underlying.find(p)
- override def foldLeft[B](z: B)(op: (B, A) => B): B = underlying.foldLeft(z)(op)
- override def foldRight[B](z: B)(op: (A, B) => B): B = underlying.foldRight(z)(op)
- override def reduceLeft[B >: A](op: (B, A) => B): B = underlying.reduceLeft(op)
- override def reduceRight[B >: A](op: (A, B) => B): B = underlying.reduceRight(op)
- override def copyToBuffer[B >: A](dest: Buffer[B]) = underlying.copyToBuffer(dest)
- override def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) = underlying.copyToArray(xs, start, len)
- override def toArray[B >: A]: Array[B] = underlying.toArray
- override def toList: List[A] = underlying.toList
- override def toSequence: Sequence[A] = underlying.toSequence
- override def toStream: Stream[A] = underlying.toStream
- override def mkString(start: String, sep: String, end: String): String = underlying.mkString(start, sep, end)
- override def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder = underlying.addString(b, start, sep, end)
-
- override def head: A = underlying.head
-}
diff --git a/src/library/scalax/collection/generic/covartest/IterableTemplate.scala b/src/library/scalax/collection/generic/covartest/IterableTemplate.scala
deleted file mode 100755
index 791d698a75..0000000000
--- a/src/library/scalax/collection/generic/covartest/IterableTemplate.scala
+++ /dev/null
@@ -1,677 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
-
-
-package scalax.collection.generic.covartest
-
-import scalax.collection.mutable.{Buffer, ArrayBuffer, ListBuffer}
-import scalax.collection.immutable.{List, Nil, ::, Stream}
-import util.control.Breaks._
-import Iterable._
-
-/** Collection classes mixing in this class provide a method
- * <code>elements</code> which returns an iterator over all the
- * elements contained in the collection.
- *
- * @note If a collection has a known <code>size</code>, it should also sub-type <code>Collection</code>.
- * Only potentially unbounded collections should directly sub-class <code>Iterable</code>.
- * @author Matthias Zenger
- * @author Martin Odersky
- * @version 2.8
- */
-trait IterableTemplate[+CC[+B] <: IterableTemplate[CC, B] with Iterable[B], +A] { self/*: CC[A]*/ =>
-
- /** The template itself seen as an instance of `CC[A]`.
- * @note: It would be logical to have a self type `CC[A]` instead, then we would not need
- * this method. Unfortunately, tyis runs afoul some pecularities in Scala's member resolution
- * algorithm: If the self type is a CC, then Iterable is one of its supertypes. Iterable
- * defines a number of concrete methods such as newBuilder which are abstract here.
- * The newBuilder method in Iterable[A] has type Builder[Iterable, A]. Because Scala
- * prefers concrete over abstract members, it is this newBuilder which is chosen, instead of
- * the abstract newBuilder in class IterableTemplate of type Builder[CC, A].
- * Even for concrete methods we have a problem because the last mixin in the parents of CC is
- * Iterable, not IterableTemplate. So resolution picks the version in Iterable, which returns
- * again an Iterable, not a CC, as would be required.
- * These problems would be avoided if Scala computed the type of a member as the glb of the types
- * all members in the class and its superclasses types.
- * I think overall this would be a better design.
- */
- protected[this] def thisCC: CC[A] = this.asInstanceOf[CC[A]]
-
- /** Creates a new iterator over all elements contained in this
- * object.
- *
- * @return the new iterator
- */
- def elements: Iterator[A]
-
- /** Create a new builder for this IterableType
- */
- def newBuilder[B]: Builder[CC, B]
-
- /** Create a new builder for this IterableType
- * with a hint what that its size should be size `sizeHint`
- */
- def newBuilder[B](sizeHint: Int): Builder[CC, B] = newBuilder[B]
-
- /** Is this collection empty? */
- def isEmpty: Boolean = !elements.hasNext
-
- /** returns true iff this collection has a bound size.
- * Many APIs in this trait will not work on collections of
- * unbound sizes.
- */
- def hasDefiniteSize = true
-
- /** Create a new iterable of type CC which contains all elements of this iterable
- * followed by all elements of Iterable `that'
- */
- def ++[B >: A](that: Iterable[B]): CC[B] = {
- val b: Builder[CC, B] = (this: IterableTemplate[CC, A]).newBuilder[B]
- b ++= thisCC
- b ++= that
- b.result
- }
-
- /** Create a new iterable of type CC which contains all elements of this iterable
- * followed by all elements of Iterator `that'
- */
- def ++[B >: A](that: Iterator[B]): CC[B] = {
- val b = newBuilder[B]
- b ++= thisCC
- b ++= that
- b.result
- }
-
- /** Returns the iterable resulting from applying the given function
- * <code>f</code> to each element of this iterable.
- *
- * @param f function to apply to each element.
- * @return <code>f(a<sub>0</sub>), ..., f(a<sub>n</sub>)</code> if this
- * iterable is <code>a<sub>0</sub>, ..., a<sub>n</sub></code>.
- */
- def map[B](f: A => B): CC[B] = {
- val b = newBuilder[B]
- for (x <- this) b += f(x)
- b.result
- }
-
- /** Applies the given function <code>f</code> to each element of
- * this iterable, then concatenates the results.
- *
- * @param f the function to apply on each element.
- * @return <code>f(a<sub>0</sub>) ::: ... ::: f(a<sub>n</sub>)</code> if
- * this iterable is <code>a<sub>0</sub>, ..., a<sub>n</sub></code>.
- */
- def flatMap[B](f: A => Iterable[B]): CC[B] = {
- val b = newBuilder[B]
- for (x <- this) b ++= f(x)
- b.result
- }
-
- /** Returns all the elements of this iterable that satisfy the
- * predicate <code>p</code>. The order of the elements is preserved.
- * @param p the predicate used to filter the iterable.
- * @return the elements of this iterable satisfying <code>p</code>.
- */
- def filter(p: A => Boolean): CC[A] = {
- val b = newBuilder[A]
- for (x <- this)
- if (p(x)) b += x
- b.result
- }
-
- /** Removes all elements of the iterable which satisfy the predicate
- * <code>p</code>. This is like <code>filter</code> with the
- * predicate inversed.
- *
- * @param p the predicate to use to test elements
- * @return the iterable without all elements which satisfy <code>p</code>
- */
- def remove(p: A => Boolean): CC[A] = filter(!p(_))
-
- /** Partitions this iterable in two iterables according to a predicate.
- *
- * @param p the predicate on which to partition
- * @return a pair of iterables: the iterable that satisfies the predicate
- * <code>p</code> and the iterable that does not.
- * The relative order of the elements in the resulting iterables
- * is the same as in the original iterable.
- */
- def partition(p: A => Boolean): (CC[A], CC[A]) = {
- val l, r = newBuilder[A]
- for (x <- this) (if (p(x)) l else r) += x
- (l.result, r.result)
- }
-
- /** Apply a function <code>f</code> to all elements of this
- * iterable object.
- *
- * @note Will not terminate for infinite-sized collections.
- * @param f a function that is applied to every element.
- * Note this function underlies the implementation of most other bulk operations.
- * It should be overridden in concrete collectionc classes with efficient implementations.
- */
- def foreach(f: A => Unit): Unit = elements.foreach(f)
-
- /** Return true iff the given predicate `p` yields true for all elements
- * of this iterable.
- *
- * @note May not terminate for infinite-sized collections.
- * @param p the predicate
- */
- def forall(p: A => Boolean): Boolean = {
- var result = true
- breakable {
- for (x <- this)
- if (!p(x)) { result = false; break }
- }
- result
- }
-
- /** Return true iff there is an element in this iterable for which the
- * given predicate `p` yields true.
- *
- * @note May not terminate for infinite-sized collections.
- * @param p the predicate
- */
- def exists(p: A => Boolean): Boolean = {
- var result = false
- breakable {
- for (x <- this)
- if (p(x)) { result = true; break }
- }
- result
- }
-
- /** Count the number of elements in the iterable which satisfy a predicate.
- *
- * @param p the predicate for which to count
- * @return the number of elements satisfying the predicate <code>p</code>.
- */
- def count(p: A => Boolean): Int = {
- var cnt = 0
- for (x <- this) {
- if (p(x)) cnt += 1
- }
- cnt
- }
-
- /** Find and return the first element of the iterable object satisfying a
- * predicate, if any.
- *
- * @note may not terminate for infinite-sized collections.
- * @note Might return different results for different runs, unless this iterable is ordered, or
- * the operator is associative and commutative.
- * @param p the predicate
- * @return an option containing the first element in the iterable object
- * satisfying <code>p</code>, or <code>None</code> if none exists.
- */
- def find(p: A => Boolean): Option[A] = {
- var result: Option[A] = None
- breakable {
- for (x <- this)
- if (p(x)) { result = Some(x); break }
- }
- result
- }
-
- /** Combines the elements of this iterable object together using the binary
- * function <code>f</code>, from left to right, and starting with
- * the value <code>z</code>.
- *
- * @note Will not terminate for infinite-sized collections.
- * @note Might return different results for different runs, unless this iterable is ordered, or
- * the operator is associative and commutative.
- * @return <code>f(... (f(f(z, a<sub>0</sub>), a<sub>1</sub>) ...),
- * a<sub>n</sub>)</code> if the iterable is
- * <code>[a<sub>0</sub>, a<sub>1</sub>, ..., a<sub>n</sub>]</code>.
- */
- def foldLeft[B](z: B)(op: (B, A) => B): B = {
- var result = z
- for (x <- this)
- result = op(result, x)
- result
- }
-
- /** Combines the elements of this iterable together using the binary
- * function <code>f</code>, from right to left, and starting with
- * the value <code>z</code>.
- *
- * @note Will not terminate for infinite-sized collections.
- * @note Might return different results for different runs, unless this iterable is ordered, or
- * the operator is associative and commutative.
- * @return <code>f(a<sub>0</sub>, f(a<sub>1</sub>, f(..., f(a<sub>n</sub>, z)...)))</code>
- * if the iterable is <code>[a<sub>0</sub>, a1, ..., a<sub>n</sub>]</code>.
- */
- def foldRight[B](z: B)(op: (A, B) => B): B = elements.foldRight(z)(op)
-
- /** Similar to <code>foldLeft</code> but can be used as
- * an operator with the order of iterable and zero arguments reversed.
- * That is, <code>z /: xs</code> is the same as <code>xs foldLeft z</code>
- * @note Will not terminate for infinite-sized collections.
- * @note Might return different results for different runs, unless this iterable is ordered, or
- * the operator is associative and commutative.
- */
- def /: [B](z: B)(op: (B, A) => B): B = foldLeft(z)(op)
-
- /** An alias for <code>foldRight</code>.
- * That is, <code>xs :\ z</code> is the same as <code>xs foldRight z</code>
- * @note Will not terminate for infinite-sized collections.
- * @note Might return different results for different runs, unless this iterable is ordered, or
- * the operator is associative and commutative.
- */
- def :\ [B](z: B)(op: (A, B) => B): B = foldRight(z)(op)
-
- /** Combines the elements of this iterable object together using the binary
- * operator <code>op</code>, from left to right
- * @note Will not terminate for infinite-sized collections.
- * @note Might return different results for different runs, unless this iterable is ordered, or
- * the operator is associative and commutative.
- * @param op The operator to apply
- * @return <code>op(... op(a<sub>0</sub>,a<sub>1</sub>), ..., a<sub>n</sub>)</code>
- if the iterable object has elements
- * <code>a<sub>0</sub>, a<sub>1</sub>, ..., a<sub>n</sub></code>.
- * @throws Predef.UnsupportedOperationException if the iterable object is empty.
- */
- def reduceLeft[B >: A](op: (B, A) => B): B = {
- if (isEmpty) throw new UnsupportedOperationException("empty.reduceLeft")
- var result: B = elements.next
- var first = true
- for (x <- this)
- if (first) first = false
- else result = op(result, x)
- result
- }
-
- /** Combines the elements of this iterable object together using the binary
- * operator <code>op</code>, from right to left
- * @note Will not terminate for infinite-sized collections.
- * @note Might return different results for different runs, unless this iterable is ordered, or
- * the operator is associative and commutative.
- * @param op The operator to apply
- *
- * @return <code>a<sub>0</sub> op (... op (a<sub>n-1</sub> op a<sub>n</sub>)...)</code>
- * if the iterable object has elements <code>a<sub>0</sub>, a<sub>1</sub>, ...,
- * a<sub>n</sub></code>.
- *
- * @throws Predef.UnsupportedOperationException if the iterator is empty.
- */
- def reduceRight[B >: A](op: (A, B) => B): B =
- elements.reduceRight(op)
-
- /** Returns an iterable formed from this iterable and the specified iterable
- * `other` by associating each element of the former with
- * the element at the same position in the latter.
- * If one of the two iterables is longer than the other, its remaining elements are ignored.
- */
- def zip[B](that: Iterable[B]): CC[(A, B)] = {
- val these = this.elements
- val those = that.elements
- val b = this.newBuilder[(A, B)]
- while (these.hasNext && those.hasNext)
- b += ((these.next, those.next))
- b.result
- }
-
- /** Returns a iterable formed from this iterable and the specified iterable
- * <code>that</code> by associating each element of the former with
- * the element at the same position in the latter.
- *
- * @param that iterable <code>that</code> may have a different length
- * as the self iterable.
- * @param thisElem element <code>thisElem</code> is used to fill up the
- * resulting iterable if the self iterable is shorter than
- * <code>that</code>
-b * @param thatElem element <code>thatElem</code> is used to fill up the
- * resulting iterable if <code>that</code> is shorter than
- * the self iterable
- * @return <code>Iterable((a<sub>0</sub>,b<sub>0</sub>), ...,
- * (a<sub>n</sub>,b<sub>n</sub>), (elem,b<sub>n+1</sub>),
- * ..., {elem,b<sub>m</sub>})</code>
- * when <code>[a<sub>0</sub>, ..., a<sub>n</sub>] zip
- * [b<sub>0</sub>, ..., b<sub>m</sub>]</code> is
- * invoked where <code>m &gt; n</code>.
- */
- def zipAll[B, A1 >: A, B1 >: B](that: Iterable[B], thisElem: A1, thatElem: B1): CC[(A1, B1)] = {
- val these = this.elements
- val those = that.elements
- val b = newBuilder[(A1, B1)]
- while (these.hasNext && those.hasNext)
- b += ((these.next, those.next))
- while (these.hasNext)
- b += ((these.next, thatElem))
- while (those.hasNext)
- b += ((thisElem, those.next))
- b.result
- }
-
- /** Zips this iterable with its indices. `s.zipWithIndex` is equivalent to
- * `s zip s.indices`, but is usually more efficient.
- */
- def zipWithIndex: CC[(A, Int)] = {
- val b = newBuilder[(A, Int)]
- var i = 0
- for (x <- this) {
- b += ((x, i))
- i +=1
- }
- b.result
- }
-
- /** Copy all elements to a given buffer
- * @note Will not terminate for infinite-sized collections.
- * @param dest The buffer to which elements are copied
- */
- def copyToBuffer[B >: A](dest: Buffer[B]) {
- for (x <- this) dest += x
- }
-
- /** Fills the given array <code>xs</code> with at most `len` elements of
- * this iterable starting at position `start`.
- * Copying will stop oce either the end of the current iterable is reached or
- * `len` elements have been copied.
- *
- * @note Will not terminate for infinite-sized collections.
- * @param xs the array to fill.
- * @param start starting index.
- * @param len number of elements to copy
- * @pre the array must be large enough to hold all elements.
- */
- def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
- var i = start
- val end = (start + len) min xs.length
- for (x <- this) {
- if (i < end) {
- xs(i) = x
- i += 1
- }
- }
- }
-
- /** Fills the given array <code>xs</code> with the elements of
- * this iterable starting at position <code>start</code>
- * until either the end of the current iterable or the end of array `xs` is reached.
- *
- * @note Will not terminate for infinite-sized collections.
- * @param xs the array to fill.
- * @param start starting index.
- * @pre the array must be large enough to hold all elements.
- */
- def copyToArray[B >: A](xs: Array[B], start: Int) {
- copyToArray(xs, start, xs.length - start)
- }
-
- /** Converts this collection to a fresh Array elements.
- * @note Will not terminate for infinite-sized collections.
- */
- def toArray[B >: A]: Array[B] = {
- var size = 0
- for (x <- this) size += 1
- val result = new Array[B](size)
- copyToArray(result, 0)
- result
- }
-
- /**
- * Create a fresh list with all the elements of this iterable object.
- * @note Will not terminate for infinite-sized collections.
- */
- def toList: List[A] = (new ListBuffer[A] ++ thisCC).toList
-
- /**
- * Returns a sequence containing all of the elements in this iterable object.
- * @note Will not terminate for infinite-sized collections.
- */
- def toSequence: Sequence[A] = toList
-
- /** @deprecated use toSequence instead
- */
- @deprecated def toSeq: Sequence[A] = toSequence
-
- /**
- * Create a stream which contains all the elements of this iterable object.
- * @note consider using <code>projection</code> for lazy behavior.
- */
- def toStream: Stream[A] = elements.toStream
-
- /** Sort the iterable according to the comparison function
- * <code>&lt;(e1: a, e2: a) =&gt; Boolean</code>,
- * which should be true iff <code>e1</code> is smaller than
- * <code>e2</code>.
- * The sort is stable. That is elements that are equal wrt `lt` appear in the
- * same order in the sorted iterable as in the original.
- *
- * @param lt the comparison function
- * @return a iterable sorted according to the comparison function
- * <code>&lt;(e1: a, e2: a) =&gt; Boolean</code>.
- * @ex <pre>
- * List("Steve", "Tom", "John", "Bob")
- * .sort((e1, e2) => (e1 compareTo e2) &lt; 0) =
- * List("Bob", "John", "Steve", "Tom")</pre>
- * !!!
- def sortWith(lt : (A,A) => Boolean): CC[A] = {
- val arr = toArray
- Array.sortWith(arr, lt)
- val b = newBuilder[A]
- for (x <- arr) b += x
- b.result
- }
- */
-
- /** Returns a string representation of this iterable object. The resulting string
- * begins with the string <code>start</code> and is finished by the string
- * <code>end</code>. Inside, the string representations of elements (w.r.t.
- * the method <code>toString()</code>) are separated by the string
- * <code>sep</code>.
- *
- * @ex <code>List(1, 2, 3).mkString("(", "; ", ")") = "(1; 2; 3)"</code>
- * @param start starting string.
- * @param sep separator string.
- * @param end ending string.
- * @return a string representation of this iterable object.
- */
- def mkString(start: String, sep: String, end: String): String =
- addString(new StringBuilder(), start, sep, end).toString
-
- /** Returns a string representation of this iterable object. The string
- * representations of elements (w.r.t. the method <code>toString()</code>)
- * are separated by the string <code>sep</code>.
- *
- * @param sep separator string.
- * @return a string representation of this iterable object.
- */
- def mkString(sep: String): String =
- addString(new StringBuilder(), sep).toString
-
- /** Converts a collection into a flat <code>String</code> by each element's toString method.
- */
- def mkString =
- addString(new StringBuilder()).toString
-
- /** Write all elements of this iterable into given string builder.
- * The written text begins with the string <code>start</code> and is finished by the string
- * <code>end</code>. Inside, the string representations of elements (w.r.t.
- * the method <code>toString()</code>) are separated by the string
- * <code>sep</code>.
- */
- def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder = {
- b append start
- var first = true
- for (x <- this) {
- if (first) first = false
- else b append sep
- b append x
- }
- b append end
- }
-
- /** Write all elements of this string into given string builder.
- * The string representations of elements (w.r.t. the method <code>toString()</code>)
- * are separated by the string <code>sep</code>.
- */
- def addString(b: StringBuilder, sep: String): StringBuilder = addString(b, "", sep, "")
-
- /** Write all elements of this string into given string builder without using
- * any separator between consecutive elements.
- */
- def addString(b: StringBuilder): StringBuilder = addString(b, "")
-
- /**
- * returns a projection that can be used to call non-strict <code>filter</code>,
- * <code>map</code>, and <code>flatMap</code> methods that build projections
- * of the collection.
- def projection : Iterable.Projection[A] = new Iterable.Projection[A] {
- def elements = Iterable.this.elements
- override def force = Iterable.this
- }
- */
-
- override def toString = mkString(stringPrefix + "(", ", ", ")")
-
- /** Defines the prefix of this object's <code>toString</code> representation.
- */
- def stringPrefix : String = {
- var string = this.getClass.getName
- val idx1 = string.lastIndexOf('.' : Int)
- if (idx1 != -1) string = string.substring(idx1 + 1)
- val idx2 = string.indexOf('$')
- if (idx2 != -1) string = string.substring(0, idx2)
- string
- }
-
- /** Creates a view of this iterable @see IterableView
- */
- def view: IterableView[CC, A] = new IterableView[CC, A] { // !!! Martin: We should maybe infer the type parameters here?
- val origin = thisCC
- val elements: Iterator[A] = self.elements
- }
-
-// The following methods return non-deterministic results, unless this iterable is an OrderedIterable
-
- /** The first element of this iterable.
- *
- * @note Might return different results for different runs, unless this iterable is ordered
- * @throws Predef.NoSuchElementException if the iterable is empty.
- */
- def head: A = if (isEmpty) throw new NoSuchElementException else elements.next
-
- /** @deprecated use head instead */
- @deprecated def first: A = head
-
- /** Returns as an option the first element of this iterable
- * or <code>None</code> if iterable is empty.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def headOption: Option[A] = if (isEmpty) None else Some(head)
-
- /** @deprecated use headOption instead
- * <code>None</code> if iterable is empty.
- */
- @deprecated def firstOption: Option[A] = headOption
-
- /** An iterable consisting of all elements of this iterable
- * except the first one.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def tail: CC[A] = drop(1)
-
- /** Return an iterable consisting only of the first <code>n</code>
- * elements of this iterable, or else the whole iterable, if it has less
- * than <code>n</code> elements.
- *
- * @param n the number of elements to take
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def take(n: Int): CC[A] = {
- val b = newBuilder[A]
- var i = 0
- breakable {
- for (x <- this) {
- b += x
- i += 1
- if (i == n) break
- }
- }
- b.result
- }
-
- /** Returns this iterable without its <code>n</code> first elements
- * If this iterable has less than <code>n</code> elements, the empty
- * iterable is returned.
- *
- * @param n the number of elements to drop
- * @return the new iterable
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def drop(n: Int): CC[A] = {
- val b = newBuilder[A]
- var i = 0
- for (x <- this) {
- if (i >= n) b += x
- i += 1
- }
- b.result
- }
-
- /** A sub-iterable starting at index `from`
- * and extending up to (but not including) index `until`.
- *
- * @note c.slice(from, to) is equivalent to (but possibly more efficient than)
- * c.drop(from).take(to - from)
- *
- * @param from The index of the first element of the returned subsequence
- * @param until The index of the element following the returned subsequence
- * @throws IndexOutOfBoundsException if <code>from &lt; 0</code>
- * or <code>length &lt; from + len<code>
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def slice(from: Int, until: Int): CC[A] = {
- val b = newBuilder[A]
- var i = 0
- breakable {
- for (x <- this) {
- if (i >= from) b += x
- i += 1
- if (i == until) break
- }
- }
- b.result
- }
-
- /** Split the iterable at a given point and return the two parts thus
- * created.
- *
- * @param n the position at which to split
- * @return a pair of iterables composed of the first <code>n</code>
- * elements, and the other elements.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def splitAt(n: Int): (CC[A], CC[A]) = {
- val l, r = newBuilder[A]
- var i = 0
- for (x <- this)
- (if (i < n) l else r) += x
- (l.result, r.result)
- }
-
- /** A sub-iterable view starting at index `from`
- * and extending up to (but not including) index `until`.
- *
- * @param from The index of the first element of the slice
- * @param until The index of the element following the slice
- * @note The difference between `view` and `slice` is that `view` produces
- * a view of the current iterable, whereas `slice` produces a new iterable.
- *
- * @note Might return different results for different runs, unless this iterable is ordered
- * @note view(from, to) is equivalent to view.slice(from, to)
- */
- def view(from: Int, until: Int): IterableView[CC, A] = view.slice(from, until)
-}
diff --git a/src/library/scalax/collection/generic/covartest/IterableView.scala b/src/library/scalax/collection/generic/covartest/IterableView.scala
deleted file mode 100755
index 43a1f68dc0..0000000000
--- a/src/library/scalax/collection/generic/covartest/IterableView.scala
+++ /dev/null
@@ -1,112 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
-
-package scalax.collection.generic.covartest
-
-/** A non-strict projection of an iterable.
- * @author Sean McDirmid
- * @author Martin Odersky
- * @note this should really be a virtual class of SequenceFactory
- */
-trait IterableView[+UC[+B] <: Iterable[B], +A] extends Iterable[A] { self =>
-
- val origin: Iterable[_]
- def elements: Iterator[A]
-
- val underlying: Iterable[_] = origin match {
- case v: IterableView[t, _] => v.underlying
- case _ => origin
- }
-
- protected def isDelay = elements eq underlying.elements
-
- private[this] var forced: UC[A] = _
- private[this] var wasForced = false
-
- def force: UC[A] = {
- if (!wasForced) {
- forced = {
- val b = underlying.newBuilder[A]
- for (x <- elements)
- b += x
- b.result
- }.asInstanceOf[UC[A]]
- wasForced = true
- }
- forced
- }
-
- def newBuilder[A] = underlying.newBuilder[A]
-
- /** Builds a new view object. This method needs to be overridden in subclasses
- * which refine in IterableView type
- */
- protected def newView[B](elems: Iterator[B]) = new IterableView[UC, B] {
- val origin = if (self.isDelay) self.origin else self
- val elements = elems
- }
-
- /** Non-strict variant of @see IterableLike.++ */
- override def ++[B >: A](that: Iterator[B]): IterableView[UC, B] = newView(elements ++ that)
-
- /** Non-strict variant of @see IterableLike.++ */
- override def ++[B >: A](that: Iterable[B]): IterableView[UC, B] = newView(elements ++ that.elements)
-
- /** Non-strict variant of @see IterableLike.map */
- override def map[B](f: A => B): IterableView[UC, B] = newView(elements map f)
-
- /** Non-strict variant of @see IterableLike.flatMap */
- override def flatMap[B](f: A => Iterable[B]): IterableView[UC, B] = newView(elements flatMap (f(_).elements))
-
- /** Non-strict variant of @see IterableLike.filter */
- override def filter(p: A => Boolean): IterableView[UC, A] = newView(elements filter p)
-
- /** Non-strict variant of @see IterableLike.partition */
- override def partition(p: A => Boolean): (IterableView[UC, A], IterableView[UC, A]) = {
- val (li, ri) = elements partition p
- (newView(li), newView(ri))
- }
-
- /** Non-strict variant of @see IterableLike.zip */
- override def zip[B](other: Iterable[B]): IterableView[UC, (A, B)] = newView(elements zip other.elements)
-
- /** Non-strict variant of @see IterableLike.zipWithIndex */
- override def zipWithIndex: IterableView[UC, (A, Int)] = newView(elements.zipWithIndex)
-
- /* Non-strict variant of @see IterableLike.zipAll
- * This is not enabled because it can't be specialized in VectorView:
- * VectorView is not covariant, yet must maintain updatability. Impossible to do this
- * with this type signature.
- override def zipAll[B, A1 >: A, B1 >: B](that: Iterable[B], thisElem: A1, thatElem: B1): IterableView[UC, (A1, B1)] =
- newView(elements zipAll (that.elements, thisElem, thatElem))
- */
-
- /** Non-strict variant of @see Iterable.take */
- override def take(n: Int): IterableView[UC, A] = newView(elements take n)
-
- /** Non-strict variant of @see Iterable.drop */
- override def drop(n: Int): IterableView[UC, A] = newView(elements drop n)
-
- /** Non-strict variant of @see Iterable.splitAt */
- override def splitAt(n: Int): (IterableView[UC, A], IterableView[UC, A]) = (take(n), drop(n))
-
- /** Non-strict variant of @see Iterable.slice */
- override def slice(from: Int, until: Int): IterableView[UC, A] = newView(elements slice (from, until))
-
- /** The projection resulting from the concatenation of this projection with the <code>rest</code> projection.
- * @param rest The projection that gets appended to this projection
- * @deprecated Use ++ instead
- */
- @deprecated def append[B >: A](rest : => Iterable[B]): IterableView[UC, B] = this ++ rest.elements
-
- override def stringPrefix = origin.stringPrefix+"V"
-
-
-}
diff --git a/src/library/scalax/collection/generic/covartest/OrderedIterableForwarder.scala b/src/library/scalax/collection/generic/covartest/OrderedIterableForwarder.scala
deleted file mode 100755
index 3a33dc6694..0000000000
--- a/src/library/scalax/collection/generic/covartest/OrderedIterableForwarder.scala
+++ /dev/null
@@ -1,37 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: IterableProxy.scala 15458 2008-06-28 20:23:22Z stepancheg $
-
-
-package scalax.collection.generic.covartest
-
-/** This trait implements a forwarder for iterable objects. It forwards
- * all calls to a different iterable object, except for
- *
- * - toString, hashCode, equals, stringPrefix
- * - newBuilder, view
- * - all calls creating a new iterable object of the same kind
- *
- * The above methods are forwarded by subclass IterableProxy
- *
- * @author Martin Odersky
- * @version 2.8
- */
-trait OrderedIterableForwarder[+A] extends OrderedIterable[A] with IterableForwarder[A] {
-
- /** The iterable object to which calls are forwarded */
- protected def underlying: OrderedIterable[A]
-
- // Iterable delegates
- // Iterable methods could be printed by cat IterableTemplate.scala | sed -n '/trait Iterable/,$ p' | egrep '^ (override )?def'
-
- override def last: A = underlying.last
- override def lastOption: Option[A] = underlying.lastOption
- override def sameElements[B >: A](that: OrderedIterable[B]): Boolean = underlying.sameElements(that)
-}
diff --git a/src/library/scalax/collection/generic/covartest/OrderedIterableTemplate.scala b/src/library/scalax/collection/generic/covartest/OrderedIterableTemplate.scala
deleted file mode 100755
index f3c509887c..0000000000
--- a/src/library/scalax/collection/generic/covartest/OrderedIterableTemplate.scala
+++ /dev/null
@@ -1,161 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
-
-
-package scalax.collection.generic.covartest
-
-import OrderedIterable._
-
-import util.control.Breaks._
-
-/** Ordered iterables are iterables where the `elements` method always returns elements in the same
- * order (namely the order in which elements were appended to the iterable). In particular, one has
- * for every two ordered iterables `xs` and `ys`:
- *
- * `(xs ++ ys).elements = xs.elements ++ ys.elements
- */
-trait OrderedIterableTemplate[+CC[+B] <: OrderedIterableTemplate[CC, B] with OrderedIterable[B], +A]
- extends IterableTemplate[CC, A] {
-
- /** The last element of this iterable.
- *
- * @throws Predef.NoSuchElementException if the iterable is empty.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def last: A = {
- var lst = head
- for (x <- this)
- lst = x
- lst
- }
-
- /** Returns as an option the last element of this iterable or
- * <code>None</code> if iterable is empty.
- *
- * @return the last element as an option.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def lastOption: Option[A] = if (isEmpty) None else Some(last)
-
- /** An iterable consisting of all elements of this iterable except the last one.
- * @throws Predef.UnsupportedOperationException if the stream is empty.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def init: CC[A] = {
- if (isEmpty) throw new UnsupportedOperationException("empty.init")
- var lst = head
- val b = newBuilder[A]
- for (x <- this) {
- b += lst
- lst = x
- }
- b.result
- }
-
- /** Returns the rightmost <code>n</code> elements from this iterable.
- *
- * @param n the number of elements to take
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def takeRight(n: Int): CC[A] = {
- val b = newBuilder[A]
- val lead = elements drop n
- var go = false
- for (x <- this) {
- if (go) b += x
- else if (lead.hasNext) lead.next
- else go = true
- }
- b.result
- }
-
- /** Returns the iterable wihtout its rightmost <code>n</code> elements.
- *
- * @param n the number of elements to take
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def dropRight(n: Int): CC[A] = {
- val b = newBuilder[A]
- val lead = elements drop n
- breakable {
- for (x <- this) {
- if (!lead.hasNext) break
- lead.next
- b += x
- }
- }
- b.result
- }
-
- /** Returns the longest prefix of this iterable whose elements satisfy
- * the predicate <code>p</code>.
- *
- * @param p the test predicate.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def takeWhile(p: A => Boolean): CC[A] = {
- val b = newBuilder[A]
- breakable {
- for (x <- this) {
- if (!p(x)) break
- b += x
- }
- }
- b.result
- }
-
- /** Returns the longest suffix of this iterable whose first element
- * does not satisfy the predicate <code>p</code>.
- *
- * @param p the test predicate.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def dropWhile(p: A => Boolean): CC[A] = {
- val b = newBuilder[A]
- var go = false
- for (x <- this) {
- if (go) b += x
- else if (!p(x)) { go = true; b += x }
- }
- b.result
- }
-
- /** Returns a pair consisting of the longest prefix of the iterable whose
- * elements all satisfy the given predicate, and the rest of the iterable.
- *
- * @param p the test predicate
- * @return a pair consisting of the longest prefix of the iterable whose
- * elements all satisfy <code>p</code>, and the rest of the iterable.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def span(p: A => Boolean): (CC[A], CC[A]) = {
- val l, r = newBuilder[A]
- var toLeft = true
- for (x <- this) {
- toLeft = toLeft && p(x)
- (if (toLeft) l else r) += x
- }
- (l.result, r.result)
- }
-
- /** Checks if the other iterable object contains the same elements as this one.
- *
- * @note will not terminate for infinite-sized iterables.
- * @param that the other iterable
- * @return true, iff both iterables contain the same elements.
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- def sameElements[B >: A](that: OrderedIterable[B]): Boolean = {
- val these = this.elements
- val those = that.elements
- while (these.hasNext && those.hasNext && these.next() == those.next()) {}
- !these.hasNext && !those.hasNext
- }
-}
diff --git a/src/library/scalax/collection/generic/covartest/SequenceFactory.scala b/src/library/scalax/collection/generic/covartest/SequenceFactory.scala
deleted file mode 100755
index eb6c093bff..0000000000
--- a/src/library/scalax/collection/generic/covartest/SequenceFactory.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-package scalax.collection.generic.covartest
-
-trait SequenceFactory[CC[A] <: Sequence[A]] extends IterableFactory[CC] {
-
- /** This method is called in a pattern match { case Sequence(...) => }.
- *
- * @param x the selector value
- * @return sequence wrapped in an option, if this is a Sequence, otherwise none
- */
- def unapplySeq[A](x: CC[A]): Some[CC[A]] = Some(x)
-}
diff --git a/src/library/scalax/collection/generic/covartest/SequenceForwarder.scala b/src/library/scalax/collection/generic/covartest/SequenceForwarder.scala
deleted file mode 100644
index 47c512545d..0000000000
--- a/src/library/scalax/collection/generic/covartest/SequenceForwarder.scala
+++ /dev/null
@@ -1,50 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: SeqProxy.scala 15458 2008-06-28 20:23:22Z stepancheg $
-
-
-package scalax.collection.generic.covartest
-
-/** This class implements a forwarder for sequences. It forwards
- * all calls to a different sequence object except for
- *
- * - toString, hashCode, equals, stringPrefix
- * - newBuilder, view, toSequence
- * - all calls creating a new iterable objetc of the same kind
- *
- * The above methods are forwarded by subclass SequenceProxy
- *
- * @author Martin Odersky
- * @version 2.8
- */
-trait SequenceForwarder[+A] extends Sequence[A] with OrderedIterableForwarder[A] {
-
- protected override def underlying: Sequence[A]
-
- // PartialFunction delegates
-
- override def apply(i: Int): A = underlying.apply(i)
- override def isDefinedAt(x: Int): Boolean = underlying.isDefinedAt(x)
-
- // Sequence delegates
- // Sequence methods could be printed by cat SequenceTemplate.scala | sed -n '/trait Seq/,$ p' | egrep '^ (override )?def'
-
- override def length: Int = underlying.length
- override def lengthCompare(l: Int) = underlying lengthCompare l
- override def segmentLength(p: A => Boolean, from: Int): Int = underlying.segmentLength(p, from)
- override def prefixLength(p: A => Boolean) = underlying.prefixLength(p)
- override def indexWhere(p: A => Boolean, from: Int): Int = underlying.indexWhere(p, from)
- override def indexOf[B >: A](elem: B, from: Int): Int = underlying.indexOf(elem, from)
- override def reversedElements: Iterator[A] = underlying.reversedElements
- override def startsWith[B](that: Sequence[B], offset: Int): Boolean = underlying.startsWith(that, offset)
- override def endsWith[B](that: Sequence[B]): Boolean = underlying.endsWith(that)
- override def indexOf[B >: A](that: Sequence[B]): Int = underlying.indexOf(that)
- override def contains(elem: Any): Boolean = underlying.contains(elem)
- override def indices: Range = underlying.indices
-}
diff --git a/src/library/scalax/collection/generic/covartest/SequenceTemplate.scala b/src/library/scalax/collection/generic/covartest/SequenceTemplate.scala
deleted file mode 100755
index eab7904af8..0000000000
--- a/src/library/scalax/collection/generic/covartest/SequenceTemplate.scala
+++ /dev/null
@@ -1,382 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Sequence.scala 16092 2008-09-12 10:37:06Z nielsen $
-
-
-package scalax.collection.generic.covartest
-
-import util.control.Breaks._
-import scalax.collection.immutable.{List, Nil, ::}
-
-import Sequence._
-
-trait SequenceTemplate[+CC[+B] <: SequenceTemplate[CC, B] with Sequence[B], +A] extends PartialFunction[Int, A] with OrderedIterableTemplate[CC, A] {
-self /*: CC[A]*/ =>
-
- /** Returns the length of the sequence.
- *
- * @return the sequence length.
- */
- def length: Int
-
- /** Result of comparing <code>length</code> with operand <code>len</code>.
- * returns <code>x</code> where
- * <code>x &lt; 0</code> iff <code>this.length &lt; len</code>
- * <code>x == 0</code> iff <code>this.length == len</code>
- * <code>x &gt; 0</code> iff <code>this.length &gt; len</code>.
- *
- * The method as implemented here does not call length directly; its running time
- * is O(length min len) instead of O(length). The method should be overwritten
- * if computing length is cheap.
- */
- def lengthCompare(len: Int): Int = {
- var i = 0
- breakable {
- for (_ <- this) {
- i += 1
- if (i > len) break
- }
- }
- i - len
- }
-
- /** Should always be <code>length</code> */
- def size = length
-
- /** Is this partial function defined for the index <code>x</code>?
- */
- def isDefinedAt(x: Int): Boolean = (x >= 0) && (x < length)
-
- /** Returns index of the first element satisying a predicate, or -1, if none exists.
- *
- * @note may not terminate for infinite-sized collections.
- * @param p the predicate
- */
- def indexWhere(p: A => Boolean): Int = indexWhere(p, 0)
-
- /** Returns length of longest segment starting from a start index `from`
- * such that every element of the segment satisfies predicate `p`.
- * @note may not terminate for infinite-sized collections.
- * @param p the predicate
- * @param from the start index
- */
- def segmentLength(p: A => Boolean, from: Int): Int = {
- var result = 0
- var i = from
- breakable {
- for (x <- this) {
- if (i >= from && !p(x)) { result = i - from; break }
- else i += 1
- }
- }
- result
- }
-
- /** Returns length of longest prefix of this seqence
- * such that every element of the prefix satisfies predicate `p`.
- * @note may not terminate for infinite-sized collections.
- * @param p the predicate
- */
- def prefixLength(p: A => Boolean) = segmentLength(p, 0)
-
- /** Returns index of the first element starting from a start index
- * satisying a predicate, or -1, if none exists.
- *
- * @note may not terminate for infinite-sized collections.
- * @param p the predicate
- * @param from the start index
- */
- def indexWhere(p: A => Boolean, from: Int): Int = {
- var result = -1
- var i = from
- breakable {
- for (x <- this) {
- if (i >= from && p(x)) { result = i; break }
- else i += 1
- }
- }
- result
- }
-
- /** Returns index of the first element satisying a predicate, or -1.
- *
- * @deprecated Use `indexWhere` instead
- */
- @deprecated def findIndexOf(p: A => Boolean): Int = indexWhere(p)
-
- /** Returns the index of the first occurence of the specified
- * object in this iterable object.
- *
- * @note may not terminate for infinite-sized collections.
- * @param elem element to search for.
- * @return the index in this sequence of the first occurence of the
- * specified element, or -1 if the sequence does not contain
- * this element.
- */
- def indexOf[B >: A](elem: B): Int = indexOf(elem, 0)
-
- /** Returns the index of the first occurence of the specified
- * object in this iterable object, starting from a start index, or
- * -1, if none exists.
- *
- * @note may not terminate for infinite-sized collections.
- * @param elem element to search for.
- */
- def indexOf[B >: A](elem: B, from: Int): Int = indexWhere(elem ==, from)
-
- /** Returns the index of the last occurence of the specified element
- * in this sequence, or -1 if the sequence does not contain this element.
- *
- * @param elem element to search for.
- * @return the index in this sequence of the last occurence of the
- * specified element, or -1 if the sequence does not contain
- * this element.
- */
- def lastIndexOf[B >: A](elem: B): Int = lastIndexOf(elem, length - 1)
-
- /** Returns the index of the last
- * occurence of the specified element in this sequence
- * before or at a given end index,
- * or -1 if the sequence does not contain this element.
- *
- * @param elem element to search for.
- * @param end the end index
- */
- def lastIndexOf[B >: A](elem: B, end: Int): Int = {
- var i = end
- val it = reversedElements
- while (it.hasNext && it.next != elem) i -= 1
- i
- }
-
- /** Returns index of the last element satisying a predicate, or -1, if none exists.
- *
- * @param p the predicate
- * @return the index of the last element satisfying <code>p</code>,
- * or -1 if such an element does not exist
- */
- def lastIndexWhere(p: A => Boolean): Int = lastIndexWhere(p, length - 1)
-
- /** Returns index of the last element not exceeding a given end index
- * and satisying a predicate, or -1 if none exists.
- *
- * @param end the end index
- * @param p the predicate
- */
- def lastIndexWhere(p: A => Boolean, end: Int): Int = {
- var i = end
- val it = reversedElements
- while (it.hasNext && (i > end || !p(it.next))) i -= 1
- i
- }
-
- /** A sequence of type <code>C</code> consisting of all elements of
- * this sequence in reverse order.
- * @note the operation is implemented by building a new sequence
- * from <code>this(length - 1), ..., this(0)</code>
- * If random access is inefficient for the given sequence implementation,
- * this operation should be overridden.
- */
- def reverse: CC[A] = {
- var xs: List[A] = List()
- for (x <- this)
- xs = x :: xs
- val b = newBuilder[A]
- for (x <- xs)
- b += x
- b.result
- }
-
- /** The elements of this sequence in reversed order
- */
- def reversedElements: Iterator[A] = reverse.elements
-
- /**
- * Checks whether the argument sequence is contained at the
- * specified index within the receiver object.
- *
- * If the both the receiver object, <code>this</code> and
- * the argument, <code>that</code> are infinite sequences
- * this method may not terminate.
- *
- * @return true if <code>that</code> is contained in
- * <code>this</code>, at the specified index, otherwise false
- *
- * @see String.startsWith
- */
- def startsWith[B](that: Sequence[B], offset: Int): Boolean = {
- val i = elements.drop(offset)
- val j = that.elements
- while (j.hasNext && i.hasNext && i.next == j.next) {}
- !j.hasNext
- }
-
- /**
- * Check whether the receiver object starts with the argument sequence.
- *
- * @return true if <code>that</code> is a prefix of <code>this</code>,
- * otherwise false
- *
- * @see Sequence.startsWith
- */
- def startsWith[B](that: Sequence[B]): Boolean = startsWith(that, 0)
-
- /** @return true if this sequence end with that sequence
- * @see String.endsWith
- */
- def endsWith[B](that: Sequence[B]): Boolean = {
- val i = this.elements.drop(length - that.length)
- val j = that.elements
- while (i.hasNext && j.hasNext && i.next == j.next) ()
- !j.hasNext
- }
-
- /** @return -1 if <code>that</code> not contained in this, otherwise the
- * index where <code>that</code> is contained
- * @see String.indexOf
- */
- def indexOf[B >: A](that: Sequence[B]): Int = {
- var i = 0
- var s: Sequence[A] = thisCC
- while (!s.isEmpty && !(s startsWith that)) {
- i += 1
- s = s drop 1
- }
- if (!s.isEmpty || that.isEmpty) i else -1
- }
-
- /** Tests if the given value <code>elem</code> is a member of this
- * sequence.
- *
- * @param elem element whose membership has to be tested.
- * @return <code>true</code> iff there is an element of this sequence
- * which is equal (w.r.t. <code>==</code>) to <code>elem</code>.
- */
- def contains(elem: Any): Boolean = exists (_ == elem)
-
- /** Computes the union of this sequence and the given sequence
- * <code>that</code>.
- *
- * @param that the sequence of elements to add to the sequence.
- * @return an sequence containing the elements of this
- * sequence and those of the given sequence <code>that</code>
- * which are not contained in this sequence.
- */
- def union[B >: A](that: Sequence[B]): CC[B] = this ++ (that diff thisCC)
-
- /** Computes the difference between this sequence and the given sequence
- * <code>that</code>.
- *
- * @param that the sequence of elements to remove from this sequence.
- * @return this sequence without the elements of the given sequence
- * <code>that</code>.
- */
- def diff[B >: A](that: Sequence[B]): CC[A] = this remove (that contains _)
-
- /** Computes the intersection between this sequence and the given sequence
- * <code>that</code>.
- *
- * @param that the sequence to intersect.
- * @return the sequence of elements contained both in this sequence and
- * in the given sequence <code>that</code>.
- */
- def intersect[B >: A](that: Sequence[B]): CC[A] = this filter(that contains _)
-
- /** Builds a new sequence from this sequence in which any duplicates (wrt to ==) removed.
- * Among duplicate elements, only the first one is retained in the result sequence
- */
- def removeDuplicates: CC[A] = {
- val b = newBuilder[A]
- var seen = Set[A]()
- for (x <- this) {
- if (!(seen contains x)) {
- b += x
- seen += x
- }
- }
- b.result
- }
-
- /** Returns a sequence of given length containing the elements of this sequence followed by zero
- * or more occurrences of given elements. If this sequence is already at least as long as given
- * length, it is returned directly. Otherwise, a new sequence is created consisting of the elements
- * of this sequence followed by enough occurrences of the given elements to reach the given length.
- */
- def padTo[B >: A](len: Int, elem: B): CC[B] = {
- var diff = len - length
- val b = newBuilder[B] //!!! drop [B] and get surprising results!
- b ++= thisCC
- while (diff > 0) {
- b += elem
- diff -=1
- }
- b.result
- }
-
- /**
- * Overridden for efficiency.
- *
- * @return the sequence itself
- */
- override def toSequence: Sequence[A] = thisCC
-
- def indices: Range = 0 until length
-
- /** Creates a view of this iterable @see OrderedIterable.View
- */
- override def view: SequenceView[CC, A] = new SequenceView[CC, A] { // !!! Martin: We should maybe infer the type parameters here?
- val origin: Sequence[_] = thisCC
- val elements: Iterator[A] = self.elements
- val length: Int = self.length
- def apply(idx: Int): A = self.apply(idx)
- }
-
- /** A sub-sequence view starting at index `from`
- * and extending up to (but not including) index `until`.
- *
- * @param from The index of the first element of the slice
- * @param until The index of the element following the slice
- * @note The difference between `view` and `slice` is that `view` produces
- * a view of the current sequence, whereas `slice` produces a new sequence.
- *
- * @note view(from, to) is equivalent to view.slice(from, to)
- */
- override def view(from: Int, until: Int): SequenceView[CC, A] = view.slice(from, until)
-
- /** Returns index of the last element satisying a predicate, or -1.
- * @deprecated use `lastIndexWhere` instead
- */
- @deprecated def findLastIndexOf(p: A => Boolean): Int = lastIndexWhere(p)
-
- /** A sub-sequence starting at index <code>from</code>
- * and extending up to the length of the current sequence
- *
- * @param from The index of the first element of the slice
- * @throws IndexOutOfBoundsException if <code>from &lt; 0</code>
- * @deprecated use <code>drop</code> instead
- */
- @deprecated def slice(from: Int): Sequence[A] = slice(from, length)
-
- /** @deprecated Should be replaced by
- *
- * <code>(s1, s2) forall { case (x, y) => f(x, y) }</code>
- */
- @deprecated def equalsWith[B](that: Sequence[B])(f: (A,B) => Boolean): Boolean = {
- val i = this.elements
- val j = that.elements
- while (i.hasNext && j.hasNext && f(i.next, j.next)) ()
- !i.hasNext && !j.hasNext
- }
-
- /** Is <code>that</code> a slice in this?
- * @deprecated Should be repaced by <code>indexOf(that) != -1</code>
- */
- @deprecated def containsSlice[B](that: Sequence[B]): Boolean = indexOf(that) != -1
-
-}
diff --git a/src/library/scalax/collection/generic/covartest/SequenceView.scala b/src/library/scalax/collection/generic/covartest/SequenceView.scala
deleted file mode 100755
index e99ffaf652..0000000000
--- a/src/library/scalax/collection/generic/covartest/SequenceView.scala
+++ /dev/null
@@ -1,131 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Sequence.scala 16092 2008-09-12 10:37:06Z nielsen $
-
-
-package scalax.collection.generic.covartest
-
-import util.control.Breaks._
-import annotation.unchecked.uncheckedVariance
-
-import Sequence._
-
-/** A non-strict projection of an iterable.
- * @author Sean McDirmid
- * @author Martin Odersky
- * @note this should really be a virtual class of SequenceFactory
- */
-trait SequenceView[+UC[+B] <: Sequence[B], +A] extends IterableView[UC, A] with Sequence[A] {
-self =>
-
- /** refined from Iterable.View */
- val origin: Sequence[_]
-
- override def newBuilder[A] = underlying.newBuilder[A].asInstanceOf[Builder[Sequence, A]]
-
- trait Transformed[+B] extends SequenceView[UC, B] {
- val origin = self
- protected def asCC = asInstanceOf[SequenceView[UC, B]]
- }
-
- class Appended[+B >: A](that: Sequence[B]) extends Transformed[B] {
- override def elements: Iterator[B] = self.elements ++ that.elements
- override def length: Int = self.length + that.length
- override def apply(idx: Int): B = {
- val ll = self.length
- if (idx < ll) self.apply(idx) else that.apply(idx - ll)
- }
- override def stringPrefix = self.stringPrefix + "A"
- }
-
- class Sliced(from: Int, to: Int) extends Transformed[A] {
- override def elements: Iterator[A] = self.elements slice (from, to)
- override lazy val length: Int = ((to min self.length) - (from max 0) min 0)
- override def apply(idx: Int): A =
- if (idx >= 0 && idx < length) self.apply(idx + from)
- else throw new IndexOutOfBoundsException(idx.toString)
- override def stringPrefix = self.stringPrefix + "S"
- override def slice(from1: Int, to1: Int) =
- new self.Sliced(from + (from1 min length max 0) , to + (to1 min length max 0)).asInstanceOf[SequenceView[UC, A]]
- }
-
- class Mapped[+B](f: A => B) extends Transformed[B] {
- override def elements: Iterator[B] = self.elements map f
- override def length: Int = self.length
- override def apply(idx: Int): B = f(self.apply(idx))
- override def stringPrefix = self.stringPrefix + "M"
- }
-
- class Reversed extends Transformed[A] {
- override def elements: Iterator[A] = self.reversedElements
- override def length: Int = self.length
- override def apply(idx: Int): A = self.apply(length - 1 - idx)
- override def stringPrefix = super.stringPrefix+"R"
- }
-
- class Patched[+B >: A](from: Int, patch: Sequence[B], replaced: Int) extends Transformed[B] {
- val plen = patch.length
- override def elements: Iterator[B] = self.elements patch (from, patch, replaced)
- override def length: Int = self.length + plen - replaced
- override def apply(idx: Int): B =
- if (idx < from) self.apply(idx)
- else if (idx < from + plen) patch.apply(idx - from)
- else self.apply(idx - plen + replaced)
- override def stringPrefix = super.stringPrefix+"P"
- }
-
- class Zipped[+B](that: Sequence[B]) extends Transformed[(A, B)] {
- override def elements: Iterator[(A, B)] = self.elements zip that.elements
- override def length = self.length min that.length
- override def apply(idx: Int): (A, B) = (self.apply(idx), that.apply(idx))
- override def stringPrefix = super.stringPrefix+"Z"
- }
-
- override def ++[B >: A](that: Iterable[B]): SequenceView[UC, B] =
- new Appended[B](that.toSequence).asCC
- override def ++[B >: A](that: Iterator[B]): SequenceView[UC, B] =
- new Appended[B](that.toSequence).asCC
- override def map[B](f: A => B): SequenceView[UC, B] =
- new Mapped(f).asCC
- override def reverse: SequenceView[UC, A] =
- (new Reversed).asCC
- def patch[B >: A](from: Int, patch: Sequence[B], replaced: Int): SequenceView[UC, B] =
- if (0 <= from && from < length) new Patched(from, patch, replaced).asCC
- else throw new IndexOutOfBoundsException(from.toString)
- override def padTo[B >: A](len: Int, elem: B): SequenceView[UC, B] =
- patch(length, fill((len - length) max 0)(elem), 0)
- override def zip[B](that: Iterable[B]): SequenceView[UC, (A, B)] =
- new Zipped(that.toSequence).asCC
- override def zipWithIndex: SequenceView[UC, (A, Int)] =
- zip((0 until length).asInstanceOf[Null]) // !@!
- /*
- override def zipAll[B, A1 >: A, B1 >: B](that: Iterable[B], thisElem: A1, thatElem: B1): SequenceView[UC, (A1, B1)] = {
- val that1 = that.toSequence
- self.padTo(that1.length, thisElem) zip that1.padTo(this.length, thatElem)//.asInstanceOf[SequenceView[UC, (A1, B1)]]
- }*/
- override def take(n: Int): SequenceView[UC, A] =
- slice(0, n)
- override def drop(n: Int): SequenceView[UC, A] =
- slice(n, Math.MAX_INT)
- override def splitAt(n: Int): (SequenceView[UC, A], SequenceView[UC, A]) = (take(n), drop(n))
- override def slice(from: Int, until: Int): SequenceView[UC, A] =
- new Sliced(from, until).asCC
- override def takeWhile(p: A => Boolean): SequenceView[UC, A] =
- take(prefixLength(p))
- override def dropWhile(p: A => Boolean): SequenceView[UC, A] =
- drop(prefixLength(p))
- override def span(p: A => Boolean): (SequenceView[UC, A], SequenceView[UC, A]) = {
- val n = prefixLength(p)
- (take(n), drop(n))
- }
-
- // missing here because we can't do anything about them, so we fall back to default construction
- // if an IterableView via newView: flatMap, filter, partition
-}
-
diff --git a/src/library/scalax/collection/generic/covartest/VectorTemplate.scala b/src/library/scalax/collection/generic/covartest/VectorTemplate.scala
deleted file mode 100644
index 8c28077ea3..0000000000
--- a/src/library/scalax/collection/generic/covartest/VectorTemplate.scala
+++ /dev/null
@@ -1,264 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2006-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Vector.scala 15437 2008-06-25 16:22:45Z stepancheg $
-
-package scalax.collection.generic.covartest
-
-import Vector._
-
-/** Sequences that support O(1) element access and O(1) length computation.
- * @author Sean McDirmid
- * @author Martin Odersky
- * @version 2.8
- */
-trait VectorTemplate[+CC[+B] <: VectorTemplate[CC, B] with Vector[B], +A] extends SequenceTemplate[CC, A] {
-self =>
-
- // Overridden methods from IterableTemplate
-
- /** The iterator returned by the elements method
- */
- protected class Elements(start: Int, end: Int) extends scalax.collection.BufferedIterator[A] {
- var i = start
- def hasNext: Boolean = i < end
- def next: A =
- if (i < end) {
- val x = self(i)
- i += 1
- x
- } else Iterator.empty.next
- def head =
- if (i < end) self(i) else Iterator.empty.next
- /** drop is overridden to enable fast searching in the middle of random access sequences */
- override def drop(n: Int): Iterator[A] =
- if (n > 0) new Elements(start + n, end) else this
- /** is overridden to be symmetric to drop */
- override def take(n: Int): Iterator[A] =
- if (n < 0) Iterator.empty.buffered
- else if (start + n < end) new Elements(start, start + n)
- else this
- }
-
- override def elements: Iterator[A] = new Elements(0, length)
-
- override def isEmpty: Boolean = { length == 0 }
-
- override def foreach(f: A => Unit): Unit = {
- var i = 0
- val len = length
- while (i < len) { f(this(i)); i += 1 }
- }
-
- override def forall(p: A => Boolean): Boolean = prefixLength(p(_)) == length
- override def exists(p: A => Boolean): Boolean = prefixLength(!p(_)) != length
-
- override def find(p: A => Boolean): Option[A] = {
- val i = prefixLength(!p(_))
- if (i < length) Some(this(i)) else None
- }
-
- private def foldl[B](start: Int, z: B, op: (B, A) => B): B = {
- var i = start
- val len = length
- var result = z
- while (i < len) {
- result = op(result, this(i))
- i += 1
- }
- result
- }
-
- private def foldr[B](start: Int, len: Int, z: B, op: (A, B) => B): B =
- if (start == len) z
- else op(this(start), foldr(start + 1, len, z, op))
-
- override def foldLeft[B](z: B)(op: (B, A) => B): B = foldl(0, z, op)
- override def foldRight[B](z: B)(op: (A, B) => B): B = foldr(0, length, z, op)
- override def reduceLeft[B >: A](op: (B, A) => B): B =
- if (length > 0) foldl(0, this(0), op) else super.reduceLeft(op)
- override def reduceRight[B >: A](op: (A, B) => B): B =
- if (length > 0) foldr(0, length - 1, this(length - 1), op) else super.reduceRight(op)
-
- override def zip[B](that: Iterable[B]): CC[(A, B)] = that match {
- case that: Vector[_] =>
- var i = 0
- val len = this.length min that.length
- val b = this.newBuilder[(A, B)]
- while (i < len) {
- b += ((this(i), that(i).asInstanceOf[B]))
- i += 1
- }
- b.result
- case _ =>
- super.zip(that)
- }
-
- override def zipAll[B, A1 >: A, B1 >: B](that: Iterable[B], thisElem: A1, thatElem: B1): CC[(A1, B1)] = that match {
- case that: Vector[_] =>
- var i = 0
- val len = this.length min that.length
- val b = this.newBuilder[(A1, B1)]
- while (i < len) {
- b += ((this(i), that(i).asInstanceOf[B]))
- i += 1
- }
- while (i < this.length) {
- b += ((this(i), thatElem))
- i += 1
- }
- while (i < that.length) {
- b += ((this(i), thatElem.asInstanceOf[B]))
- i += 1
- }
- b.result
- case _ =>
- super.zipAll(that, thisElem, thatElem)
- }
-
- override def zipWithIndex: CC[(A, Int)] = {
- val b = newBuilder[(A, Int)]
- var i = 0
- val len = length
- while (i < len) {
- b += ((this(i), i))
- i += 1
- }
- b.result
- }
-
- override def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
- var i = 0
- var j = start
- val end = length min len min (xs.length - start)
- while (i < end) {
- xs(j) = this(i)
- i += 1
- j += 1
- }
- }
-
- // Overridden methods from OrderedIterableTemplate
-
- override def head: A = if (isEmpty) throw new NoSuchElementException else this(0)
-
- override def slice(from: Int, until: Int): CC[A] = {
- val b = newBuilder[A]
- var i = from max 0
- val end = until min length
- while (i < end) {
- b += this(i)
- i += 1
- }
- b.result
- }
-
- override def take(n: Int): CC[A] = slice(0, n)
- override def drop(n: Int): CC[A] = slice(n, length)
- override def takeRight(n: Int): CC[A] = slice(length - n, length)
- override def dropRight(n: Int): CC[A] = slice(0, length - n)
- override def splitAt(n: Int): (CC[A], CC[A]) = (take(n), drop(n))
- override def takeWhile(p: A => Boolean): CC[A] = take(prefixLength(p))
- override def dropWhile(p: A => Boolean): CC[A] = drop(prefixLength(p))
- override def span(p: A => Boolean): (CC[A], CC[A]) = splitAt(prefixLength(p))
- override def last: A = if (length > 0) this(length - 1) else super.last
- override def init: CC[A] = if (length > 0) slice(0, length - 1) else super.init
-
- override def sameElements[B >: A](that: OrderedIterable[B]): Boolean = that match {
- case that: Vector[_] =>
- val len = length
- len == that.length && {
- var i = 0
- while (i < len && this(i) == that(i)) i += 1
- i == len
- }
- case _ =>
- super.sameElements(that)
- }
-
- // Overridden methods from Sequence
-
- override def lengthCompare(len: Int): Int = length - len
-
- private def negLength(n: Int) = if (n == length) -1 else n
-
- override def indexWhere(p: A => Boolean, from: Int): Int =
- negLength(from + segmentLength(!p(_), from))
-
- override def lastIndexWhere(p: A => Boolean, end: Int): Int = {
- var i = end
- while (i >= 0 && !p(this(i))) i -= 1
- i
- }
-
- override def lastIndexOf[B >: A](elem: B, end: Int): Int = lastIndexWhere(elem ==, end)
-
- override def reverse: CC[A] = {
- val b = newBuilder[A]
- var i = length
- while (0 < i) {
- i -= 1
- b += this(i)
- }
- b.result
- }
-
- override def reversedElements: Iterator[A] = new Iterator[A] {
- var i = length
- def hasNext: Boolean = 0 < i
- def next: A =
- if (0 < i) {
- i -= 1
- self(i)
- } else Iterator.empty.next
- }
-
- override def startsWith[B](that: Sequence[B], offset: Int): Boolean = that match {
- case that: Vector[_] =>
- var i = offset
- var j = 0
- val thisLen = length
- val thatLen = that.length
- while (i < thisLen && j < thatLen && this(i) == that(j)) {
- i += 1
- j += 1
- }
- j == thatLen
- case _ =>
- var i = offset
- val thisLen = length
- val thatElems = that.elements
- while (i < thisLen && thatElems.hasNext && this(i) == thatElems.next) {
- i += 1
- }
- !thatElems.hasNext
- }
-
- override def endsWith[B](that: Sequence[B]): Boolean = that match {
- case that: Vector[_] =>
- val thisLen = length
- val thatLen = that.length
- var i = thisLen - 1
- var j = thatLen - 1
- while (i >= 0 && j >= 0 && this(i) == that(j)) {
- i -= 1
- j -= 1
- }
- j == 0
- case _ =>
- super.endsWith(that)
- }
-
- override def indexOf[B >: A](that: Sequence[B]): Int = {
- var i = 0
- val last = length - that.length
- while (i <= last && !startsWith(that, i)) i += 1
- negLength(i)
- }
-}
-
diff --git a/src/library/scalax/collection/immutable/DefaultSet.scala b/src/library/scalax/collection/immutable/DefaultSet.scala
deleted file mode 100644
index a9ce3fb3df..0000000000
--- a/src/library/scalax/collection/immutable/DefaultSet.scala
+++ /dev/null
@@ -1,45 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: HashSet.scala 16884 2009-01-09 16:52:09Z cunei $
-
-package scalax.collection.immutable
-
-import generic.SetTemplate
-
-/** A default implementation of immutable sets.
- * This is currently implemented as a proxy for an immutable HashSet,
- * except that its builder returns specialized representations EmptySet,Set1,..., Set4
- * for sets of size <= 4.
- */
-class DefaultSet[A] private (hset: HashSet[A])
- extends Set[A]
- with SetTemplate[Set, A] {
-
- def this() = this(new HashSet[A])
-
- def contains(elem: A): Boolean = hset.contains(elem)
-
- def + (elem: A): Set[A] = hset + elem
-
- /** Keeps underlying HashSet representation, but switches back to EmptySet if
- * result does not contain any elements
- */
- def - (elem: A): Set[A] = {
- val hset1 = hset - elem
- if (hset1.isEmpty) new EmptySet[A]
- else new DefaultSet(hset)
- }
-
- def size: Int = hset.size
-
- def elements: Iterator[A] = hset.elements
-
- override def foreach(f: A => Unit): Unit = hset.foreach(f)
-}
-
diff --git a/src/library/scalax/collection/immutable/EmptyMap.scala b/src/library/scalax/collection/immutable/EmptyMap.scala
deleted file mode 100644
index c04d988f08..0000000000
--- a/src/library/scalax/collection/immutable/EmptyMap.scala
+++ /dev/null
@@ -1,34 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: EmptyMap.scala 16893 2009-01-13 13:09:22Z cunei $
-
-
-
-package scalax.collection.immutable
-
-/** This class implements empty immutable maps
- * @author Martin Oderskty
- * @version 1.0, 019/01/2007
- */
-@serializable
-class EmptyMap[A, B] extends Map[A, B] {
-
- def size: Int = 0
-
- def get(key: A): Option[B] = None
-
- def elements: Iterator[(A, B)] = Iterator.empty
-
- def update (key: A, value: B): Map[A, B] = new Map1(key, value)
-
- def - (key: A): Map[A, B] = this
-}
-
-
-
diff --git a/src/library/scalax/collection/immutable/EmptySet.scala b/src/library/scalax/collection/immutable/EmptySet.scala
deleted file mode 100755
index 32c4915a49..0000000000
--- a/src/library/scalax/collection/immutable/EmptySet.scala
+++ /dev/null
@@ -1,38 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: EmptySet.scala 16893 2009-01-13 13:09:22Z cunei $
-
-
-
-package scalax.collection.immutable
-
-import collection.generic.Builder
-
-/** This class implements empty immutable sets
- * @author Martin Oderskty
- * @version 1.0, 019/01/2007
- */
-@serializable
-class EmptySet[A] extends Set[A] {
-
- def size: Int = 0
-
- def contains(elem: A): Boolean = false
-
- def + (elem: A): Set[A] = new Set1(elem)
-
- def - (elem: A): Set[A] = this
-
- def elements: Iterator[A] = Iterator.empty
-
- override def foreach(f: A => Unit): Unit = {}
-}
-
-
-
diff --git a/src/library/scalax/collection/immutable/HashMap.scala b/src/library/scalax/collection/immutable/HashMap.scala
deleted file mode 100644
index 8aaa0239c1..0000000000
--- a/src/library/scalax/collection/immutable/HashMap.scala
+++ /dev/null
@@ -1,164 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: HashMap.scala 16893 2009-01-13 13:09:22Z cunei $
-
-
-package scalax.collection.immutable
-
-import generic._
-
-/** The canonical factory methods for <a href="HashMap.html">immutable HashMap's</a>.
- *
- * @author Martin Odersky
- * @version 2.0, 19/01/2007
- */
-object HashMap extends MapFactory[HashMap] {
-
- /** The empty map of this type */
- def empty[A, B] = new HashMap[A, B]
-
-}
-
-/** This class implements immutable maps using a hash table.
- * It is optimized for sequential accesses where the last updated table is accessed most often.
- * It supports with reasonable efficiency accesses to previous versions of the table by keeping
- * a change log that's regularly compacted.
- * It needs to synchronize most methods, so it is less suitable for highly concurrent accesses.
- *
- * @author Martin Odersky
- * @version 2.0, 19/01/2007
- */
-@serializable
-class HashMap[A, B] extends Map[A,B]
- with MapTemplate[A, B, HashMap]
- with collection.mutable.HashTable[A] {
-
- type Entry = collection.mutable.DefaultEntry[A, Any]
-
- protected var later: HashMap[A, B] = null
- protected var oldKey: A = _
- protected var oldValue: Option[B] = _
- protected var deltaSize: Int = _
-
- override def empty[B] = HashMap.empty[A, B]
-
- def get(key: A): Option[B] = synchronized {
- var m = this
- var cnt = 0
- while (m.later != null) {
- if (key == m.oldKey) return m.oldValue
- cnt += 1
- m = m.later
- }
- if (cnt > logLimit) makeCopy(m)
- val e = m.findEntry(key)
- if (e == null) None
- else Some(getValue(e))
- }
-
- def update(key: A, value: B): HashMap[A, B] = synchronized {
- makeCopyIfUpdated()
- val e = findEntry(key)
- if (e == null) {
- markUpdated(key, None, 1)
- later.addEntry(new Entry(key, value))
- } else {
- markUpdated(key, Some(getValue(e)), 0)
- e.value = value
- }
- later
- }
-
- def - (key: A): HashMap[A, B] = synchronized {
- makeCopyIfUpdated()
- val e = findEntry(key)
- if (e == null) this
- else {
- markUpdated(key, Some(getValue(e)), -1)
- later removeEntry key
- later
- }
- }
-
- override def size: Int = synchronized {
- var m = this
- var cnt = 0
- var s = 0
- while (m.later != null) {
- s -= m.deltaSize
- cnt += 1
- m = m.later
- }
- s += m.tableSize
- if (cnt > logLimit) makeCopy(m)
- s
- }
-
- def elements = synchronized {
- makeCopyIfUpdated()
- entries map {e => (e.key, getValue(e))}
- }
-
- private def getValue(e: Entry) =
- e.value.asInstanceOf[B]
-
- private def logLimit: Int = Math.sqrt(table.length).toInt
-
- private def markUpdated(key: A, ov: Option[B], delta: Int) {
- val lv = loadFactor
- later = new HashMap[A, B] {
- override def initialSize = 0
- override def loadFactor = lv
- table = HashMap.this.table
- tableSize = HashMap.this.tableSize
- threshold = HashMap.this.threshold
- }
- oldKey = key
- oldValue = ov
- deltaSize = delta
- }
-
- private def makeCopy(last: HashMap[A, B]) {
- def undo(m: HashMap[A, B]) {
- if (m ne last) {
- undo(m.later)
- if (m.deltaSize == 1) removeEntry(m.oldKey)
- else if (m.deltaSize == 0) findEntry(m.oldKey).value = m.oldValue.get
- else if (m.deltaSize == -1) addEntry(new Entry(m.oldKey, m.oldValue.get))
- }
- }
- def copy(e: Entry): Entry =
- if (e == null) null
- else {
- val rest = copy(e.next)
- val result = new Entry(e.key, e.value)
- result.next = rest
- result
- }
- val ltable = last.table
- val s = ltable.length
- table = new scala.Array[collection.mutable.HashEntry[A, Entry]](s)
- var i = 0
- while (i < s) {
- table(i) = copy(ltable(i).asInstanceOf[Entry])
- i += 1
- }
- tableSize = last.tableSize
- threshold = last.threshold
- undo(this)
- later = null
- }
-
- private def makeCopyIfUpdated() {
- var m = this
- while (m.later != null) m = m.later
- if (m ne this) makeCopy(m)
- }
-}
-
diff --git a/src/library/scalax/collection/immutable/HashSet.scala b/src/library/scalax/collection/immutable/HashSet.scala
deleted file mode 100644
index 56394b9bc6..0000000000
--- a/src/library/scalax/collection/immutable/HashSet.scala
+++ /dev/null
@@ -1,138 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: HashSet.scala 16884 2009-01-09 16:52:09Z cunei $
-
-package scalax.collection.immutable
-
-import generic.{SetTemplate, SetFactory, AddableBuilder}
-
-/** The canonical factory methods for <a href="HashSet.html">immutable HashSet's<la>.
- *
- * @author Martin Odersky
- * @version 2.8
- */
-object HashSet extends SetFactory[HashSet] {
-
- /** The empty set of this type.
- */
- def empty[A] = new HashSet[A]
-
-}
-
-/** This class implements immutable maps/sets using a hash table.
- * It is optimized for sequential accesses where the last updated table is accessed most often.
- * It supports with reasonable efficiency accesses to previous versions of the table by keeping
- * a change log that's regularly compacted.
- * It needs to synchronize most methods, so it is less suitable for highly concurrent accesses.
- *
- * @author Martin Odersky
- * @version 2.0, 19/01/2007
- */
-@serializable
-class HashSet[A] extends Set[A]
- with SetTemplate[HashSet, A]
- with mutable.FlatHashTable[A] {
- protected var later: HashSet[A] = null
- protected var changedElem: A = _
- protected var deleted: Boolean = _
-
- def contains(elem: A): Boolean = synchronized {
- var m = this
- var cnt = 0
- while (m.later != null) {
- if (elem == m.changedElem) return m.deleted
- cnt += 1
- m = m.later
- }
- if (cnt > logLimit) makeCopy(m)
- m.containsEntry(elem)
- }
-
- def + (elem: A): HashSet[A] = synchronized {
- makeCopyIfUpdated()
- if (containsEntry(elem)) this
- else {
- markUpdated(elem, false)
- later addEntry elem
- later
- }
- }
-
- def - (elem: A): HashSet[A] = synchronized {
- makeCopyIfUpdated()
- if (!containsEntry(elem)) this
- else {
- markUpdated(elem, true)
- later removeEntry elem
- later
- }
- }
-
- override def size: Int = synchronized {
- var m = this
- var cnt = 0
- var s = 0
- while (m.later != null) {
- if (m.deleted) s += 1 else s -= 1
- cnt += 1
- m = m.later
- }
- s += m.tableSize
- if (cnt > logLimit) makeCopy(m)
- s
- }
-
- override def elements = synchronized {
- makeCopyIfUpdated()
- // note need to cache because (later versions of) set might be mutated while elements are traversed.
- val cached = new mutable.ArrayBuffer() ++ super.elements
- cached.elements
- }
-
- override def newBuilder[B]: generic.Builder[HashSet, B] =
- new AddableBuilder[HashSet, B](HashSet.empty)
-
- private def logLimit: Int = Math.sqrt(table.length).toInt
-
- private def markUpdated(elem: A, del: Boolean) {
- val lv = loadFactor
- later = new HashSet[A] {
- override def initialSize = 0
- override def loadFactor = lv
- table = HashSet.this.table
- tableSize = HashSet.this.tableSize
- threshold = HashSet.this.threshold
- }
- changedElem = elem
- deleted = del
- }
-
- private def makeCopy(last: HashSet[A]) {
- def undo(m: HashSet[A]) {
- if (m ne last) {
- undo(m.later)
- if (m.deleted) addEntry(m.changedElem)
- else removeEntry(m.changedElem)
- }
- }
- table = new scala.Array[AnyRef](last.table.length)
- scala.Array.copy(last.table, 0, table, 0, table.length)
- tableSize = last.tableSize
- threshold = last.threshold
- undo(this)
- later = null
- }
-
- private def makeCopyIfUpdated() {
- var m = this
- while (m.later != null) m = m.later
- if (m ne this) makeCopy(m)
- }
-}
-
diff --git a/src/library/scalax/collection/immutable/Iterable.scala b/src/library/scalax/collection/immutable/Iterable.scala
deleted file mode 100644
index 0e6bb8fae0..0000000000
--- a/src/library/scalax/collection/immutable/Iterable.scala
+++ /dev/null
@@ -1,24 +0,0 @@
-package scalax.collection.immutable
-
-import generic._
-import annotation.unchecked.uncheckedVariance
-
-/** Collection classes mixing in this class provide a method
- * <code>elements</code> which returns an iterator over all the
- * elements contained in the collection.
- *
- * @note If a collection has a known <code>size</code>, it should also sub-type <code>SizedIterable</code>.
- *
- * @author Matthias Zenger
- * @autor Martin Odersky
- * @owner Martin Odersky
- * @version 2.8
- */
-trait Iterable[+A] extends collection.Iterable[A]
- with IterableTemplate[Iterable, A @uncheckedVariance]
-
-object Iterable extends IterableFactory[Iterable] with EmptyIterableFactory[Iterable] {
- val empty: Iterable[Nothing] = Nil
-}
-
-
diff --git a/src/library/scalax/collection/immutable/List.scala b/src/library/scalax/collection/immutable/List.scala
deleted file mode 100644
index cb5965a18a..0000000000
--- a/src/library/scalax/collection/immutable/List.scala
+++ /dev/null
@@ -1,952 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: List.scala 16287 2008-10-18 13:41:36Z nielsen $
-
-
-package scalax.collection.immutable
-
-import mutable.ListBuffer
-import generic.{SequenceTemplate, SequenceFactory, EmptyIterableFactory, Builder}
-import annotation.unchecked.uncheckedVariance
-
-/** A class representing an ordered collection of elements of type
- * <code>a</code>. This class comes with two implementing case
- * classes <code>scala.Nil</code> and <code>scala.::</code> that
- * implement the abstract members <code>isEmpty</code>,
- * <code>head</code> and <code>tail</code>.
- *
- * @author Martin Odersky and others
- * @version 2.8
- */
-sealed abstract class List[+A] extends Stream[A]
- with SequenceTemplate[List, A @uncheckedVariance]
- with Product {
-
- import collection.{Iterable, OrderedIterable, Sequence, Vector}
-
- /** Returns true if the list does not contain any elements.
- * @return <code>true</code>, iff the list is empty.
- */
- def isEmpty: Boolean
-
- /** Returns this first element of the list.
- *
- * @return the first element of this list.
- * @throws Predef.NoSuchElementException if the list is empty.
- */
- def head: A
-
- /** Returns this list without its first element.
- *
- * @return this list without its first element.
- * @throws Predef.NoSuchElementException if the list is empty.
- */
- def tail: List[A]
-
- /** Creates a list buffer as builder for this class */
- override def newBuilder[B]: Builder[List, B] = new ListBuffer[B]
-
- // New methods in List
-
- /** <p>
- * Add an element <code>x</code> at the beginning of this list.
- * </p>
- *
- * @param x the element to prepend.
- * @return the list with <code>x</code> added at the beginning.
- * @ex <code>1 :: List(2, 3) = List(2, 3).::(1) = List(1, 2, 3)</code>
- */
- def ::[B >: A] (x: B): List[B] =
- new scalax.collection.immutable.::(x, this)
-
- /** <p>
- * Returns a list resulting from the concatenation of the given
- * list <code>prefix</code> and this list.
- * </p>
- *
- * @param prefix the list to concatenate at the beginning of this list.
- * @return the concatenation of the two lists.
- * @ex <code>List(1, 2) ::: List(3, 4) = List(3, 4).:::(List(1, 2)) = List(1, 2, 3, 4)</code>
- */
- def :::[B >: A](prefix: List[B]): List[B] =
- if (isEmpty) prefix
- else (new ListBuffer[B] ++ prefix).prependToList(this)
-
- /** Reverse the given prefix and append the current list to that.
- * This function is equivalent to an application of <code>reverse</code>
- * on the prefix followed by a call to <code>:::</code>, but is more
- * efficient.
- *
- * @param prefix the prefix to reverse and then prepend
- * @return the concatenation of the reversed prefix and the current list.
- */
- def reverse_:::[B >: A](prefix: List[B]): List[B] = {
- var these: List[B] = this
- var pres = prefix
- while (!pres.isEmpty) {
- these = pres.head :: these
- pres = pres.tail
- }
- these
- }
-
- /** Apply a function to all the elements of the list, and return the
- * reversed list of results. This is equivalent to a call to <code>map</code>
- * followed by a call to <code>reverse</code>, but more efficient.
- * !!! should we deprecate this? Why have reverseMap, but not filterMap, say?
- * @param f the function to apply to each elements.
- * @return the reversed list of results.
- */
- def reverseMap[B](f: A => B): List[B] = {
- def loop(l: List[A], res: List[B]): List[B] = l match {
- case Nil => res
- case head :: tail => loop(tail, f(head) :: res)
- }
- loop(this, Nil)
- }
-
- /** Like xs map f, but returns <code>xs</code> unchanged if function
- * <code>f</code> maps all elements to themselves (wrt eq)
- * @note Unlike `map`, `mapConserve` is not tail-recursive
- */
- def mapConserve[B >: A] (f: A => B): List[B] = {
- def loop(ys: List[A]): List[B] =
- if (ys.isEmpty) this
- else {
- val head0 = ys.head
- val head1 = f(head0)
- if (head1.asInstanceOf[AnyRef] eq head0.asInstanceOf[AnyRef]) {
- loop(ys.tail)
- } else {
- val ys1 = head1 :: ys.tail.mapConserve(f)
- if (this eq ys) ys1
- else {
- val b = new ListBuffer[B]
- var xc = this
- while (xc ne ys) {
- b += xc.head
- xc = xc.tail
- }
- b.prependToList(ys1)
- }
- }
- }
- loop(this)
- }
-
- // Overridden methods from IterableTemplate or overloaded variants of such methods
-
- /** Appends two list objects.
- */
- override def ++[B >: A](that: Iterable[B]): List[B] =
- this ::: that.toList
-
- /** Overrides the method in Iterable for efficiency.
- *
- * @return the list itself
- */
- override def toList: List[A] = this
-
- /** Returns the <code>n</code> first elements of this list, or else the whole
- * list, if it has less than <code>n</code> elements.
-
- * @param n the number of elements to take.
- * @return the <code>n</code> first elements of this list.
- */
- override def take(n: Int): List[A] = {
- val b = new ListBuffer[A]
- var i = 0
- var these = this
- while (!these.isEmpty && i < n) {
- i += 1
- b += these.head
- these = these.tail
- }
- if (these.isEmpty) this
- else b.toList
- }
-
- /** Returns the list without its <code>n</code> first elements.
- * If this list has less than <code>n</code> elements, the empty list is returned.
- *
- * @param n the number of elements to drop.
- * @return the list without its <code>n</code> first elements.
- */
- override def drop(n: Int): List[A] = {
- var these = this
- var count = n
- while (!these.isEmpty && count > 0) {
- these = these.tail
- count -= 1
- }
- these
- }
-
- /** Returns the list with elements belonging to the given index range.
- *
- * @param start the start position of the list slice.
- * @param end the end position (exclusive) of the list slice.
- * @return the list with elements belonging to the given index range.
- */
- override def slice(start: Int, end: Int): List[A] = {
- val s = start max 0
- val e = end min this.length
- drop(s) take (e - s)
- }
-
- /** Returns the rightmost <code>n</code> elements from this list.
- *
- * @param n the number of elements to take
- * @return the suffix of length <code>n</code> of the list
- */
- override def takeRight(n: Int): List[A] = {
- def loop(lead: List[A], lag: List[A]): List[A] = lead match {
- case Nil => lag
- case _ :: tail => loop(tail, lag.tail)
- }
- loop(drop(n), this)
- }
-
- // dropRight is inherited from Stream
-
- /** Split the list at a given point and return the two parts thus
- * created.
- *
- * @param n the position at which to split
- * @return a pair of lists composed of the first <code>n</code>
- * elements, and the other elements.
- */
- override def splitAt(n: Int): (List[A], List[A]) = {
- val b = new ListBuffer[A]
- var i = 0
- var these = this
- while (!these.isEmpty && i < n) {
- i += 1
- b += these.head
- these = these.tail
- }
- (b.toList, these)
- }
-
- /** Returns the longest prefix of this list whose elements satisfy
- * the predicate <code>p</code>.
- *
- * @param p the test predicate.
- * @return the longest prefix of this list whose elements satisfy
- * the predicate <code>p</code>.
- */
- override def takeWhile(p: A => Boolean): List[A] = {
- val b = new ListBuffer[A]
- var these = this
- while (!these.isEmpty && p(these.head)) {
- b += these.head
- these = these.tail
- }
- b.toList
- }
-
- /** Returns the longest suffix of this list whose first element
- * does not satisfy the predicate <code>p</code>.
- *
- * @param p the test predicate.
- * @return the longest suffix of the list whose first element
- * does not satisfy the predicate <code>p</code>.
- */
- override def dropWhile(p: A => Boolean): List[A] =
- if (isEmpty || !p(head)) this
- else tail dropWhile p
-
- /** Returns the longest prefix of the list whose elements all satisfy
- * the given predicate, and the rest of the list.
- *
- * @param p the test predicate
- * @return a pair consisting of the longest prefix of the list whose
- * elements all satisfy <code>p</code>, and the rest of the list.
- */
- override def span(p: A => Boolean): (List[A], List[A]) = {
- val b = new ListBuffer[A]
- var these = this
- while (!these.isEmpty && p(these.head)) {
- b += these.head
- these = these.tail
- }
- (b.toList, these)
- }
-
- /** Returns the list resulting from applying the given function <code>f</code> to each
- * element of this list.
- *
- * @param f function to apply to each element.
- * @return <code>[f(a0), ..., f(an)]</code> if this list is <code>[a0, ..., an]</code>.
- */
- final override def map[B](f: A => B): List[B] = {
- val b = new ListBuffer[B]
- var these = this
- while (!these.isEmpty) {
- b += f(these.head)
- these = these.tail
- }
- b.toList
- }
-
- /** Returns all the elements of this list that satisfy the
- * predicate <code>p</code>. The order of the elements is preserved.
- * It is guarenteed that the receiver list itself is returned iff all its
- * elements satisfy the predicate `p'. Hence the following equality is valid:
- *
- * (xs filter p) eq xs == xs forall p
- *
- * @param p the predicate used to filter the list.
- * @return the elements of this list satisfying <code>p</code>.
- */
- final override def filter(p: A => Boolean): List[A] = {
- // return same list if all elements satisfy p
- var these = this
- var allTrue = true
- val b = new ListBuffer[A]
- while (!these.isEmpty) {
- if (p(these.head)) b += these.head
- else allTrue = false
- these = these.tail
- }
- if (allTrue) this else b.toList
- }
-
- /** Applies the given function <code>f</code> to each element of
- * this list, then concatenates the results.
- *
- * @param f the function to apply on each element.
- * @return <code>f(a<sub>0</sub>) ::: ... ::: f(a<sub>n</sub>)</code> if
- * this list is <code>[a<sub>0</sub>, ..., a<sub>n</sub>]</code>.
- */
- final override def flatMap[B](f: A => Iterable[B]): List[B] = {
- val b = new ListBuffer[B]
- var these = this
- while (!these.isEmpty) {
- b ++= f(these.head)
- these = these.tail
- }
- b.toList
- }
-
- /** Returns a list formed from this list and the specified list
- * <code>that</code> by associating each element of the former with
- * the element at the same position in the latter.
- * If one of the two lists is longer than the other, its remaining elements are ignored.
- *
- * !!! todo: perform speed with inherited version from Iterable, and drop
- * if not significantly better
- * @return <code>List((a<sub>0</sub>,b<sub>0</sub>), ...,
- * (a<sub>min(m,n)</sub>,b<sub>min(m,n)</sub>))</code> when
- * <code>List(a<sub>0</sub>, ..., a<sub>m</sub>)
- * zip List(b<sub>0</sub>, ..., b<sub>n</sub>)</code> is invoked.
- */
- def zip[B](that: List[B]): List[(A, B)] = {
- val b = new ListBuffer[(A, B)]
- var these = this
- var those = that
- while (!these.isEmpty && !those.isEmpty) {
- b += ((these.head, those.head))
- these = these.tail
- those = those.tail
- }
- b.toList
- }
-
- /** Returns a list formed from this list and the specified list
- * <code>that</code> by associating each element of the former with
- * the element at the same position in the latter.
- *
- * @param that list <code>that</code> may have a different length
- * as the self list.
- * @param thisElem element <code>thisElem</code> is used to fill up the
- * resulting list if the self list is shorter than
- * <code>that</code>
- * @param thatElem element <code>thatElem</code> is used to fill up the
- * resulting list if <code>that</code> is shorter than
- * the self list
- * @return <code>List((a<sub>0</sub>,b<sub>0</sub>), ...,
- * (a<sub>n</sub>,b<sub>n</sub>), (elem,b<sub>n+1</sub>),
- * ..., {elem,b<sub>m</sub>})</code>
- * when <code>[a<sub>0</sub>, ..., a<sub>n</sub>] zip
- * [b<sub>0</sub>, ..., b<sub>m</sub>]</code> is
- * invoked where <code>m &gt; n</code>.
- */
- def zipAll[B, C >: A, D >: B](that: List[B], thisElem: C, thatElem: D): List[(C, D)] = {
- val b = new ListBuffer[(C, D)]
- var these = this
- var those = that
- while (!these.isEmpty && !those.isEmpty) {
- b += ((these.head, those.head))
- these = these.tail
- those = those.tail
- }
- while (!these.isEmpty) {
- b += ((these.head, thatElem))
- these = these.tail
- }
- while (!those.isEmpty) {
- b += ((thisElem, those.head))
- those = those.tail
- }
- b.toList
- }
-
- override def stringPrefix = "List"
-
- override def toStream : Stream[A] = this
-
- /** Computes the difference between this list and the given list
- * <code>that</code>.
- *
- * @param that the list of elements to remove from this list.
- * @return this list without the elements of the given list
- * <code>that</code>.
- * @deprecated use diff instead
- */
- @deprecated def -- [B >: A](that: List[B]): List[B] = {
- val b = new ListBuffer[B]
- var these = this
- while (!these.isEmpty) {
- if (!that.contains(these.head)) b += these.head
- these = these.tail
- }
- b.toList
- }
-
- /** Computes the difference between this list and the given object
- * <code>x</code>.
- *
- * @param x the object to remove from this list.
- * @return this list without the elements of the given object
- * <code>x</code>.
- * @deprecated use diff instead
- */
- @deprecated def - [B >: A](x: B): List[B] = {
- val b = new ListBuffer[B]
- var these = this
- while (!these.isEmpty) {
- if (these.head != x) b += these.head
- these = these.tail
- }
- b.toList
- }
-
- /** <p>
- * Sort the list according to the comparison function
- * <code>&lt;(e1: a, e2: a) =&gt; Boolean</code>,
- * which should be true iff <code>e1</code> is smaller than
- * <code>e2</code>.
- * !!! todo: move sorting to IterableTemplate
- * </p>
- *
- * @param lt the comparison function
- * @return a list sorted according to the comparison function
- * <code>&lt;(e1: a, e2: a) =&gt; Boolean</code>.
- * @ex <pre>
- * List("Steve", "Tom", "John", "Bob")
- * .sort((e1, e2) => (e1 compareTo e2) &lt; 0) =
- * List("Bob", "John", "Steve", "Tom")</pre>
- * @deprecated use sortWith instead
- */
- @deprecated def sort(lt : (A,A) => Boolean): List[A] = {
- /** Merge two already-sorted lists */
- def merge(l1: List[A], l2: List[A]): List[A] = {
- val res = new ListBuffer[A]
- var left1 = l1
- var left2 = l2
-
- while (!left1.isEmpty && !left2.isEmpty) {
- if(lt(left1.head, left2.head)) {
- res += left1.head
- left1 = left1.tail
- } else {
- res += left2.head
- left2 = left2.tail
- }
- }
-
- res ++= left1
- res ++= left2
-
- res.toList
- }
-
- /** Split a list into two lists of about the same size */
- def split(lst: List[A]) = {
- val res1 = new ListBuffer[A]
- val res2 = new ListBuffer[A]
- var left = lst
-
- while (!left.isEmpty) {
- res1 += left.head
- left = left.tail
- if (!left.isEmpty) {
- res2 += left.head
- left = left.tail
- }
- }
-
- (res1.toList, res2.toList)
- }
-
-
- /** Merge-sort the specified list */
- def ms(lst: List[A]): List[A] =
- lst match {
- case Nil => lst
- case x :: Nil => lst
- case x :: y :: Nil =>
- if (lt(x,y))
- lst
- else
- y :: x :: Nil
-
- case lst =>
- val (l1, l2) = split(lst)
- val l1s = ms(l1)
- val l2s = ms(l2)
- merge(l1s, l2s)
- }
-
- ms(this)
- }
-
-}
-
-/** The empty list.
- *
- * @author Martin Odersky
- * @version 1.0, 15/07/2003
- */
-@SerialVersionUID(0 - 8256821097970055419L)
-case object Nil extends List[Nothing] {
- override def isEmpty = true
- override def head: Nothing =
- throw new NoSuchElementException("head of empty list")
- override def tail: List[Nothing] =
- throw new NoSuchElementException("tail of empty list")
-}
-
-/** A non empty list characterized by a head and a tail.
- *
- * @author Martin Odersky
- * @version 1.0, 15/07/2003
- */
-@SerialVersionUID(0L - 8476791151983527571L)
-final case class ::[B](private var hd: B, private[scalax] var tl: List[B]) extends List[B] {
- override def head : B = hd
- override def tail : List[B] = tl
- override def isEmpty: Boolean = false
-
- import java.io._
-
- private def writeObject(out: ObjectOutputStream) {
- var xs: List[B] = this
- while (!xs.isEmpty) { out.writeObject(xs.head); xs = xs.tail }
- out.writeObject(ListSerializeEnd)
- }
-
- private def readObject(in: ObjectInputStream) {
- hd = in.readObject.asInstanceOf[B]
- assert(hd != ListSerializeEnd)
- var current: ::[B] = this
- while (true) in.readObject match {
- case ListSerializeEnd =>
- current.tl = Nil
- return
- case a : Any =>
- val list : ::[B] = new ::(a.asInstanceOf[B], Nil)
- current.tl = list
- current = list
- }
- }
-}
-
-/** This object provides methods for creating specialized lists, and for
- * transforming special kinds of lists (e.g. lists of lists).
- *
- * @author Martin Odersky and others
- * @version 1.0, 15/07/2003
- */
-object List extends SequenceFactory[List] with EmptyIterableFactory[List] {
-
- override val empty: List[Nothing] = Nil
-
- override def apply[A](xs: A*) = xs.asInstanceOf[Iterable[A]].toList // !@!
-
- override def newBuilder[B]: Builder[List, B] = new ListBuffer[B]
-
- /** Create a sorted list with element values
- * <code>v<sub>n+1</sub> = step(v<sub>n</sub>)</code>
- * where <code>v<sub>0</sub> = start</code>
- * and elements are in the range between <code>start</code> (inclusive)
- * and <code>end</code> (exclusive)
- *
- * @deprecated use @see iterate instead.
- * @param start the start value of the list
- * @param end the end value of the list
- * @param step the increment function of the list, which given <code>v<sub>n</sub></code>,
- * computes <code>v<sub>n+1</sub></code>. Must be monotonically increasing
- * or decreasing.
- * @return the sorted list of all integers in range [start;end).
- */
- @deprecated def range(start: Int, end: Int, step: Int => Int): List[Int] = {
- val up = step(start) > start
- val down = step(start) < start
- val b = new ListBuffer[Int]
- var i = start
- while ((!up || i < end) && (!down || i > end)) {
- b += i
- val next = step(i)
- if (i == next)
- throw new IllegalArgumentException("the step function did not make any progress on "+ i)
- i = next
- }
- b.toList
- }
-
- /** Create a list containing several copies of an element.
- * @deprecated use @see fill instead
- *
- * @param n the length of the resulting list
- * @param elem the element composing the resulting list
- * @return a list composed of n elements all equal to elem
- */
- @deprecated def make[A](n: Int, elem: A): List[A] = {
- val b = new ListBuffer[A]
- var i = 0
- while (i < n) {
- b += elem
- i += 1
- }
- b.toList
- }
-
- /** Concatenate all the elements of a given list of lists.
- *
- * @deprecated use `xss.flatten` instead
- * @param xss the list of lists that are to be concatenated
- * @return the concatenation of all the lists
- */
- @deprecated def flatten[A](xss: List[List[A]]): List[A] = {
- val b = new ListBuffer[A]
- for (xs <- xss) {
- var xc = xs
- while (!xc.isEmpty) {
- b += xc.head
- xc = xc.tail
- }
- }
- b.toList
- }
-
- /** Transforms a list of pairs into a pair of lists.
- *
- * @param xs the list of pairs to unzip
- * @return a pair of lists.
- * @deprecated use `xs.unzp` instead
- */
- @deprecated def unzip[A,B](xs: List[(A,B)]): (List[A], List[B]) = {
- val b1 = new ListBuffer[A]
- val b2 = new ListBuffer[B]
- var xc = xs
- while (!xc.isEmpty) {
- b1 += xc.head._1
- b2 += xc.head._2
- xc = xc.tail
- }
- (b1.toList, b2.toList)
- }
-
- /** Transforms an iterable of pairs into a pair of lists.
- *
- * @deprecated use `xs.unzip` instead
- * @param xs the iterable of pairs to unzip
- * @return a pair of lists.
- */
- @deprecated def unzip[A,B](xs: Iterable[(A,B)]): (List[A], List[B]) =
- xs.foldRight[(List[A], List[B])]((Nil, Nil)) {
- case ((x, y), (xs, ys)) => (x :: xs, y :: ys)
- }
-
- /**
- * Returns the <code>Left</code> values in the given <code>Iterable</code> of <code>Either</code>s.
- * @deprecated use `Either.lefts` instead
- */
- @deprecated def lefts[A, B](es: Iterable[Either[A, B]]) =
- es.foldRight[List[A]](Nil)((e, as) => e match {
- case Left(a) => a :: as
- case Right(_) => as
- })
-
- /**
- * Returns the <code>Right</code> values in the given<code>Iterable</code> of <code>Either</code>s.
- * @deprecated use `Either.rights` instead
- */
- @deprecated def rights[A, B](es: Iterable[Either[A, B]]) =
- es.foldRight[List[B]](Nil)((e, bs) => e match {
- case Left(_) => bs
- case Right(b) => b :: bs
- })
-
- /** Transforms an Iterable of Eithers into a pair of lists.
- *
- * @param xs the iterable of Eithers to separate
- * @return a pair of lists.
- * @deprecated use `Either.separate` instead
- */
- @deprecated def separate[A,B](es: Iterable[Either[A,B]]): (List[A], List[B]) =
- es.foldRight[(List[A], List[B])]((Nil, Nil)) {
- case (Left(a), (lefts, rights)) => (a :: lefts, rights)
- case (Right(b), (lefts, rights)) => (lefts, b :: rights)
- }
-
- /** Converts an iterator to a list.
- *
- * @param it the iterator to convert
- * @return a list that contains the elements returned by successive
- * calls to <code>it.next</code>
- * @deprecated use it.toList instead
- */
- @deprecated def fromIterator[A](it: Iterator[A]): List[A] = it.toList
-
- /** Converts an array into a list.
- *
- * @param arr the array to convert
- * @return a list that contains the same elements than <code>arr</code>
- * in the same order
- * @deprecated use `array.toList` instead
- */
- @deprecated def fromArray[A](arr: Array[A]): List[A] = fromArray(arr, 0, arr.length)
-
- /** Converts a range of an array into a list.
- *
- * @param arr the array to convert
- * @param start the first index to consider
- * @param len the lenght of the range to convert
- * @return a list that contains the same elements than <code>arr</code>
- * in the same order
- * @deprecated use `array.view(start, end).toList` instead
- */
- @deprecated def fromArray[A](arr: Array[A], start: Int, len: Int): List[A] = {
- var res: List[A] = Nil
- var i = start + len
- while (i > start) {
- i -= 1
- res = arr(i) :: res
- }
- res
- }
-
- /** Parses a string which contains substrings separated by a
- * separator character and returns a list of all substrings.
- *
- * @param str the string to parse
- * @param separator the separator character
- * @return the list of substrings
- * @deprecated use `str.split(separator).toList` instead
- */
- @deprecated def fromString(str: String, separator: Char): List[String] = {
- var words: List[String] = Nil
- var pos = str.length()
- while (pos > 0) {
- val pos1 = str.lastIndexOf(separator, pos - 1)
- if (pos1 + 1 < pos)
- words = str.substring(pos1 + 1, pos) :: words
- pos = pos1
- }
- words
- }
-
- /** Returns the given string as a list of characters.
- *
- * @param str the string to convert.
- * @return the string as a list of characters.
- * @deprecated use <code>str.toList</code> instead
- */
- @deprecated def fromString(str: String): List[Char] =
- str.toList.asInstanceOf[List[Char]] // !@!
-
- /** Returns the given list of characters as a string.
- *
- * @param xs the list to convert.
- * @return the list in form of a string.
- * @deprecated use xs.mkString instead
- */
- @deprecated def toString(xs: List[Char]): String = {
- val sb = new StringBuilder()
- var xc = xs
- while (!xc.isEmpty) {
- sb.append(xc.head)
- xc = xc.tail
- }
- sb.toString()
- }
-
- /** Like xs map f, but returns <code>xs</code> unchanged if function
- * <code>f</code> maps all elements to themselves.
- * @deprecated use xs.mapConserve(f)
- */
- @deprecated def mapConserve[A <: AnyRef](xs: List[A])(f: A => A): List[A] = {
- def loop(ys: List[A]): List[A] =
- if (ys.isEmpty) xs
- else {
- val head0 = ys.head
- val head1 = f(head0)
- if (head1 eq head0) {
- loop(ys.tail)
- } else {
- val ys1 = head1 :: mapConserve(ys.tail)(f)
- if (xs eq ys) ys1
- else {
- val b = new ListBuffer[A]
- var xc = xs
- while (xc ne ys) {
- b += xc.head
- xc = xc.tail
- }
- b.prependToList(ys1)
- }
- }
- }
- loop(xs)
- }
-
- /** Returns the list resulting from applying the given function <code>f</code>
- * to corresponding elements of the argument lists.
- * @deprecated use (xs, ys).map(f) instead
- * @param f function to apply to each pair of elements.
- * @return <code>[f(a0,b0), ..., f(an,bn)]</code> if the lists are
- * <code>[a0, ..., ak]</code>, <code>[b0, ..., bl]</code> and
- * <code>n = min(k,l)</code>
- */
- @deprecated def map2[A,B,C](xs: List[A], ys: List[B])(f: (A, B) => C): List[C] = {
- val b = new ListBuffer[C]
- var xc = xs
- var yc = ys
- while (!xc.isEmpty && !yc.isEmpty) {
- b += f(xc.head, yc.head)
- xc = xc.tail
- yc = yc.tail
- }
- b.toList
- }
-
- /** Returns the list resulting from applying the given function
- * <code>f</code> to corresponding elements of the argument lists.
- *
- * @param f function to apply to each pair of elements.
- * @deprecated use (xs, ys, zs).map(f) instead
- * @return <code>[f(a<sub>0</sub>,b<sub>0</sub>,c<sub>0</sub>),
- * ..., f(a<sub>n</sub>,b<sub>n</sub>,c<sub>n</sub>)]</code>
- * if the lists are <code>[a<sub>0</sub>, ..., a<sub>k</sub>]</code>,
- * <code>[b<sub>0</sub>, ..., b<sub>l</sub>]</code>,
- * <code>[c<sub>0</sub>, ..., c<sub>m</sub>]</code> and
- * <code>n = min(k,l,m)</code>
- */
- @deprecated def map3[A,B,C,D](xs: List[A], ys: List[B], zs: List[C])(f: (A, B, C) => D): List[D] = {
- val b = new ListBuffer[D]
- var xc = xs
- var yc = ys
- var zc = zs
- while (!xc.isEmpty && !yc.isEmpty && !zc.isEmpty) {
- b += f(xc.head, yc.head, zc.head)
- xc = xc.tail
- yc = yc.tail
- zc = zc.tail
- }
- b.toList
- }
-
- /** Tests whether the given predicate <code>p</code> holds
- * for all corresponding elements of the argument lists.
- *
- * @param p function to apply to each pair of elements.
- * @return <code>(p(a<sub>0</sub>,b<sub>0</sub>) &amp;&amp;
- * ... &amp;&amp; p(a<sub>n</sub>,b<sub>n</sub>))]</code>
- * if the lists are <code>[a<sub>0</sub>, ..., a<sub>k</sub>]</code>;
- * <code>[b<sub>0</sub>, ..., b<sub>l</sub>]</code>
- * and <code>n = min(k,l)</code>
- * @deprecated use (xs, ys).forall(f) instead
- */
- @deprecated def forall2[A,B](xs: List[A], ys: List[B])(f: (A, B) => Boolean): Boolean = {
- var xc = xs
- var yc = ys
- while (!xc.isEmpty && !yc.isEmpty) {
- if (!f(xc.head, yc.head)) return false
- xc = xc.tail
- yc = yc.tail
- }
- true
- }
-
- /** Tests whether the given predicate <code>p</code> holds
- * for some corresponding elements of the argument lists.
- *
- * @param p function to apply to each pair of elements.
- * @return <code>n != 0 &amp;&amp; (p(a<sub>0</sub>,b<sub>0</sub>) ||
- * ... || p(a<sub>n</sub>,b<sub>n</sub>))]</code> if the lists are
- * <code>[a<sub>0</sub>, ..., a<sub>k</sub>]</code>,
- * <code>[b<sub>0</sub>, ..., b<sub>l</sub>]</code> and
- * <code>n = min(k,l)</code>
- * @deprecated use (xs, ys).forall(f) instead
- */
- @deprecated def exists2[A,B](xs: List[A], ys: List[B])(f: (A, B) => Boolean): Boolean = {
- var xc = xs
- var yc = ys
- while (!xc.isEmpty && !yc.isEmpty) {
- if (f(xc.head, yc.head)) return true
- xc = xc.tail
- yc = yc.tail
- }
- false
- }
-
- /** Transposes a list of lists.
- * pre: All element lists have the same length.
- *
- * @param xss the list of lists
- * @return the transposed list of lists
- * @deprecated use xss.transpose instead
- */
- @deprecated def transpose[A](xss: List[List[A]]): List[List[A]] = {
- val buf = new ListBuffer[List[A]]
- var yss = xss
- while (!yss.head.isEmpty) {
- buf += (yss map (_.head))
- yss = (yss map (_.tail))
- }
- buf.toList
- }
-
- /** Lists with ordered elements are ordered
- implicit def list2ordered[a <% Ordered[a]](x: List[a]): Ordered[List[a]] = new Ordered[List[a]] {
- def compare [b >: List[a] <% Ordered[b]](y: b): Int = y match {
- case y1: List[a] => compareLists(x, y1);
- case _ => -(y compare x)
- }
- private def compareLists(xs: List[a], ys: List[a]): Int = {
- if (xs.isEmpty && ys.isEmpty) 0
- else if (xs.isEmpty) -1
- else if (ys.isEmpty) 1
- else {
- val s = xs.head compare ys.head;
- if (s != 0) s
- else compareLists(xs.tail, ys.tail)
- }
- }
- }
- */
-}
-
-/** Only used for list serialization */
-@SerialVersionUID(0L - 8476791151975527571L)
-private[scalax] case object ListSerializeEnd
-
diff --git a/src/library/scalax/collection/immutable/Map.scala b/src/library/scalax/collection/immutable/Map.scala
deleted file mode 100755
index 923866fb8e..0000000000
--- a/src/library/scalax/collection/immutable/Map.scala
+++ /dev/null
@@ -1,66 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ 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 generic._
-
-object Map extends MapFactory[Map] {
- private val hashSeed = "Map".hashCode
- def empty[A, B]: Map[A, B] = new EmptyMap[A, B]
-}
-
-trait Map[A, B] extends MapTemplate[A, B, Map] with collection.Map[A, B] { self =>
-
- def empty[B]: Map[A, B] = new EmptyMap[A, B]
-
- /** The same map with a given default function */
- def withDefault(d: A => B): Map[A, B] = new Map[A, B] {
- def size = self.size
- def get(key: A) = self.get(key)
- def elements = self.elements
- override def empty[C] = self.empty
- def update (key: A, value: B): Map[A, B] =
- self update (key, value) withDefault d
- def - (key: A): Map[A, B] =
- self - key withDefault d
- override def default(key: A): B = d(key)
- }
-
- /** The same map with a given default value */
- def withDefaultValue(d: B): Map[A, B] = withDefault(x => d)
-
- /** 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: Map[a, b] =>
- this.size == other.size && this.forall {
- case (key, value) => other.get(key.asInstanceOf[a]) match {
- case None => false
- case Some(otherval) => value == otherval
- }
- }
- case _ => false
- }
-
- /** A hash method compatible with <code>equals</code>
- */
- override def hashCode() =
- (Map.hashSeed /: this) (_ * 41 + _.hashCode)
-
-}
diff --git a/src/library/scalax/collection/immutable/Map1.scala b/src/library/scalax/collection/immutable/Map1.scala
deleted file mode 100755
index f518c7cf17..0000000000
--- a/src/library/scalax/collection/immutable/Map1.scala
+++ /dev/null
@@ -1,39 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Map1.scala 16893 2009-01-13 13:09:22Z cunei $
-
-
-
-package scalax.collection.immutable
-
-/** This class implements immutable maps with exactly one entry
- *
- * @author Martin Oderskty
- * @version 1.0, 019/01/2007
- */
-@serializable
-class Map1[A, B](key1: A, value1: B) extends Map[A, B] {
-
- def size = 1
-
- def get(key: A): Option[B] =
- if (key == key1) Some(value1) else None
-
- def elements = Iterator((key1, value1))
-
- def update (key: A, value: B): Map[A, B] =
- if (key == key1) new Map1(key1, value)
- else null // new Map2(key1, value1, key, value)
-
- def - (key: A): Map[A, B] =
- if (key == key1) empty else this
-}
-
-
-
diff --git a/src/library/scalax/collection/immutable/Map2.scala b/src/library/scalax/collection/immutable/Map2.scala
deleted file mode 100644
index f3f55c5828..0000000000
--- a/src/library/scalax/collection/immutable/Map2.scala
+++ /dev/null
@@ -1,44 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Map1.scala 16893 2009-01-13 13:09:22Z cunei $
-
-
-
-package scalax.collection.immutable
-
-/** This class implements immutable maps with exactly one entry
- *
- * @author Martin Oderskty
- * @version 1.0, 019/01/2007
- */
-@serializable
-class Map2[A, B](key1: A, value1: B, key2: A, value2: B) extends Map[A, B] {
-
- def size = 2
-
- def get(key: A): Option[B] =
- if (key == key1) Some(value1)
- else if (key == key2) Some(value2)
- else None
-
- def elements = Iterator((key1, value1), (key2, value2))
-
- def update (key: A, value: B): Map[A, B] =
- if (key == key1) new Map2(key1, value, key2, value2)
- else if (key == key2) new Map2(key1, value1, key2, value)
- else new Map3(key1, value1, key2, value2, key, value)
-
- def - (key: A): Map[A, B] =
- if (key == key1) new Map1(key2, value2)
- else if (key == key2) new Map1(key1, value1)
- else this
-}
-
-
-
diff --git a/src/library/scalax/collection/immutable/Map3.scala b/src/library/scalax/collection/immutable/Map3.scala
deleted file mode 100644
index 3c8e6298cd..0000000000
--- a/src/library/scalax/collection/immutable/Map3.scala
+++ /dev/null
@@ -1,47 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Map1.scala 16893 2009-01-13 13:09:22Z cunei $
-
-
-
-package scalax.collection.immutable
-
-/** This class implements immutable maps with exactly one entry
- *
- * @author Martin Oderskty
- * @version 1.0, 019/01/2007
- */
-@serializable
-class Map3[A, B](key1: A, value1: B, key2: A, value2: B, key3: A, value3: B) extends Map[A, B] {
-
- def size = 3
-
- def get(key: A): Option[B] =
- if (key == key1) Some(value1)
- else if (key == key2) Some(value2)
- else if (key == key3) Some(value3)
- else None
-
- def elements = Iterator((key1, value1), (key2, value2), (key3, value3))
-
- def update (key: A, value: B): Map[A, B] =
- if (key == key1) new Map3(key1, value, key2, value2, key3, value3)
- else if (key == key2) new Map3(key1, value1, key2, value, key3, value3)
- else if (key == key3) new Map3(key1, value1, key2, value2, key3, value)
- else new Map4(key1, value1, key2, value2, key3, value3, key, value)
-
- def - (key: A): Map[A, B] =
- if (key == key1) new Map2(key2, value2, key3, value3)
- else if (key == key2) new Map2(key1, value1, key3, value3)
- else if (key == key3) new Map2(key1, value1, key2, value2)
- else this
-}
-
-
-
diff --git a/src/library/scalax/collection/immutable/Map4.scala b/src/library/scalax/collection/immutable/Map4.scala
deleted file mode 100644
index ad2dcd513b..0000000000
--- a/src/library/scalax/collection/immutable/Map4.scala
+++ /dev/null
@@ -1,50 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Map1.scala 16893 2009-01-13 13:09:22Z cunei $
-
-
-
-package scalax.collection.immutable
-
-/** This class implements immutable maps with exactly one entry
- *
- * @author Martin Oderskty
- * @version 1.0, 019/01/2007
- */
-@serializable
-class Map4[A, B](key1: A, value1: B, key2: A, value2: B, key3: A, value3: B, key4: A, value4: B) extends Map[A, B] {
-
- def size = 4
-
- def get(key: A): Option[B] =
- if (key == key1) Some(value1)
- else if (key == key2) Some(value2)
- else if (key == key3) Some(value3)
- else if (key == key4) Some(value4)
- else None
-
- def elements = Iterator((key1, value1), (key2, value2), (key3, value3), (key4, value4))
-
- def update (key: A, value: B): Map[A, B] =
- if (key == key1) new Map4(key1, value, key2, value2, key3, value3, key4, value4)
- else if (key == key2) new Map4(key1, value1, key2, value, key3, value3, key4, value4)
- else if (key == key3) new Map4(key1, value1, key2, value2, key3, value, key4, value4)
- else if (key == key4) new Map4(key1, value1, key2, value2, key3, value3, key4, value)
- else HashMap((key1, value1), (key2, value2), (key3, value3), (key4, value4), (key, value))
-
- def - (key: A): Map[A, B] =
- if (key == key1) new Map3(key2, value2, key3, value3, key4, value4)
- else if (key == key2) new Map3(key1, value1, key3, value3, key4, value4)
- else if (key == key3) new Map3(key1, value1, key2, value2, key4, value4)
- else if (key == key4) new Map3(key1, value1, key2, value2, key3, value3)
- else this
-}
-
-
-
diff --git a/src/library/scalax/collection/immutable/OrderedIterable.scala b/src/library/scalax/collection/immutable/OrderedIterable.scala
deleted file mode 100644
index 80fa418eec..0000000000
--- a/src/library/scalax/collection/immutable/OrderedIterable.scala
+++ /dev/null
@@ -1,26 +0,0 @@
-package scalax.collection.immutable
-
-import generic._
-import annotation.unchecked.uncheckedVariance
-
-/** Collection classes mixing in this class provide a method
- * <code>elements</code> which returns an iterator over all the
- * elements contained in the collection.
- *
- * @note If a collection has a known <code>size</code>, it should also sub-type <code>SizedIterable</code>.
- *
- * @author Matthias Zenger
- * @autor Martin Odersky
- * @owner Martin Odersky
- * @version 2.8
- */
-trait OrderedIterable[+A] extends immutable.Iterable[A]
- with OrderedIterableTemplate[OrderedIterable, A @uncheckedVariance]
- with collection.OrderedIterable[A]
-
-object OrderedIterable extends IterableFactory[OrderedIterable]
- with EmptyIterableFactory[OrderedIterable] {
- val empty: OrderedIterable[Nothing] = Nil
-}
-
-
diff --git a/src/library/scalax/collection/immutable/Sequence.scala b/src/library/scalax/collection/immutable/Sequence.scala
deleted file mode 100644
index 78de3cbfaf..0000000000
--- a/src/library/scalax/collection/immutable/Sequence.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-package scalax.collection.immutable
-
-import generic._
-import annotation.unchecked.uncheckedVariance
-
-/** Collection classes mixing in this class provide a method
- * <code>elements</code> which returns an iterator over all the
- * elements contained in the collection.
- *
- * @note If a collection has a known <code>size</code>, it should also sub-type <code>SizedIterable</code>.
- *
- * @author Matthias Zenger
- * @autor Martin Oderskyter
- * @owner Martin Odersky
- * @version 2.8
- */
-trait Sequence[+A] extends OrderedIterable[A]
- with SequenceTemplate[Sequence, A @uncheckedVariance]
- with collection.Sequence[A]
-
-object Sequence extends SequenceFactory[Sequence] with EmptyIterableFactory[Sequence] {
- val empty: Sequence[Nothing] = Nil
-}
-
-
diff --git a/src/library/scalax/collection/immutable/Set.scala b/src/library/scalax/collection/immutable/Set.scala
deleted file mode 100755
index 9462cd3c5f..0000000000
--- a/src/library/scalax/collection/immutable/Set.scala
+++ /dev/null
@@ -1,45 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ 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 generic._
-
-object Set extends generic.SetFactory[Set] {
- private val hashSeed = "Set".hashCode
- def empty[A]: Set[A] = new EmptySet[A]
-}
-
-trait Set[A] extends OrderedIterable[A]
- with collection.Set[A]
- with SetTemplate[Set, A] {
-
- override def newBuilder[B]: Builder[Set, B] = Set.newBuilder[B]
-
- /** 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/Set1.scala b/src/library/scalax/collection/immutable/Set1.scala
deleted file mode 100755
index 276cd83bb0..0000000000
--- a/src/library/scalax/collection/immutable/Set1.scala
+++ /dev/null
@@ -1,46 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Set1.scala 16893 2009-01-13 13:09:22Z cunei $
-
-
-
-package scalax.collection.immutable
-
-import collection.generic.Builder
-
-/** This class implements immutable sets with exactly one element.
- * @author Martin Oderskty
- * @version 1.0, 019/01/2007
- */
-@serializable
-class Set1[A](elem1: A) extends Set[A] {
-
- def size: Int = 1
-
- def contains(elem: A): Boolean =
- elem == elem1
-
- def + (elem: A): Set[A] =
- if (contains(elem)) this
- else new Set2(elem1, elem)
-
- def - (elem: A): Set[A] =
- if (elem == elem1) new EmptySet[A]
- else this
-
- def elements: Iterator[A] =
- Iterator(elem1)
-
- override def foreach(f: A => Unit): Unit = {
- f(elem1)
- }
-}
-
-
-
diff --git a/src/library/scalax/collection/immutable/Set2.scala b/src/library/scalax/collection/immutable/Set2.scala
deleted file mode 100755
index 828c52d053..0000000000
--- a/src/library/scalax/collection/immutable/Set2.scala
+++ /dev/null
@@ -1,47 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Set1.scala 16893 2009-01-13 13:09:22Z cunei $
-
-
-
-package scalax.collection.immutable
-
-import collection.generic.Builder
-
-/** This class implements immutable sets with exactly one element.
- * @author Martin Oderskty
- * @version 1.0, 019/01/2007
- */
-@serializable
-class Set2[A](elem1: A, elem2: A) extends Set[A] {
-
- def size: Int = 2
-
- def contains(elem: A): Boolean =
- elem == elem1 || elem == elem2
-
- def + (elem: A): Set[A] =
- if (contains(elem)) this
- else new Set3(elem1, elem2, elem)
-
- def - (elem: A): Set[A] =
- if (elem == elem1) new Set1(elem2)
- else if (elem == elem2) new Set1(elem1)
- else this
-
- def elements: Iterator[A] =
- Iterator(elem1, elem2)
-
- override def foreach(f: A => Unit): Unit = {
- f(elem1); f(elem2)
- }
-}
-
-
-
diff --git a/src/library/scalax/collection/immutable/Set3.scala b/src/library/scalax/collection/immutable/Set3.scala
deleted file mode 100755
index f14253231f..0000000000
--- a/src/library/scalax/collection/immutable/Set3.scala
+++ /dev/null
@@ -1,48 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Set1.scala 16893 2009-01-13 13:09:22Z cunei $
-
-
-
-package scalax.collection.immutable
-
-import collection.generic.Builder
-
-/** This class implements immutable sets with exactly one element.
- * @author Martin Oderskty
- * @version 1.0, 019/01/2007
- */
-@serializable
-class Set3[A](elem1: A, elem2: A, elem3: A) extends Set[A] {
-
- def size: Int = 3
-
- def contains(elem: A): Boolean =
- elem == elem1 || elem == elem2 || elem == elem3
-
- def + (elem: A): Set[A] =
- if (contains(elem)) this
- else new Set4(elem1, elem2, elem3, elem)
-
- def - (elem: A): Set[A] =
- if (elem == elem1) new Set2(elem2, elem3)
- else if (elem == elem2) new Set2(elem1, elem3)
- else if (elem == elem3) new Set2(elem1, elem2)
- else this
-
- def elements: Iterator[A] =
- Iterator(elem1, elem2, elem3)
-
- override def foreach(f: A => Unit): Unit = {
- f(elem1); f(elem2); f(elem3)
- }
-}
-
-
-
diff --git a/src/library/scalax/collection/immutable/Set4.scala b/src/library/scalax/collection/immutable/Set4.scala
deleted file mode 100755
index bef1b6588d..0000000000
--- a/src/library/scalax/collection/immutable/Set4.scala
+++ /dev/null
@@ -1,49 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Set1.scala 16893 2009-01-13 13:09:22Z cunei $
-
-
-
-package scalax.collection.immutable
-
-import collection.generic.Builder
-
-/** This class implements immutable sets with exactly one element.
- * @author Martin Oderskty
- * @version 1.0, 019/01/2007
- */
-@serializable
-class Set4[A](elem1: A, elem2: A, elem3: A, elem4: A) extends Set[A] {
-
- def size: Int = 4
-
- def contains(elem: A): Boolean =
- elem == elem1 || elem == elem2 || elem == elem3 || elem == elem4
-
- def + (elem: A): Set[A] =
- if (contains(elem)) this
- else new DefaultSet[A] + (elem1, elem2, elem3, elem4, elem)
-
- def - (elem: A): Set[A] =
- if (elem == elem1) new Set3(elem2, elem3, elem4)
- else if (elem == elem2) new Set3(elem1, elem3, elem4)
- else if (elem == elem3) new Set3(elem1, elem2, elem4)
- else if (elem == elem4) new Set3(elem1, elem2, elem3)
- else this
-
- def elements: Iterator[A] =
- Iterator(elem1, elem2, elem3, elem4)
-
- override def foreach(f: A => Unit): Unit = {
- f(elem1); f(elem2); f(elem3); f(elem4)
- }
-}
-
-
-
diff --git a/src/library/scalax/collection/immutable/Stream.scala b/src/library/scalax/collection/immutable/Stream.scala
deleted file mode 100755
index 4055be40bc..0000000000
--- a/src/library/scalax/collection/immutable/Stream.scala
+++ /dev/null
@@ -1,794 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Stream.scala 16287 2008-10-18 13:41:36Z nielsen $
-
-
-package scalax.collection.immutable
-
-import mutable.ListBuffer
-import generic.{SequenceTemplate, SequenceFactory, EmptyIterableFactory, Builder, LazyBuilder}
-import annotation.unchecked.uncheckedVariance
-import annotation.tailrec
-
-/**
- * The object <code>Stream</code> provides helper functions
- * to manipulate streams.
- *
- * @author Martin Odersky, Matthias Zenger
- * @version 1.1 08/08/03
- */
-object Stream extends SequenceFactory[Stream] with EmptyIterableFactory[Stream] {
-
- import collection.{Iterable, OrderedIterable, Sequence, Vector}
-
- override val empty: Stream[Nothing] = Nil
- override def apply[A](xs: A*) = xs.asInstanceOf[Iterable[A]].toList // !@!
- override def newBuilder[B]: Builder[Stream, B] = new ListBuffer[B]
-
- class ConsWrapper[A](tl: => Stream[A]) {
- def #::(hd: A): Stream[A] = new Cons(hd, tl)
- def #:::(prefix: Stream[A]): Stream[A] = prefix append tl
- }
-
- implicit def consWrapper[A](stream: => Stream[A]): ConsWrapper[A] =
- new ConsWrapper[A](stream)
-
- object #:: {
- def unapply[A](xs: Stream[A]): Option[(A, Stream[A])] =
- if (xs.isEmpty) None
- else Some(xs.head, xs.tail)
- }
-
- /** @deprecated use #:: instead */
- @deprecated lazy val lazy_:: = #::
-
- /** An alternative way of building and matching Streams using Stream.cons(hd, tl).
- */
- object cons {
-
- /** A stream consisting of a given first element and remaining elements
- * @param hd The first element of the result stream
- * @param tl The remaining elements of the result stream
- */
- def apply[A](hd: A, tl: => Stream[A]) = new Cons(hd, tl)
-
- /** Maps a stream to its head and tail */
- def unapply[A](xs: Stream[A]): Option[(A, Stream[A])] = #::.unapply(xs)
- }
-
- final class Cons[+A](hd: A, tl: => Stream[A]) extends Stream[A] {
- override def isEmpty = false
- override def head = hd
- private[this] var tlVal: Stream[A] = _
- private def tlDefined = tlVal ne null
- override def tail: Stream[A] = {
- if (!tlDefined) { tlVal = tl }
- tlVal
- }
- override def hasDefiniteSize = tlDefined && tlVal.hasDefiniteSize
-
- // Overridden methods from IterableTemplate or overloaded variants of such methods
-
- /** Create a new stream which contains all elements of this stream
- * followed by all elements of Iterable `that'
- */
- override def ++[B >: A](that: Iterable[B]): Stream[B] = this append that
-
- /** Create a new stream which contains all elements of this stream
- * followed by all elements of Iterator `that'
- */
- override def ++[B >: A](that: Iterator[B]): Stream[B] = this append that.toStream
-
- /** Returns the stream resulting from applying the given function
- * <code>f</code> to each element of this stream.
- *
- * @param f function to apply to each element.
- * @return <code>f(a<sub>0</sub>), ..., f(a<sub>n</sub>)</code> if this
- * sequence is <code>a<sub>0</sub>, ..., a<sub>n</sub></code>.
- */
- override def map[B](f: A => B): Stream[B] =
- new Cons(f(head), tail map f)
-
- /** Applies the given function <code>f</code> to each element of
- * this stream, then concatenates the results.
- *
- * @param f the function to apply on each element.
- * @return <code>f(a<sub>0</sub>) ::: ... ::: f(a<sub>n</sub>)</code> if
- * this stream is <code>[a<sub>0</sub>, ..., a<sub>n</sub>]</code>.
- */
- override def flatMap[B](f: A => Iterable[B]): Stream[B] = {
- // drops A's for which f yields an empty Iterable[B]
- def loop(s: Stream[A]): Stream[B] =
- if (s.isEmpty) Nil
- else {
- val i = f(s.head)
- if (i.isEmpty) loop(s.tail)
- else i.toStream append loop(s.tail)
- }
- loop(this)
- }
-
- /** Returns all the elements of this stream that satisfy the
- * predicate <code>p</code>. The order of the elements is preserved.
- *
- * @param p the predicate used to filter the stream.
- * @return the elements of this stream satisfying <code>p</code>.
- */
- override def filter(p: A => Boolean): Stream[A] = {
- // drops A's for which p yields false
- def loop(s: Stream[A]): Stream[A] =
- if (s.isEmpty) Nil
- else {
- val b = p(s.head)
- if (!b) loop(s.tail)
- else new Cons(s.head, tail filter p)
- }
- loop(this)
- }
-
- /** Returns all the elements of this stream that satisfy the
- * predicate <code>p</code>. The order of the elements is preserved.
- *
- * @param p the predicate used to filter the stream.
- * @return the elements of this stream satisfying <code>p</code>.
- */
- override def partition(p: A => Boolean): (Stream[A], Stream[A]) = (filter(p(_)), remove(p(_)))
-
- /** Returns a stream formed from this stream and the specified stream
- * <code>that</code> by associating each element of the former with
- * the element at the same position in the latter.
- * If one of the two streams is longer than the other, its remaining elements are ignored.
- *
- * @return <code>Stream({a<sub>0</sub>,b<sub>0</sub>}, ...,
- * {a<sub>min(m,n)</sub>,b<sub>min(m,n)</sub>)}</code> when
- * <code>Stream(a<sub>0</sub>, ..., a<sub>m</sub>)
- * zip Stream(b<sub>0</sub>, ..., b<sub>n</sub>)</code> is invoked.
- */
- def zip[B](that: Stream[B]): Stream[(A, B)] =
- if (that.isEmpty) empty
- else new Cons((this.head, that.head), this.tail zip that.tail)
-
- /** Returns a list formed from this list and the specified list
- * <code>that</code> by associating each element of the former with
- * the element at the same position in the latter.
- *
- * @param that list <code>that</code> may have a different length
- * as the self list.
- * @param thisElem element <code>thisElem</code> is used to fill up the
- * resulting list if the self list is shorter than
- * <code>that</code>
- * @param thatElem element <code>thatElem</code> is used to fill up the
- * resulting list if <code>that</code> is shorter than
- * the self list
- * @return <code>List((a<sub>0</sub>,b<sub>0</sub>), ...,
- * (a<sub>n</sub>,b<sub>n</sub>), (elem,b<sub>n+1</sub>),
- * ..., {elem,b<sub>m</sub>})</code>
- * when <code>[a<sub>0</sub>, ..., a<sub>n</sub>] zip
- * [b<sub>0</sub>, ..., b<sub>m</sub>]</code> is
- * invoked where <code>m &gt; n</code>.
- */
- def zipAll[B, A1 >: A, B1 >: B](that: Stream[B], thisElem: A1, thatElem: B1): Stream[(A1, B1)] = {
- if (that.isEmpty) new Cons((this.head, thatElem), this.tail.zipAll(that, thisElem, thatElem))
- else new Cons((this.head, that.head), this.tail.zipAll(that.tail, thisElem, thatElem))
- }
-
- /** Zips this iterable with its indices. `s.zipWithIndex` is equivalent to
- * `s zip s.indices`
- */
- override def zipWithIndex = this zip (Iterator.from(0).toStream)
-
- /** Write all defined elements of this iterable into given string builder.
- * The written text begins with the string <code>start</code> and is finished by the string
- * <code>end</code>. Inside, the string representations of defined elements (w.r.t.
- * the method <code>toString()</code>) are separated by the string
- * <code>sep</code>. The method will not force evaluation of undefined elements. A
- * tail of such elements will be represented by a "?" instead.
- */
- override def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder = {
- b append start append hd
- if (tlDefined) tlVal.addString(b, sep, sep, end)
- else b append ", ?" append end
- }
-
- /** Returns the <code>n</code> first elements of this stream, or else the whole
- * stream, if it has less than <code>n</code> elements.
- *
- * @param n the number of elements to take.
- * @return the <code>n</code> first elements of this stream.
- */
- override def take(n: Int): Stream[A] =
- if (n <= 0) Nil else new Cons(head, tail take (n-1))
-
- /** Returns the stream without its <code>n</code> first elements.
- * If the stream has less than <code>n</code> elements, the empty stream is returned.
- *
- * @param n the number of elements to drop.
- * @return the stream without its <code>n</code> first elements.
- */
- override def drop(n: Int): Stream[A] = {
- var these: Stream[A] = this
- var i = n
- while (!these.isEmpty && i > 0) {
- these = these.tail
- i -= 1
- }
- these
- }
-
- /** A substream starting at index `from`
- * and extending up to (but not including) index `until`.
- *
- * @This is equivalent to (but possibly more efficient than)
- * c.drop(from).take(to - from)
- *
- * @param from The index of the first element of the returned subsequence
- * @param until The index of the element following the returned subsequence
- * @throws IndexOutOfBoundsException if <code>from &lt; 0</code>
- * or <code>length &lt; from + len<code>
- * @note Might return different results for different runs, unless this iterable is ordered
- */
- override def slice(from: Int, to: Int): Stream[A] =
- this.drop(from).take(to - from)
-
- /** The stream without its last element.
- * @throws Predef.UnsupportedOperationException if the stream is empty.
- */
- override def init: Stream[A] =
- if (tail.isEmpty) Nil
- else new Cons(head, tail.init)
-
- /** Returns the rightmost <code>n</code> elements from this iterable.
- * @param n the number of elements to take
- */
- override def takeRight(n: Int): Stream[A] = {
- var these: Stream[A] = this
- var lead = this drop n
- while (!lead.isEmpty) {
- these = these.tail
- lead = lead.tail
- }
- these
- }
-
- /** Returns the longest prefix of this stream whose elements satisfy
- * the predicate <code>p</code>.
- *
- * @param p the test predicate.
- */
- override def takeWhile(p: A => Boolean): Stream[A] =
- if (p(head)) new Cons(head, tail takeWhile p) else Nil
-
-
- /** Returns the longest suffix of this iterable whose first element
- * does not satisfy the predicate <code>p</code>.
- *
- * @param p the test predicate.
- */
- override def dropWhile(p: A => Boolean): Stream[A] = {
- var these: Stream[A] = this
- while (!these.isEmpty && p(these.head)) these = these.tail
- these
- }
-
- /** Returns a pair consisting of the longest prefix of the stream whose
- * elements all satisfy the given predicate, and the rest of the stream.
- *
- * @param p the test predicate
- */
- override def span(p: A => Boolean): (List[A], Stream[A]) = {
- var these: Stream[A] = this
- val l = new ListBuffer[A]
- while (!these.isEmpty && p(these.head)) {
- l += these.head
- these = these.tail
- }
- (l.toList, these)
- }
-
- // Overridden methods from Sequence
-
- /** Builds a new stream from this stream in which any duplicates (wrt to ==) removed.
- * Among duplicate elements, only the first one is retained in the result stream
- */
- override def removeDuplicates: Stream[A] =
- new Cons(head, tail.filter(head !=).removeDuplicates)
-
- /** Returns a new sequence of given length containing the elements of this sequence followed by zero
- * or more occurrences of given elements.
- */
- override def padTo[B >: A](len: Int, elem: B): Stream[B] =
- new Cons(head, tail.padTo(len - 1, elem))
- }
-
- /**
- * Create an infinite stream starting at <code>start</code>
- * and incrementing by step <code>step</code>
- *
- * @param start the start value of the stream
- * @param step the increment value of the stream
- * @return the stream starting at value <code>start</code>.
- */
- def from(start: Int, step: Int): Stream[Int] =
- new Cons(start, from(start+step, step))
-
- /**
- * Create an infinite stream starting at <code>start</code>
- * and incrementing by 1.
- *
- * @param start the start value of the stream
- * @return the stream starting at value <code>start</code>.
- */
- def from(start: Int): Stream[Int] = from(start, 1)
-
- /**
- * Create an infinite stream containing the given element expression (which is computed for each
- * occurrence)
- * @param elem the element composing the resulting stream
- * @return the stream containing an inifinite number of elem
- * @deprecated use fill instead
- */
- @deprecated def fill[A](elem: => A): Stream[A] = new Cons(elem, fill(elem))
-
- /** A stream containing all elements of a given iterator, in the order they are produced.
- * @param it The iterator producing the stream's elements
- * @deprecated use it.toStream instead
- */
- @deprecated def fromIterator[A](it: Iterator[A]): Stream[A] =
- if (it.hasNext) cons(it.next, fromIterator(it)) else empty
-
- /** The concatenation of a sequence of streams
- * @deprecated use xs.flatten instead
- */
- @deprecated def concat[A](xs: Iterable[Stream[A]]): Stream[A] = concat(xs.elements)
-
- /** The concatenation of all streams returned by an iterator
- * @deprecated use xs.toStream.flatten instead
- */
- @deprecated def concat[A](xs: Iterator[Stream[A]]): Stream[A] =
- if (xs.hasNext) xs.next append concat(xs)
- else empty
-
- /**
- * Create a stream with element values
- * <code>v<sub>n+1</sub> = step(v<sub>n</sub>)</code>
- * where <code>v<sub>0</sub> = start</code>
- * and elements are in the range between <code>start</code> (inclusive)
- * and <code>end</code> (exclusive)
- * @deprecated use @see iterate instead.
- * @param start the start value of the stream
- * @param end the end value of the stream
- * @param step the increment function of the stream, must be monotonically increasing or decreasing
- * @return the stream starting at value <code>start</code>.
- */
- @deprecated def range(start: Int, end: Int, step: Int => Int): Stream[Int] = {
- val up = step(start) > start
- val down = step(start) < start
- def loop(lo: Int): Stream[Int] =
- if ((!up || lo < end) && (!down || lo > end)) cons(lo, loop(step(lo)))
- else empty
- loop(start)
- }
-
- /**
- * Create an infinite stream containing the given element.
- *
- * @param elem the element composing the resulting stream
- * @return the stream containing an inifinite number of elem
- * @deprecated use fill(elem) instead
- */
- @deprecated def const[A](elem: A): Stream[A] = cons(elem, const(elem))
-
- /** Create a stream containing several copies of an element.
- *
- * @param n the length of the resulting stream
- * @param elem the element composing the resulting stream
- * @return the stream composed of n elements all equal to elem
- * @deprecated use fill(n, elem) instead
- */
- @deprecated def make[A](n: Int, elem: A): Stream[A] =
- const(elem) take n
-}
-
-import Stream._
-
-/**
- * <p>The class <code>Stream</code> implements lazy lists where elements
- * are only evaluated when they are needed. Here is an example:</p>
- * <pre>
- * <b>object</b> Main <b>extends</b> Application {
- *
- * <b>def</b> from(n: Int): Stream[Int] =
- * Stream.cons(n, from(n + 1))
- *
- * <b>def</b> sieve(s: Stream[Int]): Stream[Int] =
- * Stream.cons(s.head, sieve(s.tail filter { _ % s.head != 0 }))
- *
- * <b>def</b> primes = sieve(from(2))
- *
- * primes take 10 print
- * }
- * </pre>
- *
- * @author Martin Odersky, Matthias Zenger
- * @version 1.1 08/08/03
- */
-abstract class Stream[+A] extends Sequence[A]
- with SequenceTemplate[Stream, A @uncheckedVariance] {
-self =>
-
- import collection.{Iterable, OrderedIterable, Sequence, Vector}
-
- /** is this stream empty? */
- def isEmpty: Boolean
-
- /** The first element of this stream
- * @throws Predef.NoSuchElementException if the stream is empty.
- */
- def head: A
-
- /** A stream consisting of the remaining elements of this stream after the first one.
- * @throws Predef.UnsupportedOperationException if the stream is empty.
- */
- def tail: Stream[A]
-
- // Implementation of abstract methods
-
- /** Create a new @see LazyBuilder to build a stream */
- def newBuilder[B]: Builder[Stream, B] = new LazyBuilder[Stream, B] {
- def result: Stream[B] = elements.toStream
- }
-
- /** Returns the number of elements in the list.
- */
- def length: Int = {
- var these = self
- var len = 0
- while (!these.isEmpty) {
- len += 1
- these = these.tail
- }
- len
- }
-
- /** Returns the <code>n</code>-th element of this stream. The first element
- * (head of the stream) is at position 0.
- *
- * @param n index of the element to return
- * @return the element at position <code>n</code> in this stream.
- * @throws Predef.NoSuchElementException if the stream is too short.
- */
- override def apply(n: Int): A = drop(n).head
-
- // New methods in Stream
-
- /** The stream resulting from the concatenation of this stream with the argument stream.
- * @param rest The stream that gets appended to this stream
- */
- def append[B >: A](rest: => Iterable[B]): Stream[B] =
- if (isEmpty) rest.toStream else new Cons(head, tail append rest)
-
- /** Force evaluation of the whole stream and return it */
- def force: Stream[A] = {
- var these = this
- while (!isEmpty) these = these.tail
- this
- }
-
- /** Prints elements of this stream one by one, separated by commas */
- def print() { print(", ") }
-
- /** Prints elements of this stream one by one, separated by <code>sep</code>
- * @param sep The separator string printed between consecutive elements.
- */
- def print(sep: String) {
- @tailrec
- def loop(these: Stream[A], start: String) {
- Console.print(start)
- if (isEmpty) Console.print("empty")
- else {
- Console.print(these.head)
- loop(these.tail, sep)
- }
- }
- loop(this, "")
- }
-
- // Overridden methods from IterableTemplate or overloaded variants of such methods
-
- /** Returns the elements in the sequence as an iterator
- */
- override def elements: Iterator[A] = new Iterator[A] {
- var these = self
- def hasNext: Boolean = !these.isEmpty
- def next: A =
- if (hasNext) {
- val result = these.head; these = these.tail; result
- } else Iterator.empty.next
- override def toList: List[A] = these.toList
- }
-
- /** Apply the given function <code>f</code> to each element of this stream
- * (while respecting the order of the elements).
- *
- * @param f the treatment to apply to each element.
- */
- override def foreach(f: A => Unit) {
- var these = this
- while (!these.isEmpty) {
- f(these.head)
- these = these.tail
- }
- }
-
- /** Tests if the predicate <code>p</code> is satisfied by all elements
- * in this list.
- *
- * !!! todo: perform speed with inherited version from Iterable, and drop
- * if not significantly better
- * @param p the test predicate.
- * @return <code>true</code> iff all elements of this list satisfy the
- * predicate <code>p</code>.
- */
- override def forall(p: A => Boolean): Boolean = {
- var these = this
- while (!these.isEmpty) {
- if (!p(these.head)) return false
- these = these.tail
- }
- true
- }
-
- /** Tests the existence in this list of an element that satisfies the
- * predicate <code>p</code>.
- *
- * !!! todo: perform speed with inherited version from Iterable, and drop
- * if not significantly better
- * @param p the test predicate.
- * @return <code>true</code> iff there exists an element in this list that
- * satisfies the predicate <code>p</code>.
- */
- override def exists(p: A => Boolean): Boolean = {
- var these = this
- while (!these.isEmpty) {
- if (p(these.head)) return true
- these = these.tail
- }
- false
- }
-
- /** Count the number of elements in the iterable which satisfy a predicate.
- *
- * !!! todo: perform speed with inherited version from Iterable, and drop
- * if not significantly better
- * @param p the predicate for which to count
- * @return the number of elements satisfying the predicate <code>p</code>.
- */
- override def count(p: A => Boolean): Int = {
- var these = this
- var cnt = 0
- while (!these.isEmpty) {
- if (p(these.head)) cnt += 1
- these = these.tail
- }
- cnt
- }
-
- /** Find and return the first element of the list satisfying a
- * predicate, if any.
- *
- * !!! todo: perform speed with inherited version from Iterable, and drop
- * if not significantly better
- * @param p the predicate
- * @return the first element in the list satisfying <code>p</code>,
- * or <code>None</code> if none exists.
- */
- override def find(p: A => Boolean): Option[A] = {
- var these = this
- while (!these.isEmpty) {
- if (p(these.head)) return Some(these.head)
- these = these.tail
- }
- None
- }
-
- /** Combines the elements of this list together using the binary
- * function <code>f</code>, from left to right, and starting with
- * the value <code>z</code>.
- *
- * !!! todo: perform speed with inherited version from Iterable, and drop
- * if not significantly better
- * @return <code>f(... (f(f(z, a<sub>0</sub>), a<sub>1</sub>) ...),
- * a<sub>n</sub>)</code> if the list is
- * <code>[a<sub>0</sub>, a<sub>1</sub>, ..., a<sub>n</sub>]</code>.
- */
- override def foldLeft[B](z: B)(f: (B, A) => B): B = {
- var acc = z
- var these = this
- while (!these.isEmpty) {
- acc = f(acc, these.head)
- these = these.tail
- }
- acc
- }
-
- /** Combines the elements of this list together using the binary
- * function <code>f</code>, from right to left, and starting with
- * the value <code>z</code>.
- *
- * @return <code>f(a<sub>0</sub>, f(a<sub>1</sub>, f(..., f(a<sub>n</sub>, z)...)))</code>
- * if the list is <code>[a<sub>0</sub>, a1, ..., a<sub>n</sub>]</code>.
- */
- override def foldRight[B](z: B)(f: (A, B) => B): B =
- if (this.isEmpty) z
- else f(head, tail.foldRight(z)(f))
-
- /** Combines the elements of this list together using the binary
- * operator <code>op</code>, from left to right
- * @param op The operator to apply
- * @return <code>op(... op(a<sub>0</sub>,a<sub>1</sub>), ..., a<sub>n</sub>)</code>
- if the list has elements
- * <code>a<sub>0</sub>, a<sub>1</sub>, ..., a<sub>n</sub></code>.
- * @throws Predef.UnsupportedOperationException if the list is empty.
- */
- override def reduceLeft[B >: A](f: (B, A) => B): B =
- if (isEmpty) throw new UnsupportedOperationException("empty.reduceLeft")
- else tail.foldLeft[B](head)(f)
-
- /** Combines the elements of this iterable object together using the binary
- * operator <code>op</code>, from right to left
- * @note Will not terminate for infinite-sized collections.
- * @param op The operator to apply
- *
- * @return <code>a<sub>0</sub> op (... op (a<sub>n-1</sub> op a<sub>n</sub>)...)</code>
- * if the iterable object has elements <code>a<sub>0</sub>, a<sub>1</sub>, ...,
- * a<sub>n</sub></code>.
- *
- * @throws Predef.UnsupportedOperationException if the iterator is empty.
- */
- override def reduceRight[B >: A](op: (A, B) => B): B =
- if (isEmpty) throw new UnsupportedOperationException("Nil.reduceRight")
- else if (tail.isEmpty) head
- else op(head, tail.reduceRight(op))
-
- /**
- * Create a stream which contains all the elements of this iterable object.
- * @note consider using <code>projection</code> for lazy behavior.
- */
- override def toStream: Stream[A] = this
-
- /** Defines the prefix of this object's <code>toString</code> representation as ``Stream''.
- */
- override def stringPrefix = "Stream"
-
- /** The last element of this stream.
- *
- * @throws Predef.NoSuchElementException if the stream is empty.
- */
- override def last: A = {
- if (isEmpty) throw new NoSuchElementException
- var these = this
- var nx = these.tail
- while (!nx.isEmpty) {
- these = nx
- nx = nx.tail
- }
- these.head
- }
-
- /** Returns the rightmost <code>n</code> elements from this iterable.
- * @param n the number of elements to take
- */
- override def dropRight(n: Int): List[A] = {
- val b = new ListBuffer[A]
- var these = this
- var lead = this drop n
- while (!lead.isEmpty) {
- b += these.head
- these = these.tail
- lead = lead.tail
- }
- b.toList
- }
-
- /** Returns true iff the other stream contains the same elements as this one.
- *
- * @note will not terminate for two infinite-sized streams.
- * @param that the other stream
- */
- def sameElements[B >: A](that: Stream[B]): Boolean = {
- val these = this
- val those = that
- while (!these.isEmpty && !those.isEmpty && these.head == those.head) {}
- these.isEmpty && those.isEmpty
- }
-
- // Overridden methods from Sequence
-
- /** Result of comparing <code>length</code> with operand <code>len</code>.
- * returns <code>x</code> where
- * <code>x &lt; 0</code> iff <code>this.length &lt; len</code>
- * <code>x == 0</code> iff <code>this.length == len</code>
- * <code>x &gt; 0</code> iff <code>this.length &gt; len</code>.
- */
- override def lengthCompare(len: Int): Int = {
- var i = 0
- var these = self
- while (!these.isEmpty && i <= len) {
- i += 1
- these = these.tail
- }
- i - len
- }
-
- /** Is this partial function defined for the index <code>x</code>?
- */
- override def isDefinedAt(x: Int): Boolean = x >= 0 && lengthCompare(x) >= 0
-
- /** Returns length of longest segment starting from a start index `from`
- * such that every element of the segment satisfies predicate `p`.
- * @note may not terminate for infinite-sized collections.
- * @param p the predicate
- * @param from the start index
- */
- override def segmentLength(p: A => Boolean, from: Int): Int = {
- var i = from
- var these = this drop from
- while (!these.isEmpty && p(these.head)) {
- i += 1
- these = these.tail
- }
- i
- }
-
- /** Returns index of the first element starting from a start index
- * satisying a predicate, or -1, if none exists.
- *
- * @note may not terminate for infinite-sized streams.
- * @param p the predicate
- * @param from the start index
- */
- override def indexWhere(p: A => Boolean, from: Int): Int = {
- var i = from
- var these = this drop from
- while (!these.isEmpty && !p(these.head)) {
- i += 1
- these = these.tail
- }
- if (these.isEmpty) -1 else i
- }
-
- /** Returns index of the last element satisying a predicate, or -1, if none exists.
- *
- * @param p the predicate
- * @return the index of the last element satisfying <code>p</code>,
- * or -1 if such an element does not exist
- */
- override def lastIndexWhere(p: A => Boolean, end: Int): Int = {
- var i = 0
- var these = this
- var last = -1
- while (!these.isEmpty && i <= end) {
- if (p(these.head)) last = i
- }
- i
- }
-
- /** A list consisting of all elements of this list in reverse order.
- */
- override def reverse: List[A] = {
- var result: List[A] = Nil
- var these = this
- while (!these.isEmpty) {
- result = these.head :: result
- these = these.tail
- }
- result
- }
-}
-
diff --git a/src/library/scalax/collection/immutable/Vector.scala b/src/library/scalax/collection/immutable/Vector.scala
deleted file mode 100644
index 93e9601bd2..0000000000
--- a/src/library/scalax/collection/immutable/Vector.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-package scalax.collection.immutable
-
-import generic._
-import annotation.unchecked.uncheckedVariance
-
-/** Collection classes mixing in this class provide a method
- * <code>elements</code> which returns an iterator over all the
- * elements contained in the collection.
- *
- * @note If a collection has a known <code>size</code>, it should also sub-type <code>SizedIterable</code>.
- * // !!! todo: insert good immutable vector implementation here.
- * @author Matthias Zenger
- * @autor Martin Odersky
- * @owner Martin Odersky
- * @version 2.8
- */
-trait Vector[+A] extends Sequence[A]
- with VectorTemplate[Vector, A @uncheckedVariance]
- with collection.Vector[A]
-
-object Vector extends SequenceFactory[Vector] with EmptyIterableFactory[Vector] {
- val empty: Vector[Nothing] = immutable.Vector.empty
-}
-
-
diff --git a/src/library/scalax/collection/mutable/Array.scala b/src/library/scalax/collection/mutable/Array.scala
deleted file mode 100755
index cf1e02008b..0000000000
--- a/src/library/scalax/collection/mutable/Array.scala
+++ /dev/null
@@ -1,410 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Array.scala 17000 2009-01-29 13:05:53Z odersky $
-
-
-package scalax.collection.mutable
-
-import scalax.collection.generic._
-import compat.Platform.arraycopy
-
-/** This object contains utility methods operating on arrays.
- *
- * @author Martin Odersky
- * @version 1.0
- */
-object Array extends SequenceFactory[Array] {
-
- /** Copy one array to another.
- * Equivalent to
- * <code>System.arraycopy(src, srcPos, dest, destPos, length)</code>,
- * except that this works also for polymorphic and boxed arrays.
- *
- * @param src ...
- * @param srcPos ...
- * @param dest ...
- * @param destPos ...
- * @param length ...
- */
- def copy(src: AnyRef, srcPos: Int, dest: AnyRef, destPos: Int, length: Int) {
- src match {
- case xs: runtime.BoxedArray[_] =>
- xs.copyTo(srcPos, dest, destPos, length)
- case _ =>
- dest match {
- case xs: runtime.BoxedArray[_] =>
- xs.copyFrom(src, srcPos, destPos, length)
- case _ =>
- def fillDest[T](da: Array[T], sa: Int=>T) {
- var d = destPos
- for (s <- srcPos to srcPos+length-1) {
- da(d) = sa(s); d += 1
- }
- }
- if (dest.isInstanceOf[Array[Any]]) {
- def fill(sa: Int=>Any) = fillDest(dest.asInstanceOf[Array[Any]], sa)
- src match {
- case sa:Array[Int] => fill(s=>Int.box(sa(s)))
-/*!!!
- case sa:Array[Long] => fill(s=>Long.box(sa(s)))
- case sa:Array[Char] => fill(s=>Char.box(sa(s)))
- case sa:Array[Boolean] => fill(s=>Boolean.box(sa(s)))
- case sa:Array[Byte] => fill(s=>Byte.box(sa(s)))
- case sa:Array[Short] => fill(s=>Short.box(sa(s)))
- case sa:Array[Double] => fill(s=>Double.box(sa(s)))
- case sa:Array[Float] => fill(s=>Float.box(sa(s)))
-*/
- case _ => arraycopy(src, srcPos, dest, destPos, length)
- }
- } else if (dest.isInstanceOf[Array[AnyVal]]) {
- def fill(sa: Int=>AnyVal) = fillDest(dest.asInstanceOf[Array[AnyVal]], sa)
- src match {
- case sa:Array[Int] => fill(sa(_))
-/*!!!
- case sa:Array[Long] => fill(sa(_))
- case sa:Array[Char] => fill(sa(_))
- case sa:Array[Boolean] => fill(sa(_))
- case sa:Array[Byte] => fill(sa(_))
- case sa:Array[Short] => fill(sa(_))
- case sa:Array[Double] => fill(sa(_))
- case sa:Array[Float] => fill(sa(_))
-*/
- case _ => arraycopy(src, srcPos, dest, destPos, length)
- }
- } else
- arraycopy(src, srcPos, dest, destPos, length)
- }
- }
- }
-
- /** Concatenate all argument sequences into a single array.
- *
- * @param xs the given argument sequences
- * @return the array created from the concatenated arguments
- */
- def concat[T](xs: Seq[T]*): Array[T] = {
- var len = 0
- for (x <- xs) len += x.length
- val result = new Array[T](len)
- var start = 0
- for (x <- xs) {
- copy(x.toArray, 0, result, start, x.length)
- start += x.length
- }
- result
- }
-
- /** Create an array with given elements.
- *
- * @param xs the elements to put in the array
- * @return the array containing elements xs.
- */
- def apply[A](xs: A*): Array[A] = {
- val array = new Array[A](xs.length)
- var i = 0
- for (x <- xs.elements) { array(i) = x; i += 1 }
- array
- }
-/*!!! enable when arrays in Scala
- def apply(xs: Boolean*): Array[Boolean] = {
- val array = new Array[Boolean](xs.length)
- var i = 0
- for (x <- xs.elements) { array(i) = x; i += 1 }
- array
- }
-
- def apply(xs: Byte*): Array[Byte] = {
- val array = new Array[Byte](xs.length)
- var i = 0
- for (x <- xs.elements) { array(i) = x; i += 1 }
- array
- }
-
- def apply(xs: Short*): Array[Short] = {
- val array = new Array[Short](xs.length)
- var i = 0
- for (x <- xs.elements) { array(i) = x; i += 1 }
- array
- }
-
- def apply(xs: Char*): Array[Char] = {
- val array = new Array[Char](xs.length)
- var i = 0
- for (x <- xs.elements) { array(i) = x; i += 1 }
- array
- }
-
- def apply(xs: Int*): Array[Int] = {
- val array = new Array[Int](xs.length)
- var i = 0
- for (x <- xs.elements) { array(i) = x; i += 1 }
- array
- }
-
- def apply(xs: Long*): Array[Long] = {
- val array = new Array[Long](xs.length)
- var i = 0
- for (x <- xs.elements) { array(i) = x; i += 1 }
- array
- }
-
- def apply(xs: Float*): Array[Float] = {
- val array = new Array[Float](xs.length)
- var i = 0
- for (x <- xs.elements) { array(i) = x; i += 1 }
- array
- }
-
- def apply(xs: Double*): Array[Double] = {
- val array = new Array[Double](xs.length)
- var i = 0
- for (x <- xs.elements) { array(i) = x; i += 1 }
- array
- }
-
- def apply(xs: Unit*): Array[Unit] = {
- val array = new Array[Unit](xs.length)
- var i = 0
- for (x <- xs.elements) { array(i) = x; i += 1 }
- array
- }
-*/
- /** Create an array containing several copies of an element.
- *
- * @param n the length of the resulting array
- * @param elem the element composing the resulting array
- * @return an array composed of n elements all equal to elem
- * @deprecated use `Array.fill` instead.
- */
- @deprecated def make[A](n: Int, elem: A): Array[A] = {
- val a = new Array[A](n)
- var i = 0
- while (i < n) {
- a(i) = elem
- i += 1
- }
- a
- }
-
- /** Create an array containing the values of a given function <code>f</code>
- * over given range <code>[0..n)</code>
- * @deprecated use `Array.tabulate` instead.
- */
- @deprecated def fromFunction[A](f: Int => A)(n: Int): Array[A] = {
- val a = new Array[A](n)
- var i = 0
- while (i < n) {
- a(i) = f(i)
- i += 1
- }
- a
- }
-
- /** Create an array containing the values of a given function <code>f</code>
- * over given range <code>[0..n1, 0..n2)</code>
- * @deprecated use `Array.tabulate` instead.
- */
- @deprecated def fromFunction[A](f: (Int, Int) => A)(n1: Int, n2: Int): Array[Array[A]] =
- fromFunction(i => fromFunction(f(i, _))(n2))(n1)
-
- /** Create an array containing the values of a given function <code>f</code>
- * over given range <code>[0..n1, 0..n2, 0..n3)</code>
- * @deprecated use `Array.tabulate` instead.
- */
- @deprecated def fromFunction[A](f: (Int, Int, Int) => A)(n1: Int, n2: Int, n3: Int): Array[Array[Array[A]]] =
- fromFunction(i => fromFunction(f(i, _, _))(n2, n3))(n1)
-
- /** Create an array containing the values of a given function <code>f</code>
- * over given range <code>[0..n1, 0..n2, 0..n3, 0..n4)</code>
- * @deprecated use `Array.tabulate` instead.
- */
- @deprecated def fromFunction[A](f: (Int, Int, Int, Int) => A)(n1: Int, n2: Int, n3: Int, n4: Int): Array[Array[Array[Array[A]]]] =
- fromFunction(i => fromFunction(f(i, _, _, _))(n2, n3, n4))(n1)
-
- /** Create an array containing the values of a given function <code>f</code>
- * over given range <code>[0..n1, 0..n2, 0..n3, 0..n4, 0..n5)</code>
- * @deprecated use `Array.tabulate` instead.
- */
- @deprecated def fromFunction[A](f: (Int, Int, Int, Int, Int) => A)(n1: Int, n2: Int, n3: Int, n4: Int, n5: Int): Array[Array[Array[Array[Array[A]]]]] =
- fromFunction(i => fromFunction(f(i, _, _, _, _))(n2, n3, n4, n5))(n1)
-
- /** Create array with given dimensions */
- def ofDim[A](n1: Int): Array[A] =
- new Array[A](n1)
- def ofDim[A](n1: Int, n2: Int): Array[Array[A]] =
- tabulate(n1)(_ => ofDim[A](n2))
- def ofDim[A](n1: Int, n2: Int, n3: Int): Array[Array[Array[A]]] =
- tabulate(n1)(_ => ofDim[A](n2, n3))
- def ofDim[A](n1: Int, n2: Int, n3: Int, n4: Int): Array[Array[Array[Array[A]]]] =
- tabulate(n1)(_ => ofDim[A](n2, n3, n4))
- def ofDim[A](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int): Array[Array[Array[Array[Array[A]]]]] =
- tabulate(n1)(_ => ofDim[A](n2, n3, n4, n5))
-}
-
-/** This class represents polymorphic arrays. <code>Array[T]</code> is Scala's representation
- * for Java's <code>T[]</code>.
- *
- * @author Martin Odersky
- * @version 1.0
- */
-final class Array[A](_length: Int) extends Vector[A] with MutableVectorTemplate[Array, A] {
-
- /** Multidimensional array creation
- * @deprecated use Array.ofDim instead
- */
- @deprecated def this(dim1: Int, dim2: Int) = {
- this(dim1)
- throw new Error()
- }
-
- /** Multidimensional array creation
- * @deprecated use Array.ofDim instead */
- @deprecated def this(dim1: Int, dim2: Int, dim3: Int) = {
- this(dim1)
- throw new Error()
- }
-
- /** Multidimensional array creation
- * @deprecated use Array.ofDim instead */
- @deprecated def this(dim1: Int, dim2: Int, dim3: Int, dim4: Int) = {
- this(dim1)
- throw new Error()
- }
-
- /** Multidimensional array creation
- * @deprecated use Array.ofDim instead */
- @deprecated def this(dim1: Int, dim2: Int, dim3: Int, dim4: Int, dim5: Int) = {
- this(dim1);
- throw new Error()
- }
-
- /** Multidimensional array creation
- * @deprecated use Array.ofDim instead */
- @deprecated def this(dim1: Int, dim2: Int, dim3: Int, dim4: Int, dim5: Int, dim6: Int) = {
- this(dim1)
- throw new Error()
- }
-
- /** Multidimensional array creation
- * @deprecated use Array.ofDim instead */
- @deprecated def this(dim1: Int, dim2: Int, dim3: Int, dim4: Int, dim5: Int, dim6: Int, dim7: Int) = {
- this(dim1)
- throw new Error()
- }
-
- /** Multidimensional array creation
- * @deprecated use Array.ofDim instead */
- @deprecated def this(dim1: Int, dim2: Int, dim3: Int, dim4: Int, dim5: Int, dim6: Int, dim7: Int, dim8: Int) = {
- this(dim1)
- throw new Error()
- }
-
- /** Multidimensional array creation
- * @deprecated use Array.ofDim instead */
- @deprecated def this(dim1: Int, dim2: Int, dim3: Int, dim4: Int, dim5: Int, dim6: Int, dim7: Int, dim8: Int, dim9: Int) = {
- this(dim1)
- throw new Error()
- }
-
- /** The length of the array */
- def length: Int = throw new Error()
-
- /** The element at given index.
- * <p>
- * Indices start a <code>0</code>; <code>xs.apply(0)</code> is the first
- * element of array <code>xs</code>.
- * </p>
- * <p>
- * Note the indexing syntax <code>xs(i)</code> is a shorthand for
- * <code>xs.apply(i)</code>.
- * </p>
- *
- * @param i the index
- * @throws ArrayIndexOutOfBoundsException if <code>i < 0</code> or
- * <code>length <= i</code>
- */
- def apply(i: Int): A = throw new Error()
-
- /* Create a new array builder */
- def newBuilder[B]: Builder[Array, B] = throw new Error()
-
- /** <p>
- * Update the element at given index.
- * </p>
- * <p>
- * Indices start a <code>0</code>; <code>xs.apply(0)</code> is the first
- * element of array <code>xs</code>.
- * </p>
- * <p>
- * Note the indexing syntax <code>xs(i) = x</code> is a shorthand
- * for <code>xs.update(i, x)</code>.
- * </p>
- *
- * @param i the index
- * @param x the value to be written at index <code>i</code>
- * @throws ArrayIndexOutOfBoundsException if <code>i < 0</code> or
- * <code>length <= i</code>
- */
- override def update(i: Int, x: A) { throw new Error() }
-
- /**
- * @return a deep string representation of this array.
- */
- def deepToString(): String = throw new Error()
-
- /** <p>
- * Returns a string representation of this array object. The resulting string
- * begins with the string <code>start</code> and is finished by the string
- * <code>end</code>. Inside, the string representations of elements (w.r.t.
- * the method <code>deepToString()</code>) are separated by the string
- * <code>sep</code>. For example:
- * </p>
- * <p>
- * <code>Array(Array(1, 2), Array(3)).deepMkString("[", "; ", "]") = "[[1; 2]; [3]]"</code>
- * </p>
- *
- * @param start starting string.
- * @param sep separator string.
- * @param end ending string.
- * @return a string representation of this array object.
- */
- def deepMkString(start: String, sep: String, end: String): String =
- throw new Error()
-
- /** Returns a string representation of this array object. The string
- * representations of elements (w.r.t. the method <code>deepToString()</code>)
- * are separated by the string <code>sep</code>.
- *
- * @param sep separator string.
- * @return a string representation of this array object.
- */
- def deepMkString(sep: String): String = throw new Error()
-
- /** <p>
- * Returns <code>true</code> if the two specified arrays are
- * <em>deeply equal</em> to one another.
- * </p>
- * <p>
- * Two array references are considered deeply equal if both are null,
- * or if they refer to arrays that contain the same number of elements
- * and all corresponding pairs of elements in the two arrays are deeply
- * equal.
- * </p>
- * <p>
- * See also method <code>deepEquals</code> in the Java class
- * <a href="http://java.sun.com/javase/6/docs/api/java/util/Arrays.html"
- * target="_top">java.utils.Arrays</a>
- * </p>
- *
- * @param that the second
- * @return <code>true</code> iff both arrays are deeply equal.
- */
- def deepEquals(that: Any): Boolean = throw new Error()
-
-}
diff --git a/src/library/scalax/collection/mutable/ArrayBuffer.scala b/src/library/scalax/collection/mutable/ArrayBuffer.scala
deleted file mode 100644
index 1692280e21..0000000000
--- a/src/library/scalax/collection/mutable/ArrayBuffer.scala
+++ /dev/null
@@ -1,140 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: ArrayBuffer.scala 15407 2008-06-20 09:26:36Z stepancheg $
-
-
-package scalax.collection.mutable
-
-import generic.{SequenceFactory, MutableVectorTemplate, Builder}
-
-/* Factory object for `ArrayBuffer` class */
-object ArrayBuffer extends SequenceFactory[ArrayBuffer] {
- def apply[A](args: A*): ArrayBuffer[A] = new ArrayBuffer[A] ++ args.asInstanceOf[Iterable[A]] // !@!
-}
-
-/** An implementation of the <code>Buffer</code> class using an array to
- * represent the assembled sequence internally. Append, update and random
- * access take constant time (amortized time). Prepends and removes are
- * linear in the buffer size.
- *
- * @author Matthias Zenger
- * @author Martin Odersky
- * @version 2.8
- */
-@serializable
-class ArrayBuffer[A](override protected val initialSize: Int)
- extends Buffer[A]
- with Vector[A]
- with MutableVectorTemplate[ArrayBuffer, A]
- with Builder[ArrayBuffer, A]
- with ResizableArray[A] {
-
- def this() = this(16)
-
- def clear() { reduceToSize(0) }
-
- override def newBuilder[B]: Builder[ArrayBuffer, B] = new ArrayBuffer[B]
-
- /** Appends a single element to this buffer and returns
- * the identity of the buffer. It takes constant time.
- *
- * @param elem the element to append.
- */
- def +=(elem: A) {
- ensureSize(size0 + 1)
- array(size0) = elem.asInstanceOf[AnyRef]
- size0 += 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 iterfable object.
- * @return the updated buffer.
- */
- override def ++=(iter: collection.Iterable[A]) = iter match {
- case v: Vector[_] =>
- val n = v.length
- ensureSize(size0 + n)
- v.copyToArray(array.asInstanceOf[scala.Array[Any]], n)
- case _ =>
- super.++=(iter)
- }
-
- /** Prepends a single element to this buffer and return
- * the identity of the buffer. It takes time linear in
- * the buffer size.
- *
- * @param elem the element to append.
- * @return the updated buffer.
- */
- def +:(elem: A): this.type = {
- ensureSize(size0 + 1)
- copy(0, 1, size0)
- array(0) = elem.asInstanceOf[AnyRef]
- size0 += 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.
- * @return the updated buffer.
- */
- override def ++:(iter: Iterable[A]): this.type = { 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.
- * @throws Predef.IndexOutOfBoundsException if <code>n</code> is out of bounds.
- */
- def insertAll(n: Int, iter: Iterable[A]) {
- if ((n < 0) || (n > size0))
- throw new IndexOutOfBoundsException(n.toString)
- val xs = iter.elements.toList
- val len = xs.length
- ensureSize(size0 + len)
- copy(n, n + len, size0 - n)
- xs.copyToArray(array.asInstanceOf[scala.Array[Any]], n)
- size0 += len
- }
-
- /** Removes the element on a given index position. It takes time linear in
- * the buffer size.
- *
- * @param n the index which refers to the first element to delete.
- * @param count the number of elemenets to delete
- * @return the updated array buffer.
- * @throws Predef.IndexOutOfBoundsException if <code>n</code> is out of bounds.
- */
- def remove(n: Int, count: Int) {
- if ((n < 0) || (n >= size0))
- throw new IndexOutOfBoundsException(n.toString)
- copy(n + count, n, size0 - (n + count))
- size0 -= count
- }
-
- /** Return a clone of this buffer.
- *
- * @return an <code>ArrayBuffer</code> with the same elements.
- */
- override def clone(): Buffer[A] = new ArrayBuffer[A] ++ this
-
- def result: ArrayBuffer[A] = this
-
- /** Defines the prefix of the string representation.
- */
- override def stringPrefix: String = "ArrayBuffer"
-}
diff --git a/src/library/scalax/collection/mutable/Buffer.scala b/src/library/scalax/collection/mutable/Buffer.scala
deleted file mode 100644
index 3d0eaec84e..0000000000
--- a/src/library/scalax/collection/mutable/Buffer.scala
+++ /dev/null
@@ -1,274 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Buffer.scala 15799 2008-08-15 18:23:54Z odersky $
-
-
-package scalax.collection.mutable
-
-import generic._
-
-/* Factory object for `Buffer` trait */
-object Buffer extends SequenceFactory[Buffer] {
- def apply[A](args: A*): Buffer[A] = ArrayBuffer.apply(args: _*)
-}
-
-/** Buffers are used to create sequences of elements incrementally by
- * appending, prepending, or inserting new elements. It is also
- * possible to access and modify elements in a random access fashion
- * via the index of the element in the current sequence.
- *
- * @author Matthias Zenger
- * @author Martin Odersky
- * @version 2.8
- */
-@cloneable
-trait Buffer[A] extends Sequence[A]
- with SequenceTemplate[Buffer, A]
- with Addable[Buffer[A], A]
- with Subtractable[Buffer[A], A]
- with Growable[A]
- with Shrinkable[A]
-// with Scriptable[Message[(Location, A)]]
- with Cloneable[Buffer[A]]
-{
-
-// Abstract methods from Vector:
-
- /** Return element at index `n`
- * @throws IndexOutofBoundsException if the index is not valid
- */
- def apply(n: Int): A
-
- /** 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.
- * @throws IndexOutofBoundsException if the index is not valid
- */
- def update(n: Int, newelem: A): Unit
-
- /** Return number of elements in the buffer
- */
- def length: Int
-
- /** Create a new buffer of the same kind as this one */
- def newBuilder[B]: Builder[Buffer, B] = new ArrayBuffer[B]
-
- override def newBuilder[B](sizeHint: Int): Builder[Buffer, B] =
- new ArrayBuffer[B](sizeHint)
-
-// Abstract methods from Appendable
-
- /** Append a single element to this buffer.
- *
- * @param elem the element to append.
- */
- def +=(elem: A): Unit
-
- /** Clears the buffer contents.
- */
- def clear()
-
-// Abstract methods new in this class
-
- /** Prepend a single element to this buffer and return
- * the identity of the buffer.
- * @param elem the element to prepend.
- */
- def +:(elem: A): this.type
-
- /** Append a single element to this buffer and return the identity of the buffer
- */
- def +(elem: A): this.type = { +=(elem); 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.
- * @throws IndexOutofBoundsException if the index is not valid
- */
- def insertAll(n: Int, iter: Iterable[A]): Unit
-
- /** Removes a number of elements from a given index position.
- *
- * @param n the index which refers to the element to delete.
- * @param count the number of elements to delete
- * @throws IndexOutofBoundsException if the index is not valid
- */
- def remove(n: Int, count: Int): Unit
-
-// Concrete methods
-
- /** Removes the element on a given index position.
- *
- * @param n the index which refers to the element to delete.
- */
- def remove(n: Int): A = {
- val elem = this(n)
- remove(n, 1)
- elem
- }
-
- /** Removes a single element from this buffer, at its first occurrence.
- * If the buffer does not contain that element, it is unchanged.
- *
- * @param x the element to remove.
- */
- def -= (x: A) {
- val i = indexOf(x)
- if (i != -1) remove(i)
- }
-
- /** Removes a single element from this buffer and returns the identity
- * of the buffer. If the buffer does not contain that element, it is unchanged.
- *
- * @param x the element to remove.
- */
- def -(elem: A): this.type = { -=(elem); this }
-
- /** Prepend two ore more elements to this buffer and return
- * the identity of the buffer.
- * @param elem the element to prepend.
- */
- def +:(elem1: A, elem2: A, elems: A*): this.type =
- elem1 +: elem2 +: (elems.asInstanceOf[Iterable[A]]) ++: 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 ++:(iter: Iterable[A]): this.type = { for (x <- iter) x +: this; this }
-
- /** Prepends a number of elements provided by an iterator
- * The identity of the buffer is returned.
- *
- * @param iter the iterator
- * @return the updated buffer.
- */
- def ++:(iter: Iterator[A]): this.type = { for (x <- iter) x +: this; this }
-
- /** Appends a elements to this buffer.
- *
- * @param elems the elements to append.
- */
- def append(elems: A*) { this ++= elems.asInstanceOf[Iterable[A]] } // !@!
-
- /** 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]) { this ++= iter }
-
- /** Prepend given elements to this list.
- *
- * @param elem the element to prepend.
- */
- def prepend(elems: A*) { elems.asInstanceOf[Iterable[A]] ++: 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(iter: Iterable[A]) { iter ++: 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(iter: Iterator[A]) { 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 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*) { insertAll(n, elems.asInstanceOf[Iterable[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) { remove(0, n) }
-
- /** 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) { remove(length - n max 0, n) }
-
- /** Send a message to this scriptable object.
- *
- * @param cmd the message to send.
- * !!!! todo: rewrite location, msg etc with enumerations or else pack in a subpackage
- def <<(cmd: Message[(Location, A)]) {
- cmd match {
- case Include((l, elem)) => l match {
- case Start => prepend(elem)
- case End => append(elem)
- case Index(n) => insert(n, elem)
- case _ => throw new UnsupportedOperationException("message " + cmd + " not understood")
- }
- case Update((l, elem)) => l match {
- case Start => update(0, elem)
- case End => update(length - 1, elem)
- case Index(n) => update(n, elem)
- case _ => throw new UnsupportedOperationException("message " + cmd + " not understood")
- }
- case Remove((l, _)) => l match {
- case Start => remove(0)
- case End => remove(length - 1)
- case Index(n) => remove(n)
- case _ => throw new UnsupportedOperationException("message " + cmd + " not understood")
- }
- case Reset() => clear
- case s: Script[_] => s.elements foreach <<
- case _ => throw new UnsupportedOperationException("message " + cmd + " not understood")
- }
- }
- */
-
- /** Defines the prefix of the string representation.
- */
- override def stringPrefix: String = "Buffer"
-
- /** Adds a number of elements in an array
- *
- * @param src the array
- * @param start the first element to append
- * @param len the number of elements to append
- * @deprecated replace by: <code>buf ++= src.view(start, end)</code>
- */
- @deprecated def ++=(src: Array[A], start: Int, len: Int) {
- var i = start
- val end = i + len
- while (i < end) {
- this += src(i)
- i += 1
- }
- }
-
-}
-
-
-
-
diff --git a/src/library/scalax/collection/mutable/DefaultEntry.scala b/src/library/scalax/collection/mutable/DefaultEntry.scala
deleted file mode 100644
index 2fb0f62226..0000000000
--- a/src/library/scalax/collection/mutable/DefaultEntry.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: DefaultEntry.scala 16893 2009-01-13 13:09:22Z cunei $
-
-
-package scalax.collection.mutable
-
-@serializable
-final class DefaultEntry[A, B](val key: A, var value: B)
- extends HashEntry[A, DefaultEntry[A, B]]
diff --git a/src/library/scalax/collection/mutable/DefaultMapModel.scala b/src/library/scalax/collection/mutable/DefaultMapModel.scala
deleted file mode 100644
index fda7798e26..0000000000
--- a/src/library/scalax/collection/mutable/DefaultMapModel.scala
+++ /dev/null
@@ -1,44 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: DefaultMapModel.scala 16893 2009-01-13 13:09:22Z cunei $
-
-
-package scalax.collection.mutable
-
-/** This class is used internally. It implements the mutable <code>Map</code>
- * class in terms of three functions: <code>findEntry</code>,
- * <code>addEntry</code>, and <code>entries</code>.
- *
- * @author Matthias Zenger
- * @version 1.0, 08/07/2003
- */
-trait DefaultMapModel[A, B] extends Map[A, B] {
-
- type Entry = DefaultEntry[A, B]
-
- protected def findEntry(key: A): Entry
- protected def addEntry(e: Entry)
- protected def entries: Iterator[Entry]
-
- def get(key: A): Option[B] = {
- val e = findEntry(key)
- if (e == null) None
- else Some(e.value);
- }
-
- def update(key: A, value: B): this.type = {
- val e = findEntry(key)
- if (e == null) addEntry(new Entry(key, value))
- else e.value = value
- this
- }
-
- def elements = entries map {e => (e.key, e.value)}
-}
-
diff --git a/src/library/scalax/collection/mutable/FlatHashTable.scala b/src/library/scalax/collection/mutable/FlatHashTable.scala
deleted file mode 100644
index c8fe2cede3..0000000000
--- a/src/library/scalax/collection/mutable/FlatHashTable.scala
+++ /dev/null
@@ -1,164 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: FlatHashTable.scala 16893 2009-01-13 13:09:22Z cunei $
-
-package scalax.collection.mutable
-
-trait FlatHashTable[A] {
-
- /** The load factor for the hash table; must be < 500 (0.5)
- */
- protected def loadFactor: Int = 450
- protected final def loadFactorDenum = 1000
-
- /** The initial size of the hash table.
- */
- protected def initialSize: Int = 16
-
- private final val tableDebug = false
-
- /** The actual hash table.
- */
- protected var table: scala.Array[AnyRef] =
- if (initialSize == 0) null else new scala.Array(initialSize)
-
- /** The number of mappings contained in this hash table.
- */
- protected var tableSize = 0
-
- /** The next size value at which to resize (capacity * load factor).
- */
- protected var threshold: Int = newThreshold(initialSize)
-
- /** Returns the number of entires in this hash table.
- */
- def size: Int = tableSize
-
- def findEntry(elem: A): Option[A] = {
- var h = index(elemHashCode(elem))
- var entry = table(h)
- while (null != entry && entry != elem) {
- h = (h + 1) % table.length
- entry = table(h)
- }
- if (null == entry) None else Some(entry.asInstanceOf[A])
- }
-
- def containsEntry(elem: A): Boolean = {
- var h = index(elemHashCode(elem))
- var entry = table(h)
- while (null != entry && entry != elem) {
- h = (h + 1) % table.length
- entry = table(h)
- }
- null != entry
- }
-
- def addEntry(elem: A) : Boolean = {
- var h = index(elemHashCode(elem))
- var entry = table(h)
- while (null != entry) {
- if (entry == elem) return false
- h = (h + 1) % table.length
- entry = table(h)
- }
- table(h) = elem.asInstanceOf[AnyRef]
- tableSize = tableSize + 1
- if (tableSize >= threshold) growTable()
- true
- }
-
- def removeEntry(elem: A) : Option[A] = {
- if (tableDebug) checkConsistent()
- def precedes(i: Int, j: Int) = {
- val d = table.length >> 1
- if (i <= j) j - i < d
- else i - j > d
- }
- var h = index(elemHashCode(elem))
- var entry = table(h)
- while (null != entry) {
- if (entry == elem) {
- var h0 = h
- var h1 = (h0 + 1) % table.length
- while (null != table(h1)) {
- val h2 = index(elemHashCode(table(h1).asInstanceOf[A]))
- //Console.println("shift at "+h1+":"+table(h1)+" with h2 = "+h2+"? "+(h2 != h1)+precedes(h2, h0)+table.length)
- if (h2 != h1 && precedes(h2, h0)) {
- //Console.println("shift "+h1+" to "+h0+"!")
- table(h0) = table(h1)
- h0 = h1
- }
- h1 = (h1 + 1) % table.length
- }
- table(h0) = null
- tableSize -= 1
- if (tableDebug) checkConsistent()
- return Some(entry.asInstanceOf[A])
- }
- h = (h + 1) % table.length
- entry = table(h)
- }
- None
- }
-
- def elements = new Iterator[A] {
- private var i = 0
- def hasNext: Boolean = {
- while (i < table.length && (null == table(i))) i += 1;
- i < table.length
- }
- def next(): A =
- if (hasNext) { i += 1; table(i - 1).asInstanceOf[A] }
- else Iterator.empty.next
- }
-
- private def growTable() {
- val oldtable = table
- table = new scala.Array[AnyRef](table.length * 2)
- tableSize = 0
- threshold = newThreshold(table.length)
- var i = 0
- while (i < oldtable.length) {
- val entry = oldtable(i)
- if (null != entry) addEntry(entry.asInstanceOf[A])
- i += 1
- }
- if (tableDebug) checkConsistent()
- }
-
- private def checkConsistent() {
- for (i <- 0 until table.length)
- if (table(i) != null && !containsEntry(table(i).asInstanceOf[A]))
- assert(false, i+" "+table(i)+" "+table.toString)
- }
-
- protected def elemHashCode(elem: A) = elem.hashCode()
-
- protected final def improve(hcode: Int) = {
- var h: Int = hcode + ~(hcode << 9)
- h = h ^ (h >>> 14)
- h = h + (h << 4)
- h ^ (h >>> 10)
- }
-
- protected final def index(hcode: Int) = improve(hcode) & (table.length - 1)
-
- private def newThreshold(size: Int) = {
- val lf = loadFactor
- assert(lf < (loadFactorDenum / 2), "loadFactor too large; must be < 0.5")
- (size.toLong * lf / loadFactorDenum ).toInt
- }
-
- protected def clear() {
- var i = table.length - 1
- while (i >= 0) { table(i) = null; i -= 1 }
- tableSize = 0
- }
-}
diff --git a/src/library/scalax/collection/mutable/HashMap.scala b/src/library/scalax/collection/mutable/HashMap.scala
deleted file mode 100644
index 4d3342636c..0000000000
--- a/src/library/scalax/collection/mutable/HashMap.scala
+++ /dev/null
@@ -1,43 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: HashMap.scala 16893 2009-01-13 13:09:22Z cunei $
-
-
-package scalax.collection.mutable
-
-import generic._
-
-/** This class implements mutable maps using a hashtable.
- *
- * @author Matthias Zenger
- * @author Martin Odersky
- * @version 2.8
- */
-object HashMap extends MapFactory[HashMap] {
-
- /** The empty map of this type */
- def empty[A, B] = new HashMap[A, B]
-
-}
-
-@serializable
-class HashMap[A, B]
- extends Map[A, B]
- with MapTemplate[A, B, HashMap]
- with HashTable[A]
- with DefaultMapModel[A, B] {
-
- def empty[B] = HashMap.empty[A, B]
-
- def -= (key: A) { removeEntry(key) }
-
- override def clear() = super.clear()
-
- override def clone(): Map[A, B] = new HashMap[A, B] ++ this
-}
diff --git a/src/library/scalax/collection/mutable/HashSet.scala b/src/library/scalax/collection/mutable/HashSet.scala
deleted file mode 100644
index 601d0885c0..0000000000
--- a/src/library/scalax/collection/mutable/HashSet.scala
+++ /dev/null
@@ -1,48 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: HashSet.scala 16893 2009-01-13 13:09:22Z cunei $
-
-
-package scalax.collection.mutable
-
-import generic.{SetTemplate, SetFactory, AddableBuilder}
-
-/** Factory object for `HashSet` class */
-object HashSet extends SetFactory[HashSet] {
- /** The empty set of this type */
- def empty[A] = new HashSet[A]
-}
-
-/** This class implements mutable sets using a hashtable.
- *
- * @author Matthias Zenger
- * @author Martin Odersky
- * @version 2.0, 31/12/2006
- */
-@serializable
-class HashSet[A]
- extends Set[A]
- with SetTemplate[HashSet, A]
- with FlatHashTable[A] {
-
- def contains(elem: A): Boolean = containsEntry(elem)
-
- def +=(elem: A) { addEntry(elem) }
-
- def -=(elem: A) { removeEntry(elem) }
-
- override def clear() = super.clear()
-
- override def newBuilder[B]: generic.Builder[HashSet, B] =
- new AddableBuilder[HashSet, B](HashSet.empty)
-
- override def clone(): HashSet[A] = new HashSet[A] ++ this
-}
-
-
diff --git a/src/library/scalax/collection/mutable/HashTable.scala b/src/library/scalax/collection/mutable/HashTable.scala
deleted file mode 100644
index 73ff61f3df..0000000000
--- a/src/library/scalax/collection/mutable/HashTable.scala
+++ /dev/null
@@ -1,172 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://www.scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: HashTable.scala 16884 2009-01-09 16:52:09Z cunei $
-
-
-package scalax.collection.mutable
-
-/** This class can be used to construct data structures that are based
- * on hashtables. Class <code>HashTable[A]</code> implements a hashtable
- * that maps keys of type <code>A</code> to values of the fully abstract
- * member type <code>Entry</code>. Classes that make use of <code>HashTable</code>
- * have to provide an implementation for <code>Entry</code>
- *
- * There are mainly two parameters that affect the performance of a hashtable:
- * the <i>initial size</i> and the <i>load factor</i>. The <i>size</i>
- * refers to the number of <i>buckets</i> in the hashtable, and the <i>load
- * factor</i> is a measure of how full the hashtable is allowed to get before
- * its size is automatically doubled. Both parameters may be changed by
- * overriding the corresponding values in class <code>HashTable</code>.
- *
- * @author Matthias Zenger
- * @author Martin Odersky
- * @version 2.0, 31/12/2006
- */
-trait HashTable[A] extends AnyRef {
-
- protected type Entry >: Null <: HashEntry[A, Entry]
-
- /** The load factor for the hash table (in 0.001 step).
- */
- protected def loadFactor: Int = 750 // corresponds to 75%
- protected final val loadFactorDenum = 1000;
-
- /** The initial size of the hash table.
- */
- protected def initialSize: Int = 16
-
- /** The initial threshold
- */
- protected def initialThreshold: Int = newThreshold(initialSize)
-
- /** The actual hash table.
- */
- protected var table: scala.Array[HashEntry[A, Entry]] =
- if (initialSize == 0) null else new scala.Array(initialSize)
-
- /** The number of mappings contained in this hash table.
- */
- protected var tableSize: Int = 0
-
- /** The next size value at which to resize (capacity * load factor).
- */
- protected var threshold: Int = initialThreshold
-
- /** Returns the size of this hash table.
- */
- def size = tableSize
-
- protected def findEntry(key: A): Entry = {
- val h = index(elemHashCode(key))
- var e = table(h).asInstanceOf[Entry]
- while (e != null && !elemEquals(e.key, key)) e = e.next
- e
- }
-
- protected def addEntry(e: Entry) {
- val h = index(elemHashCode(e.key))
- e.next = table(h).asInstanceOf[Entry]
- table(h) = e
- tableSize = tableSize + 1
- if (tableSize > threshold)
- resize(2 * table.length)
- }
-
- protected def removeEntry(key: A) : Option[Entry] = {
- val h = index(elemHashCode(key))
- var e = table(h).asInstanceOf[Entry]
- if (e != null) {
- if (elemEquals(e.key, key)) {
- table(h) = e.next
- tableSize = tableSize - 1
- return Some(e)
- } else {
- var e1 = e.next
- while (e1 != null && !elemEquals(e1.key, key)) {
- e = e1
- e1 = e1.next
- }
- if (e1 != null) {
- e.next = e1.next
- tableSize = tableSize - 1
- return Some(e1)
- }
- }
- }
- None
- }
-
- protected def entries: Iterator[Entry] = new Iterator[Entry] {
- val iterTable = table
- var idx = table.length - 1
- var es = iterTable(idx).asInstanceOf[Entry]
- scan()
- def hasNext = es != null
- def next = {
- val res = es
- es = es.next
- scan()
- res
- }
- def scan() {
- while (es == null && idx > 0) {
- idx = idx - 1
- es = iterTable(idx).asInstanceOf[Entry]
- }
- }
- }
-
- def clear() {
- var i = table.length - 1
- while (i >= 0) { table(i) = null; i = i - 1 }
- tableSize = 0
- }
-
- private def newThreshold(size: Int) =
- ((size.toLong * loadFactor)/loadFactorDenum).toInt
-
- private def resize(newSize: Int) = {
- val oldTable = table
- table = new scala.Array(newSize)
- var i = oldTable.length - 1
- while (i >= 0) {
- var e = oldTable(i)
- while (e != null) {
- val h = index(elemHashCode(e.key))
- val e1 = e.next
- e.next = table(h).asInstanceOf[Entry]
- table(h) = e
- e = e1
- }
- i = i - 1
- }
- threshold = newThreshold(newSize)
- }
-
- protected def elemEquals(key1: A, key2: A): Boolean = (key1 == key2)
-
- protected def elemHashCode(key: A) = key.hashCode()
-
- protected final def improve(hcode: Int) = {
- var h: Int = hcode + ~(hcode << 9)
- h = h ^ (h >>> 14)
- h = h + (h << 4)
- h ^ (h >>> 10)
- }
-
- protected final def index(hcode: Int) = improve(hcode) & (table.length - 1)
-}
-
-trait HashEntry[A, E] {
- val key: A
- var next: E = _
-}
-
-
-
diff --git a/src/library/scalax/collection/mutable/Iterable.scala b/src/library/scalax/collection/mutable/Iterable.scala
deleted file mode 100755
index 0872c3c549..0000000000
--- a/src/library/scalax/collection/mutable/Iterable.scala
+++ /dev/null
@@ -1,32 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
-
-package scalax.collection.mutable
-
-import generic._
-
-/** Collection classes mixing in this class provide a method
- * <code>elements</code> which returns an iterator over all the
- * elements contained in the collection.
- *
- * @note If a collection has a known <code>size</code>, it should also sub-type <code>SizedIterable</code>.
- *
- * @author Matthias Zenger
- * @autor Martin Odersky
- * @owner Martin Odersky
- * @version 2.8
- */
-trait Iterable[A] extends collection.Iterable[A] with IterableTemplate[Iterable, A]
-
-/* Factory object for `Iterable` class */
-object Iterable extends IterableFactory[Iterable] {
- /** The empty iterable */
- def apply[A](args: A*): Iterable[A] = ArrayBuffer.apply(args: _*) // !!! swicth to Array?
-}
diff --git a/src/library/scalax/collection/mutable/ListBuffer.scala b/src/library/scalax/collection/mutable/ListBuffer.scala
deleted file mode 100644
index faf897aef2..0000000000
--- a/src/library/scalax/collection/mutable/ListBuffer.scala
+++ /dev/null
@@ -1,314 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: ListBuffer.scala 14378 2008-03-13 11:39:05Z dragos $
-
-
-package scalax.collection.mutable
-
-import generic._
-import immutable.List
-import collection.immutable.{List, Nil, ::}
-
-/* Factory object for `ListBuffer` class */
-object ListBuffer extends SequenceFactory[ListBuffer] {
- def apply[A](args: A*): ListBuffer[A] = new ListBuffer[A]
-}
-
-/** A Buffer implementation back up by a list. It provides constant time
- * prepend and append. Most other operations are linear.
- *
- * @author Matthias Zenger
- * @author Martin Odersky
- * @version 2.8
- */
-@serializable
-final class ListBuffer[A]
- extends Buffer[A]
- with SequenceTemplate[ListBuffer, A]
- with Addable[ListBuffer[A], A]
- with Subtractable[ListBuffer[A], A]
- with Builder[List, A]
- with SequenceForwarder[A]
-{
- import collection.immutable.Sequence
-
- private var start: List[A] = Nil
- private var last0: ::[A] = _
- private var exported: Boolean = false
- private var len = 0
-
- protected def underlying: Sequence[A] = start
-
- override def newBuilder[B]: Builder[ListBuffer, B] =
- new AddableBuilder[ListBuffer, B](new ListBuffer[B]) // !!! Adriaan: inference failure here
-
- /** The current length of the buffer
- */
- override def length = len
-
- // Implementations of abstract methods in Buffer
-
- /** Replaces element at index <code>n</code> with the new element
- * <code>newelem</code>. Takes time linear in the buffer size. (except the first
- * element, which is updated in constant time).
- *
- * @param n the index of the element to replace.
- * @param x the new element.
- * @throws Predef.IndexOutOfBoundsException if <code>n</code> is out of bounds.
- */
- def update(n: Int, x: A) {
- try {
- if (exported) copy()
- if (n == 0) {
- val newElem = new :: (x, start.tail);
- if (last0 eq start) {
- last0 = newElem
- len += 1
- }
- start = newElem
- } else {
- var cursor = start
- var i = 1
- while (i < n) {
- cursor = cursor.tail
- i += 1
- }
- val newElem = new :: (x, cursor.tail.tail)
- if (last0 eq cursor.tail) {
- last0 = newElem
- len += 1
- }
- cursor.asInstanceOf[::[A]].tl = newElem
- }
- } catch {
- case ex: Exception => throw new IndexOutOfBoundsException(n.toString())
- }
- }
-
- /** Appends a single element to this buffer. This operation takes constant time.
- *
- * @param x the element to append.
- */
- def += (x: A) {
- if (exported) copy()
- if (start.isEmpty) {
- last0 = new :: (x, Nil)
- start = last0
- } else {
- val last1 = last0
- last0 = new :: (x, Nil)
- last1.tl = last0
- }
- len += 1
- }
-
- /** Clears the buffer contents.
- */
- def clear() {
- start = Nil
- exported = false
- len = 0
- }
-
- /** Prepends a single element to this buffer. This operation takes constant
- * time.
- *
- * @param x the element to prepend.
- * @return this buffer.
- */
- def +: (x: A): this.type = {
- if (exported) copy()
- val newElem = new :: (x, start)
- if (start.isEmpty) last0 = newElem
- start = newElem
- len += 1
- 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 new
- * 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.
- * @throws Predef.IndexOutOfBoundsException if <code>n</code> is out of bounds.
- */
- def insertAll(n: Int, iter: Iterable[A]) {
- try {
- if (exported) copy()
- var elems = iter.elements.toList.reverse
- len += elems.length
- if (n == 0) {
- while (!elems.isEmpty) {
- val newElem = new :: (elems.head, start)
- if (start.isEmpty) last0 = newElem
- start = newElem
- elems = elems.tail
- }
- } else {
- var cursor = start
- var i = 1
- while (i < n) {
- cursor = cursor.tail
- i += 1
- }
- while (!elems.isEmpty) {
- val newElem = new :: (elems.head, cursor.tail)
- if (cursor.tail.isEmpty) last0 = newElem
- cursor.asInstanceOf[::[A]].tl = newElem
- elems = elems.tail
- }
- }
- } catch {
- case ex: Exception =>
- throw new IndexOutOfBoundsException(n.toString())
- }
- }
-
- /** Removes a given number of elements on a given index position. May take time linear in
- * the buffer size.
- *
- * @param n the index which refers to the first element to remove.
- * @param count the number of elements to remove.
- */
- def remove(n: Int, count: Int) {
- if (exported) copy()
- val n1 = n max 0
- val count1 = count min (len - n1)
- var old = start.head;
- if (n1 == 0) {
- var c = count1
- while (c > 0) {
- start = start.tail
- c -= 1
- }
- } else {
- var cursor = start
- var i = 1
- while (i < n1) {
- cursor = cursor.tail
- i += 1
- }
- var c = count1
- while (c > 0) {
- if (last0 eq cursor.tail) last0 = cursor.asInstanceOf[::[A]]
- cursor.asInstanceOf[::[A]].tl = cursor.tail.tail
- c -= 1
- }
- }
- len -= count1
- }
-
-// Implementation of abstract method in Builder
-
- def result = toList
-
- /** Converts this buffer to a list. Takes constant time. The buffer is
- * copied lazily, the first time it is mutated.
- */
- override def toList: List[A] = {
- exported = !start.isEmpty
- start
- }
-
-// New methods in ListBuffer
-
- /** Prepends the elements of this buffer to a given list
- *
- * @param xs the list to which elements are prepended
- */
- def prependToList(xs: List[A]): List[A] =
- if (start.isEmpty) xs
- else { last0.tl = xs; toList }
-
-// Overrides of methods in Buffer
-
- /** Removes the element on a given index position. May take time linear in
- * the buffer size
- *
- * @param n the index which refers to the element to delete.
- * @return n the element that was formerly at position <code>n</code>.
- * @pre an element exists at position <code>n</code>
- * @throws Predef.IndexOutOfBoundsException if <code>n</code> is out of bounds.
- */
- override def remove(n: Int): A = try {
- if (n < 0 || n >= len) throw new IndexOutOfBoundsException(n.toString())
- if (exported) copy()
- var old = start.head;
- if (n == 0) {
- start = start.tail
- } else {
- var cursor = start
- var i = 1
- while (i < n) {
- cursor = cursor.tail
- i += 1
- }
- old = cursor.tail.head
- if (last0 eq cursor.tail) last0 = cursor.asInstanceOf[::[A]]
- cursor.asInstanceOf[::[A]].tl = cursor.tail.tail
- }
- len -= 1
- old
- }
-
- /** Remove a single element from this buffer. May take time linear in the buffer size.
- *
- * @param x the element to remove.
- */
- override def -= (elem: A) {
- if (exported) copy()
- if (start.isEmpty) {}
- else if (start.head == elem) {
- start = start.tail
- len -= 1
- } else {
- var cursor = start
- while (!cursor.tail.isEmpty && cursor.tail.head != elem) {
- cursor = cursor.tail
- }
- if (!cursor.tail.isEmpty) {
- val z = cursor.asInstanceOf[::[A]]
- if (z.tl == last0)
- last0 = z
- z.tl = cursor.tail.tail
- len -= 1
- }
- }
- }
-
- /** expose the underlying list but do not mark it as exported */
- def readOnly: List[A] = start
-
- // Private methods
-
- /** Copy contents of this buffer */
- private def copy() {
- var cursor = start
- val limit = last0.tail
- clear
- while (cursor ne limit) {
- this += cursor.head
- cursor = cursor.tail
- }
- }
-
- /** Returns a clone of this buffer.
- *
- * @return a <code>ListBuffer</code> with the same elements.
- */
- override def clone(): Buffer[A] = (new ListBuffer[A]) ++ this
-
- /** Defines the prefix of the string representation.
- *
- * @return the string representation of this buffer.
- */
- override def stringPrefix: String = "ListBuffer"
-}
-
diff --git a/src/library/scalax/collection/mutable/Map.scala b/src/library/scalax/collection/mutable/Map.scala
deleted file mode 100755
index 82fb6a5680..0000000000
--- a/src/library/scalax/collection/mutable/Map.scala
+++ /dev/null
@@ -1,73 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Map.scala 16884 2009-01-09 16:52:09Z cunei $
-
-
-package scalax.collection.mutable
-
-import generic._
-
-/* Factory object for `Map` class */
-object Map extends MapFactory[Map] {
- def empty[A, B]: Map[A, B] = new HashMap[A, B]
-}
-
-trait Map[A, B]
- extends collection.Map[A, B]
- with MapTemplate[A, B, Map]
- with Growable[(A, B)]
- with Shrinkable[A]
- with Cloneable[Map[A, B]] {
-self =>
-
- /** This method allows one to add a new mapping from <code>key</code>
- * to <code>value</code> to the map. If the map already contains a
- * mapping for <code>key</code>, it will be overridden by this
- * function.
- *
- * @param key The key to update
- * @param value The new value
- */
- def update(key: A, value: B): this.type
-
- /** Add a key/value pair to this map.
- * @param kv the key/value pair.
- */
- def += (kv: (A, B)) { update(kv._1, kv._2) }
-
- /** Remove a key from this map, noop if key is not present.
- * @param key the key to be removed
- */
- def -= (key: A)
-
- def -(key: A): this.type = { -=(key); this }
-
- /** Removes all elements from the set for
- * which the predicate <code>p</code> yields the value <code>false</code>.
- */
- def retain(p: A => Boolean): Unit = for ((k, v) <- this) if (!p(k)) -=(k)
-
- /** Removes all elements from the set. After this operation is completed,
- * the set will be empty.
- */
- def clear() { for ((k, v) <- elements) -=(k) }
-
- override def clone(): Map[A, B] = empty[B] ++ this
-
- /** Return a read-only projection of this set !!! just us an (immutable) setProxy? */
- def readOnly : collection.Map[A, B] = new collection.Map[A, B] {
- override def size = self.size
- override def update(key: A, value: B) = self.update(key, value)
- override def - (elem: A) = self - elem
- override def elements = self.elements
- override def foreach(f: ((A, B)) => Unit) = self.foreach(f)
- override def empty[C] = self.empty[C]
- def get(key: A) = self.get(key)
- }
-}
diff --git a/src/library/scalax/collection/mutable/OrderedIterable.scala b/src/library/scalax/collection/mutable/OrderedIterable.scala
deleted file mode 100755
index 90ef8018c7..0000000000
--- a/src/library/scalax/collection/mutable/OrderedIterable.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
-
-package scalax.collection.mutable
-
-import generic._
-
-trait OrderedIterable[A] extends Iterable[A] with collection.OrderedIterable[A] with OrderedIterableTemplate[OrderedIterable, A]
-
-/* Factory object for `OrderedIterable` class */
-object OrderedIterable extends IterableFactory[OrderedIterable] {
- /** The empty iterable */
- def apply[A](args: A*): OrderedIterable[A] = ArrayBuffer.apply(args: _*) // !!! swicth to Array?
-}
-
diff --git a/src/library/scalax/collection/mutable/ResizableArray.scala b/src/library/scalax/collection/mutable/ResizableArray.scala
deleted file mode 100644
index 11c3659712..0000000000
--- a/src/library/scalax/collection/mutable/ResizableArray.scala
+++ /dev/null
@@ -1,108 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: ResizableArray.scala 15407 2008-06-20 09:26:36Z stepancheg $
-
-
-package scalax.collection.mutable
-
-/** This class is used internally to implement data structures that
- * are based on resizable arrays.
- *
- * @author Matthias Zenger, Burak Emir
- * @version 1.0, 03/05/2004
- */
-trait ResizableArray[A] extends Vector[A] {
-
- import scala.Array // !!!
-
- protected def initialSize: Int = 16
- protected var array: Array[AnyRef] = new Array[AnyRef](initialSize min 1)
-
- protected var size0: Int = 0
-
- //##########################################################################
- // implement/override methods of Vector[A]
-
- /** Returns the length of this resizable array.
- */
- def length: Int = size0
-
- def apply(idx: Int) = {
- if (idx >= size0) throw new IndexOutOfBoundsException(idx.toString)
- array(idx).asInstanceOf[A]
- }
-
- def update(idx: Int, elem: A) {
- if (idx >= size0) throw new IndexOutOfBoundsException(idx.toString)
- array(idx) = elem.asInstanceOf[AnyRef]
- }
-
- /** Fills the given array <code>xs</code> with the elements of
- * this sequence starting at position <code>start</code>.
- *
- * @param xs the array to fill.
- * @param start starting index.
- */
- override def copyToArray[B >: A](xs: Array[B], start: Int) {
- Array.copy(array, 0, xs, start, size0)
- }
-
- /** Copy all elements to a buffer
- * @param The buffer to which elements are copied
- */
- override def copyToBuffer[B >: A](dest: Buffer[B]) {
- dest ++= array.asInstanceOf[Iterable[A]] // !@!
- }
-
- override def foreach(f: A => Unit) {
- var i = 0
- while (i < size) {
- f(array(i).asInstanceOf[A])
- i += 1
- }
- }
-
- //##########################################################################
-
- /** remove elements of this array at indices after <code>sz</code>
- */
- def reduceToSize(sz: Int) {
- require(sz <= size0)
- while (size0 > sz) {
- size0 -= 1
- array(size0) = null
- }
- }
-
- /** ensure that the internal array has at n cells */
- protected def ensureSize(n: Int) {
- if (n > array.length) {
- var newsize = array.length * 2
- while (n > newsize)
- newsize = newsize * 2
- val newar: Array[AnyRef] = new Array(newsize)
- Array.copy(array, 0, newar, 0, size0)
- array = newar
- }
- }
-
- /** Swap two elements of this array.
- */
- protected def swap(a: Int, b: Int) {
- 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) {
- Array.copy(array, m, array, n, len)
- }
-}
diff --git a/src/library/scalax/collection/mutable/Sequence.scala b/src/library/scalax/collection/mutable/Sequence.scala
deleted file mode 100755
index c4d72231d5..0000000000
--- a/src/library/scalax/collection/mutable/Sequence.scala
+++ /dev/null
@@ -1,23 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
-
-package scalax.collection.mutable
-
-import generic._
-
-trait Sequence[A] extends OrderedIterable[A] with collection.Sequence[A] with SequenceTemplate[Sequence, A]
-
-/* Factory object for `Sequence` class */
-object Sequence extends SequenceFactory[Sequence] {
- /** The empty sequence */
- def apply[A](args: A*): Sequence[A] = ArrayBuffer.apply(args: _*) // !!! swicth to Array?
-}
-
-
diff --git a/src/library/scalax/collection/mutable/Set.scala b/src/library/scalax/collection/mutable/Set.scala
deleted file mode 100644
index 78f3234336..0000000000
--- a/src/library/scalax/collection/mutable/Set.scala
+++ /dev/null
@@ -1,119 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ 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.mutable
-
-import collection.generic._
-
-/** The canonical factory methods for <a href="Set.html">mutable sets</a>.
- * Currently these return <a href="HashSet.html">HashSet's</a>.
- */
-object Set extends generic.SetFactory[Set] {
- /** The empty map of this type; this is implemented as a hashtable */
- def empty[A]: Set[A] = new HashSet[A]
-}
-
-/** This class represents mutable sets. Concrete set implementations
- * just have to provide functionality for the abstract methods in
- * <a href="../Set.html" target="contentFrame">
- * <code>scala.collection.Set</code></a> as well as for <code>+=</code>,
- * <code>-= and <code>clear</code>.
- *
- * @author Matthias Zenger
- * @author Martin Odersky
- * @version 2.8
- */
-trait Set[A] extends collection.Set[A]
- with SetTemplate[Set, A]
- with Addable[Set[A], A]
- with Subtractable[Set[A], A]
- with Growable[A]
- with Shrinkable[A]
- with Cloneable[Set[A]] {
-self =>
-
- /** 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) {
- if (included) this += elem else this -= elem
- }
-
- /** Adds a new element to the set.
- *
- * @param elem the element to be added
- */
- def +=(elem: A)
-
- /** Removes a single element from a set.
- * @param elem The element to be removed.
- */
- def -=(elem: A)
-
- /** Adds a new element to the set and returns the set itself.
- *
- * @param elem the element to be added
- */
- def +(elem: A): this.type = { +=(elem); this }
-
- /** Removed a new element from the set and returns the set itself.
- *
- * @param elem the element to be added
- */
- def -(elem: A): this.type = { -=(elem); this }
-
- /** 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 the set to intersect with.
- */
- def intersect(that: Set[A]) { retain(that.contains) }
-
- /** Method <code>retain removes all elements from the set for
- * which the predicate <code>p</code> yields the value <code>false</code>.
- */
- def retain(p: A => Boolean): Unit = foreach (elem => if (!p(elem)) -=(elem))
-
- /** Removes all elements from the set. After this operation is completed,
- * the set will be empty.
- */
- def clear() { foreach(-=) }
-
- override def clone(): Set[A] = { val b = newBuilder[A]; b ++= this; b.result }
-
- /** Send a message to this scriptable object.
- *
- * @param cmd the message to send.
- * @throws <code>Predef.UnsupportedOperationException</code>
- * if the message was not understood.
- def <<(cmd: Message[A]): Unit = cmd match {
- case Include(elem) => this += elem
- case Remove(elem) => this -= elem
- case Reset() => clear
- case s: Script[_] => s.elements foreach <<
- case _ => throw new UnsupportedOperationException("message " + cmd + " not understood")
- }
- */
-
- /** Return a read-only projection of this set !!! just us an (immutable) setProxy? */
- def readOnly : collection.Set[A] = new collection.Set[A] {
- def contains(item : A) = Set.this.contains(item)
- override def size = self.size
- override def +(elem: A) = self + elem
- override def -(elem: A) = self - elem
- override def elements = self.elements
- override def foreach(f: A => Unit) = self.foreach(f)
- override def newBuilder[B]: Builder[collection.Set, B] = self.newBuilder[B]
- }
-}
diff --git a/src/library/scalax/collection/mutable/StringBuilder.scala b/src/library/scalax/collection/mutable/StringBuilder.scala
deleted file mode 100755
index 386f316f27..0000000000
--- a/src/library/scalax/collection/mutable/StringBuilder.scala
+++ /dev/null
@@ -1,942 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2006-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: StringBuilder.scala 16884 2009-01-09 16:52:09Z cunei $
-
-
-package scalax.collection.mutable
-
-import scalax.collection.generic._
-import scalax.runtime._
-
-
-/** <p>
- * A mutable sequence of characters. This class provides an API compatible
- * with <a class="java/lang/StringBuilder" href="" target="_top">
- * <code>java.lang.StringBuilder</code></a>.
- * </p>
- *
- * @author Stephane Micheloud
- * @author Martin Odersky
- * @version 2.8
- */
-@serializable
-@SerialVersionUID(0 - 8525408645367278351L)
-final class StringBuilder(initCapacity: Int, private val initValue: String)
- extends PartialFunction[Int, Char]
- with Growable[Any]
- with java.lang.CharSequence {
- require(initCapacity > 0)
-
- type Array[T] = scala.Array[T] // !!!
-
- /** The value is used for character storage. */
- private var array = new Array[Char](initCapacity + initValue.length)
-
- /** The count is the number of characters used. */
- private var count: Int = 0
-
- /** Constructs a string builder with no characters in it and an
- * initial capacity of 16 characters.
- */
- def this() = this(16, "")
-
- /** Constructs a string builder with no characters in it and an
- * initial capacity specified by the <code>capacity</code> argument.
- *
- * @param capacity the initial capacity.
- * @throws NegativeArraySizeException if the <code>capacity</code>
- * argument is less than <code>0</code>.
- */
- def this(capacity: Int) = this(capacity, "")
-
- /** Constructs a string builder with initial characters
- * equal to characters of `str`.
- */
- def this(str: String) = this(16, str)
-
- append(initValue)
-
- def toArray: Array[Char] = array
-
- def length: Int = count
- def length_=(n: Int) { setLength(n) }
-
- /** Clears the builder contents.
- */
- def clear(): Unit = setLength(0)
-
- /** Sets the length of the character sequence.
- *
- * @param newLength the new length
- * @throws IndexOutOfBoundsException if the <code>n</code> argument is negative.
- */
- def setLength(n: Int) {
- require(n >= 0, n)
- while (count < n) append('\0')
- count = n
- }
-
- /** Returns the current capacity. The capacity is the amount of storage
- * available for newly inserted characters, beyond which an allocation
- * will occur.
- *
- * @return the current capacity
- */
- def capacity: Int = array.length
-
- /** Same as <code>ensureCapacity</code>.
- * @deprecated use `ensureCapacity` instead. An assignment is misleading
- * because it can never decrease the capacity.
- */
- @deprecated def capacity_=(n: Int) { ensureCapacity(n) }
-
- /** <p>
- * Ensures that the capacity is at least equal to the specified minimum.
- * If the current capacity is less than the argument, then a new internal
- * array is allocated with greater capacity. The new capacity is the larger of:
- * </p>
- * <ul>
- * <li>The <code>n</code> argument.
- * <li>Twice the old capacity, plus <code>2</code>.
- * </ul>
- * <p>
- * If the <code>n</code> argument is non-positive, this
- * method takes no action and simply returns.
- * </p>
- *
- * @param n the minimum desired capacity.
- */
- def ensureCapacity(n: Int) {
- if (n > array.length) {
- var newsize = array.length * 2
- while (n > newsize)
- newsize = newsize * 2
- val newar = new Array[Char](newsize)
- Array.copy(array, 0, newar, 0, count)
- array = newar
- }
- }
-
- /** <p>
- * Returns the <code>Char</code> value in this sequence at the specified index.
- * The first <code>Char</code> value is at index <code>0</code>, the next at index
- * <code>1</code>, and so on, as in array indexing.
- * </p>
- * <p>
- * The index argument must be greater than or equal to
- * <code>0</code>, and less than the length of this sequence.
- * </p>
- *
- * @param index the index of the desired <code>Char</code> value.
- * @return the <code>Char</code> value at the specified index.
- * @throws IndexOutOfBoundsException if <code>index</code> is
- * negative or greater than or equal to <code>length()</code>.
- */
- def charAt(index: Int): Char = {
- if (index < 0 || index >= count)
- throw new StringIndexOutOfBoundsException(index)
- array(index)
- }
-
- /** Same as <code>charAt</code>. */
- def apply(i: Int): Char = charAt(i)
-
- /** Does builder contain an element at given index `idx`?
- */
- def isDefinedAt(i: Int): Boolean = 0 <= i && i < count
-
- /** <p>
- * Removes the <code>Char</code> at the specified position in this
- * sequence. This sequence is shortened by one <code>Char</code>.
- * </p>
- *
- * @param index Index of <code>Char</code> to remove
- * @return This object.
- * @throws StringIndexOutOfBoundsException if the <code>index</code>
- * is negative or greater than or equal to <code>length()</code>.
- */
- def deleteCharAt(index: Int): StringBuilder = {
- if (index < 0 || index >= count)
- throw new StringIndexOutOfBoundsException(index)
- compat.Platform.arraycopy(array, index + 1, array, index, count - index - 1)
- count -= 1
- this
- }
-
- /** <p>
- * The character at the specified index is set to <code>ch</code>. This
- * sequence is altered to represent a new character sequence that is
- * identical to the old character sequence, except that it contains the
- * character <code>ch</code> at position <code>index</code>.
- * </p>
- * <p>
- * The index argument must be greater than or equal to
- * <code>0</code>, and less than the length of this sequence.
- * </p>
- *
- * @param index the index of the character to modify.
- * @param ch the new character.
- * @throws IndexOutOfBoundsException if <code>index</code> is
- * negative or greater than or equal to <code>length()</code>.
- */
- def setCharAt(index: Int, ch: Char) {
- if (index < 0 || index >= count)
- throw new StringIndexOutOfBoundsException(index)
- array(index) = ch
- }
-
- /** Same as <code>setCharAt</code>. */
- def update(i: Int, c: Char) { setCharAt(i, c) }
-
- /** Returns a new <code>String</code> that contains a subsequence of
- * characters currently contained in this character sequence. The
- * substring begins at the specified index and extends to the end of
- * this sequence.
- *
- * @param start The beginning index, inclusive.
- * @return The new string.
- * @throws StringIndexOutOfBoundsException if <code>start</code> is
- * less than zero, or greater than the length of this object.
- */
- def substring(start: Int): String = substring(start, count)
-
- /** Returns a new <code>String</code> that contains a subsequence of
- * characters currently contained in this sequence. The
- * substring begins at the specified <code>start</code> and
- * extends to the character at index <code>end - 1</code>.
- *
- * @param start The beginning index, inclusive.
- * @param end The ending index, exclusive.
- * @return The new string.
- * @throws StringIndexOutOfBoundsException if <code>start</code>
- * or <code>end</code> are negative or greater than
- * <code>length()</code>, or <code>start</code> is
- * greater than <code>end</code>.
- */
- def substring(start: Int, end: Int): String = {
- if (start < 0)
- throw new StringIndexOutOfBoundsException(start)
- if (end > count)
- throw new StringIndexOutOfBoundsException(end)
- if (start > end)
- throw new StringIndexOutOfBoundsException(end - start)
- new String(array, start, end - start)
- }
-
- def subSequence(start: Int, end: Int): java.lang.CharSequence = substring(start, end)
-
- /* Appends the string representation of the <code>Any</code> argument.
- */
- def +=(x: Any) { append(x) }
-
- /** <p>
- * Appends the string representation of the <code>Any</code>
- * argument.
- * </p>
- * <p>
- * The argument is converted to a string as if by the method
- * <code>String.valueOf</code>, and the characters of that
- * string are then appended to this sequence.
- * </p>
- *
- * @param x an <code>Any</code> object.
- * @return a reference to this object.
- */
- def append(x: Any): StringBuilder =
- append(String.valueOf(x))
-
- /** Appends the specified string to this character sequence.
- *
- * @param s a string.
- * @return a reference to this object.
- */
- def append(s: String): StringBuilder = {
- val str = if (s == null) "null" else s
- val len = str.length
- ensureCapacity(count + len)
- str.getChars(0, len, array, count)
- count += len
- this
- }
-
- /** Appends the specified string builder to this sequence.
- *
- * @param sb
- * @return
- */
- def append(sb: StringBuilder): StringBuilder =
- if (sb == null)
- append("null")
- else {
- val len = sb.length
- ensureCapacity(count + len)
- compat.Platform.arraycopy(sb.toArray, 0, array, count, len)
- count += len
- this
- }
-
- /** <p>
- * Appends the string representation of the <code>Char</code> sequence
- * argument to this sequence.
- * </p>
- * <p>
- * The characters of the sequence argument are appended, in order,
- * to the contents of this sequence. The length of this sequence
- * increases by the length of the argument.
- * </p>
- *
- * @param x the characters to be appended.
- * @return a reference to this object.
- */
- def appendAll(x: Seq[Char]): StringBuilder =
- appendAll(x.toArray, 0, x.length)
-
- /* @deprecated use appendAll instead. This method is deprecated
- * because of the possible confusion with `append(Any)`.
- */
- @deprecated def append(x: Seq[Char]): StringBuilder =
- appendAll(x)
-
- /** <p>
- * Appends the string representation of the <code>Char</code> array
- * argument to this sequence.
- * </p>
- * <p>
- * The characters of the array argument are appended, in order, to
- * the contents of this sequence. The length of this sequence
- * increases by the length of the argument.
- * </p>
- *
- * @param x the characters to be appended.
- * @return a reference to this object.
- */
- def appendAll(x: Array[Char]): StringBuilder =
- appendAll(x, 0, x.length)
-
- /** @deprecated use appendAll instead. This method is deprecated
- * because of the possible confusion with `append(Any)`.
- */
- @deprecated def append(x: Array[Char]): StringBuilder =
- appendAll(x)
-
- /** <p>
- * Appends the string representation of a subarray of the
- * <code>char</code> array argument to this sequence.
- * </p>
- * <p>
- * Characters of the <code>Char</code> array <code>x</code>, starting at
- * index <code>offset</code>, are appended, in order, to the contents
- * of this sequence. The length of this sequence increases
- * by the value of <code>len</code>.
- * </p>
- *
- * @param x the characters to be appended.
- * @param offset the index of the first <code>Char</code> to append.
- * @param len the number of <code>Char</code>s to append.
- * @return a reference to this object.
- */
- def appendAll(x: Array[Char], offset: Int, len: Int): StringBuilder = {
- ensureCapacity(count + len)
- compat.Platform.arraycopy(x, offset, array, count, len)
- count += len
- this
- }
-
- /** @deprecated use appendAll instead. This method is deprecated
- * because of the possible confusion with `append(Any, Int, Int)`.
- */
- @deprecated def append(x: Array[Char], offset: Int, len: Int): StringBuilder =
- appendAll(x, offset, len)
-
- /** <p>
- * Appends the string representation of the <code>Boolean</code>
- * argument to the sequence.
- * </p>
- * <p>
- * The argument is converted to a string as if by the method
- * <code>String.valueOf</code>, and the characters of that
- * string are then appended to this sequence.
- * </p>
- *
- * @param x a <code>Boolean</code>.
- * @return a reference to this object.
- */
- def append(x: Boolean): StringBuilder = append(String.valueOf(this))
- def append(x: Byte): StringBuilder = append(String.valueOf(x))
-
- def append(x: Char): StringBuilder = {
- ensureCapacity(count + 1)
- array(count) = x
- count += 1
- this
- }
-
- def append(x: Short): StringBuilder =
- append(String.valueOf(x))
-
- def append(x: Int): StringBuilder =
- append(String.valueOf(x))
-
- def append(x: Long): StringBuilder =
- append(String.valueOf(x))
-
- def append(x: Float): StringBuilder =
- append(String.valueOf(x))
-
- def append(x: Double): StringBuilder =
- append(String.valueOf(x))
-
- /** Removes the characters in a substring of this sequence.
- * The substring begins at the specified <code>start</code> and extends to
- * the character at index <code>end - 1</code> or to the end of the
- * sequence if no such character exists. If
- * <code>start</code> is equal to <code>end</code>, no changes are made.
- *
- * @param start The beginning index, inclusive.
- * @param end The ending index, exclusive.
- * @return This object.
- * @throws StringIndexOutOfBoundsException if <code>start</code>
- * is negative, greater than <code>length()</code>, or
- * greater than <code>end</code>.
- */
- def delete(start: Int, end: Int): StringBuilder = {
- if (start < 0 || start > end)
- throw new StringIndexOutOfBoundsException(start)
- val end0 = if (end > count) count else end
- val len = end0 - start
- if (len > 0) {
- compat.Platform.arraycopy(array, start + len, array, start, count - end0)
- count -= len
- }
- this
- }
-
- /** Replaces the characters in a substring of this sequence
- * with characters in the specified <code>String</code>. The substring
- * begins at the specified <code>start</code> and extends to the character
- * at index <code>end - 1</code> or to the end of the sequence if no such
- * character exists. First the characters in the substring are removed and
- * then the specified <code>String</code> is inserted at <code>start</code>.
- *
- * @param start The beginning index, inclusive.
- * @param end The ending index, exclusive.
- * @param str String that will replace previous contents.
- * @return This object.
- * @throws StringIndexOutOfBoundsException if <code>start</code>
- * is negative, greater than <code>length()</code>, or
- * greater than <code>end</code>.
- */
- def replace(start: Int, end: Int, str: String) {
- if (start < 0 || start > count || start > end)
- throw new StringIndexOutOfBoundsException(start)
-
- val end0 = if (end > count) count else end
- val len = str.length()
- val newCount = count + len - (end0 - start)
- ensureCapacity(newCount)
-
- compat.Platform.arraycopy(array, end, array, start + len, count - end)
- str.getChars(0, len, array, start)
- count = newCount
- this
- }
-
- /** Inserts the string representation of a subarray of the <code>str</code>
- * array argument into this sequence. The subarray begins at the specified
- * <code>offset</code> and extends <code>len</code> <code>char</code>s.
- * The characters of the subarray are inserted into this sequence at
- * the position indicated by <code>index</code>. The length of this
- * sequence increases by <code>len</code> <code>Char</code>s.
- *
- * @param index position at which to insert subarray.
- * @param str a <code>Char</code> array.
- * @param offset the index of the first <code>char</code> in subarray to
- * be inserted.
- * @param len the number of <code>Char</code>s in the subarray to
- * be inserted.
- * @return This object
- * @throws StringIndexOutOfBoundsException if <code>index</code>
- * is negative or greater than <code>length()</code>, or
- * <code>offset</code> or <code>len</code> are negative, or
- * <code>(offset+len)</code> is greater than
- * <code>str.length</code>.
- */
- def insertAll(index: Int, str: Array[Char], offset: Int, len: Int): StringBuilder = {
- if (index < 0 || index > count)
- throw new StringIndexOutOfBoundsException(index)
- if (offset < 0 || len < 0 || offset > str.length - len)
- throw new StringIndexOutOfBoundsException(
- "offset " + offset + ", len " + len +
- ", str.length " + str.length)
- ensureCapacity(count + len)
- compat.Platform.arraycopy(array, index, array, index + len, count - index)
- compat.Platform.arraycopy(str, offset, array, index, len)
- count += len
- this
- }
-
- /** @deprecated use insertAll instead. This method is deprecated
- * because of the possible confusion with `insert(Int, Any, Int, Int)`.
- */
- @deprecated def insert(index: Int, str: Array[Char], offset: Int, len: Int): StringBuilder =
- insertAll(index, str, offset, len)
-
- /** <p>
- * Inserts the string representation of the <code>Any</code>
- * argument into this character sequence.
- * </p>
- * <p>
- * The second argument is converted to a string as if by the method
- * <code>String.valueOf</code>, and the characters of that
- * string are then inserted into this sequence at the indicated
- * offset.
- * </p>
- * <p>
- * The offset argument must be greater than or equal to
- * <code>0</code>, and less than or equal to the length of this
- * sequence.
- * </p>
- *
- * @param offset the offset.
- * @param x an <code>Any</code> value.
- * @return a reference to this object.
- * @throws StringIndexOutOfBoundsException if the offset is invalid.
- */
- def insert(at: Int, x: Any): StringBuilder =
- insert(at, String.valueOf(x))
-
- /** Inserts the string into this character sequence.
- *
- * @param at the offset position.
- * @param x a string.
- * @return a reference to this object.
- * @throws StringIndexOutOfBoundsException if the offset is invalid.
- */
- def insert(at: Int, x: String): StringBuilder = {
- if (at < 0 || at > count)
- throw new StringIndexOutOfBoundsException(at)
- val str = if (x == null) "null" else x
- val len = str.length
- ensureCapacity(count + len)
- compat.Platform.arraycopy(array, at, array, at + len, count - at)
- str.getChars(0, len, array, at)
- count += len
- this
- }
-
- /** Inserts the string representation of the <code>Char</code> sequence
- * argument into this sequence.
- *
- * @param at the offset position.
- * @param x a character sequence.
- * @return a reference to this object.
- * @throws StringIndexOutOfBoundsException if the offset is invalid.
- */
- def insertAll(at: Int, x: Seq[Char]): StringBuilder =
- insertAll(at, x.toArray)
-
- /* @deprecated use insertAll instead. This method is deprecated
- * because of the possible confusion with `insert(Int, Any)`.
- */
- @deprecated def insert(at: Int, x: Seq[Char]): StringBuilder =
- insertAll(at, x)
-
- /** Inserts the string representation of the <code>Char</code> array
- * argument into this sequence.
- *
- * @param at the offset position.
- * @param x a character array.
- * @return a reference to this object.
- * @throws StringIndexOutOfBoundsException if the offset is invalid.
- */
- def insertAll(at: Int, x: Array[Char]): StringBuilder = {
- if (at < 0 || at > count)
- throw new StringIndexOutOfBoundsException(at)
- val len = x.length
- ensureCapacity(count + len)
- compat.Platform.arraycopy(array, at, array, at + len, count - at)
- compat.Platform.arraycopy(x, 0, array, at, len)
- count += len
- this
- }
-
- /* @deprecated use insertAll instead. This method is deprecated
- * because of the possible confusion with `insert(Int, Any)`.
- */
- @deprecated def insert(at: Int, x: Array[Char]): StringBuilder =
- insertAll(at, x)
-
- /** <p>
- * Inserts the string representation of the <code>Boolean</code> argument
- * into this sequence.
- * </p>
- * <p>
- * The offset argument must be greater than or equal to 0, and less than
- * or equal to the length of this sequence.
- * </p>
- *
- * @param at the offset position.
- * @param x a <code>Boolean</code> value.
- * @return a reference to this object.
- */
- def insert(at: Int, x: Boolean): StringBuilder =
- insert(at, String.valueOf(x))
-
- /** <p>
- * Inserts the string representation of the <code>Byte</code> argument
- * into this sequence.
- * </p>
- * <p>
- * The offset argument must be greater than or equal to 0, and less than
- * or equal to the length of this sequence.
- * </p>
- *
- * @param at the offset position.
- * @param x a <code>Byte</code> value.
- * @return a reference to this object.
- */
- def insert(at: Int, x: Byte): StringBuilder =
- insert(at, String.valueOf(x))
-
- /** <p>
- * Inserts the string representation of the <code>Char</code> argument
- * into this sequence.
- * </p>
- * <p>
- * The offset argument must be greater than or equal to 0, and less than
- * or equal to the length of this sequence.
- * </p>
- *
- * @param at the offset position.
- * @param x a <code>Char</code> value.
- * @return a reference to this object.
- */
- def insert(at: Int, x: Char): StringBuilder = {
- if (at < 0 || at > count)
- throw new StringIndexOutOfBoundsException(at)
- ensureCapacity(count + 1)
- compat.Platform.arraycopy(array, at, array, at + 1, count - at)
- array(at) = x
- count += 1
- this
- }
-
- /** <p>
- * Inserts the string representation of the <code>Short</code> argument
- * into this sequence.
- * </p>
- * <p>
- * The offset argument must be greater than or equal to 0, and less than
- * or equal to the length of this sequence.
- * </p>
- *
- * @param at the offset position.
- * @param x a <code>Short</code> value.
- * @return a reference to this object.
- */
- def insert(at: Int, x: Short): StringBuilder =
- insert(at, String.valueOf(x))
-
- /** <p>
- * Inserts the string representation of the <code>Int</code> argument
- * into this sequence.
- * </p>
- * <p>
- * The offset argument must be greater than or equal to 0, and less than
- * or equal to the length of this sequence.
- * </p>
- *
- * @param at the offset position.
- * @param x a <code>Int</code> value.
- * @return a reference to this object.
- */
- def insert(at: Int, x: Int): StringBuilder =
- insert(at, String.valueOf(x))
-
- /** <p>
- * Inserts the string representation of the <code>Long</code> argument
- * into this sequence.
- * </p>
- * <p>
- * The offset argument must be greater than or equal to 0, and less than
- * or equal to the length of this sequence.
- * </p>
- *
- * @param at the offset position.
- * @param x a <code>Long</code> value.
- * @return a reference to this object.
- */
- def insert(at: Int, x: Long): StringBuilder =
- insert(at, String.valueOf(x))
-
- /** <p>
- * Inserts the string representation of the <code>Float</code> argument
- * into this sequence.
- * </p>
- * <p>
- * The offset argument must be greater than or equal to 0, and less than
- * or equal to the length of this sequence.
- * </p>
- *
- * @param at the offset position.
- * @param x a <code>Float</code> value.
- * @return a reference to this object.
- */
- def insert(at: Int, x: Float): StringBuilder =
- insert(at, String.valueOf(x))
-
- /** <p>
- * Inserts the string representation of the <code>Double</code> argument
- * into this sequence.
- * </p>
- * <p>
- * The offset argument must be greater than or equal to 0, and less than
- * or equal to the length of this sequence.
- * </p>
- *
- * @param at the offset position.
- * @param x a <code>Double</code> value.
- * @return a reference to this object.
- */
- def insert(at: Int, x: Double): StringBuilder =
- insert(at, String.valueOf(x))
-
- /** <p>
- * Returns the index within this string of the first occurrence of the
- * specified substring. The integer returned is the smallest value
- * <i>k</i> such that:
- * </p>
- * <blockquote><pre>
- * this.toString().startsWith(str, <i>k</i>)</pre>
- * </blockquote>
- * <p>
- * is <code>true</code>.
- * </p>
- *
- * @param str any string.
- * @return if the string argument occurs as a substring within this
- * object, then the index of the first character of the first
- * such substring is returned; if it does not occur as a
- * substring, <code>-1</code> is returned.
- * @throws NullPointerException if <code>str</code> is <code>null</code>.
- */
- def indexOf(str: String): Int = indexOf(str, 0)
-
- /** <p>
- * Returns the index within this string of the first occurrence of the
- * specified substring, starting at the specified index. The integer
- * returned is the smallest value <code>k</code> for which:
- * </p><pre>
- * k >= Math.min(fromIndex, str.length()) &&
- * this.toString().startsWith(str, k)</pre>
- * <p>
- * If no such value of <code>k</code> exists, then <code>-1</code>
- * is returned.
- * </p>
- *
- * @param str the substring for which to search.
- * @param fromIndex the index from which to start the search.
- * @return the index within this string of the first occurrence
- * of the specified substring, starting at the specified index.
- */
- def indexOf(str: String, fromIndex: Int): Int =
- StringBuilder.indexOf(array, 0, count, str.toCharArray, 0, str.length(), fromIndex)
-
- /** <p>
- * Returns the index within this string of the rightmost occurrence
- * of the specified substring. The rightmost empty string "" is
- * considered to occur at the index value <code>this.length()</code>.
- * The returned index is the largest value <i>k</i> such that
- * </p>
- * <blockquote><pre>
- * this.toString().startsWith(str, k)</pre>
- * </blockquote>
- * <p>
- * is true.
- * </p>
- *
- * @param str the substring to search for.
- * @return if the string argument occurs one or more times as a substring
- * within this object, then the index of the first character of
- * the last such substring is returned. If it does not occur as
- * a substring, <code>-1</code> is returned.
- * @throws NullPointerException if <code>str</code> is <code>null</code>.
- */
- def lastIndexOf(str: String): Int = lastIndexOf(str, count)
-
- /** <p>
- * Returns the index within this string of the last occurrence of the
- * specified substring. The integer returned is the largest value
- * <code>k</code> such that:
- * </p><pre>val
- * k <= Math.min(fromIndex, str.length()) &&
- * this.toString().startsWith(str, k)</pre>
- * <p>
- * If no such value of <code>k</code> exists, then <code>-1</code>
- * is returned.
- * </p>
- *
- * @param str the substring to search for.
- * @param fromIndex the index to start the search from.
- * @return the index within this sequence of the last occurrence
- * of the specified substring.
- */
- def lastIndexOf(str: String, fromIndex: Int): Int =
- StringBuilder.lastIndexOf(array, 0, count, str.toCharArray, 0, str.length(), fromIndex)
-
- /** <p>
- * Causes this character sequence to be replaced by the reverse of the
- * sequence. If there are any surrogate pairs included in the sequence,
- * these are treated as single characters for the reverse operation.
- * Thus, the order of the high-low surrogates is never reversed.
- * </p>
- * <p>
- * Let <i>n</i> be the character length of this character sequence
- * (not the length in <code>Char</code> values) just prior to
- * execution of the <code>reverse</code> method. Then the
- * character at index <i>k</i> in the new character sequence is
- * equal to the character at index <i>n-k-1</i> in the old
- * character sequence.
- * </p>
- *
- * @return a reference to this object.
- */
- def reverse(): StringBuilder = {
- var hasSurrogate = false
- val n = count - 1
- var j = (n-1) >> 1
- while (j >= 0) {
- val temp = array(j)
- val temp2 = array(n - j)
- if (!hasSurrogate)
- hasSurrogate =
- (temp >= Character.MIN_HIGH_SURROGATE && temp <= Character.MAX_LOW_SURROGATE) ||
- (temp2 >= Character.MIN_HIGH_SURROGATE && temp2 <= Character.MAX_LOW_SURROGATE)
- array(j) = temp2
- array(n - j) = temp
- j -= 1
- }
- if (hasSurrogate) {
- // Reverse back all valid surrogate pairs
- var i = 0
- while (i < count - 1) {
- val c2 = array(i)
- if (Character.isLowSurrogate(c2)) {
- val c1 = array(i + 1)
- if (Character.isHighSurrogate(c1)) {
- array(i) = c1; i += 1
- array(i) = c2
- }
- }
- i += 1
- }
- }
- this
- }
-
- /** Returns a string representing the data in this sequence.
- * A new <code>String</code> object is allocated and initialized to
- * contain the character sequence currently represented by this
- * object. This <code>String</code> is then returned. Subsequent
- * changes to this sequence do not affect the contents of the
- * <code>String</code>.
- *
- * @return a string representation of this sequence of characters.
- */
- override def toString(): String = new String(array, 0, count)
-}
-
-
-object StringBuilder {
-
- type Array[T] = scala.Array[T] // !!!
-
- // method <code>java.util.Arrays.copyOf</code> exists since 1.6
- private def copyOf(src: Array[Char], newLength: Int): Array[Char] = {
- val dest = new Array[Char](newLength)
- compat.Platform.arraycopy(src, 0, dest, 0, Math.min(src.length, newLength))
- dest
- }
-
- private def indexOf(source: Array[Char], sourceOffset: Int, sourceCount: Int,
- target: Array[Char], targetOffset: Int, targetCount: Int,
- fromIndex: Int): Int =
- // todo: There are faster string search algorithms than this!
- // we should use at least KMP here.
- if (fromIndex >= sourceCount)
- if (targetCount == 0) sourceCount else -1
- else {
- val inx = if (fromIndex < 0) 0 else fromIndex
- if (targetCount == 0)
- inx
- else {
- val first = target(targetOffset)
- val max = sourceOffset + (sourceCount - targetCount)
-
- var i = sourceOffset + inx
- while (i <= max) {
- /* Look for first character. */
- if (source(i) != first) {
- i += 1
- while (i <= max && source(i) != first) i += 1
- }
- /* Found first character, now look at the rest of v2 */
- if (i <= max) {
- var j = i + 1
- val end = j + targetCount - 1
- var k = targetOffset + 1
- while (j < end && source(j) == target(k)) {
- j += 1
- k += 1
- }
- if (j == end) {
- /* Found whole string. */
- return i - sourceOffset
- }
- } // if
- i += 1
- } // while
- -1
- }
- }
-
- private def lastIndexOf(source: Array[Char], sourceOffset: Int, sourceCount: Int,
- target: Array[Char], targetOffset: Int, targetCount: Int,
- fromIndex: Int): Int = {
- val rightIndex = sourceCount - targetCount
- if (fromIndex < 0) return -1
- val inx = if (fromIndex > rightIndex) rightIndex else fromIndex
- // Empty string always matches
- if (targetCount == 0) return inx
-
- val strLastIndex = targetOffset + targetCount - 1
- val strLastChar = target(strLastIndex)
- val min = sourceOffset + targetCount - 1
- var i = min + fromIndex
-
- while (true) {
- while (i >= min && source(i) != strLastChar) i -= 1
- if (i < min) return -1
- var j = i - 1
- val start = j - (targetCount - 1)
- var k = strLastIndex - 1
- var outerWhile = false
- while (j > start && !outerWhile) {
- if (source(j) != target(k)) {
- j -= 1
- k -= 1
- i -= 1
- outerWhile = true
- }
- }
- if (!outerWhile) return start - sourceOffset + 1
- }
- -1
- }
-}
diff --git a/src/library/scalax/collection/mutable/Vector.scala b/src/library/scalax/collection/mutable/Vector.scala
deleted file mode 100644
index 1813172fbf..0000000000
--- a/src/library/scalax/collection/mutable/Vector.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2006-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Vector.scala 15437 2008-06-25 16:22:45Z stepancheg $
-
-package scalax.collection.mutable
-
-import generic._
-
-trait Vector[A] extends Sequence[A] with collection.Vector[A] with MutableVectorTemplate[Vector, A]
-
-/* Factory object for `Vector` class */
-object Vector extends SequenceFactory[Vector] {
- /** The empty vector */
- def apply[A](args: A*): Vector[A] = ArrayBuffer.apply(args: _*) // !!! swicth to Array?
-}
diff --git a/src/library/scalax/runtime/Boxed.scala b/src/library/scalax/runtime/Boxed.scala
deleted file mode 100644
index 241b12e485..0000000000
--- a/src/library/scalax/runtime/Boxed.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Buffer.scala 15799 2008-08-15 18:23:54Z odersky $
-
-
-package scalax.runtime
-
-trait Boxed {
-
-}
-
-
diff --git a/src/library/scalax/runtime/BoxedAnyArray.scala b/src/library/scalax/runtime/BoxedAnyArray.scala
deleted file mode 100755
index 6e14cafdfc..0000000000
--- a/src/library/scalax/runtime/BoxedAnyArray.scala
+++ /dev/null
@@ -1,239 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: BoxedAnyArray.scala 17000 2009-01-29 13:05:53Z odersky $
-
-
-package scalax.runtime
-
-import compat.Platform
-
-/**
- * Arrays created by <code>new Array[T](length)</code> where <code>T</code>
- * is a type variable.
- *
- * @author Martin Odersky
- */
-@serializable
-final class BoxedAnyArray[A](val length: Int) extends BoxedArray[A] {
-
- private var boxed = new Array[AnyRef](length)
- private val hash = boxed.hashCode()
- private var unboxed: AnyRef = null
- private var elemClass: Class[_] = null
-
- def apply(index: Int): A = synchronized {
- if (unboxed eq null)
- boxed(index)
- else if (elemClass eq classOf[Int])
- Int.box(unboxed.asInstanceOf[Array[Int]](index))
- else if (elemClass eq classOf[Double])
- Double.box(unboxed.asInstanceOf[Array[Double]](index))
- else if (elemClass eq classOf[Float])
- Float.box(unboxed.asInstanceOf[Array[Float]](index))
- else if (elemClass eq classOf[Long])
- Long.box(unboxed.asInstanceOf[Array[Long]](index))
- else if (elemClass eq classOf[Char])
- Char.box(unboxed.asInstanceOf[Array[Char]](index))
- else if (elemClass eq classOf[Byte])
- Byte.box(unboxed.asInstanceOf[Array[Byte]](index))
- else if (elemClass eq classOf[Short])
- Short.box(unboxed.asInstanceOf[Array[Short]](index))
- else if (elemClass eq classOf[Boolean])
- Boolean.box(unboxed.asInstanceOf[Array[Boolean]](index))
- else
- unboxed.asInstanceOf[Array[AnyRef]](index)
- }.asInstanceOf[A]
-
- def update(index: Int, _elem: A): Unit = synchronized {
- val elem = _elem.asInstanceOf[AnyRef]
- if (unboxed eq null)
- boxed(index) = elem
- else if (elemClass eq classOf[Int])
- unboxed.asInstanceOf[Array[Int]](index) = Int.unbox(elem)
- else if (elemClass eq classOf[Double])
- unboxed.asInstanceOf[Array[Double]](index) = Double.unbox(elem)
- else if (elemClass eq classOf[Float])
- unboxed.asInstanceOf[Array[Float]](index) = Float.unbox(elem)
- else if (elemClass eq classOf[Long])
- unboxed.asInstanceOf[Array[Long]](index) = Long.unbox(elem)
- else if (elemClass eq classOf[Char])
- unboxed.asInstanceOf[Array[Char]](index) = Char.unbox(elem)
- else if (elemClass eq classOf[Byte])
- unboxed.asInstanceOf[Array[Byte]](index) = Byte.unbox(elem)
- else if (elemClass eq classOf[Short])
- unboxed.asInstanceOf[Array[Short]](index) = Short.unbox(elem)
- else if (elemClass eq classOf[Boolean])
- unboxed.asInstanceOf[Array[Boolean]](index) = Boolean.unbox(elem)
- else
- unboxed.asInstanceOf[Array[AnyRef]](index) = elem
- }
-
- def unbox(elemClass: Class[_]): AnyRef = synchronized {
- if (unboxed eq null) {
- this.elemClass = elemClass;
- if (elemClass eq classOf[Int]) {
- val newvalue = new Array[Int](length)
- var i = 0
- while (i < length) {
- newvalue(i) = Int.unbox(boxed(i))
- i += 1
- }
- unboxed = newvalue
- } else if (elemClass eq classOf[Double]) {
- val newvalue = new Array[Double](length)
- var i = 0
- while (i < length) {
- newvalue(i) = Double.unbox(boxed(i))
- i += 1
- }
- unboxed = newvalue;
- } else if (elemClass eq classOf[Float]) {
- val newvalue = new Array[Float](length)
- var i = 0
- while (i < length) {
- newvalue(i) = Float.unbox(boxed(i))
- i += 1
- }
- unboxed = newvalue;
- } else if (elemClass eq classOf[Long]) {
- val newvalue = new Array[Long](length)
- var i = 0
- while (i < length) {
- newvalue(i) = Long.unbox(boxed(i))
- i += 1
- }
- unboxed = newvalue;
- } else if (elemClass eq classOf[Char]) {
- val newvalue = new Array[Char](length)
- var i = 0
- while (i < length) {
- newvalue(i) = Char.unbox(boxed(i))
- i += 1
- }
- unboxed = newvalue
- } else if (elemClass eq classOf[Byte]) {
- val newvalue = new Array[Byte](length)
- var i = 0
- while (i < length) {
- newvalue(i) = Byte.unbox(boxed(i))
- i += 1
- }
- unboxed = newvalue;
- } else if (elemClass eq classOf[Short]) {
- val newvalue = new Array[Short](length)
- var i = 0
- while (i < length) {
- newvalue(i) = Short.unbox(boxed(i))
- i += 1
- }
- unboxed = newvalue;
- } else if (elemClass eq classOf[Boolean]) {
- val newvalue = new Array[Boolean](length)
- var i = 0
- while (i < length) {
- newvalue(i) = Boolean.unbox(boxed(i))
- i += 1
- }
- unboxed = newvalue;
- } else if (elemClass == classOf[AnyRef]) {
- unboxed = boxed
- } else {
- unboxed = Platform.createArray(elemClass, length)
- if (elemClass.isArray) {
- var i = 0
- while (i < length) {
- boxed(i) match {
- case ba: BoxedArray[_] => boxed(i) = ba.unbox(elemClass.getComponentType())
- case _ =>
- }
- i += 1
- }
- }
- Platform.arraycopy(boxed, 0, unboxed, 0, length)
- }
- boxed = null
- }
- unboxed
- }
-
- override def equals(other: Any): Boolean =
- other.isInstanceOf[BoxedAnyArray[_]] && (this eq (other.asInstanceOf[BoxedAnyArray[_]])) ||
- (if (unboxed eq null) boxed == other else unboxed == other)
-
- override def hashCode(): Int = hash
-
- def value: AnyRef = {
- if (unboxed eq null) throw new NotDefinedError("BoxedAnyArray.value")
- unboxed
- }
-
- private def adapt(other: AnyRef): AnyRef =
- if (this.unboxed eq null)
- other match {
- case that: BoxedAnyArray[_] =>
- if (that.unboxed eq null) {
- that.boxed
- } else {
- if (ScalaRunTime.isValueClass(that.elemClass)) unbox(that.elemClass);
- that.unboxed
- }
- case that: BoxedArray[_] =>
- adapt(that.value)
- case that: Array[Int] =>
- unbox(classOf[Int]); that
- case that: Array[Double] =>
- unbox(classOf[Double]); that
- case that: Array[Float] =>
- unbox(classOf[Float]); that
- case that: Array[Long] =>
- unbox(classOf[Long]); that
- case that: Array[Char] =>
- unbox(classOf[Char]); that
- case that: Array[Short] =>
- unbox(classOf[Short]); that
- case that: Array[Byte] =>
- unbox(classOf[Byte]); that
- case that: Array[Boolean] =>
- unbox(classOf[Boolean]); that
- case _ =>
- other
- }
- else
- other match {
- case that: BoxedAnyArray[_] =>
- if (that.unboxed ne null) that.unboxed
- else if (ScalaRunTime.isValueClass(this.elemClass)) that.unbox(this.elemClass)
- else that.boxed
- case that: BoxedArray[_] =>
- adapt(that.value)
- case _ =>
- other
- }
-
- override def copyFrom(src: AnyRef, from: Int, to: Int, len: Int) {
- val src1 = adapt(src)
- Array.copy(src1, from, if (unboxed ne null) unboxed else boxed, to, len)
- }
-
- override def copyTo(from: Int, dest: AnyRef, to: Int, len: Int) {
- var dest1 = adapt(dest)
- Array.copy(if (unboxed ne null) unboxed else boxed, from, dest1, to, len)
- }
-
- final override def filter(p: A => Boolean): BoxedArray[A] = {
- val (len, include) = countAndMemo(p)
- val result = new BoxedAnyArray[A](len)
- var i, j = 0
- while (j < len) {
- if (include(i)) { result(j) = this(i); j += 1 }
- i += 1
- }
- result
- }
-}
diff --git a/src/library/scalax/runtime/BoxedArray.scala b/src/library/scalax/runtime/BoxedArray.scala
deleted file mode 100755
index 47bb3a0d64..0000000000
--- a/src/library/scalax/runtime/BoxedArray.scala
+++ /dev/null
@@ -1,138 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: BoxedArray.scala 17000 2009-01-29 13:05:53Z odersky $
-
-
-package scalax.runtime
-
-import Predef._
-import collection.mutable.{Vector, ArrayBuffer}
-import collection.generic._
-
-/**
- * <p>A class representing <code>Array[T]</code></p>
- *
- * @author Martin Odersky, Stephane Micheloud
- * @version 1.0
- */
-abstract class BoxedArray[A] extends Vector[A] with MutableVectorTemplate[BoxedArray, A] with Boxed {
-
- /** The length of the array */
- def length: Int
-
- /** The element at given index */
- def apply(index: Int): A
-
- /** Update element at given index */
- def update(index: Int, elem: A): Unit
-
- /** Creates new builder for this collection ==> move to subclasses
- *
- * */
- def newBuilder[B] = new ArrayBuffer[B].mapResult[BoxedArray] { // !!! Adriaan: can't drop [BoxedArray] here
- _.toArray.asInstanceOf[BoxedArray[B]]
- }
-
- /** Convert to Java array.
- * @param elemTag Either one of the tags ".N" where N is the name of a primitive type
- * (@see ScalaRunTime), or a full class name.
- */
- def unbox(elemClass: Class[_]): AnyRef
-
- /** The underlying array value
- */
- def value: AnyRef
-
- def copyFrom(src: AnyRef, from: Int, to: Int, len: Int): Unit =
- Array.copy(src, from, value, to, len)
-
- def copyTo(from: Int, dest: AnyRef, to: Int, len: Int): Unit = {
- Array.copy(value, from, dest, to, len)
- }
-
- override def equals(other: Any) =
- (value == other) ||
- other.isInstanceOf[BoxedArray[_]] && (value == other.asInstanceOf[BoxedArray[_]].value)
-
- override def hashCode(): Int = value.hashCode()
-
- /** Fills the given array <code>xs</code> with the elements of
- * this sequence starting at position <code>start</code>.
- *
- * @param xs the array to fill.
- * @param start starting index.
- * @pre the array must be large enough to hold all elements.
- */
- override def copyToArray[B](xs: Array[B], start: Int, len: Int): Unit =
- copyTo(0, xs, start, len)
-
- final def deepToString() = deepMkString(stringPrefix + "(", ", ", ")")
-
- final def deepMkString(start: String, sep: String, end: String): String = {
- def _deepToString(x: Any) = x match {
- case a: AnyRef if ScalaRunTime.isArray(a) =>
- ScalaRunTime.boxArray(a).deepMkString(start, sep, end)
- case _ =>
- ScalaRunTime.stringOf(x)
- }
- val buf = new StringBuilder()
- buf.append(start)
- val elems = elements
- if (elems.hasNext) buf.append(_deepToString(elems.next))
- while (elems.hasNext) {
- buf.append(sep); buf.append(_deepToString(elems.next))
- }
- buf.append(end)
- buf.toString
- }
-
- final def deepMkString(sep: String): String = this.deepMkString("", sep, "")
-
- final def deepEquals(that: Any): Boolean = {
- def _deepEquals(x1: Any, x2: Any) = (x1, x2) match {
- case (a1: BoxedArray[_], a2: BoxedArray[_]) =>
- _sameElements(a1, a2)
- case (a1: AnyRef, a2: AnyRef)
- if ScalaRunTime.isArray(a1) && ScalaRunTime.isArray(a2) =>
- _sameElements(ScalaRunTime.boxArray(a1), ScalaRunTime.boxArray(a2))
- case _ =>
- x1.equals(x2)
- }
- def _sameElements(a1: BoxedArray[_], a2: BoxedArray[_]): Boolean = {
- val it1 = a1.elements
- val it2 = a2.elements
- var res = true
- while (res && it1.hasNext && it2.hasNext)
- res = _deepEquals(it1.next, it2.next)
- !it1.hasNext && !it2.hasNext && res
- }
- that match {
- case a: BoxedArray[_] =>
- _sameElements(this, a)
- case a: AnyRef if ScalaRunTime.isArray(a) =>
- _sameElements(this, ScalaRunTime.boxArray(a))
- case _ =>
- false
- }
- }
-
- override final def stringPrefix: String = "Array"
-
- protected def countAndMemo(p: A => Boolean): (Int, Array[Boolean]) = {
- val len = length
- val memo = new Array[Boolean](len)
- var count = 0
- var i = 0
- while (i < len) {
- if (p(this(i))) { memo(i) = true; count += 1 }
- i += 1
- }
- (count, memo)
- }
-}
diff --git a/src/library/scalax/runtime/BoxedBooleanArray.scala b/src/library/scalax/runtime/BoxedBooleanArray.scala
deleted file mode 100755
index 1dc136a50f..0000000000
--- a/src/library/scalax/runtime/BoxedBooleanArray.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: BoxedByteArray.scala 17000 2009-01-29 13:05:53Z odersky $
-
-
-package scalax.runtime
-
-@serializable
-final class BoxedBooleanArray(val value: Array[Boolean]) extends BoxedArray[Boolean] {
-
- def length: Int = value.length
-
- def apply(index: Int): Boolean = value(index)
-
- def update(index: Int, elem: Boolean) {
- value(index) = elem
- }
- def unbox(elemClass: Class[_]): AnyRef = value
-}
diff --git a/src/library/scalax/runtime/BoxedByteArray.scala b/src/library/scalax/runtime/BoxedByteArray.scala
deleted file mode 100755
index f42dbdda38..0000000000
--- a/src/library/scalax/runtime/BoxedByteArray.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: BoxedByteArray.scala 17000 2009-01-29 13:05:53Z odersky $
-
-
-package scalax.runtime
-
-@serializable
-final class BoxedByteArray(val value: Array[Byte]) extends BoxedArray[Byte] {
-
- def length: Int = value.length
-
- def apply(index: Int): Byte = value(index)
-
- def update(index: Int, elem: Byte) {
- value(index) = elem
- }
- def unbox(elemClass: Class[_]): AnyRef = value
-}
diff --git a/src/library/scalax/runtime/BoxedCharArray.scala b/src/library/scalax/runtime/BoxedCharArray.scala
deleted file mode 100755
index c6f19d26e0..0000000000
--- a/src/library/scalax/runtime/BoxedCharArray.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: BoxedByteArray.scala 17000 2009-01-29 13:05:53Z odersky $
-
-
-package scalax.runtime
-
-@serializable
-final class BoxedCharArray(val value: Array[Char]) extends BoxedArray[Char] {
-
- def length: Int = value.length
-
- def apply(index: Int): Char = value(index)
-
- def update(index: Int, elem: Char) {
- value(index) = elem
- }
- def unbox(elemClass: Class[_]): AnyRef = value
-}
diff --git a/src/library/scalax/runtime/BoxedDoubleArray.scala b/src/library/scalax/runtime/BoxedDoubleArray.scala
deleted file mode 100755
index 16fc3e1056..0000000000
--- a/src/library/scalax/runtime/BoxedDoubleArray.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: BoxedByteArray.scala 17000 2009-01-29 13:05:53Z odersky $
-
-
-package scalax.runtime
-
-@serializable
-final class BoxedDoubleArray(val value: Array[Double]) extends BoxedArray[Double] {
-
- def length: Int = value.length
-
- def apply(index: Int): Double = value(index)
-
- def update(index: Int, elem: Double) {
- value(index) = elem
- }
- def unbox(elemClass: Class[_]): AnyRef = value
-}
diff --git a/src/library/scalax/runtime/BoxedFloatArray.scala b/src/library/scalax/runtime/BoxedFloatArray.scala
deleted file mode 100755
index d10f16f6f6..0000000000
--- a/src/library/scalax/runtime/BoxedFloatArray.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: BoxedByteArray.scala 17000 2009-01-29 13:05:53Z odersky $
-
-
-package scalax.runtime
-
-@serializable
-final class BoxedFloatArray(val value: Array[Float]) extends BoxedArray[Float] {
-
- def length: Int = value.length
-
- def apply(index: Int): Float = value(index)
-
- def update(index: Int, elem: Float) {
- value(index) = elem
- }
- def unbox(elemClass: Class[_]): AnyRef = value
-}
diff --git a/src/library/scalax/runtime/BoxedIntArray.scala b/src/library/scalax/runtime/BoxedIntArray.scala
deleted file mode 100755
index 78a033190a..0000000000
--- a/src/library/scalax/runtime/BoxedIntArray.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: BoxedByteArray.scala 17000 2009-01-29 13:05:53Z odersky $
-
-
-package scalax.runtime
-
-@serializable
-final class BoxedIntArray(val value: Array[Int]) extends BoxedArray[Int] {
-
- def length: Int = value.length
-
- def apply(index: Int): Int = value(index)
-
- def update(index: Int, elem: Int) {
- value(index) = elem
- }
- def unbox(elemClass: Class[_]): AnyRef = value
-}
diff --git a/src/library/scalax/runtime/BoxedLongArray.scala b/src/library/scalax/runtime/BoxedLongArray.scala
deleted file mode 100755
index 86816d6638..0000000000
--- a/src/library/scalax/runtime/BoxedLongArray.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: BoxedByteArray.scala 17000 2009-01-29 13:05:53Z odersky $
-
-
-package scalax.runtime
-
-@serializable
-final class BoxedLongArray(val value: Array[Long]) extends BoxedArray[Long] {
-
- def length: Int = value.length
-
- def apply(index: Int): Long = value(index)
-
- def update(index: Int, elem: Long) {
- value(index) = elem
- }
- def unbox(elemClass: Class[_]): AnyRef = value
-}
diff --git a/src/library/scalax/runtime/BoxedShortArray.scala b/src/library/scalax/runtime/BoxedShortArray.scala
deleted file mode 100755
index 6d5c82e7ba..0000000000
--- a/src/library/scalax/runtime/BoxedShortArray.scala
+++ /dev/null
@@ -1,25 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: BoxedByteArray.scala 17000 2009-01-29 13:05:53Z odersky $
-
-
-package scalax.runtime
-
-@serializable
-final class BoxedShortArray(val value: Array[Short]) extends BoxedArray[Short] {
-
- def length: Int = value.length
-
- def apply(index: Int): Short = value(index)
-
- def update(index: Int, elem: Short) {
- value(index) = elem
- }
- def unbox(elemClass: Class[_]): AnyRef = value
-}
diff --git a/src/library/scalax/runtime/BoxedString.scala b/src/library/scalax/runtime/BoxedString.scala
deleted file mode 100644
index ef5a8b43c7..0000000000
--- a/src/library/scalax/runtime/BoxedString.scala
+++ /dev/null
@@ -1,195 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: RichString.scala 15602 2008-07-24 08:20:38Z washburn $
-
-
-package scalax.runtime
-
-import scala.util.matching.Regex
-import scalax.collection._
-import scalax.collection.mutable.StringBuilder
-import scalax.collection.generic
-import scalax.collection.generic._
-
-object BoxedString {
- // just statics for rich string.
- private final val LF: Char = 0x0A
- private final val FF: Char = 0x0C
- private final val CR: Char = 0x0D
- private final val SU: Char = 0x1A
-}
-
-import BoxedString._
-
-class BoxedString(val self: String) extends StringVector[Char] with Proxy with PartialFunction[Int, Char] with Ordered[String] {
-
- /** Return element at index `n`
- * @throws IndexOutofBoundsException if the index is not valid
- */
- def apply(n: Int): Char = self charAt n
-
- def length = self.length
-
- override def unbox = self
- override def mkString = self
- override def toString = self
-
- /** return n times the current string
- */
- def * (n: Int): String = {
- val buf = new StringBuilder
- for (i <- 0 until n) buf append self
- buf.toString
- }
-
- override def compare(other: String) = self compareTo other
-
- private def isLineBreak(c: Char) = c == LF || c == FF
-
- /** <p>
- * Strip trailing line end character from this string if it has one.
- * A line end character is one of
- * </p>
- * <ul style="list-style-type: none;">
- * <li>LF - line feed (0x0A hex)</li>
- * <li>FF - form feed (0x0C hex)</li>
- * </ul>
- * <p>
- * If a line feed character LF is preceded by a carriage return CR
- * (0x0D hex), the CR character is also stripped (Windows convention).
- * </p>
- */
- def stripLineEnd: String = {
- val len = self.length
- if (len == 0) self
- else {
- val last = apply(len - 1)
- if (isLineBreak(last))
- self.substring(0, if (last == LF && len >= 2 && apply(len - 2) == CR) len - 2 else len - 1)
- else
- self
- }
- }
-
- /** <p>
- * Return all lines in this string in an iterator, including trailing
- * line end characters.
- * </p>
- * <p>
- * The number of strings returned is one greater than the number of line
- * end characters in this string. For an empty string, a single empty
- * line is returned. A line end character is one of
- * </p>
- * <ul style="list-style-type: none;">
- * <li>LF - line feed (0x0A hex)</li>
- * <li>FF - form feed (0x0C hex)</li>
- * </ul>
- */
- def linesWithSeparators = new Iterator[String] {
- val len = self.length
- var index = 0
- def hasNext: Boolean = index < len
- def next(): String = {
- if (index >= len) throw new NoSuchElementException("next on empty iterator")
- val start = index
- while (index < len && !isLineBreak(apply(index))) index += 1
- index += 1
- self.substring(start, index min len)
- }
- }
-
- /** Return all lines in this string in an iterator, excluding trailing line
- * end characters, i.e. apply <code>.stripLineEnd</code> to all lines
- * returned by <code>linesWithSeparators</code>.
- */
- def lines: Iterator[String] =
- linesWithSeparators map (line => new BoxedString(line).stripLineEnd)
-
- /** Returns this string with first character converted to upper case */
- def capitalize: String =
- if (self == null) null
- else if (self.length == 0) ""
- else {
- val chars = self.toCharArray
- chars(0) = chars(0).toUpperCase
- new String(chars)
- }
-
- /** <p>
- * For every line in this string:
- * </p>
- * <blockquote>
- * Strip a leading prefix consisting of blanks or control characters
- * followed by <code>marginChar</code> from the line.
- * </blockquote>
- */
- def stripMargin(marginChar: Char): String = {
- val buf = new StringBuilder
- for (line <- linesWithSeparators) {
- val len = line.length
- var index = 0
- while (index < len && line.charAt(index) <= ' ') index += 1
- buf append
- (if (index < len && line.charAt(index) == marginChar) line.substring(index + 1) else line)
- }
- buf.toString
- }
-
- /** <p>
- * For every line in this string:
- * </p>
- * <blockquote>
- * Strip a leading prefix consisting of blanks or control characters
- * followed by <code>|</code> from the line.
- * </blockquote>
- */
- def stripMargin: String = stripMargin('|')
-
- private def escape(ch: Char): String = "\\Q" + ch + "\\E"
-
- @throws(classOf[java.util.regex.PatternSyntaxException])
- def split(separator: Char): Array[String] = self.split(escape(separator))
-
- @throws(classOf[java.util.regex.PatternSyntaxException])
- def split(separators: Array[Char]): Array[String] = {
- val re = separators.foldLeft("[")(_+escape(_)) + "]"
- self.split(re)
- }
-
- /** You can follow a string with `.r', turning
- * it into a Regex. E.g.
- *
- * """A\w*""".r is the regular expression for identifiers starting with `A'.
- */
- def r: Regex = new Regex(self)
-
- def toBoolean: Boolean = parseBoolean(self)
- def toByte: Byte = java.lang.Byte.parseByte(self)
- def toShort: Short = java.lang.Short.parseShort(self)
- def toInt: Int = java.lang.Integer.parseInt(self)
- def toLong: Long = java.lang.Long.parseLong(self)
- def toFloat: Float = java.lang.Float.parseFloat(self)
- def toDouble: Double = java.lang.Double.parseDouble(self)
-
- private def parseBoolean(s: String): Boolean =
- if (s != null) s.toLowerCase match {
- case "true" => true
- case "false" => false
- case _ => throw new NumberFormatException("For input string: \""+s+"\"")
- }
- else
- throw new NumberFormatException("For input string: \"null\"")
-
- def toArray: Array[Char] = {
- val result = new Array[Char](length)
- self.getChars(0, length, result, 0)
- result
- }
-}
-
diff --git a/src/library/scalax/runtime/ScalaRunTime.scala b/src/library/scalax/runtime/ScalaRunTime.scala
deleted file mode 100755
index 0c8416be89..0000000000
--- a/src/library/scalax/runtime/ScalaRunTime.scala
+++ /dev/null
@@ -1,152 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: ScalaRunTime.scala 17000 2009-01-29 13:05:53Z odersky $
-
-
-package scalax.runtime
-
-/* The object <code>ScalaRunTime</code> provides ...
- */
-object ScalaRunTime {
-
- def isArray(x: AnyRef): Boolean = (x != null && x.getClass.isArray) || (x != null && x.isInstanceOf[BoxedArray[_]])
- def isValueClass(clazz: Class[_]) = clazz.isPrimitive()
-
- def forceBoxedArray[A <: Any](xs: Seq[A]): Array[A] = {
- val array = new Array[A](xs.length)
- var i = 0
- for (x <- xs.elements) { array(i) = x; i += 1 }
- array
- }
-
- def checkInitialized[T <: AnyRef](x: T): T =
- if (x == null) throw new UninitializedError else x
-
- abstract class Try[a] {
- def Catch[b >: a](handler: PartialFunction[Throwable, b]): b
- def Finally(handler: Unit): a
- }
-
- def Try[a](block: => a): Try[a] = new Try[a] with Runnable {
- var result: a = _
- var exception: Throwable = scala.runtime.ExceptionHandling.tryCatch(this)
-
- def run(): Unit = result = block
-
- def Catch[b >: a](handler: PartialFunction[Throwable, b]): b =
- if (exception eq null)
- result.asInstanceOf[b]
- // !!! else if (exception is LocalReturn)
- // !!! // ...
- else if (handler isDefinedAt exception)
- handler(exception)
- else
- throw exception
-
- def Finally(handler: Unit): a =
- if (exception eq null)
- result.asInstanceOf[a]
- else
- throw exception
- }
-
- def caseFields(x: Product): List[Any] = {
- val arity = x.productArity
- def fields(from: Int): List[Any] =
- if (from == arity) List()
- else x.productElement(from) :: fields(from + 1)
- fields(0)
- }
-
- def _toString(x: Product): String =
- caseFields(x).mkString(x.productPrefix + "(", ",", ")")
-
- def _hashCode(x: Product): Int = {
- var code = x.getClass().hashCode()
- val arr = x.productArity
- var i = 0
- while (i < arr) {
- val elem = x.productElement(i)
- code = code * 41 + (if (elem == null) 0 else elem.hashCode())
- i += 1
- }
- code
- }
-
- def _equals(x: Product, y: Any): Boolean = y match {
- case y1: Product if x.productArity == y1.productArity =>
- val arity = x.productArity
- var i = 0
- while (i < arity && x.productElement(i) == y1.productElement(i))
- i += 1
- i == arity
- case _ =>
- false
- }
-
- def _equalsWithVarArgs(x: Product, y: Any): Boolean = y match {
- case y1: Product if x.productArity == y1.productArity =>
- val arity = x.productArity
- var i = 0
- while (i < arity - 1 && x.productElement(i) == y1.productElement(i))
- i += 1
- i == arity - 1 && {
- x.productElement(i) match {
- case xs: Seq[_] =>
- y1.productElement(i) match {
- case ys: Seq[_] => xs sameElements ys
- }
- }
- }
- case _ =>
- false
- }
-
- //def checkDefined[T >: Null](x: T): T =
- // if (x == null) throw new UndefinedException else x
-
- def Seq[a](xs: a*): Seq[a] = null // interpreted specially by new backend.
-
- def arrayValue[A](x: BoxedArray[A], elemClass: Class[_]): AnyRef =
- if (x eq null) null else x.unbox(elemClass)
-
- def boxArray(value: AnyRef): BoxedArray[_] = value match {
- case x: Array[Byte] => new BoxedByteArray(x)
-/*
- case x: Array[Short] => new BoxedShortArray(x)
- case x: Array[Char] => new BoxedCharArray(x)
- case x: Array[Int] => new BoxedIntArray(x)
- case x: Array[Long] => new BoxedLongArray(x)
- case x: Array[Float] => new BoxedFloatArray(x)
- case x: Array[Double] => new BoxedDoubleArray(x)
- case x: Array[Boolean] => new BoxedBooleanArray(x)
- case x: Array[AnyRef] => new BoxedObjectArray(x)
-*/
- case x: BoxedArray[_] => x
- }
-
- /** Given any Scala value, convert it to a String.
- *
- * The primary motivation for this method is to provide a means for
- * correctly obtaining a String representation of a value, while
- * avoiding the pitfalls of naïvely calling toString on said value.
- * In particular, it addresses the fact that (a) toString cannot be
- * called on null and (b) depending on the apparent type of an
- * array, toString may or may not print it in a human-readable form.
- *
- * @param arg the value to stringify
- * @return a string representation of <code>arg</code>
- *
- */
- def stringOf(arg : Any): String = arg match {
- case null => "null"
- case (arg : AnyRef) if isArray(arg) => boxArray(arg).deepToString
- case arg => arg.toString
- }
-}
diff --git a/src/library/scalax/runtime/StringVector.scala b/src/library/scalax/runtime/StringVector.scala
deleted file mode 100644
index a612b7d7a5..0000000000
--- a/src/library/scalax/runtime/StringVector.scala
+++ /dev/null
@@ -1,54 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id: Buffer.scala 15799 2008-08-15 18:23:54Z odersky $
-
-
-package scalax.runtime
-
-import collection.immutable.Vector
-import collection.mutable.ArrayBuffer
-import collection.generic.VectorTemplate
-import annotation.unchecked.uncheckedVariance
-
-object StringVector {
-
- implicit def unbox(sv: StringVector[Char]): String = sv.mkString
-
-}
-
-@cloneable
-abstract class StringVector[+A] extends VectorTemplate[StringVector, A @uncheckedVariance] with Vector[A] {
-
- /** The length of the string */
- def length: Int
-
- /** The element at given index */
- def apply(idx: Int): A
-
- /** Creates new builder for this collection */
- def newBuilder[B] = new ArrayBuffer[B].mapResult[StringVector] { // !!! Adriaan: can't drop [StringVector] here
- buf => new StringVector[B] {
- def length = buf.length
- def apply(n: Int) = buf.apply(n)
- override def foreach(f: B => Unit) = buf.foreach(f)
- }
- }
-
- def unbox: String = {
- val sb = new StringBuilder
- for (x <- this)
- sb append x.asInstanceOf[Char]
- sb.toString
- }
-
- override def toString = mkString
-
-}
-
-
diff --git a/src/library/scalax/util/control/Breaks.scala b/src/library/scalax/util/control/Breaks.scala
deleted file mode 100755
index e89a03f76b..0000000000
--- a/src/library/scalax/util/control/Breaks.scala
+++ /dev/null
@@ -1,24 +0,0 @@
-package scalax.util.control
-
-object Breaks {
- private class BreakException extends RuntimeException
- private val breakException = new BreakException
- private class ContinueException extends RuntimeException
- private val continueException = new ContinueException
-
- /** A block from which one can exit with a `break' and which can be resumed with a `continue'. */
- def breakable(op: => Unit) {
- try {
- op
- } catch {
- case ex: BreakException =>
- case ex: ContinueException => breakable(op)
- }
- }
-
- /* Break from closest enclosing breakable block */
- def break { throw breakException }
-
- /* Continue with start of closest enclosing breakable block */
- def continue { throw continueException }
-}
diff --git a/src/library/scalax/util/control/TailRec.scala b/src/library/scalax/util/control/TailRec.scala
deleted file mode 100644
index db6cbfa2ed..0000000000
--- a/src/library/scalax/util/control/TailRec.scala
+++ /dev/null
@@ -1,24 +0,0 @@
-package scala.util.control
-
-abstract class TailRec[+A]
-
-object TailRec {
-
- case class Call[A](rest: () => TailRec[A]) extends TailRec[A]
- case class Done[A](result: A) extends TailRec[A]
-
- def tailcall[A](rest: => TailRec[A]) = new Call(() => rest)
- def done [A](result: A) = new Done(result)
- def trampoline[A](body: TailRec[A]): A = {
- def loop(body: TailRec[A]): A = body match {
- case Call(rest) => loop(rest())
- case Done(result) => result
- }
- loop(body)
- }
- def loop[A](body: TailRec[A]): A = body match {
- case Call(rest) => loop[A](rest())
- case Done(result) => result
- }
-}
-