diff options
| author | Bryce McKinlay <bryce@albatross.co.nz> | 2000-11-02 10:08:03 +0000 |
|---|---|---|
| committer | Bryce McKinlay <bryce@gcc.gnu.org> | 2000-11-02 10:08:03 +0000 |
| commit | 7177dab5c931138c85a1762acc54fd53880f4933 (patch) | |
| tree | 8357f25c2a8a67f24d63ee938da87068de9dfce6 /libjava/java/util/ArrayList.java | |
| parent | 17e2e7f92defe956f5b700558d58aefa96869817 (diff) | |
AbstractList.java: Throw messages with IndexOutOfBoundsExceptions.
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.
From-SVN: r37203
Diffstat (limited to 'libjava/java/util/ArrayList.java')
| -rw-r--r-- | libjava/java/util/ArrayList.java | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/libjava/java/util/ArrayList.java b/libjava/java/util/ArrayList.java index 75d4b406b66..084084cff3d 100644 --- a/libjava/java/util/ArrayList.java +++ b/libjava/java/util/ArrayList.java @@ -43,7 +43,7 @@ import java.io.ObjectStreamField; * to or removing from the end of a list, checking the size, &c. * * @author Jon A. Zeppieri - * @version $Id: ArrayList.java,v 1.6 2000/10/26 10:19:00 bryce Exp $ + * @version $Id: ArrayList.java,v 1.2 2000/10/29 05:06:10 bryce Exp $ * @see java.util.AbstractList * @see java.util.List */ @@ -187,7 +187,7 @@ public class ArrayList extends AbstractList if (fromIndex != toIndex) { System.arraycopy(data, toIndex, data, fromIndex, size - toIndex); - size -= (fromIndex - toIndex); + size -= (toIndex - fromIndex); } } @@ -219,9 +219,9 @@ public class ArrayList extends AbstractList */ public boolean addAll(Collection c) { + modCount++; Iterator itr = c.iterator(); int csize = c.size(); - modCount++; ensureCapacity(size + csize); for (int pos = 0; pos < csize; pos++) { @@ -240,13 +240,13 @@ public class ArrayList extends AbstractList */ public boolean addAll(int index, Collection c) { - Iterator itr = c.iterator(); - int csize = c.size(); - - modCount++; if (index < 0 || index > size) throw new IndexOutOfBoundsException("Index: " + index + ", Size:" + size); + modCount++; + Iterator itr = c.iterator(); + int csize = c.size(); + ensureCapacity(size + csize); int end = index + csize; if (size > 0 && index != size) |
