public final class IntArrayList
extends java.lang.Object
implements java.io.Serializable
| Constructor and Description |
|---|
IntArrayList()
Constructs an empty list.
|
IntArrayList(int capacity)
Constructs an empty list with the specified initial capacity.
|
IntArrayList(int[] values)
Constructs a list containing the values of the specified array.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int val)
Appends the specified value to the end of this list.
|
void |
add(int[] vals)
Appends an array to the end of this list.
|
void |
clear()
Removes all of the value from this list.
|
void |
ensureCapacity(int capacity)
Increases the capacity, if necessary, to ensure that it can hold
at least the number of values specified by the minimum capacity
argument.
|
int |
get(int index)
Returns the value at the specified position in this list.
|
boolean |
isEmpty()
Returns true if this list contains no values.
|
int |
remove(int index)
Removes the value at specified index from the list.
|
IntArrayList |
set(int index,
int val)
Replaces the value at the specified position in this list with the
specified value.
|
int |
size()
Returns the number of values in the list.
|
int[] |
toArray()
Returns an array containing all of the values in this list in
proper sequence (from first to last value).
|
int[] |
toArray(int[] dest)
Returns an array containing all of the values in this list in
proper sequence (from first to last value).
|
void |
trimToSize()
Trims the capacity to be the list's current size.
|
public IntArrayList()
public IntArrayList(int capacity)
capacity - the initial size of array list.public IntArrayList(int[] values)
values - the initial values of array list.public void ensureCapacity(int capacity)
capacity - the desired minimum capacity.public int size()
public boolean isEmpty()
public void trimToSize()
public void add(int val)
val - a value to be appended to this list.public void add(int[] vals)
vals - an array to be appended to this list.public int get(int index)
index - index of the value to returnpublic IntArrayList set(int index, int val)
index - index of the value to replaceval - value to be stored at the specified positionjava.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index ≥ size())public void clear()
public int remove(int index)
index - index of the element to remove.java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index ≥ size())public int[] toArray()
public int[] toArray(int[] dest)
dest - the array into which the values of the list are to
be stored, if it is big enough; otherwise, a new array is allocated
for this purpose.