public final class IntArray
extends java.lang.Object
Constructor and Description |
---|
IntArray()
Create an IntArray object.
|
IntArray(int capacity)
Create an IntArray object with an initial capacity.
|
Modifier and Type | Method and Description |
---|---|
IntArray |
add(int i)
Add a int into the array.
|
void |
ensureCapacity(int capacity)
Ensure that the IntArray has at least "l" capacity.
|
int |
get(int i)
Get the int value at a certain index.
|
int |
set(int i,
int val)
Set the value at a certain index.
|
int |
size()
Get the number of int values stored.
|
int[] |
toArray()
Create a int[] object with all the elements stored in this IntArray.
|
public IntArray(int capacity)
capacity
- the initial capacity.public IntArray()
public int[] toArray()
public int size()
public int get(int i)
i
- the 0-based index of the value.java.lang.ArrayIndexOutOfBoundsException
- if i is negative or >= size().public int set(int i, int val)
i
- the 0-based index.val
- the new value.java.lang.ArrayIndexOutOfBoundsException
- if i is negative or >= size().public void ensureCapacity(int capacity)
capacity
- the minimal capacity.public IntArray add(int i)
i
- the int value.