public class CopyOnWriteIntArrayList extends AbstractIntList implements ITrimmable, IntStack
This implementation is optimized to improve how data is processed with interfaces like ITrimmable, IntStack
and with optimized functions that use type-specific implementations for primitives and optimized logic for bulkactions.
| Constructor and Description |
|---|
CopyOnWriteIntArrayList()
Creates a new ArrayList with a Empty array.
|
CopyOnWriteIntArrayList(java.util.Collection<? extends java.lang.Integer> c)
Deprecated.
|
CopyOnWriteIntArrayList(int... a)
Creates a new ArrayList with a Copy of the array
|
CopyOnWriteIntArrayList(int[] a,
int length)
Creates a new ArrayList with a Copy of the array with a custom length
|
CopyOnWriteIntArrayList(int[] a,
int offset,
int length)
Creates a new ArrayList with a Copy of the array with in the custom range.
|
CopyOnWriteIntArrayList(IntCollection c)
Creates a new ArrayList a copy with the contents of the Collection.
|
CopyOnWriteIntArrayList(IntList l)
Creates a new ArrayList a copy with the contents of the List.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(int e)
Appends the specified element to the end of this list.
|
void |
add(int index,
int e)
Appends the specified element to the index of the list
|
boolean |
addAll(int[] e,
int offset,
int length)
A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
boolean |
addAll(int index,
java.util.Collection<? extends java.lang.Integer> c)
Deprecated.
|
boolean |
addAll(int index,
IntCollection c)
Appends the specified elements to the index of the list.
|
boolean |
addAll(int index,
IntList c)
Appends the specified elements to the index of the list.
|
void |
addElements(int from,
int[] 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(int e)
A Type Specific implementation of the Collection#contains function.
|
boolean |
contains(java.lang.Object o)
Deprecated.
|
CopyOnWriteIntArrayList |
copy()
A Function that does a shallow clone of the Collection itself.
|
int |
count(Int2BooleanFunction filter)
Helper function to reduce stream usage that allows to count the valid elements.
|
int[] |
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.IntBuffer buffer)
Helper function that allows to fastFill a buffer reducing the duplication requirement
|
int |
findFirst(Int2BooleanFunction filter)
Helper function to reduce stream usage that allows to filter for the first match.
|
<E> void |
forEach(E input,
ObjectIntConsumer<E> action)
Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.
|
void |
forEach(IntConsumer action)
A Type Specific foreach function that reduces (un)boxing
|
int[] |
getElements(int from,
int[] a,
int offset,
int length)
A function to fast fetch elements from the list
|
int |
getInt(int index)
A Type-Specific get function to reduce (un)boxing
|
int |
indexOf(int e)
A Type-Specific function to find the index of a given element
|
int |
indexOf(java.lang.Object o)
Deprecated.
|
int |
lastIndexOf(int e)
A Type-Specific function to find the last index of a given element
|
int |
lastIndexOf(java.lang.Object o)
Deprecated.
|
IntListIterator |
listIterator(int index)
A Type-Specific Iterator of listIterator
|
boolean |
matchesAll(Int2BooleanFunction filter)
Helper function to reduce stream usage that allows to filter for all matches.
|
boolean |
matchesAny(Int2BooleanFunction filter)
Helper function to reduce stream usage that allows to filter for any matches.
|
boolean |
matchesNone(Int2BooleanFunction filter)
Helper function to reduce stream usage that allows to filter for no matches.
|
int |
peek(int index)
Provides the Selected Object from the stack.
|
int |
pop()
A Type-Specific pop function to reduce (un)boxing
|
java.util.stream.IntStream |
primitiveStream()
Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
void |
push(int e)
Appends the specified element to the end of this Stack.
|
int |
reduce(int identity,
IntIntUnaryOperator operator)
Performs a reduction on the
elements of this Iterable
|
int |
reduce(IntIntUnaryOperator operator)
Performs a reduction on the
elements of this Iterable
|
boolean |
remIf(java.util.function.IntPredicate filter)
A optimized List#removeIf(Predicate) that more quickly removes elements from the list then the ArrayList implementation
|
boolean |
remInt(int type)
A Type-Specific implementation of remove.
|
boolean |
removeAll(java.util.Collection<?> c)
Deprecated.
|
boolean |
removeAll(IntCollection c)
A function to remove all elements that were provided in the other collection
|
boolean |
removeAll(IntCollection c,
IntConsumer 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.Integer> filter)
Deprecated.
|
int |
removeInt(int index)
A Type-Specific remove function to reduce (un)boxing
|
void |
replaceAll(java.util.function.UnaryOperator<java.lang.Integer> o)
Deprecated.
|
void |
replaceInts(java.util.function.IntUnaryOperator o)
A Type-Specific replace function to reduce (un)boxing
|
boolean |
retainAll(java.util.Collection<?> c)
Deprecated.
|
boolean |
retainAll(IntCollection 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(IntCollection c,
IntConsumer r)
A Type-Specific retainAll function that reduces (un)boxing.
|
int |
set(int index,
int 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(IntComparator c)
Sorts the elements specified by the Natural order either by using the Comparator or the elements
|
IntSplititerator |
spliterator()
A Type Specific Type Splititerator to reduce boxing/unboxing
|
IntList |
subList(int fromIndex,
int toIndex)
A Type-Specific List of subList
|
int |
swapRemove(int index)
A Highly Optimized remove function that removes the desired element.
|
java.lang.Object[] |
toArray()
Deprecated.
|
<E> E[] |
toArray(E[] a)
Deprecated.
|
int[] |
toIntArray(int[] 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(IntComparator c)
Sorts the elements specified by the Natural order either by using the Comparator or the elements using a unstable sort
|
add, addAll, addAll, addAll, equals, hashCode, iterator, listIterator, swapRemoveIntadd, containsAll, containsAll, containsAny, containsAny, remove, toIntArrayclearAndTrim, trimadd, addElements, addElements, addIfAbsent, addIfPresent, get, getElements, remove, remove, set, sort, synchronize, synchronize, unmodifiable, unstableSortaddAll, addAll, containsAll, containsAny, containsAny, parallelPrimitiveStream, pour, toIntArrayarrayflatMap, asAsync, distinct, filter, flatMap, forEach, limit, map, peek, pourAsList, pourAsSet, sortedpublic CopyOnWriteIntArrayList()
@Deprecated public CopyOnWriteIntArrayList(java.util.Collection<? extends java.lang.Integer> c)
c - the elements that should be added into the listpublic CopyOnWriteIntArrayList(IntCollection c)
c - the elements that should be added into the listpublic CopyOnWriteIntArrayList(IntList l)
l - the elements that should be added into the listpublic CopyOnWriteIntArrayList(int... a)
a - the array that should be copiedpublic CopyOnWriteIntArrayList(int[] a,
int length)
a - the array that should be copiedlength - the desired length that should be copiedpublic CopyOnWriteIntArrayList(int[] 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 boolean add(int e)
add in interface IntCollectionadd in interface IntListadd in class AbstractIntListe - element to be appended to this listCollection.add(E))List.add(Object)public void push(int e)
push in interface IntStacke - element to be appended to this StackStack.push(Object)public void add(int index,
int e)
@Deprecated
public boolean addAll(int index,
java.util.Collection<? extends java.lang.Integer> c)
addAll in interface java.util.List<java.lang.Integer>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,
IntCollection c)
addAll in interface IntListindex - 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,
IntList c)
public boolean addAll(int[] e,
int offset,
int length)
IntCollectionaddAll in interface IntCollectione - 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,
int[] a,
int offset,
int length)
addElements in interface IntListfrom - 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 int[] getElements(int from,
int[] a,
int offset,
int length)
getElements in interface IntListfrom - 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 IntListfrom - 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 int[] extractElements(int from,
int to)
extractElements in interface IntListfrom - 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.IntBuffer buffer)
IntListfillBuffer in interface IntListbuffer - where the data should be stored in.@Deprecated public boolean contains(java.lang.Object o)
contains in interface java.util.Collection<java.lang.Integer>contains in interface java.util.List<java.lang.Integer>contains in interface IntCollectioncontains in interface IntListcontains in class AbstractIntCollectiono - the element that is searched for@Deprecated public int indexOf(java.lang.Object o)
indexOf in interface java.util.List<java.lang.Integer>indexOf in interface IntListindexOf in class AbstractIntListo - the element that is searched for@Deprecated public int lastIndexOf(java.lang.Object o)
lastIndexOf in interface java.util.List<java.lang.Integer>lastIndexOf in interface IntListlastIndexOf in class AbstractIntListo - the element that is searched forpublic boolean contains(int e)
contains in interface IntCollectioncontains in class AbstractIntCollectione - the element that is searched for.public int indexOf(int e)
indexOf in interface IntListindexOf in class AbstractIntListe - the element that is searched forpublic int lastIndexOf(int e)
lastIndexOf in interface IntListlastIndexOf in class AbstractIntListe - the element that is searched forpublic void sort(IntComparator c)
sort in interface IntListc - the sorter of the elements, can be nullList.sort(java.util.Comparator),
IntArrays.stableSort(int[], IntComparator)public void unstableSort(IntComparator c)
unstableSort in interface IntListc - the sorter of the elements, can be nullList.sort(java.util.Comparator),
IntArrays.unstableSort(int[], IntComparator)public int getInt(int index)
public int peek(int index)
peek in interface IntStackindex - of the element that should be providedjava.lang.ArrayIndexOutOfBoundsException - if the index is out of boundsStack.peek(int)public IntListIterator listIterator(int index)
IntListlistIterator in interface java.util.List<java.lang.Integer>listIterator in interface IntListlistIterator in class AbstractIntListList.listIterator(int)public IntList subList(int fromIndex, int toIndex)
IntListsubList in interface java.util.List<java.lang.Integer>subList in interface IntListsubList in class AbstractIntListList.subList(int, int)public void forEach(IntConsumer action)
forEach in interface IntIterableaction - 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,m=data.length;i<m;i++)
action.accept(data[i]);
public <E> void forEach(E input,
ObjectIntConsumer<E> action)
IntIterableforEach in interface IntIterableE - the generic type of the Objectinput - the object that should be includedaction - The action to be performed for each elementpublic boolean matchesAny(Int2BooleanFunction filter)
IntIterablematchesAny in interface IntIterablefilter - that should be appliedpublic boolean matchesNone(Int2BooleanFunction filter)
IntIterablematchesNone in interface IntIterablefilter - that should be appliedpublic boolean matchesAll(Int2BooleanFunction filter)
IntIterablematchesAll in interface IntIterablefilter - that should be appliedpublic int findFirst(Int2BooleanFunction filter)
IntIterablefindFirst in interface IntIterablefilter - that should be appliedpublic int reduce(int identity,
IntIntUnaryOperator operator)
IntIterablereduce in interface IntIterableidentity - the start valueoperator - the operation that should be appliedpublic int reduce(IntIntUnaryOperator operator)
IntIterablereduce in interface IntIterableoperator - the operation that should be appliedpublic int count(Int2BooleanFunction filter)
IntIterablecount in interface IntIterablefilter - that should be appliedpublic int set(int index,
int e)
@Deprecated public void replaceAll(java.util.function.UnaryOperator<java.lang.Integer> o)
replaceAll in interface java.util.List<java.lang.Integer>replaceAll in interface IntListo - the action to replace the valuesjava.lang.NullPointerException - if o is nullpublic void replaceInts(java.util.function.IntUnaryOperator o)
replaceInts in interface IntListo - the action to replace the valuesjava.lang.NullPointerException - if o is nullpublic int removeInt(int index)
public int swapRemove(int index)
IntListswapRemove in interface IntListindex - the index of the element to be removedpublic boolean remInt(int type)
remInt in interface IntCollectionremInt in class AbstractIntCollectiontype - the element that is searched forCollection.remove(Object)public int pop()
pop in interface IntStackjava.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.Integer>removeAll in interface java.util.List<java.lang.Integer>removeAll in class java.util.AbstractCollection<java.lang.Integer>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.Integer>retainAll in interface java.util.List<java.lang.Integer>retainAll in class java.util.AbstractCollection<java.lang.Integer>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.Integer> filter)
removeIf in interface java.util.Collection<java.lang.Integer>removeIf in interface IntCollectionfilter - the filter to remove elementspublic boolean removeAll(IntCollection c)
removeAll in interface IntCollectionremoveAll in class AbstractIntCollectionc - the elements that should be removedjava.lang.NullPointerException - if the collection is nullCollection.removeAll(Collection)public boolean removeAll(IntCollection c, IntConsumer r)
IntCollectionremoveAll in interface IntCollectionremoveAll in class AbstractIntCollectionc - the collection of elements that should be removedr - elements that got removedCollection.removeAll(Collection)public boolean retainAll(IntCollection c)
retainAll in interface IntCollectionretainAll in class AbstractIntCollectionc - 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(IntCollection c, IntConsumer r)
IntCollectionretainAll in interface IntCollectionretainAll in class AbstractIntCollectionc - the collection of elements that should be keptr - elements that got removedCollection.retainAll(Collection)public boolean remIf(java.util.function.IntPredicate filter)
remIf in interface IntCollectionfilter - the filter to remove elementsCollection.removeIf(Predicate)@Deprecated public java.lang.Object[] toArray()
toArray in interface java.util.Collection<java.lang.Integer>toArray in interface java.util.List<java.lang.Integer>toArray in class java.util.AbstractCollection<java.lang.Integer>@Deprecated public <E> E[] toArray(E[] a)
toArray in interface java.util.Collection<java.lang.Integer>toArray in interface java.util.List<java.lang.Integer>toArray in class java.util.AbstractCollection<java.lang.Integer>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 int[] toIntArray(int[] a)
AbstractIntCollectiontoIntArray in interface IntCollectiontoIntArray in class AbstractIntCollectiona - 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()
public void size(int size)
size in interface IntListsize in class AbstractIntListsize - 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 CopyOnWriteIntArrayList copy()
IntCollectioncopy in interface IntCollectioncopy in interface IntListcopy in class AbstractIntListpublic java.util.stream.IntStream primitiveStream()
primitiveStream in interface IntCollectionpublic IntSplititerator spliterator()
spliterator in interface java.lang.Iterable<java.lang.Integer>spliterator in interface java.util.Collection<java.lang.Integer>spliterator in interface java.util.List<java.lang.Integer>spliterator in interface IntCollectionspliterator in interface IntIterablespliterator in interface IntList