public class IntArray
extends java.lang.Object
Constructor and Description |
---|
IntArray()
Create an int array with the default initial capacity.
|
IntArray(int capacity)
Create an int array with specified initial capacity.
|
IntArray(int[] data)
Create an int array with the given values and size.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int value)
Append a value.
|
void |
ensureCapacity(int minCapacity)
Ensure the the underlying array is large enough for the given number of
entries.
|
boolean |
equals(java.lang.Object obj) |
int |
get(int index)
Get the value at the given index.
|
int |
hashCode() |
void |
remove(int index)
Remove the value at the given index.
|
void |
removeRange(int fromIndex,
int toIndex)
Remove a number of elements.
|
int |
size()
Get the size of the list.
|
void |
toArray(int[] array)
Convert this list to an array.
|
java.lang.String |
toString() |
public IntArray()
public IntArray(int capacity)
capacity
- the initial capacitypublic IntArray(int[] data)
data
- the int arraypublic void add(int value)
value
- the value to appendpublic int get(int index)
index
- the indexpublic void remove(int index)
index
- the indexpublic void ensureCapacity(int minCapacity)
minCapacity
- the minimum capacitypublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public int size()
public void toArray(int[] array)
array
- the target arraypublic java.lang.String toString()
toString
in class java.lang.Object
public void removeRange(int fromIndex, int toIndex)
fromIndex
- the index of the first item to removetoIndex
- upper bound (exclusive)