public class IntArrayList
extends java.util.AbstractList<java.lang.Integer>
implements java.util.List<java.lang.Integer>, java.util.RandomAccess, java.io.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.
|
static int |
MAX_CAPACITY
Maximum capacity to which the array can grow.
|
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(java.lang.Integer element) |
void |
add(int index,
java.lang.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.
|
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(java.lang.Object other) |
void |
forEachOrderedInt(java.util.function.IntConsumer consumer)
For each element in order provide the int value to a
IntConsumer . |
java.lang.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.
|
java.util.stream.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.
|
java.lang.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.
|
java.lang.Integer |
set(int index,
java.lang.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.
|
java.lang.String |
toString() |
void |
trimToSize()
Trim the underlying array to be the same capacity as the current size.
|
void |
wrap(int[] initialElements,
int initialSize)
Wrap an existing array without copying it.
|
addAll, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
public static final int DEFAULT_NULL_VALUE
public static final int INITIAL_CAPACITY
public static final int MAX_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)
The array length must be greater than or equal to INITIAL_CAPACITY
.
initialElements
- to be wrapped.initialSize
- of the array to wrap.java.lang.IllegalArgumentException
- if the initialSize is is less than INITIAL_CAPACITY
or greater than
the length of the initial array.public int nullValue()
public int size()
size
in interface java.util.Collection<java.lang.Integer>
size
in interface java.util.List<java.lang.Integer>
size
in class java.util.AbstractCollection<java.lang.Integer>
public void clear()
clear
in interface java.util.Collection<java.lang.Integer>
clear
in interface java.util.List<java.lang.Integer>
clear
in class java.util.AbstractList<java.lang.Integer>
public void trimToSize()
public java.lang.Integer get(int index)
get
in interface java.util.List<java.lang.Integer>
get
in class java.util.AbstractList<java.lang.Integer>
public int getInt(int index)
index
- to get.public boolean add(java.lang.Integer element)
add
in interface java.util.Collection<java.lang.Integer>
add
in interface java.util.List<java.lang.Integer>
add
in class java.util.AbstractList<java.lang.Integer>
public boolean addInt(int element)
element
- to be added.public void add(int index, java.lang.Integer element)
add
in interface java.util.List<java.lang.Integer>
add
in class java.util.AbstractList<java.lang.Integer>
public void addInt(int index, int element)
index
- at which the element should be added.element
- to be added.public java.lang.Integer set(int index, java.lang.Integer element)
set
in interface java.util.List<java.lang.Integer>
set
in class java.util.AbstractList<java.lang.Integer>
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 java.lang.Integer remove(int index)
remove
in interface java.util.List<java.lang.Integer>
remove
in class java.util.AbstractList<java.lang.Integer>
index
- of the element to be removed.public boolean removeInt(int value)
value
- to be removed.public void pushInt(int element)
element
- to be pushed onto the end of the array.public int popInt()
java.util.NoSuchElementException
- if the array is empty.public void forEachOrderedInt(java.util.function.IntConsumer consumer)
IntConsumer
.consumer
- for each element.public java.util.stream.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(java.lang.Object other)
equals
in interface java.util.Collection<java.lang.Integer>
equals
in interface java.util.List<java.lang.Integer>
equals
in class java.util.AbstractList<java.lang.Integer>
public int hashCode()
hashCode
in interface java.util.Collection<java.lang.Integer>
hashCode
in interface java.util.List<java.lang.Integer>
hashCode
in class java.util.AbstractList<java.lang.Integer>
public java.lang.String toString()
toString
in class java.util.AbstractCollection<java.lang.Integer>
Copyright © 2014-2017 Real Logic Ltd. All Rights Reserved.