public class LongArrayList extends AbstractList<Long> implements List<Long>, RandomAccess
List implementation that stores long values with the ability to not have them boxed.| Modifier and Type | Field and Description |
|---|---|
static long |
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 |
|---|
LongArrayList()
Constructs a new list with the
INITIAL_CAPACITY using DEFAULT_NULL_VALUE. |
LongArrayList(int initialCapacity,
long nullValue)
Construct a new list.
|
LongArrayList(long[] initialElements,
int initialSize,
long nullValue)
Create a new list that wraps an existing arrays without copying it.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
Long element) |
boolean |
add(Long element) |
void |
addLong(int index,
long element)
Add an element without boxing at a given index.
|
boolean |
addLong(long element)
Add an element without boxing.
|
int |
capacity()
The current capacity for the collection.
|
void |
clear() |
boolean |
containsLong(long value)
Does the list contain this element value.
|
void |
ensureCapacity(int requiredCapacity)
Ensure the backing array has a required capacity.
|
boolean |
equals(LongArrayList that)
Type-safe overload of the
equals(Object) method. |
boolean |
equals(Object other) |
long |
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 |
fastUnorderedRemoveLong(long 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 Long> action) |
void |
forEachLong(LongConsumer action)
Iterate over the collection without boxing.
|
void |
forEachOrderedLong(LongConsumer action)
For each element in order provide the long value to a
LongConsumer. |
Long |
get(int index) |
long |
getLong(int index)
Get the element at a given index without boxing.
|
int |
hashCode() |
int |
indexOf(long value)
Index of the first element with this value.
|
int |
lastIndexOf(long value)
Index of the last element with this value.
|
LongStream |
longStream()
Create a
LongStream over the elements of underlying array. |
long |
nullValue()
The value representing a null element.
|
long |
popLong()
Pop a value off the end of the array as a stack operation.
|
void |
pushLong(long element)
Push an element onto the end of the array like a stack.
|
Long |
remove(int index)
Remove at a given index.
|
boolean |
removeLong(long value)
Remove the first instance of a value if found in the list.
|
Long |
set(int index,
Long element) |
long |
setLong(int index,
long element)
Set an element at a given index without boxing.
|
int |
size() |
long[] |
toLongArray()
Create a new array that is a copy of the elements.
|
long[] |
toLongArray(long[] 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(long[] 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 long DEFAULT_NULL_VALUE
public static final int INITIAL_CAPACITY
public LongArrayList()
INITIAL_CAPACITY using DEFAULT_NULL_VALUE.public LongArrayList(int initialCapacity,
long nullValue)
initialCapacity - for the backing array.nullValue - to be used to represent a null element.public LongArrayList(long[] initialElements,
int initialSize,
long nullValue)
initialElements - to be wrapped.initialSize - of the array to wrap.nullValue - to be used to represent a null element.public void wrap(long[] initialElements,
int initialSize)
initialElements - to be wrapped.initialSize - of the array to wrap.IllegalArgumentException - if the initialSize is less than 0 or greater than the length of the
initial array.public long nullValue()
public int size()
size in interface Collection<Long>size in interface List<Long>size in class AbstractCollection<Long>public int capacity()
public void clear()
clear in interface Collection<Long>clear in interface List<Long>clear in class AbstractList<Long>public void trimToSize()
INITIAL_CAPACITY if size is less.public Long get(int index)
public long getLong(int index)
index - to get.public boolean add(Long element)
add in interface Collection<Long>add in interface List<Long>add in class AbstractList<Long>public boolean addLong(long element)
element - to be added.public void add(int index,
Long element)
public void addLong(int index,
long element)
index - at which the element should be added.element - to be added.public long setLong(int index,
long element)
index - at which to set the element.element - to be added.public boolean containsLong(long value)
value - of the element.public int indexOf(long value)
value - for the element.public int lastIndexOf(long value)
value - for the element.public Long remove(int index)
public long fastUnorderedRemove(int index)
index - of the element to be removed.IndexOutOfBoundsException - if index is out of bounds.public boolean removeLong(long value)
value - to be removed.public boolean fastUnorderedRemoveLong(long value)
value - to be removed.public void pushLong(long element)
element - to be pushed onto the end of the array.public long popLong()
NoSuchElementException - if the array is empty.public void forEachOrderedLong(LongConsumer action)
LongConsumer.action - to be taken for each element.public LongStream longStream()
LongStream over the elements of underlying array.LongStream over the elements of underlying array.public long[] toLongArray()
public long[] toLongArray(long[] 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(LongArrayList that)
equals(Object) method.that - other list.true if lists are equal.public boolean equals(Object other)
equals in interface Collection<Long>equals in interface List<Long>equals in class AbstractList<Long>public int hashCode()
hashCode in interface Collection<Long>hashCode in interface List<Long>hashCode in class AbstractList<Long>public void forEachLong(LongConsumer action)
action - to be taken for each element.public String toString()
toString in class AbstractCollection<Long>Copyright © 2014-2022 Real Logic Limited. All Rights Reserved.