summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/mutable/MutableList.scala
diff options
context:
space:
mode:
authorAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-11-19 12:38:09 +0000
committerAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-11-19 12:38:09 +0000
commit349c8baeabaac7b59c58ada4043b7f35a94e848f (patch)
treec4e71d165450261b881fd005123b7a91b9a435da /src/library/scala/collection/mutable/MutableList.scala
parentfcbf3715187470c8568057bebb7f9577f6163e88 (diff)
downloadscala-349c8baeabaac7b59c58ada4043b7f35a94e848f.tar.gz
scala-349c8baeabaac7b59c58ada4043b7f35a94e848f.tar.bz2
scala-349c8baeabaac7b59c58ada4043b7f35a94e848f.zip
Better integration for mutable list and queue.
No review.x
Diffstat (limited to 'src/library/scala/collection/mutable/MutableList.scala')
-rw-r--r--src/library/scala/collection/mutable/MutableList.scala20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/library/scala/collection/mutable/MutableList.scala b/src/library/scala/collection/mutable/MutableList.scala
index a81cb27cf1..79c05dff11 100644
--- a/src/library/scala/collection/mutable/MutableList.scala
+++ b/src/library/scala/collection/mutable/MutableList.scala
@@ -26,16 +26,22 @@ import immutable.{List, Nil}
* @since 1
*/
@serializable @SerialVersionUID(5938451523372603072L)
-class MutableList[A] extends LinearSeq[A]
- with LinearSeqOptimized[A, MutableList[A]]
- with Builder[A, MutableList[A]] {
+class MutableList[A]
+extends LinearSeq[A]
+ with LinearSeqOptimized[A, MutableList[A]]
+ with GenericTraversableTemplate[A, MutableList]
+ with Builder[A, MutableList[A]]
+{
+ override def companion: GenericCompanion[MutableList] = MutableList
- override protected[this] def newBuilder = new MutableList[A]
+ override protected[this] def newBuilder: Builder[A, MutableList[A]] = new MutableList[A]
protected var first0: LinkedList[A] = new LinkedList[A]
- protected var last0: LinkedList[A] = _ // undefined if first0.isEmpty
+ protected var last0: LinkedList[A] = first0
protected var len: Int = 0
+ def toQueue = new Queue(first0, last0, len)
+
/** Is the list empty?
*/
override def isEmpty = len == 0
@@ -136,8 +142,10 @@ class MutableList[A] extends LinearSeq[A]
}
-object MutableList {
+object MutableList extends SeqFactory[MutableList] {
+ implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, MutableList[A]] = new GenericCanBuildFrom[A]
+ def newBuilder[A]: Builder[A, MutableList[A]] = new MutableList[A]
}