separated Vector impl from IndexedSeq

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@19354 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
rompf 2009-10-30 07:51:23 +00:00
parent 14bc60bfd6
commit 7461f1b325
9 changed files with 1106 additions and 1084 deletions

View File

@ -12,7 +12,7 @@
package scala.collection
import generic._
import scala.collection.mutable.Builder
import mutable.Builder
/** <p>
* Sequences that support O(1) element access and O(1) length computation.
@ -34,9 +34,7 @@ trait IndexedSeq[+A] extends Seq[A]
}
object IndexedSeq extends SeqFactory[IndexedSeq] {
override def empty[A]: IndexedSeq[A] = immutable.IndexedSeq.empty[A]
implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, IndexedSeq[A]] = new GenericCanBuildFrom[A]
def newBuilder[A]: Builder[A, IndexedSeq[A]] = immutable.IndexedSeq.newBuilder[A]
@deprecated("use collection.mutable.IndexedSeq instead") type Mutable[A] = scala.collection.mutable.IndexedSeq[A]
}

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@ package immutable
import generic._
import mutable.Builder
/** A subtrait of <code>collection.Seq</code> which represents sequences
/** A subtrait of <code>collection.LinearSeq</code> which represents sequences
* that cannot be mutated.
*
* @since 2.8

File diff suppressed because it is too large Load Diff

View File

@ -40,6 +40,9 @@ package object scala {
val Stream = scala.collection.immutable.Stream
val #:: = scala.collection.immutable.Stream.#::
type Vector[+A] = scala.collection.immutable.Vector[A]
val Vector = scala.collection.immutable.Vector
type StringBuilder = scala.collection.mutable.StringBuilder
val StringBuilder = scala.collection.mutable.StringBuilder

View File

@ -8,7 +8,7 @@ object Test {
b.result
}
collect[Int, IndexedSeq[Int]](List(1,2,3,4))
collect[Int, Vector[Int]](List(1,2,3,4))
collect[Char, String](List('1','2','3','4'))
collect[Char, Array[Char]](List('1','2','3','4'))
}

View File

@ -29,7 +29,7 @@ sealed abstract class List[@specialized +A] extends LinearSeq[A]
with LinearSeqLike[A, List[A]] {
override def companion: GenericCompanion[List] = List
import scala.collection.{Iterable, Traversable, Seq, IndexedSeq}
import scala.collection.{Iterable, Traversable, Seq}
/** Returns true if the list does not contain any elements.
* @return <code>true</code>, iff the list is empty.
@ -494,7 +494,7 @@ final case class ::[@specialized B](private var hd: B, private[scala] var tl: Li
*/
object List extends SeqFactory[List] {
import collection.{Iterable, Seq, IndexedSeq}
import collection.{Iterable, Seq}
implicit def builderFactory[A]: CanBuildFrom[Coll, A, List[A]] =
new GenericCanBuildFrom[A] {

View File

@ -72,6 +72,16 @@ new test starting with List()
9: List(2, 3, 4, 5, 6, 7, 8, 9, 10)
1
List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
new test starting with IndexedSeq()
10: IndexedSeq(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
9: IndexedSeq(2, 3, 4, 5, 6, 7, 8, 9, 10)
1
IndexedSeq(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
new test starting with Vector()
10: Vector(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
9: Vector(2, 3, 4, 5, 6, 7, 8, 9, 10)
1
Vector(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
new test starting with List()
10: List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
9: List(2, 3, 4, 5, 6, 7, 8, 9, 10)

View File

@ -213,6 +213,8 @@ object Test extends Application {
sequenceTest(mutable.Seq())
sequenceTest(immutable.Seq())
sequenceTest(LinearSeq())
sequenceTest(IndexedSeq())
sequenceTest(Vector())
// sequenceTest(mutable.LinearSeq())
sequenceTest(immutable.LinearSeq())
sequenceTest(mutable.IndexedSeq())