* allow zero as an initial capacity for the primitive array lists (once again). (java.util.ArrayList allows it, why shouldn't we?)
* add tests to enforce the contract git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130812 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
034ec419ea
commit
a47d25a4ff
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/FloatArrayList.java,v 1.4 2002/08/23 17:31:28 pjack Exp $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2002/08/23 17:31:28 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/FloatArrayList.java,v 1.5 2002/09/07 20:33:32 rwaldhoff Exp $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2002/09/07 20:33:32 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
|
@ -78,7 +78,7 @@ import java.util.ListIterator;
|
|||
* {@link java.util.ArrayList} of {@link Float} values and allows for
|
||||
* better compile-time type checking.<P>
|
||||
*
|
||||
* @version $Revision: 1.4 $ $Date: 2002/08/23 17:31:28 $
|
||||
* @version $Revision: 1.5 $ $Date: 2002/09/07 20:33:32 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class FloatArrayList extends AbstractList implements List, Serializable {
|
||||
|
@ -98,11 +98,10 @@ public class FloatArrayList extends AbstractList implements List, Serializable {
|
|||
* capacity.
|
||||
*
|
||||
* @param capacity the initial capacity for the list
|
||||
* @throws IllegalArgumentException if capacity is less than or equal
|
||||
* to zero
|
||||
* @throws IllegalArgumentException if capacity is less than zero
|
||||
*/
|
||||
public FloatArrayList(int capacity) {
|
||||
if (capacity <= 0) {
|
||||
if (capacity < 0) {
|
||||
throw new IllegalArgumentException("capacity=" + capacity);
|
||||
}
|
||||
_data = new float[capacity];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/IntArrayList.java,v 1.5 2002/08/22 01:50:54 pjack Exp $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2002/08/22 01:50:54 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/IntArrayList.java,v 1.6 2002/09/07 20:33:32 rwaldhoff Exp $
|
||||
* $Revision: 1.6 $
|
||||
* $Date: 2002/09/07 20:33:32 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
|
@ -78,7 +78,7 @@ import java.util.ListIterator;
|
|||
* {@link java.util.ArrayList} of {@link Integer} values and allows for
|
||||
* better compile-time type checking.<P>
|
||||
*
|
||||
* @version $Revision: 1.5 $ $Date: 2002/08/22 01:50:54 $
|
||||
* @version $Revision: 1.6 $ $Date: 2002/09/07 20:33:32 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class IntArrayList extends AbstractIntArrayList implements Serializable {
|
||||
|
@ -96,11 +96,10 @@ public class IntArrayList extends AbstractIntArrayList implements Serializable {
|
|||
* Constructs a new <Code>IntArrayList</Code> with the given capacity.
|
||||
*
|
||||
* @param the capacity for the list
|
||||
* @throws IllegalArgumentException if the capacity is less than or
|
||||
* equal to zero
|
||||
* @throws IllegalArgumentException if the capacity is less than zero
|
||||
*/
|
||||
public IntArrayList(int capacity) {
|
||||
if (capacity <= 0) {
|
||||
if (capacity < 0) {
|
||||
throw new IllegalArgumentException("capacity " + capacity);
|
||||
}
|
||||
_data = new int[capacity];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/LongArrayList.java,v 1.5 2002/08/22 01:50:54 pjack Exp $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2002/08/22 01:50:54 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/LongArrayList.java,v 1.6 2002/09/07 20:33:32 rwaldhoff Exp $
|
||||
* $Revision: 1.6 $
|
||||
* $Date: 2002/09/07 20:33:32 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
|
@ -78,7 +78,7 @@ import java.util.ListIterator;
|
|||
* {@link java.util.ArrayList} of {@link Long} values and allows for
|
||||
* better compile-time type checking.<P>
|
||||
*
|
||||
* @version $Revision: 1.5 $ $Date: 2002/08/22 01:50:54 $
|
||||
* @version $Revision: 1.6 $ $Date: 2002/09/07 20:33:32 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class LongArrayList extends AbstractLongArrayList implements Serializable {
|
||||
|
@ -98,11 +98,10 @@ public class LongArrayList extends AbstractLongArrayList implements Serializable
|
|||
* capacity.
|
||||
*
|
||||
* @param capacity the initial capacity for the array
|
||||
* @throws IllegalArgumentException if the capacity is less than or
|
||||
* equal to zero
|
||||
* @throws IllegalArgumentException if the capacity is less than zero
|
||||
*/
|
||||
public LongArrayList(int capacity) {
|
||||
if (capacity <= 0) {
|
||||
if (capacity < 0) {
|
||||
throw new IllegalArgumentException("capacity=" + capacity);
|
||||
}
|
||||
_data = new long[capacity];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/ShortArrayList.java,v 1.5 2002/08/22 01:50:54 pjack Exp $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2002/08/22 01:50:54 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/ShortArrayList.java,v 1.6 2002/09/07 20:33:32 rwaldhoff Exp $
|
||||
* $Revision: 1.6 $
|
||||
* $Date: 2002/09/07 20:33:32 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
|
@ -78,7 +78,7 @@ import java.util.ListIterator;
|
|||
* {@link java.util.ArrayList} of {@link Short} values and allows for
|
||||
* better compile-time type checking.<P>
|
||||
*
|
||||
* @version $Revision: 1.5 $ $Date: 2002/08/22 01:50:54 $
|
||||
* @version $Revision: 1.6 $ $Date: 2002/09/07 20:33:32 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class ShortArrayList extends AbstractShortArrayList implements Serializable {
|
||||
|
@ -98,11 +98,10 @@ public class ShortArrayList extends AbstractShortArrayList implements Serializab
|
|||
* capacity.
|
||||
*
|
||||
* @param capacity the initial capacity for the array
|
||||
* @throws IllegalArgumentException if the capacity is less than or
|
||||
* equal to zero
|
||||
* @throws IllegalArgumentException if the capacity is less than zero
|
||||
*/
|
||||
public ShortArrayList(int capacity) {
|
||||
if (capacity <= 0) {
|
||||
if (capacity < 0) {
|
||||
throw new IllegalArgumentException("capacity=" + capacity);
|
||||
}
|
||||
_data = new short[capacity];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/UnsignedByteArrayList.java,v 1.5 2002/08/22 01:50:54 pjack Exp $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2002/08/22 01:50:54 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/UnsignedByteArrayList.java,v 1.6 2002/09/07 20:33:32 rwaldhoff Exp $
|
||||
* $Revision: 1.6 $
|
||||
* $Date: 2002/09/07 20:33:32 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
|
@ -80,7 +80,7 @@ import java.util.ListIterator;
|
|||
* than a {@link java.util.ArrayList} and offers better compile-time type
|
||||
* checking.
|
||||
*
|
||||
* @version $Revision: 1.5 $ $Date: 2002/08/22 01:50:54 $
|
||||
* @version $Revision: 1.6 $ $Date: 2002/09/07 20:33:32 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class UnsignedByteArrayList extends AbstractShortArrayList implements Serializable {
|
||||
|
@ -100,11 +100,10 @@ public class UnsignedByteArrayList extends AbstractShortArrayList implements Ser
|
|||
* specified initial capacity.
|
||||
*
|
||||
* @param capacity the capacity for this list
|
||||
* @throws IllegalArgumentException if the given capacity is less than
|
||||
* or equal to zero
|
||||
* @throws IllegalArgumentException if the given capacity is less than zero
|
||||
*/
|
||||
public UnsignedByteArrayList(int capacity) {
|
||||
if (capacity <= 0) {
|
||||
if (capacity < 0) {
|
||||
throw new IllegalArgumentException("capacity=" + capacity);
|
||||
}
|
||||
_data = new byte[capacity];
|
||||
|
@ -174,26 +173,26 @@ public class UnsignedByteArrayList extends AbstractShortArrayList implements Ser
|
|||
checkRangeIncludingEndpoint(index);
|
||||
ensureCapacity(_size+1);
|
||||
int numtomove = _size-index;
|
||||
System.arraycopy(_data,index,_data,index+1,numtomove);
|
||||
_data[index] = fromShort(value);
|
||||
_size++;
|
||||
System.arraycopy(_data,index,_data,index+1,numtomove);
|
||||
_data[index] = fromShort(value);
|
||||
_size++;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
modCount++;
|
||||
modCount++;
|
||||
_size = 0;
|
||||
}
|
||||
|
||||
public short removeShortAt(int index) {
|
||||
checkRange(index);
|
||||
modCount++;
|
||||
modCount++;
|
||||
short oldval = toShort(_data[index]);
|
||||
int numtomove = _size - index - 1;
|
||||
if(numtomove > 0) {
|
||||
System.arraycopy(_data,index+1,_data,index,numtomove);
|
||||
int numtomove = _size - index - 1;
|
||||
if(numtomove > 0) {
|
||||
System.arraycopy(_data,index+1,_data,index,numtomove);
|
||||
}
|
||||
_size--;
|
||||
return oldval;
|
||||
return oldval;
|
||||
}
|
||||
|
||||
public boolean removeShort(short value) {
|
||||
|
@ -208,22 +207,22 @@ public class UnsignedByteArrayList extends AbstractShortArrayList implements Ser
|
|||
}
|
||||
|
||||
public void ensureCapacity(int mincap) {
|
||||
modCount++;
|
||||
if(mincap > _data.length) {
|
||||
int newcap = (_data.length * 3)/2 + 1;
|
||||
byte[] olddata = _data;
|
||||
_data = new byte[newcap < mincap ? mincap : newcap];
|
||||
System.arraycopy(olddata,0,_data,0,_size);
|
||||
}
|
||||
modCount++;
|
||||
if(mincap > _data.length) {
|
||||
int newcap = (_data.length * 3)/2 + 1;
|
||||
byte[] olddata = _data;
|
||||
_data = new byte[newcap < mincap ? mincap : newcap];
|
||||
System.arraycopy(olddata,0,_data,0,_size);
|
||||
}
|
||||
}
|
||||
|
||||
public void trimToSize() {
|
||||
modCount++;
|
||||
if(_size < _data.length) {
|
||||
byte[] olddata = _data;
|
||||
_data = new byte[_size];
|
||||
System.arraycopy(olddata,0,_data,0,_size);
|
||||
}
|
||||
modCount++;
|
||||
if(_size < _data.length) {
|
||||
byte[] olddata = _data;
|
||||
_data = new byte[_size];
|
||||
System.arraycopy(olddata,0,_data,0,_size);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
@ -246,17 +245,17 @@ public class UnsignedByteArrayList extends AbstractShortArrayList implements Ser
|
|||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream out) throws IOException{
|
||||
out.defaultWriteObject();
|
||||
out.defaultWriteObject();
|
||||
out.writeInt(_data.length);
|
||||
for(int i=0;i<_size;i++) {
|
||||
for(int i=0;i<_size;i++) {
|
||||
out.writeByte(_data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
in.defaultReadObject();
|
||||
_data = new byte[in.readInt()];
|
||||
for(int i=0;i<_size;i++) {
|
||||
for(int i=0;i<_size;i++) {
|
||||
_data[i] = in.readByte();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/UnsignedIntArrayList.java,v 1.5 2002/08/22 01:50:54 pjack Exp $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2002/08/22 01:50:54 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/UnsignedIntArrayList.java,v 1.6 2002/09/07 20:33:32 rwaldhoff Exp $
|
||||
* $Revision: 1.6 $
|
||||
* $Date: 2002/09/07 20:33:32 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
|
@ -80,7 +80,7 @@ import java.util.ListIterator;
|
|||
* than a {@link java.util.ArrayList} and offers better compile-time type
|
||||
* checking.
|
||||
*
|
||||
* @version $Revision: 1.5 $ $Date: 2002/08/22 01:50:54 $
|
||||
* @version $Revision: 1.6 $ $Date: 2002/09/07 20:33:32 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class UnsignedIntArrayList extends AbstractLongArrayList implements Serializable {
|
||||
|
@ -100,11 +100,10 @@ public class UnsignedIntArrayList extends AbstractLongArrayList implements Seria
|
|||
* specified initial capacity.
|
||||
*
|
||||
* @param capacity the capacity for this list
|
||||
* @throws IllegalArgumentException if the given capacity is less than
|
||||
* or equal to zero
|
||||
* @throws IllegalArgumentException if the given capacity is less than zero
|
||||
*/
|
||||
public UnsignedIntArrayList(int capacity) {
|
||||
if (capacity <= 0) {
|
||||
if (capacity < 0) {
|
||||
throw new IllegalArgumentException("capacity=" + capacity);
|
||||
}
|
||||
_data = new int[capacity];
|
||||
|
@ -174,26 +173,26 @@ public class UnsignedIntArrayList extends AbstractLongArrayList implements Seria
|
|||
checkRangeIncludingEndpoint(index);
|
||||
ensureCapacity(_size+1);
|
||||
int numtomove = _size-index;
|
||||
System.arraycopy(_data,index,_data,index+1,numtomove);
|
||||
_data[index] = fromLong(value);
|
||||
_size++;
|
||||
System.arraycopy(_data,index,_data,index+1,numtomove);
|
||||
_data[index] = fromLong(value);
|
||||
_size++;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
modCount++;
|
||||
modCount++;
|
||||
_size = 0;
|
||||
}
|
||||
|
||||
public long removeLongAt(int index) {
|
||||
checkRange(index);
|
||||
modCount++;
|
||||
modCount++;
|
||||
long oldval = toLong(_data[index]);
|
||||
int numtomove = _size - index - 1;
|
||||
if(numtomove > 0) {
|
||||
System.arraycopy(_data,index+1,_data,index,numtomove);
|
||||
int numtomove = _size - index - 1;
|
||||
if(numtomove > 0) {
|
||||
System.arraycopy(_data,index+1,_data,index,numtomove);
|
||||
}
|
||||
_size--;
|
||||
return oldval;
|
||||
return oldval;
|
||||
}
|
||||
|
||||
public boolean removeLong(long value) {
|
||||
|
@ -208,22 +207,22 @@ public class UnsignedIntArrayList extends AbstractLongArrayList implements Seria
|
|||
}
|
||||
|
||||
public void ensureCapacity(int mincap) {
|
||||
modCount++;
|
||||
if(mincap > _data.length) {
|
||||
int newcap = (_data.length * 3)/2 + 1;
|
||||
int[] olddata = _data;
|
||||
_data = new int[newcap < mincap ? mincap : newcap];
|
||||
System.arraycopy(olddata,0,_data,0,_size);
|
||||
}
|
||||
modCount++;
|
||||
if(mincap > _data.length) {
|
||||
int newcap = (_data.length * 3)/2 + 1;
|
||||
int[] olddata = _data;
|
||||
_data = new int[newcap < mincap ? mincap : newcap];
|
||||
System.arraycopy(olddata,0,_data,0,_size);
|
||||
}
|
||||
}
|
||||
|
||||
public void trimToSize() {
|
||||
modCount++;
|
||||
if(_size < _data.length) {
|
||||
int[] olddata = _data;
|
||||
_data = new int[_size];
|
||||
System.arraycopy(olddata,0,_data,0,_size);
|
||||
}
|
||||
modCount++;
|
||||
if(_size < _data.length) {
|
||||
int[] olddata = _data;
|
||||
_data = new int[_size];
|
||||
System.arraycopy(olddata,0,_data,0,_size);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
@ -245,17 +244,17 @@ public class UnsignedIntArrayList extends AbstractLongArrayList implements Seria
|
|||
}
|
||||
}
|
||||
private void writeObject(ObjectOutputStream out) throws IOException{
|
||||
out.defaultWriteObject();
|
||||
out.defaultWriteObject();
|
||||
out.writeInt(_data.length);
|
||||
for(int i=0;i<_size;i++) {
|
||||
for(int i=0;i<_size;i++) {
|
||||
out.writeInt(_data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
in.defaultReadObject();
|
||||
_data = new int[in.readInt()];
|
||||
for(int i=0;i<_size;i++) {
|
||||
for(int i=0;i<_size;i++) {
|
||||
_data[i] = in.readInt();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/UnsignedShortArrayList.java,v 1.5 2002/08/22 01:50:54 pjack Exp $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2002/08/22 01:50:54 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/UnsignedShortArrayList.java,v 1.6 2002/09/07 20:33:32 rwaldhoff Exp $
|
||||
* $Revision: 1.6 $
|
||||
* $Date: 2002/09/07 20:33:32 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
|
@ -80,7 +80,7 @@ import java.util.ListIterator;
|
|||
* than a {@link java.util.ArrayList} and offers better compile-time type
|
||||
* checking.
|
||||
*
|
||||
* @version $Revision: 1.5 $ $Date: 2002/08/22 01:50:54 $
|
||||
* @version $Revision: 1.6 $ $Date: 2002/09/07 20:33:32 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class UnsignedShortArrayList extends AbstractIntArrayList implements Serializable {
|
||||
|
@ -101,11 +101,10 @@ public class UnsignedShortArrayList extends AbstractIntArrayList implements Seri
|
|||
* specified initial capacity.
|
||||
*
|
||||
* @param capacity the capacity for this list
|
||||
* @throws IllegalArgumentException if the given capacity is less than
|
||||
* or equal to zero
|
||||
* @throws IllegalArgumentException if the given capacity is less than zero
|
||||
*/
|
||||
public UnsignedShortArrayList(int capacity) {
|
||||
if (capacity <= 0) {
|
||||
if (capacity < 0) {
|
||||
throw new IllegalArgumentException("capacity=" + capacity);
|
||||
}
|
||||
_data = new short[capacity];
|
||||
|
@ -175,26 +174,26 @@ public class UnsignedShortArrayList extends AbstractIntArrayList implements Seri
|
|||
checkRangeIncludingEndpoint(index);
|
||||
ensureCapacity(_size+1);
|
||||
int numtomove = _size-index;
|
||||
System.arraycopy(_data,index,_data,index+1,numtomove);
|
||||
_data[index] = fromInt(value);
|
||||
_size++;
|
||||
System.arraycopy(_data,index,_data,index+1,numtomove);
|
||||
_data[index] = fromInt(value);
|
||||
_size++;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
modCount++;
|
||||
modCount++;
|
||||
_size = 0;
|
||||
}
|
||||
|
||||
public int removeIntAt(int index) {
|
||||
checkRange(index);
|
||||
modCount++;
|
||||
modCount++;
|
||||
int oldval = toInt(_data[index]);
|
||||
int numtomove = _size - index - 1;
|
||||
if(numtomove > 0) {
|
||||
System.arraycopy(_data,index+1,_data,index,numtomove);
|
||||
int numtomove = _size - index - 1;
|
||||
if(numtomove > 0) {
|
||||
System.arraycopy(_data,index+1,_data,index,numtomove);
|
||||
}
|
||||
_size--;
|
||||
return oldval;
|
||||
return oldval;
|
||||
}
|
||||
|
||||
public boolean removeInt(int value) {
|
||||
|
@ -209,22 +208,22 @@ public class UnsignedShortArrayList extends AbstractIntArrayList implements Seri
|
|||
}
|
||||
|
||||
public void ensureCapacity(int mincap) {
|
||||
modCount++;
|
||||
if(mincap > _data.length) {
|
||||
int newcap = (_data.length * 3)/2 + 1;
|
||||
short[] olddata = _data;
|
||||
_data = new short[newcap < mincap ? mincap : newcap];
|
||||
System.arraycopy(olddata,0,_data,0,_size);
|
||||
}
|
||||
modCount++;
|
||||
if(mincap > _data.length) {
|
||||
int newcap = (_data.length * 3)/2 + 1;
|
||||
short[] olddata = _data;
|
||||
_data = new short[newcap < mincap ? mincap : newcap];
|
||||
System.arraycopy(olddata,0,_data,0,_size);
|
||||
}
|
||||
}
|
||||
|
||||
public void trimToSize() {
|
||||
modCount++;
|
||||
if(_size < _data.length) {
|
||||
short[] olddata = _data;
|
||||
_data = new short[_size];
|
||||
System.arraycopy(olddata,0,_data,0,_size);
|
||||
}
|
||||
modCount++;
|
||||
if(_size < _data.length) {
|
||||
short[] olddata = _data;
|
||||
_data = new short[_size];
|
||||
System.arraycopy(olddata,0,_data,0,_size);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
@ -247,17 +246,17 @@ public class UnsignedShortArrayList extends AbstractIntArrayList implements Seri
|
|||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream out) throws IOException{
|
||||
out.defaultWriteObject();
|
||||
out.defaultWriteObject();
|
||||
out.writeInt(_data.length);
|
||||
for(int i=0;i<_size;i++) {
|
||||
for(int i=0;i<_size;i++) {
|
||||
out.writeShort(_data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
in.defaultReadObject();
|
||||
_data = new short[in.readInt()];
|
||||
for(int i=0;i<_size;i++) {
|
||||
for(int i=0;i<_size;i++) {
|
||||
_data[i] = in.readShort();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestFloatArrayList.java,v 1.2 2002/06/21 04:01:31 mas Exp $
|
||||
* $Revision: 1.2 $
|
||||
* $Date: 2002/06/21 04:01:31 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestFloatArrayList.java,v 1.3 2002/09/07 20:33:32 rwaldhoff Exp $
|
||||
* $Revision: 1.3 $
|
||||
* $Date: 2002/09/07 20:33:32 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
|
@ -68,7 +68,7 @@ import org.apache.commons.collections.TestList;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.2 $ $Date: 2002/06/21 04:01:31 $
|
||||
* @version $Revision: 1.3 $ $Date: 2002/09/07 20:33:32 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class TestFloatArrayList extends TestList {
|
||||
|
@ -98,6 +98,10 @@ public class TestFloatArrayList extends TestList {
|
|||
|
||||
//------------------------------------------------------------------- Tests
|
||||
|
||||
public void testZeroInitialCapacityIsValid() {
|
||||
FloatArrayList list = new FloatArrayList(0);
|
||||
}
|
||||
|
||||
public void testAddGet() {
|
||||
FloatArrayList list = createList();
|
||||
for(float i=0F;i<1000F;i++) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestIntArrayList.java,v 1.3 2002/08/19 21:19:03 pjack Exp $
|
||||
* $Revision: 1.3 $
|
||||
* $Date: 2002/08/19 21:19:03 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestIntArrayList.java,v 1.4 2002/09/07 20:33:32 rwaldhoff Exp $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2002/09/07 20:33:32 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
|
@ -67,7 +67,7 @@ import junit.framework.TestSuite;
|
|||
import org.apache.commons.collections.BulkTest;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.3 $ $Date: 2002/08/19 21:19:03 $
|
||||
* @version $Revision: 1.4 $ $Date: 2002/09/07 20:33:32 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class TestIntArrayList extends TestAbstractIntArrayList {
|
||||
|
@ -89,5 +89,11 @@ public class TestIntArrayList extends TestAbstractIntArrayList {
|
|||
return new IntArrayList();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------- Tests
|
||||
|
||||
public void testZeroInitialCapacityIsValid() {
|
||||
IntArrayList list = new IntArrayList(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestLongArrayList.java,v 1.3 2002/08/19 21:19:03 pjack Exp $
|
||||
* $Revision: 1.3 $
|
||||
* $Date: 2002/08/19 21:19:03 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestLongArrayList.java,v 1.4 2002/09/07 20:33:32 rwaldhoff Exp $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2002/09/07 20:33:32 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
|
@ -67,7 +67,7 @@ import junit.framework.TestSuite;
|
|||
import org.apache.commons.collections.BulkTest;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.3 $ $Date: 2002/08/19 21:19:03 $
|
||||
* @version $Revision: 1.4 $ $Date: 2002/09/07 20:33:32 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class TestLongArrayList extends TestAbstractLongArrayList {
|
||||
|
@ -89,5 +89,11 @@ public class TestLongArrayList extends TestAbstractLongArrayList {
|
|||
return new LongArrayList();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------- Tests
|
||||
|
||||
public void testZeroInitialCapacityIsValid() {
|
||||
LongArrayList list = new LongArrayList(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestShortArrayList.java,v 1.3 2002/08/19 21:19:03 pjack Exp $
|
||||
* $Revision: 1.3 $
|
||||
* $Date: 2002/08/19 21:19:03 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestShortArrayList.java,v 1.4 2002/09/07 20:33:32 rwaldhoff Exp $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2002/09/07 20:33:32 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
|
@ -67,7 +67,7 @@ import junit.framework.TestSuite;
|
|||
import org.apache.commons.collections.BulkTest;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.3 $ $Date: 2002/08/19 21:19:03 $
|
||||
* @version $Revision: 1.4 $ $Date: 2002/09/07 20:33:32 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class TestShortArrayList extends TestAbstractShortArrayList {
|
||||
|
@ -89,5 +89,11 @@ public class TestShortArrayList extends TestAbstractShortArrayList {
|
|||
return new ShortArrayList();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------- Tests
|
||||
|
||||
public void testZeroInitialCapacityIsValid() {
|
||||
ShortArrayList list = new ShortArrayList(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestUnsignedByteArrayList.java,v 1.3 2002/08/19 21:19:03 pjack Exp $
|
||||
* $Revision: 1.3 $
|
||||
* $Date: 2002/08/19 21:19:03 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestUnsignedByteArrayList.java,v 1.4 2002/09/07 20:33:32 rwaldhoff Exp $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2002/09/07 20:33:32 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
|
@ -67,7 +67,7 @@ import junit.framework.TestSuite;
|
|||
import org.apache.commons.collections.BulkTest;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.3 $ $Date: 2002/08/19 21:19:03 $
|
||||
* @version $Revision: 1.4 $ $Date: 2002/09/07 20:33:32 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class TestUnsignedByteArrayList extends TestAbstractShortArrayList {
|
||||
|
@ -89,5 +89,11 @@ public class TestUnsignedByteArrayList extends TestAbstractShortArrayList {
|
|||
return new UnsignedByteArrayList();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------- Tests
|
||||
|
||||
public void testZeroInitialCapacityIsValid() {
|
||||
UnsignedByteArrayList list = new UnsignedByteArrayList(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestUnsignedIntArrayList.java,v 1.3 2002/08/19 21:19:03 pjack Exp $
|
||||
* $Revision: 1.3 $
|
||||
* $Date: 2002/08/19 21:19:03 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestUnsignedIntArrayList.java,v 1.4 2002/09/07 20:33:32 rwaldhoff Exp $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2002/09/07 20:33:32 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
|
@ -67,7 +67,7 @@ import junit.framework.TestSuite;
|
|||
import org.apache.commons.collections.BulkTest;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.3 $ $Date: 2002/08/19 21:19:03 $
|
||||
* @version $Revision: 1.4 $ $Date: 2002/09/07 20:33:32 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class TestUnsignedIntArrayList extends TestAbstractLongArrayList {
|
||||
|
@ -89,5 +89,11 @@ public class TestUnsignedIntArrayList extends TestAbstractLongArrayList {
|
|||
return new UnsignedIntArrayList();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------- Tests
|
||||
|
||||
public void testZeroInitialCapacityIsValid() {
|
||||
UnsignedIntArrayList list = new UnsignedIntArrayList(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestUnsignedShortArrayList.java,v 1.3 2002/08/19 21:19:03 pjack Exp $
|
||||
* $Revision: 1.3 $
|
||||
* $Date: 2002/08/19 21:19:03 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/primitives/Attic/TestUnsignedShortArrayList.java,v 1.4 2002/09/07 20:33:32 rwaldhoff Exp $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2002/09/07 20:33:32 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
|
@ -67,7 +67,7 @@ import junit.framework.TestSuite;
|
|||
import org.apache.commons.collections.BulkTest;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.3 $ $Date: 2002/08/19 21:19:03 $
|
||||
* @version $Revision: 1.4 $ $Date: 2002/09/07 20:33:32 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class TestUnsignedShortArrayList extends TestAbstractIntArrayList {
|
||||
|
@ -89,5 +89,11 @@ public class TestUnsignedShortArrayList extends TestAbstractIntArrayList {
|
|||
return new UnsignedShortArrayList();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------- Tests
|
||||
|
||||
public void testZeroInitialCapacityIsValid() {
|
||||
UnsignedShortArrayList list = new UnsignedShortArrayList(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue