| java.util.AbstractList org.cougaar.util.ArrayListFoundation
All known Subclasses: org.cougaar.util.TimeSpanSet,
ArrayListFoundation | public class ArrayListFoundation extends AbstractList implements List,Cloneable,java.io.Serializable(Code) | | A copy of java.util.ArrayList, modified so that previously
private data members are here declared protected and which does not
use iterators to walk itself p>
This allows extending classes to have efficient access to the
actual data storage elements so that the supported API extensions
have first-class access.
See Also: java.util.ArrayList |
Field Summary | |
protected transient Object | elementData The array buffer into which the elements of the ArrayListFoundation are stored. | protected transient int | size The size of the ArrayListFoundation (the number of elements it contains). |
Constructor Summary | |
public | ArrayListFoundation(int initialCapacity) Constructs an empty list with the specified initial capacity. | public | ArrayListFoundation() Constructs an empty list. | public | ArrayListFoundation(Collection c) Constructs a list containing the elements of the specified
collection, in the order they are returned by the collection's
iterator. |
Method Summary | |
public boolean | add(Object o) Appends the specified element to the end of this list.
Parameters: o - element to be appended to this list. | public void | add(int index, Object element) Inserts the specified element at the specified position in this
list. | public boolean | addAll(Collection c) Appends all of the elements in the specified Collection to the end of
this list, in the order that they are returned by the
specified Collection's Iterator. | public boolean | addAll(int index, Collection c) Inserts all of the elements in the specified Collection into this
list, starting at the specified position. | public void | clear() Removes all of the elements from this list. | public Object | clone() Returns a shallow copy of this ArrayListFoundation instance. | public boolean | contains(Object elem) Returns true if this list contains the specified element. | public synchronized void | ensureCapacity(int minCapacity) Increases the capacity of this ArrayListFoundation instance, if
necessary, to ensure that it can hold at least the number of elements
specified by the minimum capacity argument. | public boolean | equals(Object o) Compares the specified object with this list for equality. | public Object | get(int index) Returns the element at the specified position in this list.
Parameters: index - index of element to return. | public int | hashCode() Returns the hash code value for this list. | public int | indexOf(Object elem) Searches for the first occurence of the given argument, testing
for equality using the equals method. | public boolean | isEmpty() Tests if this list has no elements. | public int | lastIndexOf(Object elem) Returns the index of the last occurrence of the specified object in
this list.
Parameters: elem - the desired element. | public boolean | remove(Object o) Removes a single instance of the specified element from this
collection, if it is present (optional operation). | public Object | remove(int index) Removes the element at the specified position in this list.
Shifts any subsequent elements to the left (subtracts one from their
indices).
Parameters: index - the index of the element to removed. | public boolean | removeAll(Collection c) Removes from this collection all of its elements that are contained in
the specified collection (optional operation).
This implementation walks the elements of this collection, checking each
element in turn to see if it's contained in the specified collection. | protected void | removeRange(int fromIndex, int toIndex) Removes from this List all of the elements whose index is between
fromIndex, inclusive and toIndex, exclusive. | public boolean | retainAll(Collection c) Retains only the elements in this collection that are contained in the
specified collection (optional operation). | public Object | set(int index, Object element) Replaces the element at the specified position in this list with
the specified element.
Parameters: index - index of element to replace. Parameters: element - element to be stored at the specified position. | public int | size() Returns the number of elements in this list. | public Object[] | toArray() Returns an array containing all of the elements in this list
in the correct order. | public Object[] | toArray(Object a) Returns an array containing all of the elements in this list in the
correct order. | public String | toString() Returns a string representation of this collection. | public void | trimToSize() Trims the capacity of this ArrayListFoundation instance to be the
list's current size. |
elementData | protected transient Object elementData(Code) | | The array buffer into which the elements of the ArrayListFoundation are stored.
The capacity of the ArrayListFoundation is the length of this array buffer.
|
size | protected transient int size(Code) | | The size of the ArrayListFoundation (the number of elements it contains).
|
ArrayListFoundation | public ArrayListFoundation(int initialCapacity)(Code) | | Constructs an empty list with the specified initial capacity.
Parameters: initialCapacity - the initial capacity of the list. |
ArrayListFoundation | public ArrayListFoundation()(Code) | | Constructs an empty list.
|
ArrayListFoundation | public ArrayListFoundation(Collection c)(Code) | | Constructs a list containing the elements of the specified
collection, in the order they are returned by the collection's
iterator. The ArrayListFoundation instance has an initial capacity of
110% the size of the specified collection.
|
add | public boolean add(Object o)(Code) | | Appends the specified element to the end of this list.
Parameters: o - element to be appended to this list. true (as per the general contract of Collection.add). |
add | public void add(int index, Object element)(Code) | | Inserts the specified element at the specified position in this
list. Shifts the element currently at that position (if any) and
any subsequent elements to the right (adds one to their indices).
Parameters: index - index at which the specified element is to be inserted. Parameters: element - element to be inserted. throws: IndexOutOfBoundsException - if index is out of range(index < 0 || index > size()). |
addAll | public boolean addAll(Collection c)(Code) | | Appends all of the elements in the specified Collection to the end of
this list, in the order that they are returned by the
specified Collection's Iterator. The behavior of this operation is
undefined if the specified Collection is modified while the operation
is in progress. (This implies that the behavior of this call is
undefined if the specified Collection is this list, and this
list is nonempty.)
Parameters: c - elements to be inserted into this list. throws: IndexOutOfBoundsException - if index out of range (index< 0 || index > size()). |
addAll | public boolean addAll(int index, Collection c)(Code) | | Inserts all of the elements in the specified Collection into this
list, starting at the specified position. Shifts the element
currently at that position (if any) and any subsequent elements to
the right (increases their indices). The new elements will appear
in the list in the order that they are returned by the
specified Collection's iterator.
Parameters: index - index at which to insert first elementfrom the specified collection. Parameters: c - elements to be inserted into this list. throws: IndexOutOfBoundsException - if index out of range (index< 0 || index > size()). |
clear | public void clear()(Code) | | Removes all of the elements from this list. The list will
be empty after this call returns.
|
clone | public Object clone()(Code) | | Returns a shallow copy of this ArrayListFoundation instance. (The
elements themselves are not copied.)
a clone of this ArrayListFoundation instance. |
contains | public boolean contains(Object elem)(Code) | | Returns true if this list contains the specified element.
Parameters: elem - element whose presence in this List is to be tested. |
ensureCapacity | public synchronized void ensureCapacity(int minCapacity)(Code) | | Increases the capacity of this ArrayListFoundation instance, if
necessary, to ensure that it can hold at least the number of elements
specified by the minimum capacity argument.
Parameters: minCapacity - the desired minimum capacity. |
equals | public boolean equals(Object o)(Code) | | Compares the specified object with this list for equality. Returns
true if and only if the specified object is also a list, both
lists have the same size, and all corresponding pairs of elements in
the two lists are equal. (Two elements e1 and
e2 are equal if (e1==null ? e2==null :
e1.equals(e2)).) In other words, two lists are defined to be
equal if they contain the same elements in the same order.
This implementation first checks if the specified object is this
list. If so, it returns true; if not, it checks if the
specified object is a list. If not, it returns false; if so,
it iterates over both lists, comparing corresponding pairs of elements.
If any comparison returns false, this method returns
false. If either iterator runs out of elements before the
other it returns false (as the lists are of unequal length);
otherwise it returns true when the iterations complete.
Parameters: o - the object to be compared for equality with this list. true if the specified object is equal to this list. |
get | public Object get(int index)(Code) | | Returns the element at the specified position in this list.
Parameters: index - index of element to return. the element at the specified position in this list. throws: IndexOutOfBoundsException - if index is out of range (index< 0 || index >= size()). |
hashCode | public int hashCode()(Code) | | Returns the hash code value for this list.
This implementation uses exactly the code that is used to define the
list hash function in the documentation for the List.hashCode
method.
the hash code value for this list. |
indexOf | public int indexOf(Object elem)(Code) | | Searches for the first occurence of the given argument, testing
for equality using the equals method.
Parameters: elem - an object. the index of the first occurrence of the argument in thislist; returns -1 if the object is not found. See Also: Object.equals(Object) |
isEmpty | public boolean isEmpty()(Code) | | Tests if this list has no elements.
true if this list has no elements;false otherwise. |
lastIndexOf | public int lastIndexOf(Object elem)(Code) | | Returns the index of the last occurrence of the specified object in
this list.
Parameters: elem - the desired element. the index of the last occurrence of the specified object inthis list; returns -1 if the object is not found. |
remove | public boolean remove(Object o)(Code) | | Removes a single instance of the specified element from this
collection, if it is present (optional operation). More formally,
removes an element e such that (o==null ? e==null :
o.equals(e)), if the collection contains one or more such
elements. Returns true if the collection contained the
specified element (or equivalently, if the collection changed as a
result of the call).
This implementation walks the elements of the collection looking for the
specified element. If it finds the element, it removes the element
from the collection.
Parameters: o - element to be removed from this collection, if present. true if the collection contained the specifiedelement. |
remove | public Object remove(int index)(Code) | | Removes the element at the specified position in this list.
Shifts any subsequent elements to the left (subtracts one from their
indices).
Parameters: index - the index of the element to removed. the element that was removed from the list. throws: IndexOutOfBoundsException - if index out of range (index< 0 || index >= size()). |
removeAll | public boolean removeAll(Collection c)(Code) | | Removes from this collection all of its elements that are contained in
the specified collection (optional operation).
This implementation walks the elements of this collection, checking each
element in turn to see if it's contained in the specified collection. If
it's so contained, it's removed from this collection.
Parameters: c - elements to be removed from this collection. true if this collection changed as a result of thecall. See Also: ArrayListFoundation.remove(Object) See Also: ArrayListFoundation.contains(Object) |
removeRange | protected void removeRange(int fromIndex, int toIndex)(Code) | | Removes from this List all of the elements whose index is between
fromIndex, inclusive and toIndex, exclusive. Shifts any succeeding
elements to the left (reduces their index).
This call shortens the list by (toIndex - fromIndex) elements.
(If toIndex==fromIndex, this operation has no effect.)
Parameters: fromIndex - index of first element to be removed. Parameters: toIndex - index after last element to be removed. |
retainAll | public boolean retainAll(Collection c)(Code) | | Retains only the elements in this collection that are contained in the
specified collection (optional operation). In other words, removes
from this collection all of its elements that are not contained in the
specified collection.
This implementation walks the elements of this collection, checking each
element returned in turn to see if it's contained in the specified
collection. If it's not so contained, it's removed from this collection.
true if this collection changed as a result of thecall. See Also: ArrayListFoundation.remove(Object) See Also: ArrayListFoundation.contains(Object) |
set | public Object set(int index, Object element)(Code) | | Replaces the element at the specified position in this list with
the specified element.
Parameters: index - index of element to replace. Parameters: element - element to be stored at the specified position. the element previously at the specified position. throws: IndexOutOfBoundsException - if index out of range(index < 0 || index >= size()). |
size | public int size()(Code) | | Returns the number of elements in this list.
the number of elements in this list. |
toArray | public Object[] toArray()(Code) | | Returns an array containing all of the elements in this list
in the correct order.
an array containing all of the elements in this listin the correct order. |
toArray | public Object[] toArray(Object a)(Code) | | Returns an array containing all of the elements in this list in the
correct order. The runtime type of the returned array is that of the
specified array. If the list fits in the specified array, it is
returned therein. Otherwise, a new array is allocated with the runtime
type of the specified array and the size of this list.
If the list fits in the specified array with room to spare (i.e., the
array has more elements than the list), the element in the array
immediately following the end of the collection is set to
null. This is useful in determining the length of the list
only if the caller knows that the list does not contain any
null elements.
Parameters: a - the array into which the elements of the list are tobe stored, if it is big enough; otherwise, a new array of thesame runtime type is allocated for this purpose. an array containing the elements of the list. throws: ArrayStoreException - if the runtime type of a is not a supertypeof the runtime type of every element in this list. |
toString | public String toString()(Code) | | Returns a string representation of this collection. The string
representation consists of a list of the collection's elements,
enclosed in square brackets ("[]"). Adjacent elements are
separated by the characters ", " (comma and space). Elements
are converted to strings as by String.valueOf(Object).
This implementation creates an empty string buffer, appends a left
square bracket, and walks the elements of the collection appending the string
representation of each element in turn. After appending each element
except the last, the string ", " is appended. Finally a right
bracket is appended. A string is obtained from the string buffer, and
returned.
a string representation of this collection. |
trimToSize | public void trimToSize()(Code) | | Trims the capacity of this ArrayListFoundation instance to be the
list's current size. An application can use this operation to minimize
the storage of an ArrayListFoundation instance.
|
Fields inherited from java.util.AbstractList | protected transient int modCount(Code)(Java Doc)
|
|
|