diff options
author | Philipp Haller <hallerp@gmail.com> | 2009-09-08 10:37:01 +0000 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2009-09-08 10:37:01 +0000 |
commit | 6b01bf9c30fb8f52415166739508286a08f9e3db (patch) | |
tree | 032facdaedaa469d631b56620464236255fb4ef3 /src/library/scala/collection/mutable/DoubleLinkedList.scala | |
parent | ba6cdaf1f3b7b0b4dc8b90bd5a6bf0b68dbabaec (diff) | |
download | scala-6b01bf9c30fb8f52415166739508286a08f9e3db.tar.gz scala-6b01bf9c30fb8f52415166739508286a08f9e3db.tar.bz2 scala-6b01bf9c30fb8f52415166739508286a08f9e3db.zip |
Reintegrated DoubleLinkedList, SynchronizedBuff...
Reintegrated DoubleLinkedList, SynchronizedBuffer, ArrayStack,
BufferProxy.
Diffstat (limited to 'src/library/scala/collection/mutable/DoubleLinkedList.scala')
-rw-r--r-- | src/library/scala/collection/mutable/DoubleLinkedList.scala | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/library/scala/collection/mutable/DoubleLinkedList.scala b/src/library/scala/collection/mutable/DoubleLinkedList.scala index 3b28648489..e66a20c0cf 100644 --- a/src/library/scala/collection/mutable/DoubleLinkedList.scala +++ b/src/library/scala/collection/mutable/DoubleLinkedList.scala @@ -1,5 +1,3 @@ -/* TODO: reintegrate - /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL ** @@ -23,16 +21,29 @@ import scala.collection.generic._ * @version 2.8 */ @serializable -class DoubleLinkedList[A]/*(_elem: A, _next: DoubleLinkedList[A])*/ extends LinearSequence[A] with DoubleLinkedListTemplate[A, DoubleLinkedList[A]] { - override protected[this] def newBuilder = DoubleLinkedList.newBuilder - override def traversableBuilder[B]: Builder[B, DoubleLinkedList[B]] = DoubleLinkedList.newBuilder[B] +class DoubleLinkedList[A](_elem: A, _next: DoubleLinkedList[A]) extends LinearSequence[A] + with TraversableClass[A, DoubleLinkedList] + with DoubleLinkedListTemplate[A, DoubleLinkedList[A]] { + elem = _elem + next = _next + override def companion: Companion[DoubleLinkedList] = DoubleLinkedList } object DoubleLinkedList extends SequenceFactory[DoubleLinkedList] { - implicit def builderFactory[A]: BuilderFactory[A, DoubleLinkedList[A], Coll] = new BuilderFactory[A, DoubleLinkedList[A], Coll] { def apply(from: Coll) = from.traversableBuilder[A] } - def newBuilder[A]: Builder[A, DoubleLinkedList[A]] = null // !!! + implicit def builderFactory[A]: BuilderFactory[A, DoubleLinkedList[A], Coll] = //new BuilderFactory[A, DoubleLinkedList[A], Coll] { def apply(from: Coll) = from.traversableBuilder[A] } + new VirtualBuilderFactory[A] + def newBuilder[A]: Builder[A, DoubleLinkedList[A]] = + new Builder[A, DoubleLinkedList[A]] { + var current: DoubleLinkedList[A] = _ + def +=(elem: A): this.type = { + val tmp = new DoubleLinkedList(elem, null) + if (current != null) + current.insert(tmp) + else + current = tmp + this + } + def clear() { current = null } + def result() = current + } } - - - -*/ |