mirror of
https://github.com/apache/commons-collections.git
synced 2025-02-17 15:35:00 +00:00
Added better class-level documentation as suggested by Jonathan Carlson.
Also provided default implementations for many of the abstract methods in Abstract*List. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130807 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ebdaf3cb68
commit
f7e4fdd91d
@ -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.4 2002/08/21 23:54:18 pjack Exp $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2002/08/21 23:54:18 $
|
||||
* $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.5 2002/08/22 01:50:54 pjack Exp $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2002/08/22 01:50:54 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
@ -69,9 +69,15 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
/**
|
||||
* Abstract base class for lists backed by an <Code>int</Code> array.
|
||||
* Abstract base class for lists of primitive <Code>int</Code> elements
|
||||
* backed by an array.<P>
|
||||
*
|
||||
* @version $Revision: 1.4 $ $Date: 2002/08/21 23:54:18 $
|
||||
* Extending this class is essentially the same as extending its superclass
|
||||
* ({@link AbstractIntList}. However, this class assumes that the
|
||||
* primitive values will be stored in an underlying primitive array, and
|
||||
* provides methods for manipulating the capacity of that array.<P>
|
||||
*
|
||||
* @version $Revision: 1.5 $ $Date: 2002/08/22 01:50:54 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public abstract class AbstractIntArrayList extends AbstractIntList {
|
||||
|
@ -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/AbstractIntList.java,v 1.2 2002/08/21 23:54:18 pjack Exp $
|
||||
* $Revision: 1.2 $
|
||||
* $Date: 2002/08/21 23:54:18 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/AbstractIntList.java,v 1.3 2002/08/22 01:50:54 pjack Exp $
|
||||
* $Revision: 1.3 $
|
||||
* $Date: 2002/08/22 01:50:54 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
@ -69,9 +69,28 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
/**
|
||||
* Abstract base class for lists backed by an <Code>int</Code> array.
|
||||
* Abstract base class for lists of primitive <Code>int</Code> elements.<P>
|
||||
*
|
||||
* @version $Revision: 1.2 $ $Date: 2002/08/21 23:54:18 $
|
||||
* The {@link List} methods are all implemented, but they forward to
|
||||
* abstract methods that operate on <Code>int</Code> elements. For
|
||||
* instance, the {@link #get(int)} method simply forwards to
|
||||
* {@link #getInt(int)}. The primitive <Code>int</Code> that is
|
||||
* returned from {@link #getInt(int)} is wrapped in a {@link java.lang.Integer}
|
||||
* and returned from {@link #get(int)}.<p>
|
||||
*
|
||||
* Concrete implementations offer substantial memory savings by not storing
|
||||
* primitives as wrapped objects. If you excuslively use the primitive
|
||||
* signatures, there can also be substantial performance gains, since
|
||||
* temporary wrapper objects do not need to be created.<p>
|
||||
*
|
||||
* To implement a read-only list of <Code>int</Code> elements, you need
|
||||
* only implement the {@link #getInt(int)} and {@link #size()} methods.
|
||||
* To implement a modifiable list, you will also need to implement the
|
||||
* {@link #setInt(int,int)}, {@link #addInt(int,int)},
|
||||
* {@link #removeIntAt(int)} and {@link #clear()} methods. You may want
|
||||
* to override the other methods to increase performance.<P>
|
||||
*
|
||||
* @version $Revision: 1.3 $ $Date: 2002/08/22 01:50:54 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public abstract class AbstractIntList extends AbstractList {
|
||||
@ -98,40 +117,65 @@ public abstract class AbstractIntList extends AbstractList {
|
||||
*/
|
||||
abstract public int getInt(int index);
|
||||
|
||||
|
||||
//--------------------------------------------------------------- Accessors
|
||||
|
||||
/**
|
||||
* Returns <Code>true</Code> if this list contains the given
|
||||
* <Code>int</Code> element.
|
||||
* <Code>int</Code> element. The default implementation uses
|
||||
* {@link #indexOfInt(int)} to determine if the given value is
|
||||
* in this list.
|
||||
*
|
||||
* @param value the element to search for
|
||||
* @return true if this list contains the given value, false otherwise
|
||||
*/
|
||||
abstract public boolean containsInt(int value);
|
||||
|
||||
public boolean containsInt(int value) {
|
||||
return indexOfInt(value) >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first index of the given <Code>int</Code> element, or
|
||||
* -1 if the value is not in this list.
|
||||
* -1 if the value is not in this list. The default implementation is:
|
||||
*
|
||||
* <pre>
|
||||
* for (int i = 0; i < size(); i++) {
|
||||
* if (getInt(i) == value) return i;
|
||||
* }
|
||||
* return -1;
|
||||
* </pre>
|
||||
*
|
||||
* @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);
|
||||
|
||||
public int indexOfInt(int value) {
|
||||
for (int i = 0; i < size(); i++) {
|
||||
if (getInt(i) == value) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last index of the given <Code>int</Code> element, or
|
||||
* -1 if the value is not in this list.
|
||||
* -1 if the value is not in this list. The default implementation is:
|
||||
*
|
||||
* <pre>
|
||||
* for (int i = size() - 1; i >= 0; i--) {
|
||||
* if (getInt(i) == value) return i;
|
||||
* }
|
||||
* return -1;
|
||||
* </pre>
|
||||
*
|
||||
* @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);
|
||||
public int lastIndexOfInt(int value) {
|
||||
for (int i = size() - 1; i >= 0; i--) {
|
||||
if (getInt(i) == value) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------- Accessors
|
||||
|
||||
/**
|
||||
* Returns <code>new Integer({@link #getInt getInt(index)})</code>.
|
||||
*
|
||||
@ -212,15 +256,6 @@ public abstract class AbstractIntList extends AbstractList {
|
||||
*/
|
||||
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.
|
||||
@ -243,17 +278,6 @@ public abstract class AbstractIntList extends AbstractList {
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@ -261,6 +285,41 @@ public abstract class AbstractIntList extends AbstractList {
|
||||
|
||||
//--------------------------------------------------------------- Modifiers
|
||||
|
||||
/**
|
||||
* Adds the given <Code>int</Code> value to the end of this list.
|
||||
* The default implementation invokes {@link #addInt(int,int)
|
||||
* addInt(size(), value)}.
|
||||
*
|
||||
* @param value the value to add
|
||||
* @return true, always
|
||||
*/
|
||||
public boolean addInt(int value) {
|
||||
addInt(size(), value);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the first occurrence of the given <Code>int</Code> value
|
||||
* from this list. The default implementation is:
|
||||
*
|
||||
* <pre>
|
||||
* int i = indexOfInt(value);
|
||||
* if (i < 0) return false;
|
||||
* removeIntAt(i);
|
||||
* return true;
|
||||
* </pre>
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public boolean removeInt(int value) {
|
||||
int i = indexOfInt(value);
|
||||
if (i < 0) return false;
|
||||
removeIntAt(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>new Integer({@link #setInt(int,int)
|
||||
* setInt(index,((Integer)value).intValue())})</code>.
|
||||
|
@ -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.4 2002/08/21 23:54:18 pjack Exp $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2002/08/21 23:54:18 $
|
||||
* $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.5 2002/08/22 01:50:54 pjack Exp $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2002/08/22 01:50:54 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
@ -69,9 +69,15 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
/**
|
||||
* Abstract base class for lists backed by a <Code>long</Code> array.
|
||||
* Abstract base class for lists of primitive <Code>long</Code> elements
|
||||
* backed by an array.<P>
|
||||
*
|
||||
* @version $Revision: 1.4 $ $Date: 2002/08/21 23:54:18 $
|
||||
* Extending this class is essentially the same as extending its superclass
|
||||
* ({@link AbstractLongList}. However, this class assumes that the
|
||||
* primitive values will be stored in an underlying primitive array, and
|
||||
* provides methods for manipulating the capacity of that array.<P>
|
||||
*
|
||||
* @version $Revision: 1.5 $ $Date: 2002/08/22 01:50:54 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public abstract class AbstractLongArrayList extends AbstractLongList {
|
||||
|
@ -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/AbstractLongList.java,v 1.2 2002/08/21 23:54:18 pjack Exp $
|
||||
* $Revision: 1.2 $
|
||||
* $Date: 2002/08/21 23:54:18 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/AbstractLongList.java,v 1.3 2002/08/22 01:50:54 pjack Exp $
|
||||
* $Revision: 1.3 $
|
||||
* $Date: 2002/08/22 01:50:54 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
@ -69,9 +69,28 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
/**
|
||||
* Abstract base class for lists backed by a <Code>long</Code> array.
|
||||
* Abstract base class for lists of primitive <Code>long</Code> elements.<P>
|
||||
*
|
||||
* @version $Revision: 1.2 $ $Date: 2002/08/21 23:54:18 $
|
||||
* The {@link List} methods are all implemented, but they forward to
|
||||
* abstract methods that operate on <Code>long</Code> elements. For
|
||||
* instance, the {@link #get(int)} method simply forwards to
|
||||
* {@link #getLong(int)}. The primitive <Code>long</Code> that is
|
||||
* returned from {@link #getLong(int)} is wrapped in a {@link java.lang.Long}
|
||||
* and returned from {@link #get(int)}.<p>
|
||||
*
|
||||
* Concrete implementations offer substantial memory savings by not storing
|
||||
* primitives as wrapped objects. If you excuslively use the primitive
|
||||
* signatures, there can also be substantial performance gains, since
|
||||
* temporary wrapper objects do not need to be created.<p>
|
||||
*
|
||||
* To implement a read-only list of <Code>long</Code> elements, you need
|
||||
* only implement the {@link #getLong(int)} and {@link #size()} methods.
|
||||
* To implement a modifiable list, you will also need to implement the
|
||||
* {@link #setLong(int,long)}, {@link #addLong(int,long)},
|
||||
* {@link #removeLongAt(int)} and {@link #clear()} methods. You may want
|
||||
* to override the other methods to increase performance.<P>
|
||||
*
|
||||
* @version $Revision: 1.3 $ $Date: 2002/08/22 01:50:54 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public abstract class AbstractLongList extends AbstractList {
|
||||
@ -97,37 +116,65 @@ public abstract class AbstractLongList extends AbstractList {
|
||||
*/
|
||||
abstract public long getLong(int index);
|
||||
|
||||
//--------------------------------------------------------------- Accessors
|
||||
|
||||
/**
|
||||
* Returns <Code>true</Code> if this list contains the given
|
||||
* <Code>long</Code> element.
|
||||
* <Code>long</Code> element. The default implementation uses
|
||||
* {@link #indexOfLong(long)} to determine if the given value is
|
||||
* in this list.
|
||||
*
|
||||
* @param value the element to search for
|
||||
* @return true if this list contains the given value, false otherwise
|
||||
*/
|
||||
abstract public boolean containsLong(long value);
|
||||
public boolean containsLong(long value) {
|
||||
return indexOfLong(value) >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first index of the given <Code>long</Code> element, or
|
||||
* -1 if the value is not in this list.
|
||||
* -1 if the value is not in this list. The default implementation is:
|
||||
*
|
||||
* <pre>
|
||||
* for (int i = 0; i < size(); i++) {
|
||||
* if (getLong(i) == value) return i;
|
||||
* }
|
||||
* return -1;
|
||||
* </pre>
|
||||
*
|
||||
* @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);
|
||||
public int indexOfLong(long value) {
|
||||
for (int i = 0; i < size(); i++) {
|
||||
if (getLong(i) == value) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last index of the given <Code>long</Code> element, or
|
||||
* -1 if the value is not in this list.
|
||||
* -1 if the value is not in this list. The default implementation is:
|
||||
*
|
||||
* <pre>
|
||||
* for (int i = size() - 1; i >= 0; i--) {
|
||||
* if (getLong(i) == value) return i;
|
||||
* }
|
||||
* return -1;
|
||||
* </pre>
|
||||
*
|
||||
* @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);
|
||||
public int lastIndexOfLong(long value) {
|
||||
for (int i = size() - 1; i >= 0; i--) {
|
||||
if (getLong(i) == value) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------- Accessors
|
||||
|
||||
/**
|
||||
* Returns <code>new Long({@link #getLong getLong(index)})</code>.
|
||||
*
|
||||
@ -208,14 +255,6 @@ public abstract class AbstractLongList extends AbstractList {
|
||||
*/
|
||||
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.
|
||||
@ -237,16 +276,6 @@ public abstract class AbstractLongList extends AbstractList {
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@ -254,6 +283,41 @@ public abstract class AbstractLongList extends AbstractList {
|
||||
|
||||
//--------------------------------------------------------------- Modifiers
|
||||
|
||||
/**
|
||||
* Adds the given <Code>long</Code> value to the end of this list.
|
||||
* The default implementation invokes {@link #addLong(int,long)
|
||||
* addLong(size(), value)}.
|
||||
*
|
||||
* @param value the value to add
|
||||
* @return true, always
|
||||
*/
|
||||
public boolean addLong(long value) {
|
||||
addLong(size(), value);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the first occurrence of the given <Code>long</Code> value
|
||||
* from this list. The default implementation is:
|
||||
*
|
||||
* <pre>
|
||||
* int i = indexOfLong(value);
|
||||
* if (i < 0) return false;
|
||||
* removeLongAt(i);
|
||||
* return true;
|
||||
* </pre>
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public boolean removeLong(long value) {
|
||||
int i = indexOfLong(value);
|
||||
if (i < 0) return false;
|
||||
removeLongAt(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>new Long({@link #setLong(int,long)
|
||||
* setLong(index,((Long).longValue())})</code>.
|
||||
|
@ -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.4 2002/08/21 23:54:18 pjack Exp $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2002/08/21 23:54:18 $
|
||||
* $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.5 2002/08/22 01:50:54 pjack Exp $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2002/08/22 01:50:54 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
@ -69,9 +69,15 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
/**
|
||||
* Abstract base class for lists backed by a <Code>short</Code> array.
|
||||
* Abstract base class for lists of primitive <Code>short</Code> elements
|
||||
* backed by an array.<P>
|
||||
*
|
||||
* @version $Revision: 1.4 $ $Date: 2002/08/21 23:54:18 $
|
||||
* Extending this class is essentially the same as extending its superclass
|
||||
* ({@link AbstractShortList}. However, this class assumes that the
|
||||
* primitive values will be stored in an underlying primitive array, and
|
||||
* provides methods for manipulating the capacity of that array.<P>
|
||||
*
|
||||
* @version $Revision: 1.5 $ $Date: 2002/08/22 01:50:54 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public abstract class AbstractShortArrayList extends AbstractShortList {
|
||||
|
@ -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/AbstractShortList.java,v 1.2 2002/08/21 23:54:18 pjack Exp $
|
||||
* $Revision: 1.2 $
|
||||
* $Date: 2002/08/21 23:54:18 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/AbstractShortList.java,v 1.3 2002/08/22 01:50:54 pjack Exp $
|
||||
* $Revision: 1.3 $
|
||||
* $Date: 2002/08/22 01:50:54 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
@ -69,9 +69,28 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
/**
|
||||
* Abstract base class for lists backed by a <Code>short</Code> array.
|
||||
* Abstract base class for lists of primitive <Code>short</Code> elements.<P>
|
||||
*
|
||||
* @version $Revision: 1.2 $ $Date: 2002/08/21 23:54:18 $
|
||||
* The {@link List} methods are all implemented, but they forward to
|
||||
* abstract methods that operate on <Code>short</Code> elements. For
|
||||
* instance, the {@link #get(int)} method simply forwards to
|
||||
* {@link #getShort(int)}. The primitive <Code>short</Code> that is
|
||||
* returned from {@link #getShort(int)} is wrapped in a {@link java.lang.Short}
|
||||
* and returned from {@link #get(int)}.<p>
|
||||
*
|
||||
* Concrete implementations offer substantial memory savings by not storing
|
||||
* primitives as wrapped objects. If you excuslively use the primitive
|
||||
* signatures, there can also be substantial performance gains, since
|
||||
* temporary wrapper objects do not need to be created.<p>
|
||||
*
|
||||
* To implement a read-only list of <Code>short</Code> elements, you need
|
||||
* only implement the {@link #getShort(int)} and {@link #size()} methods.
|
||||
* To implement a modifiable list, you will also need to implement the
|
||||
* {@link #setShort(int,short)}, {@link #addShort(int,short)},
|
||||
* {@link #removeShortAt(int)} and {@link #clear()} methods. You may want
|
||||
* to override the other methods to increase performance.<P>
|
||||
*
|
||||
* @version $Revision: 1.3 $ $Date: 2002/08/22 01:50:54 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public abstract class AbstractShortList extends AbstractList {
|
||||
@ -97,37 +116,65 @@ public abstract class AbstractShortList extends AbstractList {
|
||||
*/
|
||||
abstract public short getShort(int index);
|
||||
|
||||
//--------------------------------------------------------------- Accessors
|
||||
|
||||
/**
|
||||
* Returns <Code>true</Code> if this list contains the given
|
||||
* <Code>short</Code> element.
|
||||
* <Code>short</Code> element. The default implementation uses
|
||||
* {@link #indexOfShort(short)} to determine if the given value is
|
||||
* in this list.
|
||||
*
|
||||
* @param value the element to search for
|
||||
* @return true if this list contains the given value, false otherwise
|
||||
*/
|
||||
abstract public boolean containsShort(short value);
|
||||
public boolean containsShort(short value) {
|
||||
return indexOfShort(value) >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first index of the given <Code>short</Code> element, or
|
||||
* -1 if the value is not in this list.
|
||||
* -1 if the value is not in this list. The default implementation is:
|
||||
*
|
||||
* <pre>
|
||||
* for (int i = 0; i < size(); i++) {
|
||||
* if (getShort(i) == value) return i;
|
||||
* }
|
||||
* return -1;
|
||||
* </pre>
|
||||
*
|
||||
* @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);
|
||||
public int indexOfShort(short value) {
|
||||
for (int i = 0; i < size(); i++) {
|
||||
if (getShort(i) == value) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last index of the given <Code>short</Code> element, or
|
||||
* -1 if the value is not in this list.
|
||||
* -1 if the value is not in this list. The default implementation is:
|
||||
*
|
||||
* <pre>
|
||||
* for (int i = size() - 1; i >= 0; i--) {
|
||||
* if (getShort(i) == value) return i;
|
||||
* }
|
||||
* return -1;
|
||||
* </pre>
|
||||
*
|
||||
* @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);
|
||||
public int lastIndexOfShort(short value) {
|
||||
for (int i = size() - 1; i >= 0; i--) {
|
||||
if (getShort(i) == value) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------- Accessors
|
||||
|
||||
/**
|
||||
* Returns <code>new Short({@link #getShort getShort(index)})</code>.
|
||||
*
|
||||
@ -208,14 +255,6 @@ public abstract class AbstractShortList extends AbstractList {
|
||||
*/
|
||||
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.
|
||||
@ -237,16 +276,6 @@ public abstract class AbstractShortList extends AbstractList {
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@ -254,6 +283,41 @@ public abstract class AbstractShortList extends AbstractList {
|
||||
|
||||
//--------------------------------------------------------------- Modifiers
|
||||
|
||||
/**
|
||||
* Adds the given <Code>short</Code> value to the end of this list.
|
||||
* The default implementation invokes {@link #addShort(int,short)
|
||||
* addShort(size(), value)}.
|
||||
*
|
||||
* @param value the value to add
|
||||
* @return true, always
|
||||
*/
|
||||
public boolean addShort(short value) {
|
||||
addShort(size(), value);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the first occurrence of the given <Code>short</Code> value
|
||||
* from this list. The default implementation is:
|
||||
*
|
||||
* <pre>
|
||||
* int i = indexOfShort(value);
|
||||
* if (i < 0) return false;
|
||||
* removeShortAt(i);
|
||||
* return true;
|
||||
* </pre>
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public boolean removeShort(short value) {
|
||||
int i = indexOfShort(value);
|
||||
if (i < 0) return false;
|
||||
removeShortAt(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>new Short({@link #setShort(int,short)
|
||||
* setShort(index,((Short)value.shortValue())})</code>.
|
||||
|
@ -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.4 2002/08/21 23:54:18 pjack Exp $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2002/08/21 23:54:18 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/IntArrayList.java,v 1.5 2002/08/22 01:50:54 pjack Exp $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2002/08/22 01:50:54 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
@ -72,9 +72,13 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
/**
|
||||
* A list of <Code>int</Code> elements.
|
||||
* A list of <Code>int</Code> elements backed by an <Code>int</Code> array.
|
||||
* This class implements the {@link List} interface for an array of
|
||||
* <Code>int</Code> values. This class uses less memory than an
|
||||
* {@link java.util.ArrayList} of {@link Integer} values and allows for
|
||||
* better compile-time type checking.<P>
|
||||
*
|
||||
* @version $Revision: 1.4 $ $Date: 2002/08/21 23:54:18 $
|
||||
* @version $Revision: 1.5 $ $Date: 2002/08/22 01:50:54 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class IntArrayList extends AbstractIntArrayList implements Serializable {
|
||||
|
@ -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.4 2002/08/21 23:54:18 pjack Exp $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2002/08/21 23:54:18 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/LongArrayList.java,v 1.5 2002/08/22 01:50:54 pjack Exp $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2002/08/22 01:50:54 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
@ -72,9 +72,13 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
/**
|
||||
* A list of <Code>long</COde> elements.
|
||||
* A list of <Code>long</Code> elements backed by a <Code>long</Code> array.
|
||||
* This class implements the {@link List} interface for an array of
|
||||
* <Code>long</Code> values. This class uses less memory than an
|
||||
* {@link java.util.ArrayList} of {@link Long} values and allows for
|
||||
* better compile-time type checking.<P>
|
||||
*
|
||||
* @version $Revision: 1.4 $ $Date: 2002/08/21 23:54:18 $
|
||||
* @version $Revision: 1.5 $ $Date: 2002/08/22 01:50:54 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class LongArrayList extends AbstractLongArrayList implements Serializable {
|
||||
|
@ -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.4 2002/08/21 23:54:18 pjack Exp $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2002/08/21 23:54:18 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/ShortArrayList.java,v 1.5 2002/08/22 01:50:54 pjack Exp $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2002/08/22 01:50:54 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
@ -72,9 +72,13 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
/**
|
||||
* A list of <Code>short</Code> elements.
|
||||
*
|
||||
* @version $Revision: 1.4 $ $Date: 2002/08/21 23:54:18 $
|
||||
* A list of <Code>short</Code> elements backed by an <Code>short</Code> array.
|
||||
* This class implements the {@link List} interface for an array of
|
||||
* <Code>short</Code> values. This class uses less memory than an
|
||||
* {@link java.util.ArrayList} of {@link Short} values and allows for
|
||||
* better compile-time type checking.<P>
|
||||
*
|
||||
* @version $Revision: 1.5 $ $Date: 2002/08/22 01:50:54 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class ShortArrayList extends AbstractShortArrayList implements Serializable {
|
||||
|
@ -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.4 2002/08/21 23:54:18 pjack Exp $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2002/08/21 23:54:18 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/UnsignedByteArrayList.java,v 1.5 2002/08/22 01:50:54 pjack Exp $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2002/08/22 01:50:54 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
@ -72,11 +72,15 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
/**
|
||||
* A list of unsigned 8-bit values, stored in a <Code>short</Code> array.
|
||||
* A list of unsigned 8-bit values backed by a <Code>byte</Code> array.
|
||||
* The unsigned 8-bit values are converted to and from a signed 8-bit
|
||||
* <code>byte</code> that's stored in the stored in the array.
|
||||
* Mutators on this class will reject any <Code>short</Code> that does not
|
||||
* express an unsigned 8-bit value.
|
||||
* express an unsigned 8-bit value. This implementation uses less memory
|
||||
* than a {@link java.util.ArrayList} and offers better compile-time type
|
||||
* checking.
|
||||
*
|
||||
* @version $Revision: 1.4 $ $Date: 2002/08/21 23:54:18 $
|
||||
* @version $Revision: 1.5 $ $Date: 2002/08/22 01:50:54 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class UnsignedByteArrayList extends AbstractShortArrayList implements Serializable {
|
||||
|
@ -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.4 2002/08/21 23:54:18 pjack Exp $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2002/08/21 23:54:18 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/UnsignedIntArrayList.java,v 1.5 2002/08/22 01:50:54 pjack Exp $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2002/08/22 01:50:54 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
@ -72,11 +72,15 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
/**
|
||||
* A list of unsigned 32-bit values, stored in a <Code>long</Code> array.
|
||||
* A list of unsigned 32-bit values backed by an <Code>int</Code> array.
|
||||
* The unsigned 32-bit values are converted to and from a signed 32-bit
|
||||
* <code>int</code> that's stored in the stored in the array.
|
||||
* Mutators on this class will reject any <Code>long</Code> that does not
|
||||
* express an unsigned 16-bit value.
|
||||
* express an unsigned 32-bit value. This implementation uses less memory
|
||||
* than a {@link java.util.ArrayList} and offers better compile-time type
|
||||
* checking.
|
||||
*
|
||||
* @version $Revision: 1.4 $ $Date: 2002/08/21 23:54:18 $
|
||||
* @version $Revision: 1.5 $ $Date: 2002/08/22 01:50:54 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class UnsignedIntArrayList extends AbstractLongArrayList implements Serializable {
|
||||
|
@ -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.4 2002/08/21 23:54:18 pjack Exp $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2002/08/21 23:54:18 $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/primitives/Attic/UnsignedShortArrayList.java,v 1.5 2002/08/22 01:50:54 pjack Exp $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2002/08/22 01:50:54 $
|
||||
*
|
||||
* ====================================================================
|
||||
*
|
||||
@ -72,11 +72,15 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
/**
|
||||
* A list of unsigned 16-bit values, stored in an <Code>int</Code> array.
|
||||
* A list of unsigned 16-bit values backed by a <Code>short</Code> array.
|
||||
* The unsigned 8-bit values are converted to and from a signed 16-bit
|
||||
* <code>short</code> that's stored in the stored in the array.
|
||||
* Mutators on this class will reject any <Code>int</Code> that does not
|
||||
* express an unsigned 16-bit value.
|
||||
* express an unsigned 16-bit value. This implementation uses less memory
|
||||
* than a {@link java.util.ArrayList} and offers better compile-time type
|
||||
* checking.
|
||||
*
|
||||
* @version $Revision: 1.4 $ $Date: 2002/08/21 23:54:18 $
|
||||
* @version $Revision: 1.5 $ $Date: 2002/08/22 01:50:54 $
|
||||
* @author Rodney Waldhoff
|
||||
*/
|
||||
public class UnsignedShortArrayList extends AbstractIntArrayList implements Serializable {
|
||||
|
Loading…
x
Reference in New Issue
Block a user