diff options
author | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-11-02 10:08:03 +0000 |
---|---|---|
committer | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-11-02 10:08:03 +0000 |
commit | 369a67794e5de32d7ce0891ed9fafd8808089cd9 (patch) | |
tree | 8357f25c2a8a67f24d63ee938da87068de9dfce6 /libjava/java/util/AbstractSequentialList.java | |
parent | 520ad935e451f8ddfc00786d524d29e92f25012e (diff) | |
download | ppe42-gcc-369a67794e5de32d7ce0891ed9fafd8808089cd9.tar.gz ppe42-gcc-369a67794e5de32d7ce0891ed9fafd8808089cd9.zip |
2000-11-02 Bryce McKinlay <bryce@albatross.co.nz>
* java/util/AbstractList.java: Throw messages with
IndexOutOfBoundsExceptions.
(listIterator()): Call listIterator(0).
(size): New field. Initialize to size().
(hasNext): Test position against size, not size().
(remove): Increment knownMod by one instead of resetting it from
modCount.
(add): Ditto.
(SubList.upMod): Removed.
(SubList.set): Don't call upMod() or update knownMod.
(SubList.add(int,Object)): Increment modCount instead of calling
upMod().
(SubList.remove): Ditto.
(SubList.addAll): Don't call backingList.size(). Increment size from
c.size().
(SubList.iterator): New method. Call listIterator(0).
(SubList.listIterator): New method. Restore code to return an
anonymous listIterator implementation (with some changes).
* java/util/AbstractSequentialList.java: Throw messages with
IndexOutOfBoundsExceptions.
(addAll): Add a specnote.
* java/util/ArrayList.java (removeRange): Get the math right.
(addAll): Increment modCount _before_ creating iterator.
* java/util/LinkedList.java: Rewritten, mostly.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37203 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/util/AbstractSequentialList.java')
-rw-r--r-- | libjava/java/util/AbstractSequentialList.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libjava/java/util/AbstractSequentialList.java b/libjava/java/util/AbstractSequentialList.java index 07809da0c41..b9b8e63d1f6 100644 --- a/libjava/java/util/AbstractSequentialList.java +++ b/libjava/java/util/AbstractSequentialList.java @@ -64,6 +64,12 @@ public abstract class AbstractSequentialList extends AbstractList i.add(o); } + /** + * @specnote The spec in the JDK1.3 online docs is wrong. The implementation + * should not call next() to skip over new elements as they are + * added, because iterator.add() should add new elements BEFORE + * the cursor. + */ public boolean addAll(int index, Collection c) { boolean modified = false; @@ -81,7 +87,8 @@ public abstract class AbstractSequentialList extends AbstractList { ListIterator i = listIterator(index); if (index < 0 || index > size()) - throw new IndexOutOfBoundsException(); + throw new IndexOutOfBoundsException("Index: " + index + ", Size:" + + size()); return i.next(); } @@ -100,7 +107,8 @@ public abstract class AbstractSequentialList extends AbstractList { ListIterator i = listIterator(index); if (index < 0 || index > size()) - throw new IndexOutOfBoundsException(); + throw new IndexOutOfBoundsException("Index: " + index + ", Size:" + + size()); Object removed = i.next(); i.remove(); return removed; @@ -110,7 +118,8 @@ public abstract class AbstractSequentialList extends AbstractList { ListIterator i = listIterator(index); if (index < 0 || index > size()) - throw new IndexOutOfBoundsException(); + throw new IndexOutOfBoundsException("Index: " + index + ", Size:" + + size()); Object old = i.next(); i.set(o); return old; |