gcc/libjava/java/util/ArrayList.java

418 lines
11 KiB
Java
Raw Normal View History

/* ArrayList.java -- JDK1.2's answer to Vector; this is an array-backed
implementation of the List interface
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */
package java.util;
import java.lang.reflect.Array;
import java.io.Serializable;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
/**
* An array-backed implementation of the List interface. ArrayList
* performs well on simple tasks: random access into a list, appending
* to or removing from the end of a list, checking the size, &c.
*
* @author Jon A. Zeppieri
* @see java.util.AbstractList
* @see java.util.List
*/
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
public class ArrayList extends AbstractList
implements List, Cloneable, Serializable
{
/** the default capacity for new ArrayLists */
private static final int DEFAULT_CAPACITY = 16;
/** the number of elements in this list */
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
int size;
/** where the data is stored */
transient Object[] data;
/**
* Construct a new ArrayList with the supplied initial capacity.
*
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
* @param capacity Initial capacity of this ArrayList
*/
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
public ArrayList(int capacity)
{
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
data = new Object[capacity];
}
/**
* Construct a new ArrayList with the default capcity
*/
public ArrayList()
{
this(DEFAULT_CAPACITY);
}
/**
* Construct a new ArrayList, and initialize it with the elements
* in the supplied Collection; Sun specs say that the initial
* capacity is 110% of the Collection's size.
*
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
* @param c the collection whose elements will initialize this list
*/
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
public ArrayList(Collection c)
{
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
this((int) (c.size() * 1.1));
addAll(c);
}
/**
* Guarantees that this list will have at least enough capacity to
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
* hold minCapacity elements.
*
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
* @specnote This implementation will grow the list to
* max(current * 2, minCapacity) if (minCapacity > current). The JCL says
* explictly that "this method increases its capacity to minCap", while
* the JDK 1.3 online docs specify that the list will grow to at least the
* size specified.
* @param minCapacity the minimum guaranteed capacity
*/
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
public void ensureCapacity(int minCapacity)
{
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
Object[] newData;
int current = data.length;
if (minCapacity > current)
{
newData = new Object[Math.max((current * 2), minCapacity)];
System.arraycopy(data, 0, newData, 0, size);
data = newData;
}
}
/**
* Appends the supplied element to the end of this list.
*
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
* @param e the element to be appended to this list
*/
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
public boolean add(Object e)
{
modCount++;
if (size == data.length)
ensureCapacity(size + 1);
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
data[size++] = e;
return true;
}
/**
* Retrieves the element at the user-supplied index.
*
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
* @param index the index of the element we are fetching
* @throws IndexOutOfBoundsException (iIndex < 0) || (iIndex >= size())
*/
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
public Object get(int index)
{
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
if (index < 0 || index >= size)
throw new IndexOutOfBoundsException("Index: " + index + ", Size:" +
size);
return data[index];
}
/**
* Returns the number of elements in this list
*/
public int size()
{
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
return size;
}
/**
* Removes the element at the user-supplied index
*
* @param iIndex the index of the element to be removed
* @return the removed Object
* @throws IndexOutOfBoundsException (iIndex < 0) || (iIndex >= size())
*/
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
public Object remove(int index)
{
modCount++;
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
if (index < 0 || index > size)
throw new IndexOutOfBoundsException("Index: " + index + ", Size:" +
size);
Object r = data[index];
if (index != --size)
System.arraycopy(data, (index + 1), data, index, (size - index));
data[size] = null;
return r;
}
/**
* Removes all elements in the half-open interval [iFromIndex, iToIndex).
*
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
* @param fromIndex the first index which will be removed
* @param toIndex one greater than the last index which will be
* removed
*/
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
protected void removeRange(int fromIndex, int toIndex)
{
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
modCount++;
if (fromIndex != toIndex)
{
System.arraycopy(data, toIndex, data, fromIndex, size - toIndex);
size -= (toIndex - fromIndex);
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
}
}
/**
* Adds the supplied element at the specified index, shifting all
* elements currently at that index or higher one to the right.
*
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
* @param index the index at which the element is being added
* @param e the item being added
*/
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
public void add(int index, Object e)
{
modCount++;
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
if (index < 0 || index > size)
throw new IndexOutOfBoundsException("Index: " + index + ", Size:" +
size);
if (size == data.length)
ensureCapacity(size + 1);
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
if (index != size)
System.arraycopy(data, index, data, index + 1, size - index);
data[index] = e;
size++;
}
/**
* Add each element in the supplied Collection to this List.
*
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
* @param c a Collection containing elements to be
* added to this List
*/
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
public boolean addAll(Collection c)
{
return addAll(size, c);
}
/**
* Add all elements in the supplied collection, inserting them beginning
* at the specified index.
*
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
* @param index the index at which the elements will be inserted
* @param c the Collection containing the elements to be
* inserted
*/
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
public boolean addAll(int index, Collection c)
{
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
if (index < 0 || index > size)
throw new IndexOutOfBoundsException("Index: " + index + ", Size:" +
size);
modCount++;
Iterator itr = c.iterator();
int csize = c.size();
if (csize + size > data.length)
ensureCapacity(size + csize);
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
int end = index + csize;
if (size > 0 && index != size)
System.arraycopy(data, index, data, end, csize);
size += csize;
for (; index < end; index++)
{
data[index] = itr.next();
}
return (csize > 0);
}
/**
* Creates a shallow copy of this ArrayList
*/
public Object clone()
{
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
ArrayList clone = null;
try
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
{
clone = (ArrayList) super.clone();
clone.data = new Object[data.length];
System.arraycopy(data, 0, clone.data, 0, size);
}
catch (CloneNotSupportedException e) {}
return clone;
}
/**
* Returns true iff oElement is in this ArrayList.
*
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
* @param e the element whose inclusion in the List is being
* tested
*/
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
public boolean contains(Object e)
{
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
return (indexOf(e) != -1);
}
/**
* Returns the lowest index at which oElement appears in this List, or
* -1 if it does not appear.
*
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
* @param e the element whose inclusion in the List is being
* tested
*/
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
public int indexOf(Object e)
{
for (int i = 0; i < size; i++)
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
{
if (e == null ? data[i] == null : e.equals(data[i]))
return i;
}
return -1;
}
/**
* Returns the highest index at which oElement appears in this List, or
* -1 if it does not appear.
*
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
* @param e the element whose inclusion in the List is being
* tested
*/
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
public int lastIndexOf(Object e)
{
int i;
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
for (i = size - 1; i >= 0; i--)
{
if (e == null ? data[i] == null : e.equals(data[i]))
return i;
}
return -1;
}
/**
* Removes all elements from this List
*/
public void clear()
{
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
modCount++;
for (int i = 0; i < size; i++)
{
data[i] = null;
}
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
size = 0;
}
/**
* Sets the element at the specified index.
*
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
* @param index the index at which the element is being set
* @param e the element to be set
* @return the element previously at the specified index, or null if
* none was there
*/
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
public Object set(int index, Object e)
{
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
Object result;
if (index < 0 || index >= size)
throw new IndexOutOfBoundsException("Index: " + index + ", Size:" +
size);
result = data[index];
// SEH: no structural change, so don't update modCount
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
data[index] = e;
return result;
}
/**
* Returns an Object Array containing all of the elements in this ArrayList
*/
public Object[] toArray()
{
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
Object[] array = new Object[size];
System.arraycopy(data, 0, array, 0, size);
return array;
}
/**
* 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
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
* of this List, then size() index will be set to null.
*
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
* @param array the passed-in Array
*/
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
public Object[] toArray(Object[] array)
{
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
if (array.length < size)
array = (Object[]) Array.newInstance(array.getClass().getComponentType(),
size);
else if (array.length > size)
array[size] = null;
System.arraycopy(data, 0, array, 0, size);
return array;
}
/**
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
* Trims the capacity of this List to be equal to its size;
* a memory saver.
*/
public void trimToSize()
{
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
// not a structural change from the perspective of iterators on this list,
// so don't update modCount
Object[] newData = new Object[size];
System.arraycopy(data, 0, newData, 0, size);
data = newData;
}
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
private void writeObject(ObjectOutputStream out) throws IOException
{
int i;
// The 'size' field.
out.defaultWriteObject();
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
// FIXME: Do we really want to serialize unused list entries??
out.writeInt(data.length);
for (i = 0; i < data.length; i++)
out.writeObject(data[i]);
}
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
int i;
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
int capacity;
// the `size' field.
in.defaultReadObject();
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
capacity = in.readInt();
data = new Object[capacity];
AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. 2000-10-29 Bryce McKinlay <bryce@albatross.co.nz> * java/util/AbstractCollection.java (addAll): Use size() instead of hasNext() in iterator loop. (clear): Ditto. (contains): Ditto. Simplify loop. (containsAll): Ditto. (remove): Ditto. (removeAll): Ditto. (retainAll): Ditto. (toArray): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractList.java (addAll): Use size() instead of hasNext() in iterator loop. (equals): Ditto. (hashCode): Ditto. (indexOf): Ditto. Don't take null check outside of the loop. (iterator): Return an AbstractListItr instead of anonymous class. (lastIndexOf): Use a for loop bounded by size() instead of hasPrevious() in iterator loop. (listIterator): Return an AbstractListItr. (removeRange): Remove bounds checking code and docs. (AbstractListItr): New inner class. Code moved here from listIterator(). (SubList.iterator): Removed. Use default implementation from AbstractList instead. (SubList.listIterator): As above. * java/util/AbstractMap.java (clear): Use a for loop bounded by size() instead of hasNext() in iterator loop. (containsValue): Ditto. (equals): Ditto. (get): Ditto. (put): Ditto. (putAll): Ditto. (remove): Ditto. (toString): Ditto. Use string concatenation operators, not StringBuffer. * java/util/AbstractSequentialList.java (addAll): Use a for loop bounded by size() instead of hasNext() in iterator loop. * java/util/AbstractSet.java (hashCode): Don't catch exception as part of normal execution flow. Do an explicit null check instead. * java/util/ArrayList.java (_iSize): Rename to `size'. (_arData): Rename to `data'. (get): Check lower bounds also. Simplify IndexOutOfBoundsException message. (remove): Ditto. (removeRange): Make protected. Don't check bounds. (add): Check lower bounds also. Simplify IndexOutOfBoundsException message. (addAll (Collection)): Use a size-bounded for loop instead of hasNext() check. (addAll (int, Collection)): Check lower bounds. Simplify exception string. (clone): Clone the data array too. (indexOf): Inline doesEqual(). (lastIndexOf): Ditto. (clear): Don't set array data to null. (set): Check lower bounds. Simplify exception string. (toArray): Correct comment. (trimToSize): Don't update modCount, this is not a structural change. Add comment. * java/util/BitSet.java: Merged with classpath, new JDK 1.2 methods implemented. (toString): Declare `bit' as long, not int. (data): Made package-private, not private. From-SVN: r37116
2000-10-29 06:06:10 +01:00
for (i = 0; i < capacity; i++)
data[i] = in.readObject();
}
}