This is the mail archive of the java-patches@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH: LinkedList.removeFirst() & removeLast()


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  <bryce@albatross.co.nz>

	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.

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;
   }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]