From Adam Welc <welc@cs.purdue.edu>:
authorBryce McKinlay <bryce@albatross.co.nz>
Sat, 2 Dec 2000 01:48:07 +0000 (01:48 +0000)
committerBryce McKinlay <bryce@gcc.gnu.org>
Sat, 2 Dec 2000 01:48:07 +0000 (01:48 +0000)
* java/util/LinkedList.java (removeFirst): Update `first' field.
Handle the last == first case.
(removeLast): Update `last' field. Handle the last == first case.

From-SVN: r37940

libjava/ChangeLog
libjava/java/util/LinkedList.java

index d5b0c5b119eeb1ec28962aa979b5b9e3ca9a3102..3a1b79477bf62d20f3d20a059ebd026533a6c64e 100644 (file)
@@ -5,6 +5,11 @@
        * java/lang/dtoa.c: Include string.h.
        * java/lang/natString.cc (toLowerCase): Initialize `ch' to prevent
        compiler warning.
+       
+       From Adam Welc <welc@cs.purdue.edu>:
+       * java/util/LinkedList.java (removeFirst): Update `first' field.
+       Handle the last == first case.
+       (removeLast): Update `last' field. Handle the last == first case.
 
 2000-12-01  Warren Levy  <warrenl@cygnus.com>
 
index 22219294479586591314b6e5bc57eee4d72357c2..e3ce52587ea26bddaaaf46974b11f17f6472065c 100644 (file)
@@ -183,6 +183,11 @@ public class LinkedList extends AbstractSequentialList
     
     if (first.next != null)
       first.next.previous = null;
+    else
+      last = null;
+
+    first = first.next;
+    
     return r;
   }
 
@@ -195,7 +200,12 @@ public class LinkedList extends AbstractSequentialList
     Object r = last.data;
     
     if (last.previous != null)
-      last.previous.next = null;    
+      last.previous.next = null;
+    else
+      first = null;
+    
+    last = last.previous;
+    
     return r;
   }