diff options
author | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-11-27 08:30:26 +0000 |
---|---|---|
committer | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-11-27 08:30:26 +0000 |
commit | a6547bafa26e1948e2c941f0810ccd60e432d9ff (patch) | |
tree | b0e987ae6c453d2859183427b6ec7482250e8054 /libjava/java/util/ArrayList.java | |
parent | d7503801e5662ff8d132df1e21bdfcbeaa3a5174 (diff) | |
download | ppe42-gcc-a6547bafa26e1948e2c941f0810ccd60e432d9ff.tar.gz ppe42-gcc-a6547bafa26e1948e2c941f0810ccd60e432d9ff.zip |
2000-11-27 Bryce McKinlay <bryce@albatross.co.nz>
* java/util/Vector.java (ensureCapacity): Don't increment modCount.
(addElement): Don't increment elementCount twice. Doh.
* java/util/ArrayList.java (add): Only call ensureCapacity if the
array needs to be expanded.
(addAll): Ditto.
* java/util/Collections.java (UnmodifiableCollection): Implement
toString().
(UnmodifiableList): Throw UnsupportedOperationException from
modification methods. Set `l' from the one-parameter constructor.
(UnmodifiableMap): Implement toString().
(SynchronizedCollection): Ditto.
(SynchronizedList): Set `l' from the one-parameter constructor.
(SynchronizedSortedSet): Set `ss' from the one-parameter constructor.
(SynchronizedMap): Implement toString().
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37785 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/util/ArrayList.java')
-rw-r--r-- | libjava/java/util/ArrayList.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/libjava/java/util/ArrayList.java b/libjava/java/util/ArrayList.java index ef7d6e5f7d3..d440cdaec52 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.3 2000/11/02 10:08:03 bryce Exp $ + * @version $Id: ArrayList.java,v 1.4 2000/11/22 11:59:59 bryce Exp $ * @see java.util.AbstractList * @see java.util.List */ @@ -127,7 +127,8 @@ public class ArrayList extends AbstractList public boolean add(Object e) { modCount++; - ensureCapacity(size + 1); + if (size == data.length) + ensureCapacity(size + 1); data[size++] = e; return true; } @@ -204,7 +205,8 @@ public class ArrayList extends AbstractList if (index < 0 || index > size) throw new IndexOutOfBoundsException("Index: " + index + ", Size:" + size); - ensureCapacity(size + 1); + if (size == data.length) + ensureCapacity(size + 1); if (index != size) System.arraycopy(data, index, data, index + 1, size - index); data[index] = e; @@ -239,7 +241,8 @@ public class ArrayList extends AbstractList Iterator itr = c.iterator(); int csize = c.size(); - ensureCapacity(size + csize); + if (csize + size > data.length) + ensureCapacity(size + csize); int end = index + csize; if (size > 0 && index != size) System.arraycopy(data, index, data, end, csize); |