summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/generic/DoubleLinkedListTemplate.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2009-05-08 16:33:15 +0000
committerMartin Odersky <odersky@gmail.com>2009-05-08 16:33:15 +0000
commit14a631a5fec42d04d0723355a0b93e482b5e4662 (patch)
treef639c2a22e89e193b9abea391993ecfd4d5326ee /src/library/scala/collection/generic/DoubleLinkedListTemplate.scala
parent2379eb4ebbd28c8892b50a1d9fa8a687099eea4d (diff)
downloadscala-14a631a5fec42d04d0723355a0b93e482b5e4662.tar.gz
scala-14a631a5fec42d04d0723355a0b93e482b5e4662.tar.bz2
scala-14a631a5fec42d04d0723355a0b93e482b5e4662.zip
massive new collections checkin.
Diffstat (limited to 'src/library/scala/collection/generic/DoubleLinkedListTemplate.scala')
-rwxr-xr-xsrc/library/scala/collection/generic/DoubleLinkedListTemplate.scala47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/library/scala/collection/generic/DoubleLinkedListTemplate.scala b/src/library/scala/collection/generic/DoubleLinkedListTemplate.scala
new file mode 100755
index 0000000000..c86717f517
--- /dev/null
+++ b/src/library/scala/collection/generic/DoubleLinkedListTemplate.scala
@@ -0,0 +1,47 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id: DoubleLinkedList.scala 16893 2009-01-13 13:09:22Z cunei $
+
+
+package scala.collection.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.
+ *
+ * @author Matthias Zenger
+ * @version 1.0, 08/07/2003
+ */
+trait DoubleLinkedListTemplate[A, This >: Null <: LinearSequence[A] with DoubleLinkedListTemplate[A, This]] extends LinkedListTemplate[A, This] { self =>
+
+ var prev: This = _
+
+ override def append(that: This): Unit =
+ if (next eq null) {
+ next = that
+ if (that ne null) that.prev = thisCollection
+ } else
+ next.append(that)
+
+ override def insert(that: This): Unit = if (that ne null) {
+ that.append(next)
+ next = that
+ that.prev = thisCollection
+ }
+
+ def remove() {
+ if (next ne null)
+ next.prev = prev
+ if (prev ne null)
+ prev.next = next
+ prev = null
+ next = null
+ }
+}