You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by pj...@apache.org on 2002/08/13 21:41:36 UTC
cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections/primitives AbstractIntArrayList.java AbstractLongArrayList.java AbstractShortArrayList.java FloatArrayList.java IntArrayList.java LongArrayList.java ShortArrayList.java UnsignedByteArrayList.java UnsignedIntArrayList.java UnsignedShortArrayList.java
pjack 2002/08/13 12:41:36
Modified: collections/src/java/org/apache/commons/collections/primitives
AbstractIntArrayList.java
AbstractLongArrayList.java
AbstractShortArrayList.java FloatArrayList.java
IntArrayList.java LongArrayList.java
ShortArrayList.java UnsignedByteArrayList.java
UnsignedIntArrayList.java
UnsignedShortArrayList.java
Log:
Added documentation to classes in primitives package.
Revision Changes Path
1.2 +225 -15 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/AbstractIntArrayList.java
Index: AbstractIntArrayList.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/AbstractIntArrayList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractIntArrayList.java 4 Jun 2002 16:01:27 -0000 1.1
+++ AbstractIntArrayList.java 13 Aug 2002 19:41:36 -0000 1.2
@@ -69,81 +69,291 @@
import java.util.ListIterator;
/**
+ * Abstract base class for lists backed by an <Code>int</Code> array.
+ *
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
public abstract class AbstractIntArrayList extends AbstractList implements List, Serializable {
//------------------------------------------------------ Abstract Accessors
-
+
+ /**
+ * Returns the maximum size the list can reach before the array
+ * is resized.
+ *
+ * @return the maximum size the list can reach before the array is resized
+ */
abstract public int capacity();
+
+
+ /**
+ * Returns the number of <Code>int</Code> elements currently in this
+ * list.
+ *
+ * @return the size of this list
+ */
abstract public int size();
+
+
+ /**
+ * Returns the <Code>int</Code> element at the specified index in this
+ * array.
+ *
+ * @param index the index of the element to return
+ * @return the <Code>int</Code> element at that index
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than or equal to {@link #size()}
+ */
abstract public int getInt(int index);
+
+
+ /**
+ * Returns <Code>true</Code> if this list contains the given
+ * <Code>int</Code> element.
+ *
+ * @param value the element to search for
+ * @return true if this list contains the given value, false otherwise
+ */
abstract public boolean containsInt(int value);
+
+
+ /**
+ * Returns the first index of the given <Code>int</Code> element, or
+ * -1 if the value is not in this list.
+ *
+ * @param value the element to search for
+ * @return the first index of that element, or -1 if the element is
+ * not in this list
+ */
abstract public int indexOfInt(int value);
+
+
+ /**
+ * Returns the last index of the given <Code>int</Code> element, or
+ * -1 if the value is not in this list.
+ *
+ * @param value the element to search for
+ * @return the last index of that element, or -1 if the element is
+ * not in this list
+ */
abstract public int lastIndexOfInt(int value);
//--------------------------------------------------------------- Accessors
- /** Returns <code>new Integer({@link #getInt getInteger(index)})</code>. */
+ /**
+ * Returns <code>new Integer({@link #getInt getInt(index)})</code>.
+ *
+ * @param index the index of the element to return
+ * @return an {@link Integer} object wrapping the <Code>int</Code>
+ * value at that index
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than or equal to {@link #size()}
+ */
public Object get(int index) {
return new Integer(getInt(index));
}
- /** Returns <code>{@link #containsInt containsInt(((Integer)value).intValue())}</code>. */
+ /**
+ * Returns <code>{@link #containsInt containsInt(((Integer)value).intValue())}</code>.
+ *
+ * @param value an {@link Integer} object whose wrapped <Code>int</Code>
+ * value to search for
+ * @return true if this list contains that <Code>int</Code> value
+ * @throws ClassCastException if the given object is not an
+ * {@link Integer}
+ * @throws NullPointerException if the given object is <Code>null</Code>
+ */
public boolean contains(Object value) {
return containsInt(((Integer)value).intValue());
}
- /** Returns <code>({@link #size} == 0)</code>. */
+ /**
+ * Returns <code>({@link #size} == 0)</code>.
+ *
+ * @return true if this list is empty, false otherwise
+ */
public boolean isEmpty() {
return (0 == size());
}
- /** Returns <code>{@link #indexOfInt indexOfInt(((Integer)value).intValue())}</code>. */
+ /**
+ * Returns <code>{@link #indexOfInt indexOfInt(((Integer)value).intValue())}</code>.
+ *
+ * @param value an {@link Integer} object whose wrapped <Code>int</Code>
+ * value to search for
+ * @return the first index of that <Code>int</Code> value, or -1 if
+ * this list does not contain that value
+ * @throws ClassCastException if the given object is not an
+ * {@link Integer}
+ * @throws NullPointerException if the given object is <Code>null</Code>
+ */
public int indexOf(Object value) {
return indexOfInt(((Integer)value).intValue());
}
- /** Returns <code>{@link #lastIndexOfInt lastIndexOfInt(((Integer)value).intValue())}</code>. */
+ /**
+ * Returns <code>{@link #lastIndexOfInt lastIndexOfInt(((Integer)value).intValue())}</code>.
+ *
+ * @param value an {@link Integer} object whose wrapped <Code>int</Code>
+ * value to search for
+ * @return the last index of that <Code>int</Code> value, or -1 if
+ * this list does not contain that value
+ * @throws ClassCastException if the given object is not an
+ * {@link Integer}
+ * @throws NullPointerException if the given object is <Code>null</Code>
+ */
public int lastIndexOf(Object value) {
return lastIndexOfInt(((Integer)value).intValue());
}
//------------------------------------------------------ Abstract Modifiers
+ /**
+ * Sets the element at the given index to the given <Code>int</Code>
+ * value.
+ *
+ * @param index the index of the element to set
+ * @param value the <Code>int</Code> value to set it to
+ * @return the previous <Code>int</Code> value at that index
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than or equal to {@link #size()}.
+ */
abstract public int setInt(int index, int value);
+
+ /**
+ * Adds the given <Code>int</Code> value to the end of this list.
+ *
+ * @param value the value to add
+ * @return true, always
+ */
abstract public boolean addInt(int value);
+
+
+ /**
+ * Inserts the given <Code>int</Code> value into this list at the
+ * specified index.
+ *
+ * @param index the index for the insertion
+ * @param value the value to insert at that index
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than {@link #size()}
+ */
abstract public void addInt(int index, int value);
+
+
+ /**
+ * Removes the <Code>int</Code> element at the specified index.
+ *
+ * @param index the index of the element to remove
+ * @return the removed <Code>int</Code> value
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than or equal to {@link #size()}
+ */
abstract public int removeIntAt(int index);
+
+
+ /**
+ * Removes the first occurrence of the given <Code>int</COde> value
+ * from this list.
+ *
+ * @param value the value to remove
+ * @return true if this list contained that value and removed it,
+ * or false if this list didn't contain the value
+ */
abstract public boolean removeInt(int value);
+
+ /**
+ * Removes all <Code>int</Code> values from this list.
+ */
abstract public void clear();
+
+ /**
+ * Ensures that the length of the internal <Code>int</Code> array is
+ * at list the given value.
+ *
+ * @param mincap the minimum capcity for this list
+ */
abstract public void ensureCapacity(int mincap);
+
+ /**
+ * Resizes the internal array such that {@link #capacity()} is equal
+ * to {@link #size()}.
+ */
abstract public void trimToSize();
//--------------------------------------------------------------- Modifiers
- /** Returns <code>new Integer({@link #setInt(int,int) setInt(index,((Integer)value).intValue())})</code>. */
+ /**
+ * Returns <code>new Integer({@link #setInt(int,int)
+ * setInt(index,((Integer)value).intValue())})</code>.
+ *
+ * @param index the index of the element to set
+ * @param value an {@link Integer} object whose <Code>int</Code> value
+ * to set at that index
+ * @return an {@link Integer} that wraps the <Code>int</Code> value
+ * previously at that index
+ * @throws IndexOutOfBoundsException if the index is negative or greater
+ * than or equal to {@link #size()}
+ * @throws ClassCastException if the given value is not an {@link Integer}
+ * @throws NullPointerException if the given value is <Code>null</COde>
+ */
public Object set(int index, Object value) {
return new Integer(setInt(index,((Integer)value).intValue()));
}
- /** Invokes <code>{@link #addInt(int) addInt(((Integer)value).intValue())})</code>. */
+ /**
+ * Invokes <code>{@link #addInt(int) addInt(((Integer)value).intValue())})</code>.
+ *
+ * @param value an {@link Integer} object that wraps the <Code>int</Code>
+ * value to add
+ * @return true, always
+ * @throws ClassCastException if the given value is not an {@link Integer}
+ * @throws NullPointerException if the given value is <Code>null</COde>
+ */
public boolean add(Object value) {
return addInt(((Integer)value).intValue());
}
- /** Invokes <code>{@link #addInt(int,int) addInt(index,((Integer)value).intValue())})</code>. */
+ /**
+ * Invokes <code>{@link #addInt(int,int) addInt(index,((Integer)value).intValue())})</code>.
+ *
+ * @param index the index of the insertion
+ * @param value an {@link Integer} object that wraps the <Code>int</Code>
+ * value to insert
+ * @throws IndexOutOfBoundsException if the index is negative or greater
+ * than {@link #size()}
+ * @throws ClassCastException if the given value is not an {@link Integer}
+ * @throws NullPointerException if the given value is <Code>null</COde>
+ */
public void add(int index, Object value) {
addInt(index,((Integer)value).intValue());
}
- /** Returns <code>new Integer({@link #removeIntAt(int) removeIntAt(index)})</code>. */
+ /**
+ * Returns <code>new Integer({@link #removeIntAt(int) removeIntAt(index)})</code>.
+ *
+ * @param index the index of the element to remove
+ * @return an {@link Integer} object that wraps the value that was
+ * removed from that index
+ * @throws IndexOutOfBoundsException if the given index is negative
+ * or greater than or equal to {@link #size()}
+ */
public Object remove(int index) {
return new Integer(removeIntAt(index));
}
- /** Returns <code>{@link #removeInt(int) removeInt(((Integer)value).intValue())}</code>. */
+ /**
+ * Returns <code>{@link #removeInt(int) removeInt(((Integer)value).intValue())}</code>.
+ *
+ * @param value an {@link Integer} object that wraps the <Code>int</Code>
+ * value to remove
+ * @return true if the first occurrence of that <Code>int</Code> value
+ * was removed from this list, or <Code>false</Code> if this list
+ * did not contain that <Code>int</Code> value
+ * @throws ClassCastException if the given value is not an {@link Integer}
+ * @throws NullPointerException if the given value is <Code>null</COde>
+ */
public boolean remove(Object value) {
return removeInt(((Integer)value).intValue());
}
1.2 +225 -14 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/AbstractLongArrayList.java
Index: AbstractLongArrayList.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/AbstractLongArrayList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractLongArrayList.java 4 Jun 2002 16:01:27 -0000 1.1
+++ AbstractLongArrayList.java 13 Aug 2002 19:41:36 -0000 1.2
@@ -69,6 +69,8 @@
import java.util.ListIterator;
/**
+ * Abstract base class for lists backed by a <Code>long</Code> array.
+ *
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
@@ -76,75 +78,284 @@
//------------------------------------------------------ Abstract Accessors
+ /**
+ * Returns the maximum size the list can reach before the array
+ * is resized.
+ *
+ * @return the maximum size the list can reach before the array is resized
+ */
abstract public int capacity();
+
+ /**
+ * Returns the number of <Code>long</Code> elements currently in this
+ * list.
+ *
+ * @return the size of this list
+ */
abstract public int size();
+
+ /**
+ * Returns the <Code>long</Code> element at the specified index in this
+ * array.
+ *
+ * @param index the index of the element to return
+ * @return the <Code>long</Code> element at that index
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than or equal to {@link #size()}
+ */
abstract public long getLong(int index);
+
+ /**
+ * Returns <Code>true</Code> if this list contains the given
+ * <Code>long</Code> element.
+ *
+ * @param value the element to search for
+ * @return true if this list contains the given value, false otherwise
+ */
abstract public boolean containsLong(long value);
+
+ /**
+ * Returns the first index of the given <Code>long</Code> element, or
+ * -1 if the value is not in this list.
+ *
+ * @param value the element to search for
+ * @return the first index of that element, or -1 if the element is
+ * not in this list
+ */
abstract public int indexOfLong(long value);
+
+ /**
+ * Returns the last index of the given <Code>long</Code> element, or
+ * -1 if the value is not in this list.
+ *
+ * @param value the element to search for
+ * @return the last index of that element, or -1 if the element is
+ * not in this list
+ */
abstract public int lastIndexOfLong(long value);
//--------------------------------------------------------------- Accessors
- /** Returns <code>new Long({@link #getLong getLong(index)})</code>. */
+ /**
+ * Returns <code>new Long({@link #getLong getLong(index)})</code>.
+ *
+ * @param index the index of the element to return
+ * @return an {@link Long} object wrapping the <Code>long</Code>
+ * value at that index
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than or equal to {@link #size()}
+ */
public Object get(int index) {
return new Long(getLong(index));
}
- /** Returns <code>{@link #containsLong containsLong(((Long)value).longValue())}</code>. */
+ /**
+ * Returns <code>{@link #containsLong containsLong(((Long)value).longValue())}</code>.
+ *
+ * @param value an {@link Long} object whose wrapped <Code>long</Code>
+ * value to search for
+ * @return true if this list contains that <Code>long</Code> value
+ * @throws ClassCastException if the given object is not an
+ * {@link Long}
+ * @throws NullPointerException if the given object is <Code>null</Code>
+ */
public boolean contains(Object value) {
return containsLong(((Long)value).longValue());
}
- /** Returns <code>({@link #size} == 0)</code>. */
+ /**
+ * Returns <code>({@link #size} == 0)</code>.
+ *
+ * @return true if this list is empty, false otherwise
+ */
public boolean isEmpty() {
return (0 == size());
}
- /** Returns <code>{@link #indexOfLong indexOfLong(((Long)value).longValue())}</code>. */
+ /**
+ * Returns <code>{@link #indexOfLong indexOfLong(((Long).longValue())}</code>.
+ *
+ * @param value an {@link Long} object whose wrapped <Code>long</Code>
+ * value to search for
+ * @return the first index of that <Code>long</Code> value, or -1 if
+ * this list does not contain that value
+ * @throws ClassCastException if the given object is not an
+ * {@link Long}
+ * @throws NullPointerException if the given object is <Code>null</Code>
+ */
public int indexOf(Object value) {
return indexOfLong(((Long)value).longValue());
}
- /** Returns <code>{@link #lastIndexOfLong lastIndexOfLong(((Long)value).longValue())}</code>. */
+ /**
+ * Returns <code>{@link #lastIndexOfLong lastIndexOfLong(((Long).longValue())}</code>.
+ *
+ * @param value an {@link Long} object whose wrapped <Code>long</Code>
+ * value to search for
+ * @return the last index of that <Code>long</Code> value, or -1 if
+ * this list does not contain that value
+ * @throws ClassCastException if the given object is not an
+ * {@link Long}
+ * @throws NullPointerException if the given object is <Code>null</Code>
+ */
public int lastIndexOf(Object value) {
return lastIndexOfLong(((Long)value).longValue());
}
//------------------------------------------------------ Abstract Modifiers
+ /**
+ * Sets the element at the given index to the given <Code>long</Code>
+ * value.
+ *
+ * @param index the index of the element to set
+ * @param value the <Code>long</Code> value to set it to
+ * @return the previous <Code>long</Code> value at that index
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than or equal to {@link #size()}.
+ */
abstract public long setLong(int index, long value);
+
+ /**
+ * Adds the given <Code>long</Code> value to the end of this list.
+ *
+ * @param value the value to add
+ * @return true, always
+ */
abstract public boolean addLong(long value);
+
+ /**
+ * Inserts the given <Code>long</Code> value into this list at the
+ * specified index.
+ *
+ * @param index the index for the insertion
+ * @param value the value to insert at that index
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than {@link #size()}
+ */
abstract public void addLong(int index, long value);
+
+ /**
+ * Removes the <Code>long</Code> element at the specified index.
+ *
+ * @param index the index of the element to remove
+ * @return the removed <Code>long</Code> value
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than or equal to {@link #size()}
+ */
abstract public long removeLongAt(int index);
+
+ /**
+ * Removes the first occurrence of the given <Code>long</Code> value
+ * from this list.
+ *
+ * @param value the value to remove
+ * @return true if this list contained that value and removed it,
+ * or false if this list didn't contain the value
+ */
abstract public boolean removeLong(long value);
+
+ /**
+ * Removes all <Code>long</Code> values from this list.
+ */
abstract public void clear();
+
+ /**
+ * Ensures that the length of the internal <Code>long</Code> array is
+ * at list the given value.
+ *
+ * @param mincap the minimum capcity for this list
+ */
abstract public void ensureCapacity(int mincap);
+
+ /**
+ * Resizes the internal array such that {@link #capacity()} is equal
+ * to {@link #size()}.
+ */
abstract public void trimToSize();
//--------------------------------------------------------------- Modifiers
- /** Returns <code>new Long({@link #setLong(int,long) setLong(index,((Long)value).longValue())})</code>. */
+ /**
+ * Returns <code>new Long({@link #setLong(int,long)
+ * setLong(index,((Long).longValue())})</code>.
+ *
+ * @param index the index of the element to set
+ * @param value an {@link Long} object whose <Code>long</Code> value
+ * to set at that index
+ * @return an {@link Long} that wraps the <Code>long</Code> value
+ * previously at that index
+ * @throws IndexOutOfBoundsException if the index is negative or greater
+ * than or equal to {@link #size()}
+ * @throws ClassCastException if the given value is not an {@link Long}
+ * @throws NullPointerException if the given value is <Code>null</COde>
+ */
public Object set(int index, Object value) {
return new Long(setLong(index,((Long)value).longValue()));
}
- /** Invokes <code>{@link #addLong(long) addLong(((Long)value).longValue())})</code>. */
+ /**
+ * Invokes <code>{@link #addLong(long) addLong(((Long)value).longValue())})</code>.
+ *
+ * @param value an {@link Long} object that wraps the <Code>long</Code>
+ * value to add
+ * @return true, always
+ * @throws ClassCastException if the given value is not an {@link Long}
+ * @throws NullPointerException if the given value is <Code>null</COde>
+ */
public boolean add(Object value) {
return addLong(((Long)value).longValue());
}
- /** Invokes <code>{@link #addLong(int,long) addLong(index,((Long)value).longValue())})</code>. */
+ /**
+ * Invokes <code>{@link #addLong(int,long) addLong(index,((Long)value).longValue())})</code>.
+ *
+ * @param index the index of the insertion
+ * @param value an {@link Long} object that wraps the <Code>long</Code>
+ * value to insert
+ * @throws IndexOutOfBoundsException if the index is negative or greater
+ * than {@link #size()}
+ * @throws ClassCastException if the given value is not an {@link Long}
+ * @throws NullPointerException if the given value is <Code>null</COde>
+ */
public void add(int index, Object value) {
addLong(index,((Long)value).longValue());
}
- /** Returns <code>new Long({@link #removeLongAt(int) removeLongAt(index)})</code>. */
+ /**
+ * Returns <code>new Long({@link #removeLongAt(int) removeLongAt(index)})</code>.
+ *
+ * @param index the index of the element to remove
+ * @return an {@link Long} object that wraps the value that was
+ * removed from that index
+ * @throws IndexOutOfBoundsException if the given index is negative
+ * or greater than or equal to {@link #size()}
+ */
public Object remove(int index) {
return new Long(removeLongAt(index));
}
- /** Returns <code>{@link #removeLong(long) removeLong(((Long)value).longValue())}</code>. */
+ /**
+ * Returns <code>{@link #removeLong(long) removeLong(((Long)value).longValue())}</code>.
+ *
+ * @param value an {@link Long} object that wraps the <Code>long</Code>
+ * value to remove
+ * @return true if the first occurrence of that <Code>long</Code> value
+ * was removed from this list, or <Code>false</Code> if this list
+ * did not contain that <Code>long</Code> value
+ * @throws ClassCastException if the given value is not an {@link Long}
+ * @throws NullPointerException if the given value is <Code>null</COde>
+ */
public boolean remove(Object value) {
return removeLong(((Long)value).longValue());
}
}
+
+
+
+ //--------------------------------------------------------------- Accessors
+
+
+
+
+
1.2 +225 -14 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/AbstractShortArrayList.java
Index: AbstractShortArrayList.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/AbstractShortArrayList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractShortArrayList.java 4 Jun 2002 16:01:27 -0000 1.1
+++ AbstractShortArrayList.java 13 Aug 2002 19:41:36 -0000 1.2
@@ -69,6 +69,8 @@
import java.util.ListIterator;
/**
+ * Abstract base class for lists backed by a <Code>short</Code> array.
+ *
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
@@ -76,75 +78,284 @@
//------------------------------------------------------ Abstract Accessors
+ /**
+ * Returns the maximum size the list can reach before the array
+ * is resized.
+ *
+ * @return the maximum size the list can reach before the array is resized
+ */
abstract public int capacity();
+
+ /**
+ * Returns the number of <Code>short</Code> elements currently in this
+ * list.
+ *
+ * @return the size of this list
+ */
abstract public int size();
+
+ /**
+ * Returns the <Code>short</Code> element at the specified index in this
+ * array.
+ *
+ * @param index the index of the element to return
+ * @return the <Code>short</Code> element at that index
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than or equal to {@link #size()}
+ */
abstract public short getShort(int index);
+
+ /**
+ * Returns <Code>true</Code> if this list contains the given
+ * <Code>short</Code> element.
+ *
+ * @param value the element to search for
+ * @return true if this list contains the given value, false otherwise
+ */
abstract public boolean containsShort(short value);
+
+ /**
+ * Returns the first index of the given <Code>short</Code> element, or
+ * -1 if the value is not in this list.
+ *
+ * @param value the element to search for
+ * @return the first index of that element, or -1 if the element is
+ * not in this list
+ */
abstract public int indexOfShort(short value);
+
+ /**
+ * Returns the last index of the given <Code>short</Code> element, or
+ * -1 if the value is not in this list.
+ *
+ * @param value the element to search for
+ * @return the last index of that element, or -1 if the element is
+ * not in this list
+ */
abstract public int lastIndexOfShort(short value);
//--------------------------------------------------------------- Accessors
- /** Returns <code>new Short({@link #getShort getShort(index)})</code>. */
+ /**
+ * Returns <code>new Short({@link #getShort getShort(index)})</code>.
+ *
+ * @param index the index of the element to return
+ * @return an {@link Short} object wrapping the <Code>short</Code>
+ * value at that index
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than or equal to {@link #size()}
+ */
public Object get(int index) {
return new Short(getShort(index));
}
- /** Returns <code>{@link #containsShort containsShort(((Short)value).shortValue())}</code>. */
+ /**
+ * Returns <code>{@link #containsShort containsShort(((Short)value.shortValue())}</code>.
+ *
+ * @param value an {@link Short} object whose wrapped <Code>short</Code>
+ * value to search for
+ * @return true if this list contains that <Code>short</Code> value
+ * @throws ClassCastException if the given object is not an
+ * {@link Short}
+ * @throws NullPointerException if the given object is <Code>null</Code>
+ */
public boolean contains(Object value) {
return containsShort(((Short)value).shortValue());
}
- /** Returns <code>({@link #size} == 0)</code>. */
+ /**
+ * Returns <code>({@link #size} == 0)</code>.
+ *
+ * @return true if this list is empty, false otherwise
+ */
public boolean isEmpty() {
return (0 == size());
}
- /** Returns <code>{@link #indexOfShort indexOfShort(((Short)value).shortValue())}</code>. */
+ /**
+ * Returns <code>{@link #indexOfShort indexOfShort(((Short)value.shortValue())}</code>.
+ *
+ * @param value an {@link Short} object whose wrapped <Code>short</Code>
+ * value to search for
+ * @return the first index of that <Code>short</Code> value, or -1 if
+ * this list does not contain that value
+ * @throws ClassCastException if the given object is not an
+ * {@link Short}
+ * @throws NullPointerException if the given object is <Code>null</Code>
+ */
public int indexOf(Object value) {
return indexOfShort(((Short)value).shortValue());
}
- /** Returns <code>{@link #lastIndexOfShort lastIndexOfShort(((Short)value).shortValue())}</code>. */
+ /**
+ * Returns <code>{@link #lastIndexOfShort lastIndexOfShort(((Short)value.shortValue())}</code>.
+ *
+ * @param value an {@link Short} object whose wrapped <Code>short</Code>
+ * value to search for
+ * @return the last index of that <Code>short</Code> value, or -1 if
+ * this list does not contain that value
+ * @throws ClassCastException if the given object is not an
+ * {@link Short}
+ * @throws NullPointerException if the given object is <Code>null</Code>
+ */
public int lastIndexOf(Object value) {
return lastIndexOfShort(((Short)value).shortValue());
}
//------------------------------------------------------ Abstract Modifiers
+ /**
+ * Sets the element at the given index to the given <Code>short</Code>
+ * value.
+ *
+ * @param index the index of the element to set
+ * @param value the <Code>short</Code> value to set it to
+ * @return the previous <Code>short</Code> value at that index
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than or equal to {@link #size()}.
+ */
abstract public short setShort(int index, short value);
+
+ /**
+ * Adds the given <Code>short</Code> value to the end of this list.
+ *
+ * @param value the value to add
+ * @return true, always
+ */
abstract public boolean addShort(short value);
+
+ /**
+ * Inserts the given <Code>short</Code> value into this list at the
+ * specified index.
+ *
+ * @param index the index for the insertion
+ * @param value the value to insert at that index
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than {@link #size()}
+ */
abstract public void addShort(int index, short value);
+
+ /**
+ * Removes the <Code>short</Code> element at the specified index.
+ *
+ * @param index the index of the element to remove
+ * @return the removed <Code>short</Code> value
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than or equal to {@link #size()}
+ */
abstract public short removeShortAt(int index);
+
+ /**
+ * Removes the first occurrence of the given <Code>short</Code> value
+ * from this list.
+ *
+ * @param value the value to remove
+ * @return true if this list contained that value and removed it,
+ * or false if this list didn't contain the value
+ */
abstract public boolean removeShort(short value);
+
+ /**
+ * Removes all <Code>short</Code> values from this list.
+ */
abstract public void clear();
+
+ /**
+ * Ensures that the length of the internal <Code>short</Code> array is
+ * at list the given value.
+ *
+ * @param mincap the minimum capcity for this list
+ */
abstract public void ensureCapacity(int mincap);
+
+ /**
+ * Resizes the internal array such that {@link #capacity()} is equal
+ * to {@link #size()}.
+ */
abstract public void trimToSize();
//--------------------------------------------------------------- Modifiers
- /** Returns <code>new Short({@link #setShort(int,short) setShort(index,((Short)value).shortValue())})</code>. */
+ /**
+ * Returns <code>new Short({@link #setShort(int,short)
+ * setShort(index,((Short)value.shortValue())})</code>.
+ *
+ * @param index the index of the element to set
+ * @param value an {@link Short} object whose <Code>short</Code> value
+ * to set at that index
+ * @return an {@link Short} that wraps the <Code>short</Code> value
+ * previously at that index
+ * @throws IndexOutOfBoundsException if the index is negative or greater
+ * than or equal to {@link #size()}
+ * @throws ClassCastException if the given value is not an {@link Short}
+ * @throws NullPointerException if the given value is <Code>null</COde>
+ */
public Object set(int index, Object value) {
return new Short(setShort(index,((Short)value).shortValue()));
}
- /** Invokes <code>{@link #addShort(short) addShort(((Short)value).shortValue())})</code>. */
+ /**
+ * Invokes <code>{@link #addShort(short) addShort(((Short)value.shortValue())})</code>.
+ *
+ * @param value an {@link Short} object that wraps the <Code>short</Code>
+ * value to add
+ * @return true, always
+ * @throws ClassCastException if the given value is not an {@link Short}
+ * @throws NullPointerException if the given value is <Code>null</COde>
+ */
public boolean add(Object value) {
return addShort(((Short)value).shortValue());
}
- /** Invokes <code>{@link #addShort(int,short) addShort(index,((Short)value).shortValue())})</code>. */
+ /**
+ * Invokes <code>{@link #addShort(int,short) addShort(index,((Short)value.shortValue())})</code>.
+ *
+ * @param index the index of the insertion
+ * @param value an {@link Short} object that wraps the <Code>short</Code>
+ * value to insert
+ * @throws IndexOutOfBoundsException if the index is negative or greater
+ * than {@link #size()}
+ * @throws ClassCastException if the given value is not an {@link Short}
+ * @throws NullPointerException if the given value is <Code>null</COde>
+ */
public void add(int index, Object value) {
addShort(index,((Short)value).shortValue());
}
- /** Returns <code>new Short({@link #removeShortAt(int) removeShortAt(index)})</code>. */
+ /**
+ * Returns <code>new Short({@link #removeShortAt(int) removeIntAt(index)})</code>.
+ *
+ * @param index the index of the element to remove
+ * @return an {@link Short} object that wraps the value that was
+ * removed from that index
+ * @throws IndexOutOfBoundsException if the given index is negative
+ * or greater than or equal to {@link #size()}
+ */
public Object remove(int index) {
return new Short(removeShortAt(index));
}
- /** Returns <code>{@link #removeShort(short) removeShort(((Short)value).shortValue())}</code>. */
+ /**
+ * Returns <code>{@link #removeShort(short) removeShort(((Short)value.shortValue())}</code>.
+ *
+ * @param value an {@link Short} object that wraps the <Code>short</Code>
+ * value to remove
+ * @return true if the first occurrence of that <Code>short</Code> value
+ * was removed from this list, or <Code>false</Code> if this list
+ * did not contain that <Code>short</Code> value
+ * @throws ClassCastException if the given value is not an {@link Short}
+ * @throws NullPointerException if the given value is <Code>null</COde>
+ */
public boolean remove(Object value) {
return removeShort(((Short)value).shortValue());
}
+
}
+
+
+
+ //--------------------------------------------------------------- Accessors
+
+
+
+
1.3 +166 -7 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/FloatArrayList.java
Index: FloatArrayList.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/FloatArrayList.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FloatArrayList.java 21 Jun 2002 03:50:40 -0000 1.2
+++ FloatArrayList.java 13 Aug 2002 19:41:36 -0000 1.3
@@ -72,45 +72,106 @@
import java.util.ListIterator;
/**
+ * A list backed by a <Code>float</Code> array.
+ *
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
public class FloatArrayList extends AbstractList implements List, Serializable {
//------------------------------------------------------------ Constructors
-
+
+ /**
+ * Constructs a new <Code>FloatArrayList</Code> with a default initial
+ * capacity.
+ */
public FloatArrayList() {
this(8);
}
+ /**
+ * Constructs a new <Code>FloatArrayList</Code> with the specified initial
+ * capacity.
+ *
+ * @param capacity the initial capacity for the list
+ * @throws IllegalArgumentException if capacity is less than or equal
+ * to zero
+ */
public FloatArrayList(int capacity) {
+ if (capacity <= 0) {
+ throw new IllegalArgumentException("capacity=" + capacity);
+ }
_data = new float[capacity];
}
//--------------------------------------------------------------- Accessors
-
+
+ /**
+ * Returns the capacity of this list.
+ *
+ * @return the capacity of this list
+ */
public int capacity() {
return _data.length;
}
+ /**
+ * Returns the size of this list.
+ *
+ * @return the size of this list
+ */
public int size() {
return _size;
}
+ /**
+ * Returns a {@link Float} that wraps the <Code>float</Code> value at
+ * the given index.
+ *
+ * @param index the index of the <Code>float</Code>value to return
+ * @return a {@link Float} that wraps the <Code>float</Code> value
+ * at that index
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than or equal to {@link #size()}
+ */
public Object get(int index) {
checkRange(index);
return new Float(_data[index]);
}
+ /**
+ * Returns the <Code>float</Code> value at the given index.
+ *
+ * @param index the index of the <Code>float</Code> value to return
+ * @return the <Code>float</Code> value at that index
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than or equal to {@link #size()}
+ */
public float getFloat(int index) {
checkRange(index);
return _data[index];
}
+ /**
+ * Returns true if this list contains the given <Code>float</Code>
+ * value.
+ *
+ * @param value the <Code>float</COde> value to search for
+ * @return true if this list contains the given <Code>float</COde>
+ * value, false otherwise
+ */
public boolean containsFloat(float value) {
return (-1 != indexOfFloat(value));
}
+ /**
+ * Returns the index of the first occurrence of the given <Code>float</Code>
+ * value, or -1 if this list does not contain that value.
+ *
+ * @param value the <Code>float</COde> value to search for
+ * @return the index of the first occurrence of that value, or -1
+ * if this list does not contain that value
+ */
public int indexOfFloat(float value) {
for(int i=0;i<_size;i++) {
if(value == _data[i]) {
@@ -120,6 +181,14 @@
return -1;
}
+ /**
+ * Returns the index of the last occurrence of the given <Code>float</Code>
+ * value, or -1 if this list does not contain that value.
+ *
+ * @param value the <Code>float</COde> value to search for
+ * @return the index of the last occurrence of that value, or -1
+ * if this list does not contain that value
+ */
public int lastIndexOfFloat(float value) {
for(int i=_size-1;i>=0;i--) {
if(value == _data[i]) {
@@ -130,7 +199,17 @@
}
//--------------------------------------------------------------- Modifiers
-
+
+ /**
+ * Sets the element at the given index to the given <Code>float</COde>
+ * value.
+ *
+ * @param index the index of the element to set
+ * @param value the new <Code>float</Code> value for that element
+ * @return the previous <Code>float</Code> value at that index
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than or equal to {@link #size()}
+ */
public float setFloat(int index, float value) {
checkRange(index);
float old = _data[index];
@@ -138,18 +217,47 @@
return old;
}
+ /**
+ * Returns <Code>new Float({@link #setFloat(int,float)
+ * set(index, ((Float)value).floatValue())})</Code>.
+ *
+ * @param index the index of the element to set
+ * @param value a {@link Float} instance that warps the new
+ * <Code>float</Code> value for that element
+ * @return a {@link Float} instance that wraps the previous
+ * <Code>float</Code> value at that index
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than or equal to {@link #size()}
+ * @throws ClassCastException if the given value is not a {@link Float}
+ * @throws NullPointerException if the given value is <Code>null</COde>
+ */
public Object set(int index, Object value) {
Float f = (Float)value;
return new Float(setFloat(index, f.floatValue()));
}
+ /**
+ * Adds the given <Code>float</COde> value to this list.
+ *
+ * @param value the <Code>float</COde> value to add
+ * @return true, always
+ */
public boolean addFloat(float value) {
ensureCapacity(_size+1);
_data[_size++] = value;
return true;
}
+ /**
+ * Inserts the given <code>float</Code> value into this list at the
+ * given index.
+ *
+ * @param index the index of the insertion
+ * @param value the <Code>float</COde> value to insert at that index
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than {@link #size()}
+ */
public void addFloat(int index, float value) {
checkRangeIncludingEndpoint(index);
ensureCapacity(_size+1);
@@ -159,15 +267,39 @@
_size++;
}
+
+ /**
+ * Invokes {@link #addFloat(int,float)
+ * add(index, ((Float)value).floatValue())}.
+ *
+ * @param index the index of the insertion
+ * @param value a {@link Float} instance that wraps the
+ * <Code>float</COde> value to insert at that index
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than {@link #size()}
+ * @throws ClassCastException if the given value is not a {@link Float}
+ * @throws NullPointerException if the given value is <Code>null</COde>
+ */
public void add(int index, Object value) {
addFloat(index,((Float)value).floatValue());
}
+ /**
+ * Removes all <Code>float</Code> values from this list.
+ */
public void clear() {
modCount++;
_size = 0;
}
+ /**
+ * Removes the <Code>float</Code> at the given index.
+ *
+ * @param index the index of the <Code>float</Code> value to remove
+ * @return the removed <Code>float</Code> value
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than or equal to {@link #size()}
+ */
public float removeFloatAt(int index) {
checkRange(index);
modCount++;
@@ -180,6 +312,14 @@
return oldval;
}
+ /**
+ * Removes the first occurrence of the given <Code>float</Code> value
+ * from this list.
+ *
+ * @param value the <Code>float</Code> value to remove
+ * @return true if the first occurrence of that value was removed, or
+ * false if this list did not contain that value
+ */
public boolean removeFloat(float value) {
int index = indexOfFloat(value);
if(-1 == index) {
@@ -190,10 +330,25 @@
}
}
+ /**
+ * Removes the <Code>float</Code> at the given index.
+ *
+ * @param index the index of the <Code>float</Code> value to remove
+ * @return a {@link Float} instance that wraps the removed
+ * <Code>float</Code> value
+ * @throws IndexOutOfBoundsException if the index is negative or
+ * greater than or equal to {@link #size()}
+ */
public Object remove(int index) {
return new Float(removeFloatAt(index));
}
+ /**
+ * Ensures that the internal array is big enough to hold the specified
+ * number of elements.
+ *
+ * @param mincap the minium capacity
+ */
public void ensureCapacity(int mincap) {
modCount++;
if(mincap > _data.length) {
@@ -204,6 +359,10 @@
}
}
+ /**
+ * Trims this list such that {@link #capacity()} is equal to
+ * {@link #size()}.
+ */
public void trimToSize() {
modCount++;
if(_size < _data.length) {
1.2 +26 -7 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/IntArrayList.java
Index: IntArrayList.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/IntArrayList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- IntArrayList.java 4 Jun 2002 16:01:27 -0000 1.1
+++ IntArrayList.java 13 Aug 2002 19:41:36 -0000 1.2
@@ -72,23 +72,40 @@
import java.util.ListIterator;
/**
+ * A list of <Code>int</Code> elements.
+ *
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
public class IntArrayList extends AbstractIntArrayList implements List, Serializable {
- //------------------------------------------------------------ Constructors
-
+ //------------------------------------------------------------ Constructors
+
+ /**
+ * Constructs a new <Code>IntArrayList</Code> with a default capacity.
+ */
public IntArrayList() {
this(8);
}
+ /**
+ * 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
+ */
public IntArrayList(int capacity) {
+ if (capacity <= 0) {
+ throw new IllegalArgumentException("capacity " + capacity);
+ }
_data = new int[capacity];
}
//--------------------------------------------------------------- Accessors
-
+
+ // Note: JavaDoc for these methods is inherited from the superclass.
+
public int capacity() {
return _data.length;
}
@@ -125,6 +142,8 @@
}
//--------------------------------------------------------------- Modifiers
+
+ // Note: JavaDoc for these methods is inherited from the superclass.
public int setInt(int index, int value) {
checkRange(index);
1.2 +21 -4 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/LongArrayList.java
Index: LongArrayList.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/LongArrayList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LongArrayList.java 4 Jun 2002 16:01:27 -0000 1.1
+++ LongArrayList.java 13 Aug 2002 19:41:36 -0000 1.2
@@ -72,6 +72,8 @@
import java.util.ListIterator;
/**
+ * A list of <Code>long</COde> elements.
+ *
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
@@ -79,11 +81,26 @@
//------------------------------------------------------------ Constructors
+ /**
+ * Constructs a new <Code>LongArrayList</CodE> with a default initial
+ * capacity.
+ */
public LongArrayList() {
this(8);
}
+ /**
+ * Constructs a new <Code>LongArrayList</CodE> with the given initial
+ * capacity.
+ *
+ * @param capacity the initial capacity for the array
+ * @throws IllegalArgumentException if the capacity is less than or
+ * equal to zero
+ */
public LongArrayList(int capacity) {
+ if (capacity <= 0) {
+ throw new IllegalArgumentException("capacity=" + capacity);
+ }
_data = new long[capacity];
}
1.2 +21 -4 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/ShortArrayList.java
Index: ShortArrayList.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/ShortArrayList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ShortArrayList.java 4 Jun 2002 16:01:27 -0000 1.1
+++ ShortArrayList.java 13 Aug 2002 19:41:36 -0000 1.2
@@ -72,6 +72,8 @@
import java.util.ListIterator;
/**
+ * A list of <Code>short</Code> elements.
+ *
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
@@ -79,11 +81,26 @@
//------------------------------------------------------------ Constructors
+ /**
+ * Constructs a new <Code>ShortArrayList</CodE> with a default initial
+ * capacity.
+ */
public ShortArrayList() {
this(8);
}
+ /**
+ * Constructs a new <Code>ShortArrayList</CodE> with the given initial
+ * capacity.
+ *
+ * @param capacity the initial capacity for the array
+ * @throws IllegalArgumentException if the capacity is less than or
+ * equal to zero
+ */
public ShortArrayList(int capacity) {
+ if (capacity <= 0) {
+ throw new IllegalArgumentException("capacity=" + capacity);
+ }
_data = new short[capacity];
}
1.2 +31 -4 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/UnsignedByteArrayList.java
Index: UnsignedByteArrayList.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/UnsignedByteArrayList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UnsignedByteArrayList.java 4 Jun 2002 16:01:27 -0000 1.1
+++ UnsignedByteArrayList.java 13 Aug 2002 19:41:36 -0000 1.2
@@ -72,6 +72,10 @@
import java.util.ListIterator;
/**
+ * A list of unsigned 8-bit values, stored in a <Code>short</Code> array.
+ * Mutators on this class will reject any <Code>short</Code> that does not
+ * express an unsigned 8-bit value.
+ *
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
@@ -79,11 +83,26 @@
//------------------------------------------------------------ Constructors
+ /**
+ * Constructs a new <Code>UnsignedByteArrayList</Code> with a
+ * default initial capacity.
+ */
public UnsignedByteArrayList() {
this(8);
}
+ /**
+ * Constructs a new <Code>UnsignedByteArrayList</Code> with the
+ * specified initial capacity.
+ *
+ * @param capacity the capacity for this list
+ * @throws IllegalArgumentException if the given capacity is less than
+ * or equal to zero
+ */
public UnsignedByteArrayList(int capacity) {
+ if (capacity <= 0) {
+ throw new IllegalArgumentException("capacity=" + capacity);
+ }
_data = new byte[capacity];
}
@@ -252,6 +271,14 @@
private transient byte[] _data = null;
private int _size = 0;
+
+ /**
+ * The maximum possible unsigned 8-bit value.
+ */
public static final short MAX_VALUE = 0xFF;
+
+ /**
+ * The minimum possible unsigned 8-bit value.
+ */
public static final short MIN_VALUE = 0;
}
1.2 +31 -4 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/UnsignedIntArrayList.java
Index: UnsignedIntArrayList.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/UnsignedIntArrayList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UnsignedIntArrayList.java 4 Jun 2002 16:01:27 -0000 1.1
+++ UnsignedIntArrayList.java 13 Aug 2002 19:41:36 -0000 1.2
@@ -72,6 +72,10 @@
import java.util.ListIterator;
/**
+ * A list of unsigned 32-bit values, stored in a <Code>long</Code> array.
+ * Mutators on this class will reject any <Code>long</Code> that does not
+ * express an unsigned 16-bit value.
+ *
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
@@ -79,11 +83,26 @@
//------------------------------------------------------------ Constructors
+ /**
+ * Constructs a new <Code>UnsignedIntArrayList</Code> with a
+ * default initial capacity.
+ */
public UnsignedIntArrayList() {
this(8);
}
+ /**
+ * Constructs a new <Code>UnsignedIntArrayList</Code> with the
+ * specified initial capacity.
+ *
+ * @param capacity the capacity for this list
+ * @throws IllegalArgumentException if the given capacity is less than
+ * or equal to zero
+ */
public UnsignedIntArrayList(int capacity) {
+ if (capacity <= 0) {
+ throw new IllegalArgumentException("capacity=" + capacity);
+ }
_data = new int[capacity];
}
@@ -251,6 +270,14 @@
private transient int[] _data = null;
private int _size = 0;
+
+ /**
+ * The maximum possible unsigned 32-bit value.
+ */
public static final long MAX_VALUE = 0xFFFFFFFFL;
+
+ /**
+ * The minimum possible unsigned 32-bit value.
+ */
public static final long MIN_VALUE = 0L;
}
1.2 +34 -5 jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/UnsignedShortArrayList.java
Index: UnsignedShortArrayList.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/primitives/UnsignedShortArrayList.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UnsignedShortArrayList.java 4 Jun 2002 16:01:27 -0000 1.1
+++ UnsignedShortArrayList.java 13 Aug 2002 19:41:36 -0000 1.2
@@ -72,6 +72,10 @@
import java.util.ListIterator;
/**
+ * A list of unsigned 16-bit values, stored in an <Code>int</Code> array.
+ * Mutators on this class will reject any <Code>int</Code> that does not
+ * express an unsigned 16-bit value.
+ *
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
@@ -79,11 +83,27 @@
//------------------------------------------------------------ Constructors
+ /**
+ * Constructs a new <Code>UnsignedShortArrayList</Code> with a
+ * default initial capacity.
+ */
public UnsignedShortArrayList() {
this(8);
}
+
+ /**
+ * Constructs a new <Code>UnsignedShortArrayList</Code> with the
+ * specified initial capacity.
+ *
+ * @param capacity the capacity for this list
+ * @throws IllegalArgumentException if the given capacity is less than
+ * or equal to zero
+ */
public UnsignedShortArrayList(int capacity) {
+ if (capacity <= 0) {
+ throw new IllegalArgumentException("capacity=" + capacity);
+ }
_data = new short[capacity];
}
@@ -130,7 +150,7 @@
}
//--------------------------------------------------------------- Modifiers
-
+
public int setInt(int index, int value) {
assertValidUnsignedShort(value);
checkRange(index);
@@ -252,6 +272,15 @@
private transient short[] _data = null;
private int _size = 0;
+
+ /**
+ * The maximum possible unsigned 16-bit value.
+ */
public static final int MAX_VALUE = 0xFFFF;
+
+
+ /**
+ * The minimum possible unsigned 16-bit value.
+ */
public static final int MIN_VALUE = 0;
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>