diff options
author | Martin Odersky <odersky@gmail.com> | 2009-05-08 16:33:15 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2009-05-08 16:33:15 +0000 |
commit | 14a631a5fec42d04d0723355a0b93e482b5e4662 (patch) | |
tree | f639c2a22e89e193b9abea391993ecfd4d5326ee /src/library/scala/collection/mutable/DoubleLinkedList.scala | |
parent | 2379eb4ebbd28c8892b50a1d9fa8a687099eea4d (diff) | |
download | scala-14a631a5fec42d04d0723355a0b93e482b5e4662.tar.gz scala-14a631a5fec42d04d0723355a0b93e482b5e4662.tar.bz2 scala-14a631a5fec42d04d0723355a0b93e482b5e4662.zip |
massive new collections checkin.
Diffstat (limited to 'src/library/scala/collection/mutable/DoubleLinkedList.scala')
-rw-r--r-- | src/library/scala/collection/mutable/DoubleLinkedList.scala | 56 |
1 files changed, 20 insertions, 36 deletions
diff --git a/src/library/scala/collection/mutable/DoubleLinkedList.scala b/src/library/scala/collection/mutable/DoubleLinkedList.scala index db2a6299b4..6b8174357a 100644 --- a/src/library/scala/collection/mutable/DoubleLinkedList.scala +++ b/src/library/scala/collection/mutable/DoubleLinkedList.scala @@ -1,7 +1,7 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ @@ -11,42 +11,26 @@ package scala.collection.mutable +import generic._ -/** This extensible class may be used as a basis for implementing double - * linked lists. Type variable <code>A</code> refers to the element type - * of the list, type variable <code>This</code> is used to model self - * types of linked lists. +/** This class implements single linked lists where both the head (<code>elem</code>) + * and the tail (<code>next</code>) are mutable. * - * @author Matthias Zenger - * @version 1.0, 08/07/2003 + * @author Matthias Zenger + * @author Martin Odersky + * @version 2.8 */ -abstract class DoubleLinkedList[A, This >: Null <: DoubleLinkedList[A, This]] - extends SingleLinkedList[A, This] -{ self: This => - - var prev: This - - override def append(that: This): Unit = - if (that eq null) - () - else if (next eq null) { - next = that - that.prev = this - } else - next.append(that) - - override def insert(that: This): Unit = if (that ne null) { - that.append(next) - next = that - that.prev = this - } - - def remove() { - if (next ne null) - next.prev = prev - if (prev ne null) - prev.next = next - prev = null - next = null - } +@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 traversibleBuilder[B]: Builder[B, DoubleLinkedList[B], Any] = DoubleLinkedList.newBuilder[B] } + +object DoubleLinkedList extends SequenceFactory[DoubleLinkedList] { + type Coll = DoubleLinkedList[_] + implicit def builderFactory[A]: BuilderFactory[A, DoubleLinkedList[A], Coll] = new BuilderFactory[A, DoubleLinkedList[A], Coll] { def apply(from: Coll) = from.traversibleBuilder[A] } + def newBuilder[A]: Builder[A, DoubleLinkedList[A], Any] = null // !!! +} + + + |