|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.triactive.jdo.util.IntArrayList
A variation on the standard ArrayList class that efficiently handles arrays of integers. Using this class rather than ArrayList avoids the need to "box" each element in an instance of java.lang.Integer. It is useful where performance is important.
Constructor Summary | |
IntArrayList()
Constructs an empty list with an initial capacity of ten. |
|
IntArrayList(int initialCapacity)
Constructs an empty list with the specified initial capacity. |
|
IntArrayList(int[] initialContents)
Constructs a list containing the elements of the specified array. |
Method Summary | |
void |
add(int element)
Appends the specified element to the end of this list. |
void |
add(int index,
int element)
Inserts the specified element at the specified position in this list. |
void |
addAll(int[] ai)
Appends all of the elements in the specified array to the end of this list. |
void |
addAll(int index,
int[] ai)
Inserts all of the elements in the specified array into this list, starting at the specified position. |
void |
clear()
Removes all of the elements from this list. |
java.lang.Object |
clone()
Returns a copy of this IntArrayList instance. |
boolean |
contains(int elem)
Returns true if this list contains the specified element. |
boolean |
containsAll(int[] ai)
Returns true if this list contains all of the elements in the specified list. |
void |
ensureCapacity(int minCapacity)
Increases the capacity of this IntArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument. |
boolean |
equals(java.lang.Object o)
Compares the specified object with this list for equality. |
int |
get(int index)
Returns the element at the specified position in this list. |
int |
hashCode()
Returns the hash code value for this list. |
int |
indexOf(int elem)
Searches for the first occurence of the given argument. |
boolean |
isEmpty()
Tests if this list has no elements. |
int |
lastIndexOf(int elem)
Returns the index of the last occurrence of the specified integer in this list. |
int |
remove(int index)
Removes the element at the specified position in this list. |
boolean |
removeAll(int[] ai)
Removes from this list all of its elements that are contained in the specified array. |
boolean |
retainAll(int[] ai)
Retains only the elements in this list that are contained in the specified array. |
int |
set(int index,
int element)
Replaces the element at the specified position in this list with the specified element. |
int |
size()
Returns the number of elements in this list. |
int[] |
toArray()
Returns an array containing all of the elements in this list. |
java.lang.String |
toString()
Returns a string representation of this list. |
void |
trimToSize()
Trims the capacity of this IntArrayList instance to be the list's current size. |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public IntArrayList()
public IntArrayList(int initialCapacity)
initialCapacity
- The initial capacity of the list.
java.lang.IllegalArgumentException
- If the specified initial capacity is negative.public IntArrayList(int[] initialContents)
initialContents
- The array whose elements are to be placed into this list.Method Detail |
public void trimToSize()
public void ensureCapacity(int minCapacity)
minCapacity
- The desired minimum capacity.public int size()
public boolean isEmpty()
public boolean contains(int elem)
elem
- element whose presence in this List is to be tested.
true
if the specified element is present;
false
otherwise.public int indexOf(int elem)
elem
- An integer to search for.
public int lastIndexOf(int elem)
elem
- The desired element.
public java.lang.Object clone()
public int[] toArray()
public int get(int index)
index
- Index of element to return.
java.lang.IndexOutOfBoundsException
- If index is out of range (index < 0 || index >= size()).public int set(int index, int element)
index
- Index of element to replace.element
- Element to be stored at the specified position.
java.lang.IndexOutOfBoundsException
- If index is out of range (index < 0 || index >= size()).public void add(int element)
element
- Element to be appended to this list.public void add(int index, int element)
index
- Index at which the specified element is to be inserted.element
- Element to be inserted.
java.lang.IndexOutOfBoundsException
- If index is out of range (index < 0 || index > size()).public int remove(int index)
index
- The index of the element to removed.
java.lang.IndexOutOfBoundsException
- If index is out of range (index < 0 || index >= size()).public void clear()
public void addAll(int[] ai)
ai
- The elements to be added to this list.public void addAll(int index, int[] ai)
index
- Index at which to insert first element from the specified array.ai
- Elements to be inserted into this list.
java.lang.IndexOutOfBoundsException
- If index is out of range (index < 0 || index > size()).public boolean containsAll(int[] ai)
This implementation iterates over the specified array, checking each element in turn to see if it's contained in this list. If all elements are so contained true is returned, otherwise false.
ai
- Array to be checked for containment in this list.
contains(int)
public boolean removeAll(int[] ai)
This implementation iterates over this list, checking each element in turn to see if it's contained in the specified array. If it's so contained, it's removed from this list.
ai
- Elements to be removed from this list.
remove(int)
,
contains(int)
public boolean retainAll(int[] ai)
This implementation iterates over this list, checking each element in turn to see if it's contained in the specified array. If it's not so contained, it's removed from this list.
ai
- Elements to be retained in this list.
remove(int)
,
contains(int)
public boolean equals(java.lang.Object o)
o
- the object to be compared for equality with this list.
public int hashCode()
public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |