public class LongArrayList extends AbstractLongList implements ILongArray, LongStack
This implementation is optimized to improve how data is processed with interfaces like ILongArray, LongStack
and with optimized functions that use type-specific implementations for primitives and optimized logic for bulkactions.
ISizeProvider.CollectionSize| Constructor and Description |
|---|
LongArrayList()
Creates a new ArrayList with a Empty array.
|
LongArrayList(java.util.Collection<? extends java.lang.Long> c)
Deprecated.
|
LongArrayList(int size)
Creates a new ArrayList with the specific requested size
|
LongArrayList(long... a)
Creates a new ArrayList with a Copy of the array
|
LongArrayList(long[] a,
int length)
Creates a new ArrayList with a Copy of the array with a custom length
|
LongArrayList(long[] a,
int offset,
int length)
Creates a new ArrayList with a Copy of the array with in the custom range.
|
LongArrayList(LongCollection c)
Creates a new ArrayList a copy with the contents of the Collection.
|
LongArrayList(LongList l)
Creates a new ArrayList a copy with the contents of the List.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
long e)
Appends the specified element to the index of the list
|
boolean |
add(long e)
Appends the specified element to the end of this list.
|
boolean |
addAll(int index,
java.util.Collection<? extends java.lang.Long> c)
Deprecated.
|
boolean |
addAll(int index,
LongCollection c)
Appends the specified elements to the index of the list.
|
boolean |
addAll(int index,
LongList c)
Appends the specified elements to the index of the list.
|
boolean |
addAll(long[] e,
int offset,
int length)
A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
void |
addElements(int from,
long[] a,
int offset,
int length)
Appends the specified array elements to the index of the list.
|
void |
clear()
A function to clear all elements in the list.
|
void |
clearAndTrim(int size)
Trims the collection down to the requested size and clears all elements while doing so
|
boolean |
contains(long e)
A Type Specific implementation of the Collection#contains function.
|
boolean |
contains(java.lang.Object o)
Deprecated.
|
LongArrayList |
copy()
A Function that does a shallow clone of the Collection itself.
|
int |
count(java.util.function.LongPredicate filter)
Helper function to reduce stream usage that allows to count the valid elements.
|
long[] |
elements()
Provides the Underlying Array in the Implementation
|
void |
ensureCapacity(int size)
Increases the capacity of this implementation instance, if necessary,
to ensure that it can hold at least the number of elements specified by
the minimum capacity argument.
|
long[] |
extractElements(int from,
int to)
A function to fast extract elements out of the list, this removes the elements that were fetched.
|
void |
fillBuffer(java.nio.LongBuffer buffer)
Helper function that allows to fastFill a buffer reducing the duplication requirement
|
long |
findFirst(java.util.function.LongPredicate filter)
Helper function to reduce stream usage that allows to filter for the first match.
|
<E> void |
forEach(E input,
ObjectLongConsumer<E> action)
Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.
|
void |
forEach(LongConsumer action)
A Type Specific foreach function that reduces (un)boxing
|
long[] |
getElements(int from,
long[] a,
int offset,
int length)
A function to fast fetch elements from the list
|
long |
getLong(int index)
A Type-Specific get function to reduce (un)boxing
|
int |
indexOf(long e)
A Type-Specific function to find the index of a given element
|
int |
indexOf(java.lang.Object o)
Deprecated.
|
int |
lastIndexOf(long e)
A Type-Specific function to find the last index of a given element
|
int |
lastIndexOf(java.lang.Object o)
Deprecated.
|
boolean |
matchesAll(java.util.function.LongPredicate filter)
Helper function to reduce stream usage that allows to filter for all matches.
|
boolean |
matchesAny(java.util.function.LongPredicate filter)
Helper function to reduce stream usage that allows to filter for any matches.
|
boolean |
matchesNone(java.util.function.LongPredicate filter)
Helper function to reduce stream usage that allows to filter for no matches.
|
long |
peek(int index)
Provides the Selected Object from the stack.
|
long |
pop()
A Type-Specific pop function to reduce (un)boxing
|
java.util.stream.LongStream |
primitiveStream()
Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
void |
push(long e)
Appends the specified element to the end of this Stack.
|
long |
reduce(long identity,
LongLongUnaryOperator operator)
Performs a reduction on the
elements of this Iterable
|
long |
reduce(LongLongUnaryOperator operator)
Performs a reduction on the
elements of this Iterable
|
boolean |
remIf(java.util.function.LongPredicate filter)
A optimized List#removeIf(Predicate) that more quickly removes elements from the list then the ArrayList implementation
|
boolean |
remLong(long type)
A Type-Specific implementation of remove.
|
boolean |
removeAll(java.util.Collection<?> c)
Deprecated.
|
boolean |
removeAll(LongCollection c)
A function to remove all elements that were provided in the other collection
|
boolean |
removeAll(LongCollection c,
LongConsumer r)
A Type-Specific removeAll function that reduces (un)boxing.
|
void |
removeElements(int from,
int to)
a function to fast remove elements from the list.
|
boolean |
removeIf(java.util.function.Predicate<? super java.lang.Long> filter)
Deprecated.
|
long |
removeLong(int index)
A Type-Specific remove function to reduce (un)boxing
|
void |
replaceAll(java.util.function.UnaryOperator<java.lang.Long> o)
Deprecated.
|
void |
replaceLongs(java.util.function.LongUnaryOperator o)
A Type-Specific replace function to reduce (un)boxing
|
boolean |
retainAll(java.util.Collection<?> c)
Deprecated.
|
boolean |
retainAll(LongCollection c)
A function to retain all elements that were provided in the other collection
This function might delegate to a more appropriate function if necessary
|
boolean |
retainAll(LongCollection c,
LongConsumer r)
A Type-Specific retainAll function that reduces (un)boxing.
|
long |
set(int index,
long e)
A Type-Specific set function to reduce (un)boxing
|
int |
size()
A function to return the size of the list
|
void |
size(int size)
A function to ensure the elements are within the requested size.
|
void |
sort(LongComparator c)
Sorts the elements specified by the Natural order either by using the Comparator or the elements
|
LongSplititerator |
spliterator()
A Type Specific Type Splititerator to reduce boxing/unboxing
|
long |
swapRemove(int index)
A Highly Optimized remove function that removes the desired element.
|
java.lang.Object[] |
toArray()
Deprecated.
|
<E> E[] |
toArray(E[] a)
Deprecated.
|
long[] |
toLongArray(long[] a)
A Type-Specific implementation of toArray.
|
boolean |
trim(int size)
Trims the original collection down to the size of the current elements or the requested size depending which is bigger
|
void |
unstableSort(LongComparator c)
Sorts the elements specified by the Natural order either by using the Comparator or the elements using a unstable sort
|
static LongArrayList |
wrap(long... a)
Creates a wrapped arraylist that uses the array as backing array
|
static LongArrayList |
wrap(long[] a,
int length)
Creates a wrapped arraylist that uses the array as backing array and a custom fill size
|
add, addAll, addAll, addAll, equals, hashCode, iterator, listIterator, listIterator, subList, swapRemoveLongadd, containsAll, containsAll, containsAny, containsAny, remove, toLongArrayelementsclearAndTrim, trimadd, addElements, addElements, addIfAbsent, addIfPresent, forEachIndexed, get, getElements, remove, remove, set, sort, synchronize, synchronize, unmodifiable, unstableSortaddAll, addAll, containsAll, containsAny, containsAny, parallelPrimitiveStream, pour, toLongArrayarrayflatMap, asAsync, distinct, filter, flatMap, forEach, limit, map, peek, pourAsList, pourAsSet, repeat, sortedofpublic LongArrayList()
public LongArrayList(int size)
size - the minimum initial size of the Backing array@Deprecated public LongArrayList(java.util.Collection<? extends java.lang.Long> c)
c - the elements that should be added into the listpublic LongArrayList(LongCollection c)
c - the elements that should be added into the listpublic LongArrayList(LongList l)
l - the elements that should be added into the listpublic LongArrayList(long... a)
a - the array that should be copiedpublic LongArrayList(long[] a,
int length)
a - the array that should be copiedlength - the desired length that should be copiedpublic LongArrayList(long[] a,
int offset,
int length)
a - the array that should be copiedoffset - the starting offset of where the array should be copied fromlength - the desired length that should be copiedjava.lang.IllegalStateException - if offset is smaller then 0java.lang.IllegalStateException - if the offset + length exceeds the array lengthpublic static LongArrayList wrap(long... a)
a - elements that should be wrappedpublic static LongArrayList wrap(long[] a, int length)
a - elements that should be wrappedlength - the size of the elements within the arraypublic boolean add(long e)
add in interface LongCollectionadd in interface LongListadd in class AbstractLongListe - element to be appended to this listCollection.add(E))List.add(Object)public void push(long e)
push in interface LongStacke - element to be appended to this StackStack.push(Object)public void add(int index,
long e)
@Deprecated
public boolean addAll(int index,
java.util.Collection<? extends java.lang.Long> c)
addAll in interface java.util.List<java.lang.Long>index - the index where to append the elements toc - the elements to append to the listjava.lang.IndexOutOfBoundsException - if index is outside of the lists rangejava.lang.NullPointerException - if collection contains a null elementpublic boolean addAll(int index,
LongCollection c)
addAll in interface LongListindex - the index where to append the elements toc - the elements to append to the listjava.lang.IndexOutOfBoundsException - if index is outside of the lists rangeList.addAll(int, java.util.Collection)public boolean addAll(int index,
LongList c)
public boolean addAll(long[] e,
int offset,
int length)
LongCollectionaddAll in interface LongCollectione - the elements that should be addedoffset - where to start within the arraylength - how many elements of the array should be addedpublic void addElements(int from,
long[] a,
int offset,
int length)
addElements in interface LongListfrom - the index where to append the elements toa - the elements to append to the listoffset - where to start ino the arraylength - the amount of elements to insertjava.lang.IndexOutOfBoundsException - if index is outside of the lists rangepublic long[] getElements(int from,
long[] a,
int offset,
int length)
getElements in interface LongListfrom - index where the list should be fetching elements froma - the array where the values should be inserted tooffset - the startIndex of where the array should be written tolength - the number of elements the values should be fetched fromjava.lang.NullPointerException - if the array is nulljava.lang.IndexOutOfBoundsException - if from is outside of the lists rangejava.lang.IllegalStateException - if offset or length are smaller then 0 or exceed the array lengthpublic void removeElements(int from,
int to)
removeElements in interface LongListfrom - the start index of where the elements should be removed from (inclusive)to - the end index of where the elements should be removed to (exclusive)public long[] extractElements(int from,
int to)
extractElements in interface LongListfrom - the start index of where the elements should be fetched from (inclusive)to - the end index of where the elements should be fetched to (exclusive)public void fillBuffer(java.nio.LongBuffer buffer)
LongListfillBuffer in interface LongListbuffer - where the data should be stored in.@Deprecated public boolean contains(java.lang.Object o)
contains in interface java.util.Collection<java.lang.Long>contains in interface java.util.List<java.lang.Long>contains in interface LongCollectioncontains in interface LongListcontains in class AbstractLongCollectiono - the element that is searched for@Deprecated public int indexOf(java.lang.Object o)
indexOf in interface java.util.List<java.lang.Long>indexOf in interface LongListindexOf in class AbstractLongListo - the element that is searched for@Deprecated public int lastIndexOf(java.lang.Object o)
lastIndexOf in interface java.util.List<java.lang.Long>lastIndexOf in interface LongListlastIndexOf in class AbstractLongListo - the element that is searched forpublic boolean contains(long e)
contains in interface LongCollectioncontains in class AbstractLongCollectione - the element that is searched for.public int indexOf(long e)
indexOf in interface LongListindexOf in class AbstractLongListe - the element that is searched forpublic int lastIndexOf(long e)
lastIndexOf in interface LongListlastIndexOf in class AbstractLongListe - the element that is searched forpublic void sort(LongComparator c)
sort in interface LongListc - the sorter of the elements, can be nullList.sort(java.util.Comparator),
LongArrays.stableSort(long[], LongComparator)public void unstableSort(LongComparator c)
unstableSort in interface LongListc - the sorter of the elements, can be nullList.sort(java.util.Comparator),
LongArrays.unstableSort(long[], LongComparator)public long getLong(int index)
public long peek(int index)
peek in interface LongStackindex - of the element that should be providedjava.lang.ArrayIndexOutOfBoundsException - if the index is out of boundsStack.peek(int)public long[] elements()
elements in interface ILongArrayjava.lang.ClassCastException - if the return type does not match the underlying array. (Only for Object Implementations)public void forEach(LongConsumer action)
forEach in interface LongIterableaction - The action to be performed for each elementjava.lang.NullPointerException - if the specified action is nullIterable.forEach(java.util.function.Consumer)The default implementation behaves as if:
for(int i = 0;i<size;i++)
action.accept(data[i]);
public <E> void forEach(E input,
ObjectLongConsumer<E> action)
LongIterableforEach in interface LongIterableE - the generic type of the Objectinput - the object that should be includedaction - The action to be performed for each elementpublic boolean matchesAny(java.util.function.LongPredicate filter)
LongIterablematchesAny in interface LongIterablefilter - that should be appliedpublic boolean matchesNone(java.util.function.LongPredicate filter)
LongIterablematchesNone in interface LongIterablefilter - that should be appliedpublic boolean matchesAll(java.util.function.LongPredicate filter)
LongIterablematchesAll in interface LongIterablefilter - that should be appliedpublic long findFirst(java.util.function.LongPredicate filter)
LongIterablefindFirst in interface LongIterablefilter - that should be appliedpublic long reduce(long identity,
LongLongUnaryOperator operator)
LongIterablereduce in interface LongIterableidentity - the start valueoperator - the operation that should be appliedpublic long reduce(LongLongUnaryOperator operator)
LongIterablereduce in interface LongIterableoperator - the operation that should be appliedpublic int count(java.util.function.LongPredicate filter)
LongIterablecount in interface LongIterablefilter - that should be appliedpublic long set(int index,
long e)
@Deprecated public void replaceAll(java.util.function.UnaryOperator<java.lang.Long> o)
replaceAll in interface java.util.List<java.lang.Long>replaceAll in interface LongListo - the action to replace the valuesjava.lang.NullPointerException - if o is nullpublic void replaceLongs(java.util.function.LongUnaryOperator o)
replaceLongs in interface LongListo - the action to replace the valuesjava.lang.NullPointerException - if o is nullpublic long removeLong(int index)
removeLong in interface LongListindex - the index of the element to fetchjava.lang.IndexOutOfBoundsException - if the index is out of rangeList.remove(int)public long swapRemove(int index)
LongListswapRemove in interface LongListindex - the index of the element to be removedpublic boolean remLong(long type)
remLong in interface LongCollectionremLong in class AbstractLongCollectiontype - the element that is searched forCollection.remove(Object)public long pop()
pop in interface LongStackjava.lang.IndexOutOfBoundsException - if the index is out of rangeStack.pop()@Deprecated public boolean removeAll(java.util.Collection<?> c)
removeAll in interface java.util.Collection<java.lang.Long>removeAll in interface java.util.List<java.lang.Long>removeAll in class java.util.AbstractCollection<java.lang.Long>c - the elements that should be removedjava.lang.NullPointerException - if the collection is null@Deprecated public boolean retainAll(java.util.Collection<?> c)
retainAll in interface java.util.Collection<java.lang.Long>retainAll in interface java.util.List<java.lang.Long>retainAll in class java.util.AbstractCollection<java.lang.Long>c - the elements that should be kept. If empty, LongArrayList#clear is called.java.lang.NullPointerException - if the collection is null@Deprecated public boolean removeIf(java.util.function.Predicate<? super java.lang.Long> filter)
removeIf in interface java.util.Collection<java.lang.Long>removeIf in interface LongCollectionfilter - the filter to remove elementspublic boolean removeAll(LongCollection c)
removeAll in interface LongCollectionremoveAll in class AbstractLongCollectionc - the elements that should be removedjava.lang.NullPointerException - if the collection is nullCollection.removeAll(Collection)public boolean removeAll(LongCollection c, LongConsumer r)
LongCollectionremoveAll in interface LongCollectionremoveAll in class AbstractLongCollectionc - the collection of elements that should be removedr - elements that got removedCollection.removeAll(Collection)public boolean retainAll(LongCollection c)
retainAll in interface LongCollectionretainAll in class AbstractLongCollectionc - the elements that should be kept. If empty, LongArrayList#clear is called.java.lang.NullPointerException - if the collection is nullCollection.retainAll(Collection)public boolean retainAll(LongCollection c, LongConsumer r)
LongCollectionretainAll in interface LongCollectionretainAll in class AbstractLongCollectionc - the collection of elements that should be keptr - elements that got removedCollection.retainAll(Collection)public boolean remIf(java.util.function.LongPredicate filter)
remIf in interface LongCollectionfilter - the filter to remove elementsCollection.removeIf(Predicate)@Deprecated public java.lang.Object[] toArray()
toArray in interface java.util.Collection<java.lang.Long>toArray in interface java.util.List<java.lang.Long>toArray in class java.util.AbstractCollection<java.lang.Long>@Deprecated public <E> E[] toArray(E[] a)
toArray in interface java.util.Collection<java.lang.Long>toArray in interface java.util.List<java.lang.Long>toArray in class java.util.AbstractCollection<java.lang.Long>a - original array. If null a Object array with the right size is created. If to small the Array of the same type is created with the right sizepublic long[] toLongArray(long[] a)
AbstractLongCollectiontoLongArray in interface LongCollectiontoLongArray in class AbstractLongCollectiona - array that the elements should be injected to. If null or to small a new array with the right size is createdCollection.toArray(Object[])public int size()
size in interface java.util.Collection<java.lang.Long>size in interface java.util.List<java.lang.Long>size in interface LongStacksize in interface ISizeProvidersize in class java.util.AbstractCollection<java.lang.Long>public void size(int size)
size in interface LongListsize in class AbstractLongListsize - the requested amount of elements/room for elementspublic void clear()
public boolean trim(int size)
trim in interface ITrimmablesize - the requested trim size.public void clearAndTrim(int size)
clearAndTrim in interface ITrimmablesize - the amount of elements that should be allowedpublic void ensureCapacity(int size)
ensureCapacity in interface IArraysize - the desired minimum capacitypublic LongArrayList copy()
LongCollectioncopy in interface LongCollectioncopy in interface LongListcopy in class AbstractLongListpublic java.util.stream.LongStream primitiveStream()
primitiveStream in interface LongCollectionpublic LongSplititerator spliterator()
spliterator in interface java.lang.Iterable<java.lang.Long>spliterator in interface java.util.Collection<java.lang.Long>spliterator in interface java.util.List<java.lang.Long>spliterator in interface LongCollectionspliterator in interface LongIterablespliterator in interface LongList