summaryrefslogtreecommitdiff
path: root/libjava/java/util/LinkedList.java
diff options
context:
space:
mode:
authorBryce McKinlay <bryce@albatross.co.nz>2000-11-03 03:58:05 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>2000-11-03 03:58:05 +0000
commit8d218b6742d2cd67c639ad6668431a56ccca0705 (patch)
tree513ddc423b9316dfe96f3d5e79a6ca4749279337 /libjava/java/util/LinkedList.java
parent19944601d69c0777c1aec481792c201a3b58b960 (diff)
AbstractList.java (SubList): Make it a top-level private class.
2000-11-03 Bryce McKinlay <bryce@albatross.co.nz> * 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. From-SVN: r37218
Diffstat (limited to 'libjava/java/util/LinkedList.java')
-rw-r--r--libjava/java/util/LinkedList.java30
1 files changed, 23 insertions, 7 deletions
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;
}