diff options
author | Martin Odersky <odersky@gmail.com> | 2009-02-15 15:41:08 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2009-02-15 15:41:08 +0000 |
commit | f2032c958854476587f6e78668b16216a28dc9a8 (patch) | |
tree | ca223769bb1e6fcca3d69b62364646ccc817de59 /src/library/scalax/collection/generic/mutable/VectorView.scala | |
parent | 04840e2ed4530df9a5ca59b984bf2b37a976dc70 (diff) | |
download | scala-f2032c958854476587f6e78668b16216a28dc9a8.tar.gz scala-f2032c958854476587f6e78668b16216a28dc9a8.tar.bz2 scala-f2032c958854476587f6e78668b16216a28dc9a8.zip |
removed generic/mutable, generic/covariant pack...
removed generic/mutable, generic/covariant packages
Diffstat (limited to 'src/library/scalax/collection/generic/mutable/VectorView.scala')
-rw-r--r-- | src/library/scalax/collection/generic/mutable/VectorView.scala | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/src/library/scalax/collection/generic/mutable/VectorView.scala b/src/library/scalax/collection/generic/mutable/VectorView.scala deleted file mode 100644 index 05d2ad8152..0000000000 --- a/src/library/scalax/collection/generic/mutable/VectorView.scala +++ /dev/null @@ -1,95 +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.mutable - -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 VectorView[+UC[B] <: Vector[B], A] extends SequenceView[UC, A] with Vector[A] { -self => - - /** refined from Iterable.View */ - val origin: Vector[_] - - trait Transformed[B] extends super.Transformed[B] with VectorView[UC, B] { - override val origin = self - override def elements: Iterator[B] = new Elements(0, length) - override protected def asCC = asInstanceOf[VectorView[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]): VectorView[UC, A] = - new Appended(that).asCC - - override def reverse: VectorView[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]): VectorView[UC, (A, B)] = - new Zipped(toVector(that)).asCC - - override def zipWithIndex: VectorView[UC, (A, Int)] = - zip((0 until length).asInstanceOf[Null]) // !@! - override def take(n: Int): VectorView[UC, A] = - slice(0, n) - override def drop(n: Int): VectorView[UC, A] = - slice(n, Math.MAX_INT) - override def splitAt(n: Int): (VectorView[UC, A], VectorView[UC, A]) = (take(n), drop(n)) - override def slice(from: Int, until: Int): VectorView[UC, A] = - new Sliced(from, until).asCC - override def takeWhile(p: A => Boolean): VectorView[UC, A] = - take(prefixLength(p)) - override def dropWhile(p: A => Boolean): VectorView[UC, A] = - drop(prefixLength(p)) - override def span(p: A => Boolean): (VectorView[UC, A], VectorView[UC, A]) = { - val n = prefixLength(p) - (take(n), drop(n)) - } -} - |