summaryrefslogtreecommitdiff
path: root/libjava/java/util/ArrayList.java
diff options
context:
space:
mode:
authorBryce McKinlay <bryce@albatross.co.nz>2000-11-22 11:59:59 +0000
committerBryce McKinlay <bryce@gcc.gnu.org>2000-11-22 11:59:59 +0000
commit79af883cd48fbd3267a319c8d89aefc2ed129516 (patch)
tree9f0271f14f274b6e8dc112c3c88edbeb6d136806 /libjava/java/util/ArrayList.java
parente9905e2d9d42a818ec671da242e56c44a14baac5 (diff)
downloadgcc-79af883cd48fbd3267a319c8d89aefc2ed129516.tar.gz
Makefile.in: Rebuilt.
2000-11-22 Bryce McKinlay <bryce@albatross.co.nz> * Makefile.in: Rebuilt. * Makefile.am (core_java_source_files): Added Collections.java. * java/util/List.java: Merged from classpath. * java/util/Vector.java: Ditto. * java/util/Collections.java: From classpath. * java/util/ArrayList.java (addAll(Collection)): Call addAll(int,Collection) instead of duplicating code. (indexOf): Clean up int initialization. (clear): Set cleared array entries to null, to allow garbage collection. * java/util/List.java: Minor formatting fixes. * java/util/SimpleTimeZone.java: ditto. From-SVN: r37652
Diffstat (limited to 'libjava/java/util/ArrayList.java')
-rw-r--r--libjava/java/util/ArrayList.java24
1 files changed, 9 insertions, 15 deletions
diff --git a/libjava/java/util/ArrayList.java b/libjava/java/util/ArrayList.java
index 084084cff3d..ef7d6e5f7d3 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.2 2000/10/29 05:06:10 bryce Exp $
+ * @version $Id: ArrayList.java,v 1.3 2000/11/02 10:08:03 bryce Exp $
* @see java.util.AbstractList
* @see java.util.List
*/
@@ -219,15 +219,7 @@ public class ArrayList extends AbstractList
*/
public boolean addAll(Collection c)
{
- modCount++;
- Iterator itr = c.iterator();
- int csize = c.size();
- ensureCapacity(size + csize);
- for (int pos = 0; pos < csize; pos++)
- {
- data[size++] = itr.next();
- }
- return (csize > 0);
+ return addAll(size, c);
}
/**
@@ -295,9 +287,7 @@ public class ArrayList extends AbstractList
*/
public int indexOf(Object e)
{
- int i;
-
- for (i = 0; i < size; i++)
+ for (int i = 0; i < size; i++)
{
if (e == null ? data[i] == null : e.equals(data[i]))
return i;
@@ -330,6 +320,10 @@ public class ArrayList extends AbstractList
public void clear()
{
modCount++;
+ for (int i = 0; i < size; i++)
+ {
+ data[i] = null;
+ }
size = 0;
}
@@ -364,8 +358,8 @@ public class ArrayList extends AbstractList
}
/**
- * Returns an Array whse component type is the runtime component type of
- * the passes-in Array. The returned Array is populated with all of the
+ * Returns an Array whose component type is the runtime component type of
+ * the passed-in Array. The returned Array is populated with all of the
* elements in this ArrayList. If the passed-in Array is not large enough
* to store all of the elements in this List, a new Array will be created
* and returned; if the passed-in Array is <i>larger</i> than the size