public class LongArrayList
extends java.util.AbstractList<java.lang.Long>
implements java.util.List<java.lang.Long>, java.util.RandomAccess, java.io.Serializable
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.
|
static int |
MAX_CAPACITY
Maximum capacity to which the array can grow.
|
Constructor and Description |
---|
LongArrayList() |
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,
java.lang.Long element) |
boolean |
add(java.lang.Long element) |
void |
addLong(int index,
long element)
Add a element without boxing at a given index.
|
boolean |
addLong(long element)
Add an element without boxing.
|
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) |
boolean |
equals(java.lang.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 |
forEachOrderedLong(java.util.function.LongConsumer consumer)
For each element in order provide the long value to a
LongConsumer . |
java.lang.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.
|
java.util.stream.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.
|
java.lang.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.
|
java.lang.Long |
set(int index,
java.lang.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.
|
java.lang.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, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
public static final long DEFAULT_NULL_VALUE
public static final int INITIAL_CAPACITY
public static final int MAX_CAPACITY
public LongArrayList()
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)
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 long nullValue()
public int size()
size
in interface java.util.Collection<java.lang.Long>
size
in interface java.util.List<java.lang.Long>
size
in class java.util.AbstractCollection<java.lang.Long>
public void clear()
clear
in interface java.util.Collection<java.lang.Long>
clear
in interface java.util.List<java.lang.Long>
clear
in class java.util.AbstractList<java.lang.Long>
public void trimToSize()
INITIAL_CAPACITY
if size is less.public java.lang.Long get(int index)
get
in interface java.util.List<java.lang.Long>
get
in class java.util.AbstractList<java.lang.Long>
public long getLong(int index)
index
- to get.public boolean add(java.lang.Long element)
add
in interface java.util.Collection<java.lang.Long>
add
in interface java.util.List<java.lang.Long>
add
in class java.util.AbstractList<java.lang.Long>
public boolean addLong(long element)
element
- to be added.public void add(int index, java.lang.Long element)
add
in interface java.util.List<java.lang.Long>
add
in class java.util.AbstractList<java.lang.Long>
public void addLong(int index, long element)
index
- at which the element should be added.element
- to be added.public java.lang.Long set(int index, java.lang.Long element)
set
in interface java.util.List<java.lang.Long>
set
in class java.util.AbstractList<java.lang.Long>
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 java.lang.Long remove(int index)
remove
in interface java.util.List<java.lang.Long>
remove
in class java.util.AbstractList<java.lang.Long>
index
- of the element to be removed.public long fastUnorderedRemove(int index)
index
- of the element to be removed.java.lang.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()
java.util.NoSuchElementException
- if the array is empty.public void forEachOrderedLong(java.util.function.LongConsumer consumer)
LongConsumer
.consumer
- for each element.public java.util.stream.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)
public boolean equals(java.lang.Object other)
equals
in interface java.util.Collection<java.lang.Long>
equals
in interface java.util.List<java.lang.Long>
equals
in class java.util.AbstractList<java.lang.Long>
public int hashCode()
hashCode
in interface java.util.Collection<java.lang.Long>
hashCode
in interface java.util.List<java.lang.Long>
hashCode
in class java.util.AbstractList<java.lang.Long>
public java.lang.String toString()
toString
in class java.util.AbstractCollection<java.lang.Long>
Copyright © 2014-2018 Real Logic Ltd. All Rights Reserved.