public class IntArray extends Object
Constructor and Description |
---|
IntArray()
Creates an ordered array with a capacity of 16.
|
IntArray(boolean ordered,
int capacity) |
IntArray(boolean ordered,
int[] array,
int startIndex,
int count)
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 |
add(int value1,
int value2) |
void |
add(int value1,
int value2,
int value3) |
void |
add(int value1,
int value2,
int value3,
int value4) |
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 accommodate the specified number of additional items.
|
boolean |
equals(Object object) |
int |
first()
Returns the first item.
|
int |
get(int index) |
int |
hashCode() |
void |
incr(int index,
int value) |
int |
indexOf(int value) |
void |
insert(int index,
int value) |
boolean |
isEmpty()
Returns true if the array is empty.
|
int |
lastIndexOf(int value) |
void |
mul(int index,
int value) |
boolean |
notEmpty()
Returns true if the array has one or more items.
|
int |
peek()
Returns the last item.
|
int |
pop()
Removes and returns the last item.
|
int |
random()
Returns a random item from the array, or zero if the array is empty.
|
boolean |
removeAll(IntArray array)
Removes from this array all of elements contained in the specified array.
|
int |
removeIndex(int index)
Removes and returns the item at the specified index.
|
void |
removeRange(int start,
int end)
Removes the items between the specified indices, inclusive.
|
boolean |
removeValue(int value) |
void |
reverse() |
void |
set(int index,
int value) |
int[] |
setSize(int newSize)
Sets the array size, leaving any values beyond the current size undefined.
|
int[] |
shrink()
Reduces the size of the backing array to the size of the actual items.
|
void |
shuffle() |
void |
sort() |
void |
swap(int first,
int second) |
int[] |
toArray() |
String |
toString() |
String |
toString(String separator) |
void |
truncate(int newSize)
Reduces the size of the array to the specified size.
|
static IntArray |
with(int... array) |
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, int startIndex, int count)
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 add(int value1, int value2)
public void add(int value1, int value2, int value3)
public void add(int value1, int value2, int value3, int value4)
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 incr(int index, int value)
public void mul(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 int lastIndexOf(int value)
public boolean removeValue(int value)
public int removeIndex(int index)
public void removeRange(int start, int end)
public boolean removeAll(IntArray array)
public int pop()
public int peek()
public int first()
public boolean notEmpty()
public boolean isEmpty()
public void clear()
public int[] shrink()
items
public int[] ensureCapacity(int additionalCapacity)
items
public int[] setSize(int newSize)
items
public void sort()
public void reverse()
public void shuffle()
public void truncate(int newSize)
public int random()
public int[] toArray()
public static IntArray with(int... array)
IntArray(int[])
Copyright © 2019. All rights reserved.