diff options
author | Paul Phillips <paulp@improving.org> | 2011-03-27 19:46:12 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-03-27 19:46:12 +0000 |
commit | c17e46682a9b42eaf4d33d9f60b50c826ab4009e (patch) | |
tree | 2c18c246de913d41b513354d5f3785693a2cd699 /src/library/scala/collection/mutable/DoubleLinkedListLike.scala | |
parent | fbdda78887e6dc594d08bf2376d0bba164d14009 (diff) | |
download | scala-c17e46682a9b42eaf4d33d9f60b50c826ab4009e.tar.gz scala-c17e46682a9b42eaf4d33d9f60b50c826ab4009e.tar.bz2 scala-c17e46682a9b42eaf4d33d9f60b50c826ab4009e.zip |
Fix for linked lists closes #4080 and proves my...
Fix for linked lists closes #4080 and proves my desire not to ship
obviously broken code is even greater than my will to hold out for any
help. I threw in a free fix for this which I noticed while in there.
scala> scala.collection.mutable.LinkedList[Int]().head
res0: Int = 0
Also was reminded how useless tests can be:
val ten = DoubleLinkedList(1 to 10: _*)
ten.insert(DoubleLinkedList(11))
// Post-insert position test
require(ten.last == 11)
Fortunately a test confirming buggy behavior still serves a purpose by
breaking when you fix the bug which allowed it to pass, thus letting you
fix the broken test too. Life's (very) little compensations. Linked list
code should still be presumed broken. No review.
Diffstat (limited to 'src/library/scala/collection/mutable/DoubleLinkedListLike.scala')
-rw-r--r-- | src/library/scala/collection/mutable/DoubleLinkedListLike.scala | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/library/scala/collection/mutable/DoubleLinkedListLike.scala b/src/library/scala/collection/mutable/DoubleLinkedListLike.scala index 18a0e164a2..7ad2f9558f 100644 --- a/src/library/scala/collection/mutable/DoubleLinkedListLike.scala +++ b/src/library/scala/collection/mutable/DoubleLinkedListLike.scala @@ -110,12 +110,9 @@ trait DoubleLinkedListLike[A, This <: Seq[A] with DoubleLinkedListLike[A, This]] private def outofbounds(n: Int) = throw new IndexOutOfBoundsException(n.toString) - override def drop(n: Int): This = super[SeqLike].drop(n) - - override def tail = drop(1) - - override def apply(n: Int): A = atLocation(n)(_.elem)(outofbounds(n)) - override def update(n: Int, x: A): Unit = atLocation(n)(_.elem = x)(outofbounds(n)) - override def get(n: Int): Option[A] = atLocation[Option[A]](n)(x => Some(x.elem))(None) - + override def drop(n: Int): This = super[SeqLike].drop(n) + override def tail = drop(1) + override def apply(n: Int): A = atLocation(n)(_.elem)(outofbounds(n)) + override def update(n: Int, x: A): Unit = atLocation(n)(_.elem = x)(outofbounds(n)) + override def get(n: Int): Option[A] = atLocation[Option[A]](n)(x => Some(x.elem))(None) } |