public class IntList
extends java.lang.Object
List, IntList does not require each int to be boxed. This makes it helpful in use cases
where storing Integer leads to excessive time spent in garbage collection.| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_INITIAL_CAPACITY |
| Constructor and Description |
|---|
IntList()
Constructs a new IntList with a capacity of
DEFAULT_INITIAL_CAPACITY. |
IntList(int initialCapacity)
Constructs a new IntList with the specified capacity.
|
IntList(IntList other)
Constructs a new IntList that contains all the elements of the given IntList.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int value)
Appends an int to the end of the list, growing the list if necessary.
|
void |
clear()
Empties the list.
|
int |
get(int index)
Returns the
indexth int in the list. |
boolean |
isEmpty() |
int |
size()
Accessor.
|
java.lang.String |
toString() |
public static final int DEFAULT_INITIAL_CAPACITY
public IntList()
DEFAULT_INITIAL_CAPACITY.public IntList(int initialCapacity)
initialCapacity - The number of ints that can be stored in this IntList before it will need to be
reallocated.public IntList(IntList other)
other - the IntList to copy.public int size()
public boolean isEmpty()
true if there are ints stored in the list.public void clear()
public int get(int index)
indexth int in the list.index - The list index of the desired int.index in the list.java.lang.IndexOutOfBoundsException - if the index is negative or greater than the number of ints stored in the
list.public void add(int value)
value - The int to add to the end of the list.public java.lang.String toString()
toString in class java.lang.Object