diff options
Diffstat (limited to 'src/library/scalax')
10 files changed, 0 insertions, 439 deletions
diff --git a/src/library/scalax/collection/generic/covariant/IterableFactory.scala b/src/library/scalax/collection/generic/covariant/IterableFactory.scala deleted file mode 100755 index 0fd2284cea..0000000000 --- a/src/library/scalax/collection/generic/covariant/IterableFactory.scala +++ /dev/null @@ -1,20 +0,0 @@ -package scalax.collection.generic.covariant - -trait IterableFactory[CC[+A] <: Iterable[A]] extends generic.IterableFactory[CC] { - - /** The empty collection of type CC */ - val empty: CC[Nothing] - - override protected def newBuilder[A]: Builder[CC, A] = - empty.newBuilder[A].asInstanceOf[Builder[CC, A]] - // the cast here is unavoidable because CC is not constrained with covariant.IterableTemplate[CC, A] - // It's can't be constrained because some suntype links between covariant and generic Templates - // are missing. That's a consequence of our hacks to have both nonvariant and covariant templates. - - /** Create CC collection of specified elements */ - override def apply[A](args: A*): CC[A] = - (empty ++ args.asInstanceOf[Iterable[A]]).asInstanceOf[CC[A]] - // the cast here is unavoidable because CC is not constrained with covariant.IterableTemplate[CC, A] - // It's can't be constrained because some suntype links between covariant and generic Templates - // are missing. That's a consequence of our hacks to have both nonvariant and covariant templates. -} diff --git a/src/library/scalax/collection/generic/covariant/IterableTemplate.scala b/src/library/scalax/collection/generic/covariant/IterableTemplate.scala deleted file mode 100755 index 715f88cd8e..0000000000 --- a/src/library/scalax/collection/generic/covariant/IterableTemplate.scala +++ /dev/null @@ -1,39 +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.covariant - -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>Collection</code>. - * Only potentially unbounded collections should directly sub-class <code>Iterable</code>. - * @author Matthias Zenger - * @version 1.1, 04/02/2004 - */ -trait IterableTemplate[+CC[+B] <: IterableTemplate[CC, B] with Iterable[B], +A] - extends generic.IterableTemplate[CC, A @uncheckedVariance] { self /*: CC[A]*/ => - -/* can't have a covariant view here, because mutable.Vector would - override it - override def view: IterableView[CC, A] = new IterableView[CC, A] { - val origin = thisCC - val elements: Iterator[A] = self.elements - } -*/ -} - - -// !!! todo: explain why @uncheckedVariance is justified here. - diff --git a/src/library/scalax/collection/generic/covariant/OrderedIterableTemplate.scala b/src/library/scalax/collection/generic/covariant/OrderedIterableTemplate.scala deleted file mode 100755 index 77e72c19d5..0000000000 --- a/src/library/scalax/collection/generic/covariant/OrderedIterableTemplate.scala +++ /dev/null @@ -1,17 +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.covariant - -import annotation.unchecked.uncheckedVariance - -trait OrderedIterableTemplate[+CC[+B] <: OrderedIterable[B] with OrderedIterableTemplate[CC, B], +A] - extends generic.OrderedIterableTemplate[CC, A @uncheckedVariance] {self /*: CC[A]*/ => } diff --git a/src/library/scalax/collection/generic/covariant/SequenceFactory.scala b/src/library/scalax/collection/generic/covariant/SequenceFactory.scala deleted file mode 100755 index 49a6e685fa..0000000000 --- a/src/library/scalax/collection/generic/covariant/SequenceFactory.scala +++ /dev/null @@ -1,3 +0,0 @@ -package scalax.collection.generic.covariant - -trait SequenceFactory[CC[+A] <: Sequence[A]] extends IterableFactory[CC] with generic.SequenceFactory[CC] diff --git a/src/library/scalax/collection/generic/covariant/SequenceTemplate.scala b/src/library/scalax/collection/generic/covariant/SequenceTemplate.scala deleted file mode 100755 index 1e8a416aec..0000000000 --- a/src/library/scalax/collection/generic/covariant/SequenceTemplate.scala +++ /dev/null @@ -1,17 +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.covariant - -import annotation.unchecked.uncheckedVariance - -trait SequenceTemplate[+CC[+B] <: SequenceTemplate[CC, B] with Sequence[B], +A] - extends generic.SequenceTemplate[CC, A @uncheckedVariance] diff --git a/src/library/scalax/collection/generic/covariant/VectorTemplate.scala b/src/library/scalax/collection/generic/covariant/VectorTemplate.scala deleted file mode 100644 index ee618abd21..0000000000 --- a/src/library/scalax/collection/generic/covariant/VectorTemplate.scala +++ /dev/null @@ -1,17 +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.covariant - -import annotation.unchecked.uncheckedVariance - -trait VectorTemplate[+CC[+B] <: VectorTemplate[CC, B] with Vector[B], +A] - extends generic.VectorTemplate[CC, A @uncheckedVariance] {self /*: CC[A]*/ => } diff --git a/src/library/scalax/collection/generic/mutable/Growable.scala b/src/library/scalax/collection/generic/mutable/Growable.scala deleted file mode 100644 index 4d585129ad..0000000000 --- a/src/library/scalax/collection/generic/mutable/Growable.scala +++ /dev/null @@ -1,94 +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.mutable - -/** This class represents collections that can be augmented using a += operator. - * - * @autor Martin Odersky - * @owner Martin Odersky - * @version 2.8 - */ -trait Growable[A] { - - /** Add a single element to this collection. - * - * @param elem the element to add. - */ - def +=(elem: A): Unit - - /** Add a 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 - * - * @param iter the iterator. - */ - def ++=(iter: collection.Iterator[A]) { iter foreach += } - - /** Adds a number of elements provided by an iterable object - * via its <code>elements</code> method. - * - * @param iter the iterable object. - */ - def ++=(iter: collection.Iterable[A]) { iter foreach += } - - /** Add a single element to this collection and return - * the identity of the collection. - * - * @param elem the element to add. - */ - def +(elem: A): this.type = { this += elem; this } - - /** Add two or more elements to this collection and return - * the identity of the 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.type = - this + elem1 + elem2 ++ elems.asInstanceOf[Iterable[A]] // !@! - - /** Adds a number of elements provided by an iterable object - * via its <code>elements</code> method. The identity of the - * collection is returned. - * - * @param iter the iterable object. - * @return the updated collection. - */ - def ++(iter: Iterable[A]): this.type = { this ++= iter; this } - - /** Adds a number of elements provided by an iterator - * via its <code>elements</code> method. The identity of the - * collection is returned. - * - * @param iter the iterator - * @return the updated collection. - */ - def ++(iter: Iterator[A]): this.type = { this ++= iter; this } - - /** Clears the collection contents. - */ - def clear() -} - - - - diff --git a/src/library/scalax/collection/generic/mutable/Shrinkable.scala b/src/library/scalax/collection/generic/mutable/Shrinkable.scala deleted file mode 100644 index 49e1b57eb6..0000000000 --- a/src/library/scalax/collection/generic/mutable/Shrinkable.scala +++ /dev/null @@ -1,82 +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.mutable - -/** This class represents collections that can be shrunk using a -= operator. - * - * @autor Martin Odersky - * @owner Martin Odersky - * @version 2.8 - */ -trait Shrinkable[A] { - - /** Remove a single element from this collection. - * - * @param elem the element to append. - */ - def -=(elem: A): Unit - - /** Remove two or more elements from this collection. - * @param elem1 the first element. - * @param elem2 the second element. - * @param elems the remaining elements. - */ - def -= (elem1: A, elem2: A, elems: A*) { - this -= elem1 - this -= elem2 - this --= elems.asInstanceOf[Iterable[A]] // !@! - } - - /** Remove all the elements provided by an iterable - * <code>elems</code> from the collection. - */ - def --=(elems: Iterable[A]) { elems foreach -= } - - /** Remove all the elements provided by an iterator - * <code>elems</code> from the collection. - */ - def --=(elems: Iterator[A]) { elems foreach -= } - /** Remove a single element from the collection. - * @return the collection itself with the element removed. - * - * @param elem the element to be removed - */ - def - (elem: A): this.type = { -=(elem); this } - - /** Remove two or more elements from this collection. - * - * @param elem1 the first element. - * @param elem2 the second element. - * @param elems the remaining elements. - * @return the collection itself with the elements removed. - */ - def - (elem1: A, elem2: A, elems: A*): this.type = { -=(elem1, elem2, elems: _*); this } - - /** Remove all the elements provided by an iterator - * <code>elems</code> from the collection. - * - * @param elems An iterator containing the elements to remove from the collection. - * @return the collection itself with the elements removed. - */ - def -- (elems: Iterable[A]): this.type = { this --= elems; this } - - /** Remove all the elements provided by an iterator - * <code>elems</code> from the collection. - * - * @param elems An iterator containing the elements to remove from the collection. - * @return the collection itself with the elements removed. - */ - def -- (elems: Iterator[A]): this.type = { this --= elems; this } -} - - - - diff --git a/src/library/scalax/collection/generic/mutable/VectorTemplate.scala b/src/library/scalax/collection/generic/mutable/VectorTemplate.scala deleted file mode 100644 index 4d748a79d1..0000000000 --- a/src/library/scalax/collection/generic/mutable/VectorTemplate.scala +++ /dev/null @@ -1,55 +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.mutable - -import collection.mutable.Vector -import collection.mutable.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 generic.VectorTemplate[CC, A] { -self => - - def update(idx: Int, elem: A) - - /** Creates a view of this iterable @see OrderedIterable.View - */ - override def view: VectorView[CC, A] = new VectorView[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): VectorView[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/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)) - } -} - |