From 43c829d31814e587f8aa5dcc80ac537fa30c10b4 Mon Sep 17 00:00:00 2001 From: pjack Date: Tue, 13 Aug 2002 19:41:36 +0000 Subject: [PATCH] Added documentation to classes in primitives package. PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130772 13f79535-47bb-0310-9956-ffa450edef68 --- .../primitives/AbstractIntArrayList.java | 240 ++++++++++++++++-- .../primitives/AbstractLongArrayList.java | 239 ++++++++++++++++- .../primitives/AbstractShortArrayList.java | 239 ++++++++++++++++- .../primitives/FloatArrayList.java | 173 ++++++++++++- .../collections/primitives/IntArrayList.java | 33 ++- .../collections/primitives/LongArrayList.java | 25 +- .../primitives/ShortArrayList.java | 25 +- .../primitives/UnsignedByteArrayList.java | 35 ++- .../primitives/UnsignedIntArrayList.java | 35 ++- .../primitives/UnsignedShortArrayList.java | 39 ++- 10 files changed, 1005 insertions(+), 78 deletions(-) diff --git a/src/java/org/apache/commons/collections/primitives/AbstractIntArrayList.java b/src/java/org/apache/commons/collections/primitives/AbstractIntArrayList.java index f7f4f8f5b..92bb3e8a8 100644 --- a/src/java/org/apache/commons/collections/primitives/AbstractIntArrayList.java +++ b/src/java/org/apache/commons/collections/primitives/AbstractIntArrayList.java @@ -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/AbstractIntArrayList.java,v 1.1 2002/06/04 16:01:27 rwaldhoff Exp $ - * $Revision: 1.1 $ - * $Date: 2002/06/04 16:01:27 $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/AbstractIntArrayList.java,v 1.2 2002/08/13 19:41:36 pjack Exp $ + * $Revision: 1.2 $ + * $Date: 2002/08/13 19:41:36 $ * * ==================================================================== * @@ -69,81 +69,291 @@ import java.util.List; import java.util.ListIterator; /** - * @version $Revision: 1.1 $ $Date: 2002/06/04 16:01:27 $ + * Abstract base class for lists backed by an int array. + * + * @version $Revision: 1.2 $ $Date: 2002/08/13 19:41:36 $ * @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 int elements currently in this + * list. + * + * @return the size of this list + */ abstract public int size(); + + + /** + * Returns the int element at the specified index in this + * array. + * + * @param index the index of the element to return + * @return the int 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 true if this list contains the given + * int 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 int 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 int 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 new Integer({@link #getInt getInteger(index)}). */ + /** + * Returns new Integer({@link #getInt getInt(index)}). + * + * @param index the index of the element to return + * @return an {@link Integer} object wrapping the int + * 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 {@link #containsInt containsInt(((Integer)value).intValue())}. */ + /** + * Returns {@link #containsInt containsInt(((Integer)value).intValue())}. + * + * @param value an {@link Integer} object whose wrapped int + * value to search for + * @return true if this list contains that int value + * @throws ClassCastException if the given object is not an + * {@link Integer} + * @throws NullPointerException if the given object is null + */ public boolean contains(Object value) { return containsInt(((Integer)value).intValue()); } - /** Returns ({@link #size} == 0). */ + /** + * Returns ({@link #size} == 0). + * + * @return true if this list is empty, false otherwise + */ public boolean isEmpty() { return (0 == size()); } - /** Returns {@link #indexOfInt indexOfInt(((Integer)value).intValue())}. */ + /** + * Returns {@link #indexOfInt indexOfInt(((Integer)value).intValue())}. + * + * @param value an {@link Integer} object whose wrapped int + * value to search for + * @return the first index of that int 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 null + */ public int indexOf(Object value) { return indexOfInt(((Integer)value).intValue()); } - /** Returns {@link #lastIndexOfInt lastIndexOfInt(((Integer)value).intValue())}. */ + /** + * Returns {@link #lastIndexOfInt lastIndexOfInt(((Integer)value).intValue())}. + * + * @param value an {@link Integer} object whose wrapped int + * value to search for + * @return the last index of that int 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 null + */ public int lastIndexOf(Object value) { return lastIndexOfInt(((Integer)value).intValue()); } //------------------------------------------------------ Abstract Modifiers + /** + * Sets the element at the given index to the given int + * value. + * + * @param index the index of the element to set + * @param value the int value to set it to + * @return the previous int 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 int 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 int 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 int element at the specified index. + * + * @param index the index of the element to remove + * @return the removed int 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 int 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 int values from this list. + */ abstract public void clear(); + + /** + * Ensures that the length of the internal int 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 new Integer({@link #setInt(int,int) setInt(index,((Integer)value).intValue())}). */ + /** + * Returns new Integer({@link #setInt(int,int) + * setInt(index,((Integer)value).intValue())}). + * + * @param index the index of the element to set + * @param value an {@link Integer} object whose int value + * to set at that index + * @return an {@link Integer} that wraps the int 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 null + */ public Object set(int index, Object value) { return new Integer(setInt(index,((Integer)value).intValue())); } - /** Invokes {@link #addInt(int) addInt(((Integer)value).intValue())}). */ + /** + * Invokes {@link #addInt(int) addInt(((Integer)value).intValue())}). + * + * @param value an {@link Integer} object that wraps the int + * value to add + * @return true, always + * @throws ClassCastException if the given value is not an {@link Integer} + * @throws NullPointerException if the given value is null + */ public boolean add(Object value) { return addInt(((Integer)value).intValue()); } - /** Invokes {@link #addInt(int,int) addInt(index,((Integer)value).intValue())}). */ + /** + * Invokes {@link #addInt(int,int) addInt(index,((Integer)value).intValue())}). + * + * @param index the index of the insertion + * @param value an {@link Integer} object that wraps the int + * 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 null + */ public void add(int index, Object value) { addInt(index,((Integer)value).intValue()); } - /** Returns new Integer({@link #removeIntAt(int) removeIntAt(index)}). */ + /** + * Returns new Integer({@link #removeIntAt(int) removeIntAt(index)}). + * + * @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 {@link #removeInt(int) removeInt(((Integer)value).intValue())}. */ + /** + * Returns {@link #removeInt(int) removeInt(((Integer)value).intValue())}. + * + * @param value an {@link Integer} object that wraps the int + * value to remove + * @return true if the first occurrence of that int value + * was removed from this list, or false if this list + * did not contain that int value + * @throws ClassCastException if the given value is not an {@link Integer} + * @throws NullPointerException if the given value is null + */ public boolean remove(Object value) { return removeInt(((Integer)value).intValue()); } diff --git a/src/java/org/apache/commons/collections/primitives/AbstractLongArrayList.java b/src/java/org/apache/commons/collections/primitives/AbstractLongArrayList.java index c8f9949bd..54ca16ecb 100644 --- a/src/java/org/apache/commons/collections/primitives/AbstractLongArrayList.java +++ b/src/java/org/apache/commons/collections/primitives/AbstractLongArrayList.java @@ -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/AbstractLongArrayList.java,v 1.1 2002/06/04 16:01:27 rwaldhoff Exp $ - * $Revision: 1.1 $ - * $Date: 2002/06/04 16:01:27 $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/AbstractLongArrayList.java,v 1.2 2002/08/13 19:41:36 pjack Exp $ + * $Revision: 1.2 $ + * $Date: 2002/08/13 19:41:36 $ * * ==================================================================== * @@ -69,82 +69,293 @@ import java.util.List; import java.util.ListIterator; /** - * @version $Revision: 1.1 $ $Date: 2002/06/04 16:01:27 $ + * Abstract base class for lists backed by a long array. + * + * @version $Revision: 1.2 $ $Date: 2002/08/13 19:41:36 $ * @author Rodney Waldhoff */ public abstract class AbstractLongArrayList 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 long elements currently in this + * list. + * + * @return the size of this list + */ abstract public int size(); + + /** + * Returns the long element at the specified index in this + * array. + * + * @param index the index of the element to return + * @return the long 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 true if this list contains the given + * long 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 long 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 long 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 new Long({@link #getLong getLong(index)}). */ + /** + * Returns new Long({@link #getLong getLong(index)}). + * + * @param index the index of the element to return + * @return an {@link Long} object wrapping the long + * 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 {@link #containsLong containsLong(((Long)value).longValue())}. */ + /** + * Returns {@link #containsLong containsLong(((Long)value).longValue())}. + * + * @param value an {@link Long} object whose wrapped long + * value to search for + * @return true if this list contains that long value + * @throws ClassCastException if the given object is not an + * {@link Long} + * @throws NullPointerException if the given object is null + */ public boolean contains(Object value) { return containsLong(((Long)value).longValue()); } - /** Returns ({@link #size} == 0). */ + /** + * Returns ({@link #size} == 0). + * + * @return true if this list is empty, false otherwise + */ public boolean isEmpty() { return (0 == size()); } - /** Returns {@link #indexOfLong indexOfLong(((Long)value).longValue())}. */ + /** + * Returns {@link #indexOfLong indexOfLong(((Long).longValue())}. + * + * @param value an {@link Long} object whose wrapped long + * value to search for + * @return the first index of that long 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 null + */ public int indexOf(Object value) { return indexOfLong(((Long)value).longValue()); } - /** Returns {@link #lastIndexOfLong lastIndexOfLong(((Long)value).longValue())}. */ + /** + * Returns {@link #lastIndexOfLong lastIndexOfLong(((Long).longValue())}. + * + * @param value an {@link Long} object whose wrapped long + * value to search for + * @return the last index of that long 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 null + */ public int lastIndexOf(Object value) { return lastIndexOfLong(((Long)value).longValue()); } //------------------------------------------------------ Abstract Modifiers + /** + * Sets the element at the given index to the given long + * value. + * + * @param index the index of the element to set + * @param value the long value to set it to + * @return the previous long 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 long 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 long 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 long element at the specified index. + * + * @param index the index of the element to remove + * @return the removed long 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 long 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 long values from this list. + */ abstract public void clear(); + + /** + * Ensures that the length of the internal long 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 new Long({@link #setLong(int,long) setLong(index,((Long)value).longValue())}). */ + /** + * Returns new Long({@link #setLong(int,long) + * setLong(index,((Long).longValue())}). + * + * @param index the index of the element to set + * @param value an {@link Long} object whose long value + * to set at that index + * @return an {@link Long} that wraps the long 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 null + */ public Object set(int index, Object value) { return new Long(setLong(index,((Long)value).longValue())); } - /** Invokes {@link #addLong(long) addLong(((Long)value).longValue())}). */ + /** + * Invokes {@link #addLong(long) addLong(((Long)value).longValue())}). + * + * @param value an {@link Long} object that wraps the long + * value to add + * @return true, always + * @throws ClassCastException if the given value is not an {@link Long} + * @throws NullPointerException if the given value is null + */ public boolean add(Object value) { return addLong(((Long)value).longValue()); } - /** Invokes {@link #addLong(int,long) addLong(index,((Long)value).longValue())}). */ + /** + * Invokes {@link #addLong(int,long) addLong(index,((Long)value).longValue())}). + * + * @param index the index of the insertion + * @param value an {@link Long} object that wraps the long + * 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 null + */ public void add(int index, Object value) { addLong(index,((Long)value).longValue()); } - /** Returns new Long({@link #removeLongAt(int) removeLongAt(index)}). */ + /** + * Returns new Long({@link #removeLongAt(int) removeLongAt(index)}). + * + * @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 {@link #removeLong(long) removeLong(((Long)value).longValue())}. */ + /** + * Returns {@link #removeLong(long) removeLong(((Long)value).longValue())}. + * + * @param value an {@link Long} object that wraps the long + * value to remove + * @return true if the first occurrence of that long value + * was removed from this list, or false if this list + * did not contain that long value + * @throws ClassCastException if the given value is not an {@link Long} + * @throws NullPointerException if the given value is null + */ public boolean remove(Object value) { return removeLong(((Long)value).longValue()); } } + + + + //--------------------------------------------------------------- Accessors + + + + + diff --git a/src/java/org/apache/commons/collections/primitives/AbstractShortArrayList.java b/src/java/org/apache/commons/collections/primitives/AbstractShortArrayList.java index 372411c98..9a9700fbd 100644 --- a/src/java/org/apache/commons/collections/primitives/AbstractShortArrayList.java +++ b/src/java/org/apache/commons/collections/primitives/AbstractShortArrayList.java @@ -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/AbstractShortArrayList.java,v 1.1 2002/06/04 16:01:27 rwaldhoff Exp $ - * $Revision: 1.1 $ - * $Date: 2002/06/04 16:01:27 $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/AbstractShortArrayList.java,v 1.2 2002/08/13 19:41:36 pjack Exp $ + * $Revision: 1.2 $ + * $Date: 2002/08/13 19:41:36 $ * * ==================================================================== * @@ -69,82 +69,293 @@ import java.util.List; import java.util.ListIterator; /** - * @version $Revision: 1.1 $ $Date: 2002/06/04 16:01:27 $ + * Abstract base class for lists backed by a short array. + * + * @version $Revision: 1.2 $ $Date: 2002/08/13 19:41:36 $ * @author Rodney Waldhoff */ public abstract class AbstractShortArrayList 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 short elements currently in this + * list. + * + * @return the size of this list + */ abstract public int size(); + + /** + * Returns the short element at the specified index in this + * array. + * + * @param index the index of the element to return + * @return the short 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 true if this list contains the given + * short 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 short 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 short 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 new Short({@link #getShort getShort(index)}). */ + /** + * Returns new Short({@link #getShort getShort(index)}). + * + * @param index the index of the element to return + * @return an {@link Short} object wrapping the short + * 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 {@link #containsShort containsShort(((Short)value).shortValue())}. */ + /** + * Returns {@link #containsShort containsShort(((Short)value.shortValue())}. + * + * @param value an {@link Short} object whose wrapped short + * value to search for + * @return true if this list contains that short value + * @throws ClassCastException if the given object is not an + * {@link Short} + * @throws NullPointerException if the given object is null + */ public boolean contains(Object value) { return containsShort(((Short)value).shortValue()); } - /** Returns ({@link #size} == 0). */ + /** + * Returns ({@link #size} == 0). + * + * @return true if this list is empty, false otherwise + */ public boolean isEmpty() { return (0 == size()); } - /** Returns {@link #indexOfShort indexOfShort(((Short)value).shortValue())}. */ + /** + * Returns {@link #indexOfShort indexOfShort(((Short)value.shortValue())}. + * + * @param value an {@link Short} object whose wrapped short + * value to search for + * @return the first index of that short 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 null + */ public int indexOf(Object value) { return indexOfShort(((Short)value).shortValue()); } - /** Returns {@link #lastIndexOfShort lastIndexOfShort(((Short)value).shortValue())}. */ + /** + * Returns {@link #lastIndexOfShort lastIndexOfShort(((Short)value.shortValue())}. + * + * @param value an {@link Short} object whose wrapped short + * value to search for + * @return the last index of that short 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 null + */ public int lastIndexOf(Object value) { return lastIndexOfShort(((Short)value).shortValue()); } //------------------------------------------------------ Abstract Modifiers + /** + * Sets the element at the given index to the given short + * value. + * + * @param index the index of the element to set + * @param value the short value to set it to + * @return the previous short 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 short 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 short 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 short element at the specified index. + * + * @param index the index of the element to remove + * @return the removed short 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 short 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 short values from this list. + */ abstract public void clear(); + + /** + * Ensures that the length of the internal short 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 new Short({@link #setShort(int,short) setShort(index,((Short)value).shortValue())}). */ + /** + * Returns new Short({@link #setShort(int,short) + * setShort(index,((Short)value.shortValue())}). + * + * @param index the index of the element to set + * @param value an {@link Short} object whose short value + * to set at that index + * @return an {@link Short} that wraps the short 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 null + */ public Object set(int index, Object value) { return new Short(setShort(index,((Short)value).shortValue())); } - /** Invokes {@link #addShort(short) addShort(((Short)value).shortValue())}). */ + /** + * Invokes {@link #addShort(short) addShort(((Short)value.shortValue())}). + * + * @param value an {@link Short} object that wraps the short + * value to add + * @return true, always + * @throws ClassCastException if the given value is not an {@link Short} + * @throws NullPointerException if the given value is null + */ public boolean add(Object value) { return addShort(((Short)value).shortValue()); } - /** Invokes {@link #addShort(int,short) addShort(index,((Short)value).shortValue())}). */ + /** + * Invokes {@link #addShort(int,short) addShort(index,((Short)value.shortValue())}). + * + * @param index the index of the insertion + * @param value an {@link Short} object that wraps the short + * 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 null + */ public void add(int index, Object value) { addShort(index,((Short)value).shortValue()); } - /** Returns new Short({@link #removeShortAt(int) removeShortAt(index)}). */ + /** + * Returns new Short({@link #removeShortAt(int) removeIntAt(index)}). + * + * @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 {@link #removeShort(short) removeShort(((Short)value).shortValue())}. */ + /** + * Returns {@link #removeShort(short) removeShort(((Short)value.shortValue())}. + * + * @param value an {@link Short} object that wraps the short + * value to remove + * @return true if the first occurrence of that short value + * was removed from this list, or false if this list + * did not contain that short value + * @throws ClassCastException if the given value is not an {@link Short} + * @throws NullPointerException if the given value is null + */ public boolean remove(Object value) { return removeShort(((Short)value).shortValue()); } + } + + + + //--------------------------------------------------------------- Accessors + + + + diff --git a/src/java/org/apache/commons/collections/primitives/FloatArrayList.java b/src/java/org/apache/commons/collections/primitives/FloatArrayList.java index 0c7c8b666..8369dfb48 100644 --- a/src/java/org/apache/commons/collections/primitives/FloatArrayList.java +++ b/src/java/org/apache/commons/collections/primitives/FloatArrayList.java @@ -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.2 2002/06/21 03:50:40 mas Exp $ - * $Revision: 1.2 $ - * $Date: 2002/06/21 03:50:40 $ + * $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.3 2002/08/13 19:41:36 pjack Exp $ + * $Revision: 1.3 $ + * $Date: 2002/08/13 19:41:36 $ * * ==================================================================== * @@ -72,45 +72,106 @@ import java.util.List; import java.util.ListIterator; /** - * @version $Revision: 1.2 $ $Date: 2002/06/21 03:50:40 $ + * A list backed by a float array. + * + * @version $Revision: 1.3 $ $Date: 2002/08/13 19:41:36 $ * @author Rodney Waldhoff */ public class FloatArrayList extends AbstractList implements List, Serializable { //------------------------------------------------------------ Constructors - + + /** + * Constructs a new FloatArrayList with a default initial + * capacity. + */ public FloatArrayList() { this(8); } + /** + * Constructs a new FloatArrayList 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 float value at + * the given index. + * + * @param index the index of the floatvalue to return + * @return a {@link Float} that wraps the float 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 float value at the given index. + * + * @param index the index of the float value to return + * @return the float 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 float + * value. + * + * @param value the float value to search for + * @return true if this list contains the given float + * value, false otherwise + */ public boolean containsFloat(float value) { return (-1 != indexOfFloat(value)); } + /** + * Returns the index of the first occurrence of the given float + * value, or -1 if this list does not contain that value. + * + * @param value the float 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 @@ public class FloatArrayList extends AbstractList implements List, Serializable { return -1; } + /** + * Returns the index of the last occurrence of the given float + * value, or -1 if this list does not contain that value. + * + * @param value the float 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 @@ public class FloatArrayList extends AbstractList implements List, Serializable { } //--------------------------------------------------------------- Modifiers - + + /** + * Sets the element at the given index to the given float + * value. + * + * @param index the index of the element to set + * @param value the new float value for that element + * @return the previous float 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 @@ public class FloatArrayList extends AbstractList implements List, Serializable { return old; } + /** + * Returns new Float({@link #setFloat(int,float) + * set(index, ((Float)value).floatValue())}). + * + * @param index the index of the element to set + * @param value a {@link Float} instance that warps the new + * float value for that element + * @return a {@link Float} instance that wraps the previous + * float 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 null + */ public Object set(int index, Object value) { Float f = (Float)value; return new Float(setFloat(index, f.floatValue())); } + /** + * Adds the given float value to this list. + * + * @param value the float value to add + * @return true, always + */ public boolean addFloat(float value) { ensureCapacity(_size+1); _data[_size++] = value; return true; } + /** + * Inserts the given float value into this list at the + * given index. + * + * @param index the index of the insertion + * @param value the float 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 @@ public class FloatArrayList extends AbstractList implements List, Serializable { _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 + * float 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 null + */ public void add(int index, Object value) { addFloat(index,((Float)value).floatValue()); } + /** + * Removes all float values from this list. + */ public void clear() { modCount++; _size = 0; } + /** + * Removes the float at the given index. + * + * @param index the index of the float value to remove + * @return the removed float 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 @@ public class FloatArrayList extends AbstractList implements List, Serializable { return oldval; } + /** + * Removes the first occurrence of the given float value + * from this list. + * + * @param value the float 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 @@ public class FloatArrayList extends AbstractList implements List, Serializable { } } + /** + * Removes the float at the given index. + * + * @param index the index of the float value to remove + * @return a {@link Float} instance that wraps the removed + * float 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 @@ public class FloatArrayList extends AbstractList implements List, Serializable { } } + /** + * Trims this list such that {@link #capacity()} is equal to + * {@link #size()}. + */ public void trimToSize() { modCount++; if(_size < _data.length) { diff --git a/src/java/org/apache/commons/collections/primitives/IntArrayList.java b/src/java/org/apache/commons/collections/primitives/IntArrayList.java index a4ac61bbd..39f3caf16 100644 --- a/src/java/org/apache/commons/collections/primitives/IntArrayList.java +++ b/src/java/org/apache/commons/collections/primitives/IntArrayList.java @@ -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.1 2002/06/04 16:01:27 rwaldhoff Exp $ - * $Revision: 1.1 $ - * $Date: 2002/06/04 16:01:27 $ + * $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.2 2002/08/13 19:41:36 pjack Exp $ + * $Revision: 1.2 $ + * $Date: 2002/08/13 19:41:36 $ * * ==================================================================== * @@ -72,23 +72,40 @@ import java.util.List; import java.util.ListIterator; /** - * @version $Revision: 1.1 $ $Date: 2002/06/04 16:01:27 $ + * A list of int elements. + * + * @version $Revision: 1.2 $ $Date: 2002/08/13 19:41:36 $ * @author Rodney Waldhoff */ public class IntArrayList extends AbstractIntArrayList implements List, Serializable { - //------------------------------------------------------------ Constructors - + //------------------------------------------------------------ Constructors + + /** + * Constructs a new IntArrayList with a default capacity. + */ public IntArrayList() { this(8); } + /** + * Constructs a new IntArrayList 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 @@ public class IntArrayList extends AbstractIntArrayList implements List, Serializ } //--------------------------------------------------------------- Modifiers + + // Note: JavaDoc for these methods is inherited from the superclass. public int setInt(int index, int value) { checkRange(index); diff --git a/src/java/org/apache/commons/collections/primitives/LongArrayList.java b/src/java/org/apache/commons/collections/primitives/LongArrayList.java index bcc9d4009..0a88e36b3 100644 --- a/src/java/org/apache/commons/collections/primitives/LongArrayList.java +++ b/src/java/org/apache/commons/collections/primitives/LongArrayList.java @@ -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.1 2002/06/04 16:01:27 rwaldhoff Exp $ - * $Revision: 1.1 $ - * $Date: 2002/06/04 16:01:27 $ + * $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.2 2002/08/13 19:41:36 pjack Exp $ + * $Revision: 1.2 $ + * $Date: 2002/08/13 19:41:36 $ * * ==================================================================== * @@ -72,18 +72,35 @@ import java.util.List; import java.util.ListIterator; /** - * @version $Revision: 1.1 $ $Date: 2002/06/04 16:01:27 $ + * A list of long elements. + * + * @version $Revision: 1.2 $ $Date: 2002/08/13 19:41:36 $ * @author Rodney Waldhoff */ public class LongArrayList extends AbstractLongArrayList implements List, Serializable { //------------------------------------------------------------ Constructors + /** + * Constructs a new LongArrayList with a default initial + * capacity. + */ public LongArrayList() { this(8); } + /** + * Constructs a new LongArrayList 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]; } diff --git a/src/java/org/apache/commons/collections/primitives/ShortArrayList.java b/src/java/org/apache/commons/collections/primitives/ShortArrayList.java index b6fbb157c..b184103d2 100644 --- a/src/java/org/apache/commons/collections/primitives/ShortArrayList.java +++ b/src/java/org/apache/commons/collections/primitives/ShortArrayList.java @@ -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.1 2002/06/04 16:01:27 rwaldhoff Exp $ - * $Revision: 1.1 $ - * $Date: 2002/06/04 16:01:27 $ + * $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.2 2002/08/13 19:41:36 pjack Exp $ + * $Revision: 1.2 $ + * $Date: 2002/08/13 19:41:36 $ * * ==================================================================== * @@ -72,18 +72,35 @@ import java.util.List; import java.util.ListIterator; /** - * @version $Revision: 1.1 $ $Date: 2002/06/04 16:01:27 $ + * A list of short elements. + * + * @version $Revision: 1.2 $ $Date: 2002/08/13 19:41:36 $ * @author Rodney Waldhoff */ public class ShortArrayList extends AbstractShortArrayList implements List, Serializable { //------------------------------------------------------------ Constructors + /** + * Constructs a new ShortArrayList with a default initial + * capacity. + */ public ShortArrayList() { this(8); } + /** + * Constructs a new ShortArrayList 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]; } diff --git a/src/java/org/apache/commons/collections/primitives/UnsignedByteArrayList.java b/src/java/org/apache/commons/collections/primitives/UnsignedByteArrayList.java index 3f412c10f..f43ccb2b5 100644 --- a/src/java/org/apache/commons/collections/primitives/UnsignedByteArrayList.java +++ b/src/java/org/apache/commons/collections/primitives/UnsignedByteArrayList.java @@ -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.1 2002/06/04 16:01:27 rwaldhoff Exp $ - * $Revision: 1.1 $ - * $Date: 2002/06/04 16:01:27 $ + * $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.2 2002/08/13 19:41:36 pjack Exp $ + * $Revision: 1.2 $ + * $Date: 2002/08/13 19:41:36 $ * * ==================================================================== * @@ -72,18 +72,37 @@ import java.util.List; import java.util.ListIterator; /** - * @version $Revision: 1.1 $ $Date: 2002/06/04 16:01:27 $ + * A list of unsigned 8-bit values, stored in a short array. + * Mutators on this class will reject any short that does not + * express an unsigned 8-bit value. + * + * @version $Revision: 1.2 $ $Date: 2002/08/13 19:41:36 $ * @author Rodney Waldhoff */ public class UnsignedByteArrayList extends AbstractShortArrayList implements List, Serializable { //------------------------------------------------------------ Constructors + /** + * Constructs a new UnsignedByteArrayList with a + * default initial capacity. + */ public UnsignedByteArrayList() { this(8); } + /** + * Constructs a new UnsignedByteArrayList 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 @@ public class UnsignedByteArrayList extends AbstractShortArrayList implements Lis 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; } diff --git a/src/java/org/apache/commons/collections/primitives/UnsignedIntArrayList.java b/src/java/org/apache/commons/collections/primitives/UnsignedIntArrayList.java index 11b7c3c33..1ae53af5b 100644 --- a/src/java/org/apache/commons/collections/primitives/UnsignedIntArrayList.java +++ b/src/java/org/apache/commons/collections/primitives/UnsignedIntArrayList.java @@ -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.1 2002/06/04 16:01:27 rwaldhoff Exp $ - * $Revision: 1.1 $ - * $Date: 2002/06/04 16:01:27 $ + * $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.2 2002/08/13 19:41:36 pjack Exp $ + * $Revision: 1.2 $ + * $Date: 2002/08/13 19:41:36 $ * * ==================================================================== * @@ -72,18 +72,37 @@ import java.util.List; import java.util.ListIterator; /** - * @version $Revision: 1.1 $ $Date: 2002/06/04 16:01:27 $ + * A list of unsigned 32-bit values, stored in a long array. + * Mutators on this class will reject any long that does not + * express an unsigned 16-bit value. + * + * @version $Revision: 1.2 $ $Date: 2002/08/13 19:41:36 $ * @author Rodney Waldhoff */ public class UnsignedIntArrayList extends AbstractLongArrayList implements List, Serializable { //------------------------------------------------------------ Constructors + /** + * Constructs a new UnsignedIntArrayList with a + * default initial capacity. + */ public UnsignedIntArrayList() { this(8); } + /** + * Constructs a new UnsignedIntArrayList 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 @@ public class UnsignedIntArrayList extends AbstractLongArrayList implements List, 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; } diff --git a/src/java/org/apache/commons/collections/primitives/UnsignedShortArrayList.java b/src/java/org/apache/commons/collections/primitives/UnsignedShortArrayList.java index 24c412ce7..3332a85f9 100644 --- a/src/java/org/apache/commons/collections/primitives/UnsignedShortArrayList.java +++ b/src/java/org/apache/commons/collections/primitives/UnsignedShortArrayList.java @@ -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.1 2002/06/04 16:01:27 rwaldhoff Exp $ - * $Revision: 1.1 $ - * $Date: 2002/06/04 16:01:27 $ + * $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.2 2002/08/13 19:41:36 pjack Exp $ + * $Revision: 1.2 $ + * $Date: 2002/08/13 19:41:36 $ * * ==================================================================== * @@ -72,18 +72,38 @@ import java.util.List; import java.util.ListIterator; /** - * @version $Revision: 1.1 $ $Date: 2002/06/04 16:01:27 $ + * A list of unsigned 16-bit values, stored in an int array. + * Mutators on this class will reject any int that does not + * express an unsigned 16-bit value. + * + * @version $Revision: 1.2 $ $Date: 2002/08/13 19:41:36 $ * @author Rodney Waldhoff */ public class UnsignedShortArrayList extends AbstractIntArrayList implements List, Serializable { //------------------------------------------------------------ Constructors + /** + * Constructs a new UnsignedShortArrayList with a + * default initial capacity. + */ public UnsignedShortArrayList() { this(8); } + + /** + * Constructs a new UnsignedShortArrayList 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 @@ public class UnsignedShortArrayList extends AbstractIntArrayList implements List } //--------------------------------------------------------------- Modifiers - + public int setInt(int index, int value) { assertValidUnsignedShort(value); checkRange(index); @@ -252,6 +272,15 @@ public class UnsignedShortArrayList extends AbstractIntArrayList implements List 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; }