IntList.Array| Constructor and Description |
|---|
IntList.Array(int initialCapacity)
Construct a new empty IntList with the given intial capacity
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int value)
Adds a new element to the end of the list
|
void |
compact()
Compacts the underlying storage array to only big as big as it needs to be to hold the current data.
|
int |
get(int index)
Gets the value at this index.
|
boolean |
isEmpty()
Returns true if this list is empty
IntList.size()==0) |
int |
set(int index,
int newValue)
sets the value of the list at the given index
|
int |
size()
Returns the size of this list like
List.size() |
void |
sort()
sorts the values in this list in increasing order
|
IntList |
subList(int minIndex,
int maxIndexExclusive)
Creates a sub list
|
int[] |
toIntArray() |
int[] |
toIntArray(int minIndex,
int maxIndexExclusive)
returns a copy of a sub-list of the elements in this list as an array
|
public IntList.Array(int initialCapacity)
initialCapacity - the initial capacity of the internal arraypublic int get(int index)
IntListList.get(int)public int set(int index,
int newValue)
index - the index in the range 0->size()-1newValue - the new valuepublic void add(int value)
value - the new value to addpublic int size()
IntListList.size()public void compact()
public int[] toIntArray()
public int[] toIntArray(int minIndex,
int maxIndexExclusive)
minIndex - the first index for the sublistmaxIndexExclusive - the last index (exclusive) for the sublistpublic void sort()
public boolean isEmpty()
IntListIntList.size()==0)isEmpty in class IntListIntList.size()==0)