From 8856e75045a99a9510faa152d0dbe3ec5c0df68d Mon Sep 17 00:00:00 2001 From: bryce Date: Fri, 3 Nov 2000 03:58:05 +0000 Subject: 2000-11-03 Bryce McKinlay * java/util/AbstractList.java (SubList): Make it a top-level private class. * java/util/LinkedList.java (remove): Do update modCount and knownMod. (add): Ditto. * Makefile.am (ordinary_java_source_files): Add LinkedList.java. * Makefile.in: Rebuilt. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37218 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/java/util/LinkedList.java | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'libjava/java/util/LinkedList.java') diff --git a/libjava/java/util/LinkedList.java b/libjava/java/util/LinkedList.java index 5854496708e..22219294479 100644 --- a/libjava/java/util/LinkedList.java +++ b/libjava/java/util/LinkedList.java @@ -322,7 +322,7 @@ public class LinkedList extends AbstractSequentialList prev.next = e; prev = e; } - // Fix up the links between the last new entry and the following entry. + // Link the new chain of entries into the list. prev.next = after; if (after != null) after.previous = e; @@ -541,7 +541,7 @@ public class LinkedList extends AbstractSequentialList * position, in a list of given size. */ LinkedListItr(int index) - { + { if (index == size) { next = null; @@ -621,8 +621,8 @@ public class LinkedList extends AbstractSequentialList next = lastReturned.next; previous = lastReturned.previous; - // Because the list is being manipulated directly, there's no need to - // touch either modCount or knownMod here. + modCount++; + knownMod++; removeEntry(lastReturned); lastReturned = null; @@ -631,11 +631,27 @@ public class LinkedList extends AbstractSequentialList public void add(Object o) { checkMod(); - // Because the list is being manipulated directly, there's no need to - // touch either modCount or knownMod here. + modCount++; + knownMod++; Entry e = new Entry(o); - addEntry(position, e); + e.previous = previous; + e.next = next; + + if (previous != null) + previous.next = e; + else + first = e; + + if (next != null) + { + next.previous = e; + next = next.next; + } + else + last = e; + previous = e; + size++; position++; lastReturned = null; } -- cgit v1.2.1