public class IntArrayList extends AbstractList<Integer> implements List<Integer>, RandomAccess, Serializable
List implementation that stores int values with the ability to not have them boxed.| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_NULL_VALUE
The default value that will be used in place of null for an element.
|
static int |
INITIAL_CAPACITY
Initial capacity to which the array will be sized.
|
modCount| Constructor and Description |
|---|
IntArrayList() |
IntArrayList(int[] initialElements,
int initialSize,
int nullValue)
Create a new list that wraps an existing arrays without copying it.
|
IntArrayList(int initialCapacity,
int nullValue)
Construct a new list.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(Integer element) |
void |
add(int index,
Integer element) |
boolean |
addInt(int element)
Add an element without boxing.
|
void |
addInt(int index,
int element)
Add a element without boxing at a given index.
|
int |
capacity()
The current capacity for the collection.
|
void |
clear() |
boolean |
containsInt(int value)
Does the list contain this element value.
|
void |
ensureCapacity(int requiredCapacity)
Ensure the backing array has a required capacity.
|
boolean |
equals(IntArrayList that) |
boolean |
equals(Object other) |
int |
fastUnorderedRemove(int index)
Removes element at index, but instead of copying all elements to the left,
it replaces the item in the slot with the last item in the list.
|
boolean |
fastUnorderedRemoveInt(int value)
Remove the first instance of a value if found in the list and replaces it with the last item
in the list.
|
void |
forEach(Consumer<? super Integer> action) |
void |
forEachInt(IntConsumer action)
Iterate over the collection without boxing.
|
void |
forEachOrderedInt(IntConsumer action)
For each element in order provide the int value to a
IntConsumer. |
Integer |
get(int index) |
int |
getInt(int index)
Get the element at a given index without boxing.
|
int |
hashCode() |
int |
indexOf(int value)
Index of the first element with this value.
|
IntStream |
intStream()
Create a
IntStream over the elements of underlying array. |
int |
lastIndexOf(int value)
Index of the last element with this value.
|
int |
nullValue()
The value representing a null element.
|
int |
popInt()
Pop a value off the end of the array as a stack operation.
|
void |
pushInt(int element)
Push an element onto the end of the array like a stack.
|
Integer |
remove(int index)
Remove at a given index.
|
boolean |
removeInt(int value)
Remove the first instance of a value if found in the list.
|
Integer |
set(int index,
Integer element) |
int |
setInt(int index,
int element)
Set an element at a given index without boxing.
|
int |
size() |
int[] |
toIntArray()
Create a new array that is a copy of the elements.
|
int[] |
toIntArray(int[] dst)
Create a new array that is a copy of the elements.
|
String |
toString() |
void |
trimToSize()
Trim the underlying array to be the current size, or
INITIAL_CAPACITY if size is less. |
void |
wrap(int[] initialElements,
int initialSize)
Wrap an existing array without copying it.
|
addAll, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subListaddAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArrayclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddAll, addAll, contains, containsAll, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeAll, replaceAll, retainAll, sort, spliterator, subList, toArray, toArrayparallelStream, removeIf, streampublic static final int DEFAULT_NULL_VALUE
public static final int INITIAL_CAPACITY
public IntArrayList()
public IntArrayList(int initialCapacity,
int nullValue)
initialCapacity - for the backing array.nullValue - to be used to represent a null element.public IntArrayList(int[] initialElements,
int initialSize,
int nullValue)
initialElements - to be wrapped.initialSize - of the array to wrap.nullValue - to be used to represent a null element.public void wrap(int[] initialElements,
int initialSize)
initialElements - to be wrapped.initialSize - of the array to wrap.IllegalArgumentException - if the initialSize is is less than 0 or greater than the length of the
initial array.public int nullValue()
public int size()
size in interface Collection<Integer>size in interface List<Integer>size in class AbstractCollection<Integer>public int capacity()
public void clear()
clear in interface Collection<Integer>clear in interface List<Integer>clear in class AbstractList<Integer>public void trimToSize()
INITIAL_CAPACITY if size is less.public Integer get(int index)
public int getInt(int index)
index - to get.public boolean add(Integer element)
add in interface Collection<Integer>add in interface List<Integer>add in class AbstractList<Integer>public boolean addInt(int element)
element - to be added.public void add(int index,
Integer element)
public void addInt(int index,
int element)
index - at which the element should be added.element - to be added.public int setInt(int index,
int element)
index - at which to set the element.element - to be added.public boolean containsInt(int value)
value - of the element.public int indexOf(int value)
value - for the element.public int lastIndexOf(int value)
value - for the element.public Integer remove(int index)
public int fastUnorderedRemove(int index)
index - of the element to be removed.IndexOutOfBoundsException - if index is out of bounds.public boolean removeInt(int value)
value - to be removed.public boolean fastUnorderedRemoveInt(int value)
value - to be removed.public void pushInt(int element)
element - to be pushed onto the end of the array.public int popInt()
NoSuchElementException - if the array is empty.public void forEachOrderedInt(IntConsumer action)
IntConsumer.action - to be taken for each element.public IntStream intStream()
IntStream over the elements of underlying array.IntStream over the elements of underlying array.public int[] toIntArray()
public int[] toIntArray(int[] dst)
dst - destination array for the copy if it is the correct size.public void ensureCapacity(int requiredCapacity)
requiredCapacity - for the backing array.public boolean equals(IntArrayList that)
public boolean equals(Object other)
equals in interface Collection<Integer>equals in interface List<Integer>equals in class AbstractList<Integer>public int hashCode()
hashCode in interface Collection<Integer>hashCode in interface List<Integer>hashCode in class AbstractList<Integer>public void forEachInt(IntConsumer action)
action - to be taken for each element.public String toString()
toString in class AbstractCollection<Integer>Copyright © 2014-2020 Real Logic Limited. All Rights Reserved.