blob: 743ab9897d56c62939ba2e38fb8887baf4790f0c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
package scala.collection.immutable
import generic._
import mutable.ArrayBuffer
/** A subtrait of collection.Vector which represents sequences
* that cannot be mutated.
*/
trait Vector[+A] extends Sequence[A]
with collection.Vector[A]
with TraversableClass[A, Vector]
with VectorTemplate[A, Vector[A]] {
override def companion: Companion[Vector] = Vector
}
object Vector extends SequenceFactory[Vector] {
class Impl[A](buf: ArrayBuffer[A]) extends Vector[A] { // todo: insert better vector implementation here
def length = buf.length
def apply(idx: Int) = buf.apply(idx)
}
implicit def builderFactory[A]: BuilderFactory[A, Vector[A], Coll] = new VirtualBuilderFactory[A]
def newBuilder[A]: Builder[A, Vector[A]] = new ArrayBuffer[A] mapResult (buf => new Impl(buf))
}
|