public class IntArray
extends java.lang.Object
Constructor and Description |
---|
IntArray()
Creates an ordered array with a capacity of 16.
|
IntArray(boolean ordered,
int capacity) |
IntArray(boolean ordered,
int[] array)
Creates a new array containing the elements in the specified array.
|
IntArray(int capacity)
Creates an ordered array with the specified capacity.
|
IntArray(int[] array)
Creates a new ordered array containing the elements in the specified array.
|
IntArray(IntArray array)
Creates a new array containing the elements in the specific array.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int value) |
void |
addAll(int[] array) |
void |
addAll(int[] array,
int offset,
int length) |
void |
addAll(IntArray array) |
void |
addAll(IntArray array,
int offset,
int length) |
void |
clear() |
boolean |
contains(int value) |
int[] |
ensureCapacity(int additionalCapacity)
Increases the size of the backing array to acommodate the specified number of additional items.
|
int |
get(int index) |
int |
indexOf(int value) |
void |
insert(int index,
int value) |
int |
peek()
Returns the last item.
|
int |
pop()
Removes and returns the last item.
|
int |
removeIndex(int index)
Removes and returns the item at the specified index.
|
boolean |
removeValue(int value) |
void |
reverse() |
void |
set(int index,
int value) |
void |
shrink()
Reduces the size of the backing array to the size of the actual items.
|
void |
sort() |
void |
swap(int first,
int second) |
int[] |
toArray() |
java.lang.String |
toString() |
java.lang.String |
toString(java.lang.String separator) |
void |
truncate(int newSize)
Reduces the size of the array to the specified size.
|
public IntArray()
public IntArray(int capacity)
public IntArray(boolean ordered, int capacity)
ordered
- If false, methods that remove elements may change the order of other elements in the array, which avoids a
memory copy.capacity
- Any elements added beyond this will cause the backing array to be grown.public IntArray(IntArray array)
public IntArray(int[] array)
public IntArray(boolean ordered, int[] array)
ordered
- If false, methods that remove elements may change the order of other elements in the array, which avoids a
memory copy.public void add(int value)
public void addAll(IntArray array)
public void addAll(IntArray array, int offset, int length)
public void addAll(int[] array)
public void addAll(int[] array, int offset, int length)
public int get(int index)
public void set(int index, int value)
public void insert(int index, int value)
public void swap(int first, int second)
public boolean contains(int value)
public int indexOf(int value)
public boolean removeValue(int value)
public int removeIndex(int index)
public int pop()
public int peek()
public void clear()
public void shrink()
public int[] ensureCapacity(int additionalCapacity)
items
public void sort()
public void reverse()
public void truncate(int newSize)
public int[] toArray()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(java.lang.String separator)