public class IntList
extends Object
Constructor and Description |
---|
IntList()
Basic constructor - initializes with capacity of 10
|
IntList(int initialCapacity)
Constructor to specify initial capacity explicitly
|
Modifier and Type | Method and Description |
---|---|
void |
add(int value)
Add a value to the end of the list, expanding the array if necessary
|
int |
binarySearch(int searchFor)
Perform a binary search for the given value.
|
int[] |
calcSortMap()
Calculate a reordering of the elements of the list that would put them
in sorted order.
|
void |
clear()
Remove all elements from the list (but doesn't resize the array)
|
void |
compact()
Resize the array so it exactly fits the current elements
|
void |
ensureCapacity(int cap)
Ensure that at least the given number of elements can be stored
|
void |
fill(int value)
Fill the list with a given data value
|
int |
get(int index)
Get an element from the list
|
int |
getLast()
Get the last element from the list
|
boolean |
isEmpty()
Check if the list is empty (i.e. size() == 0)
|
void |
remap(int[] map)
Apply a sort order to the elements -- see
calcSortMap() |
void |
resize(int newSize)
Resize the array to the specified size.
|
void |
set(int index,
int value)
Set an element in the list
|
int |
size()
Retrieve the current number of elements in the list
|
void |
sort()
Sort all the elements in the list in ascending order
|
int[] |
toArray()
Get an array of the elements.
|
public IntList()
public IntList(int initialCapacity)
public final void add(int value)
public final void ensureCapacity(int cap)
public final void compact()
public final void resize(int newSize)
public final int[] toArray()
public final boolean isEmpty()
public final void clear()
public final int size()
public final int get(int index)
public final int getLast()
public final void set(int index, int value)
public final void fill(int value)
public final void sort()
public final int binarySearch(int searchFor)
sort()
if necessary.Arrays.binarySearch(int[], int)
public final int[] calcSortMap()
remap(int[])
on each array including the original.public final void remap(int[] map)
calcSortMap()