classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PATCH: LinkedList.removeFirst() & removeLast()


From: Bryce McKinlay
Subject: PATCH: LinkedList.removeFirst() & removeLast()
Date: Sat, 02 Dec 2000 14:46:22 +1300

Stuart Ballard wrote:

> Could whoever it was that did this
> rewrite (Tom?) take a look at these changes and reply to Adam?

Thanks, Adam. Your fix looks fine to me, but we also need to handle the
case where size == 1 and first == last. I'm checking this patch in to
libgcj and classpath.

regards

  [ bryce ]


2000-12-02  Bryce McKinlay  <address@hidden>

        From Adam Welc <address@hidden>:
        * java/util/LinkedList.java (removeFirst): Update `first' field.
        Handle the last == first case.
        (removeLast): Update `last' field. Handle the last == first case.

Index: java/util/LinkedList.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/util/LinkedList.java,v
retrieving revision 1.3
diff -u -r1.3 LinkedList.java
--- LinkedList.java     2000/11/03 03:58:05     1.3
+++ LinkedList.java     2000/12/02 01:39:54
@@ -183,6 +183,11 @@
     
     if (first.next != null)
       first.next.previous = null;
+    else
+      last = null;
+
+    first = first.next;
+    
     return r;
   }
 
@@ -195,7 +200,12 @@
     Object r = last.data;
     
     if (last.previous != null)
-      last.previous.next = null;    
+      last.previous.next = null;
+    else
+      first = null;
+    
+    last = last.previous;
+    
     return r;
   }
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]