T - the keyType of elements maintained by this Collectionpublic class CopyOnWriteObjectArrayList<T> extends AbstractObjectList<T> implements ITrimmable, Stack<T>
This implementation is optimized to improve how data is processed with interfaces like ITrimmable, Stack
and with optimized functions that use type-specific implementations for primitives and optimized logic for bulkactions.
ISizeProvider.CollectionSize| Constructor and Description |
|---|
CopyOnWriteObjectArrayList()
Creates a new ArrayList with a Empty array.
|
CopyOnWriteObjectArrayList(java.util.Collection<? extends T> c)
Deprecated.
|
CopyOnWriteObjectArrayList(ObjectCollection<T> c)
Creates a new ArrayList a copy with the contents of the Collection.
|
CopyOnWriteObjectArrayList(ObjectList<T> l)
Creates a new ArrayList a copy with the contents of the List.
|
CopyOnWriteObjectArrayList(T... a)
Creates a new ArrayList with a Copy of the array
|
CopyOnWriteObjectArrayList(T[] a,
int length)
Creates a new ArrayList with a Copy of the array with a custom length
|
CopyOnWriteObjectArrayList(T[] a,
int offset,
int length)
Creates a new ArrayList with a Copy of the array with in the custom range.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
T e)
Appends the specified element to the index of the list
|
boolean |
add(T e)
Appends the specified element to the end of this list.
|
boolean |
addAll(int index,
java.util.Collection<? extends T> c)
Deprecated.
|
boolean |
addAll(int index,
ObjectCollection<T> c)
Appends the specified elements to the index of the list.
|
boolean |
addAll(int index,
ObjectList<T> c)
Appends the specified elements to the index of the list.
|
boolean |
addAll(T[] e,
int offset,
int length)
A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
void |
addElements(int from,
T[] 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(java.lang.Object o)
Deprecated.
|
CopyOnWriteObjectArrayList<T> |
copy()
A Function that does a shallow clone of the Collection itself.
|
int |
count(java.util.function.Predicate<T> filter)
Helper function to reduce stream usage that allows to count the valid elements.
|
<K> K[] |
extractElements(int from,
int to,
java.lang.Class<K> type)
A function to fast extract elements out of the list, this removes the elements that were fetched.
|
T |
findFirst(java.util.function.Predicate<T> filter)
Helper function to reduce stream usage that allows to filter for the first match.
|
void |
forEach(java.util.function.Consumer<? super T> action)
A Type Specific foreach function that reduces (un)boxing
|
<E> void |
forEach(E input,
ObjectObjectConsumer<E,T> action)
Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.
|
T |
get(int index)
A Type-Specific get function to reduce (un)boxing
|
T[] |
getElements(int from,
T[] a,
int offset,
int length)
A function to fast fetch elements from the list
|
int |
indexOf(java.lang.Object o)
Deprecated.
|
int |
lastIndexOf(java.lang.Object o)
Deprecated.
|
ObjectListIterator<T> |
listIterator(int index)
A Type-Specific Iterator of listIterator
|
boolean |
matchesAll(java.util.function.Predicate<T> filter)
Helper function to reduce stream usage that allows to filter for all matches.
|
boolean |
matchesAny(java.util.function.Predicate<T> filter)
Helper function to reduce stream usage that allows to filter for any matches.
|
boolean |
matchesNone(java.util.function.Predicate<T> filter)
Helper function to reduce stream usage that allows to filter for no matches.
|
static <T> CopyOnWriteObjectArrayList<T> |
of(java.lang.Class<T> c)
Creates a new ArrayList with a EmptyObject array of the Type requested
|
T |
peek(int index)
Provides the Selected Object from the stack.
|
T |
pop()
A Type-Specific pop function to reduce (un)boxing
|
void |
push(T e)
Appends the specified element to the end of this Stack.
|
<E> E |
reduce(E identity,
java.util.function.BiFunction<E,T,E> operator)
Performs a reduction on the
elements of this Iterable
|
T |
reduce(ObjectObjectUnaryOperator<T,T> operator)
Performs a reduction on the
elements of this Iterable
|
T |
remove(int index)
A Type-Specific remove function to reduce (un)boxing
|
boolean |
remove(java.lang.Object type) |
boolean |
removeAll(java.util.Collection<?> c)
Deprecated.
|
boolean |
removeAll(ObjectCollection<T> c)
A function to remove all elements that were provided in the other collection
|
boolean |
removeAll(ObjectCollection<T> c,
java.util.function.Consumer<T> 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 T> filter)
Deprecated.
|
void |
replaceAll(java.util.function.UnaryOperator<T> o)
A function to replace all values in the list
|
boolean |
retainAll(java.util.Collection<?> c)
Deprecated.
|
boolean |
retainAll(ObjectCollection<T> 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(ObjectCollection<T> c,
java.util.function.Consumer<T> r)
A Type-Specific retainAll function that reduces (un)boxing.
|
T |
set(int index,
T 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(java.util.Comparator<? super T> c)
Sorts the elements specified by the Natural order either by using the Comparator or the elements
|
ObjectSplititerator<T> |
spliterator()
A Type Specific Type Splititerator to reduce boxing/unboxing
|
ObjectList<T> |
subList(int fromIndex,
int toIndex)
A Type-Specific List of subList
|
T |
swapRemove(int index)
A Highly Optimized remove function that removes the desired element.
|
java.lang.Object[] |
toArray()
A toArray implementation that ensures the Array itself is a Object.
|
<E> E[] |
toArray(E[] a)
A toArray implementation that ensures the Array itself is a Object.
|
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(java.util.Comparator<? super T> c)
Sorts the elements specified by the Natural order either by using the Comparator or the elements using a unstable sort
|
addAll, addAll, addAll, equals, hashCode, iterator, listIterator, swapRemovecontainsAll, containsAll, containsAny, containsAnyclearAndTrim, trimaddElements, addElements, addIfAbsent, addIfPresent, forEachIndexed, getElements, synchronize, synchronize, unmodifiableaddAll, addAll, containsAll, containsAny, containsAny, pour, toArrayarrayflatMap, asAsync, distinct, filter, flatMap, limit, map, peek, pourAsList, pourAsSet, repeat, sortedofpublic CopyOnWriteObjectArrayList()
@Deprecated public CopyOnWriteObjectArrayList(java.util.Collection<? extends T> c)
c - the elements that should be added into the listpublic CopyOnWriteObjectArrayList(ObjectCollection<T> c)
c - the elements that should be added into the listpublic CopyOnWriteObjectArrayList(ObjectList<T> l)
l - the elements that should be added into the listpublic CopyOnWriteObjectArrayList(T... a)
a - the array that should be copiedpublic CopyOnWriteObjectArrayList(T[] a, int length)
a - the array that should be copiedlength - the desired length that should be copiedpublic CopyOnWriteObjectArrayList(T[] 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 <T> CopyOnWriteObjectArrayList<T> of(java.lang.Class<T> c)
T - the keyType of elements maintained by this Collectionc - the type of the arraypublic boolean add(T e)
add in interface java.util.Collection<T>add in interface java.util.List<T>add in class AbstractObjectList<T>e - element to be appended to this listCollection.add(E))public void push(T e)
public void add(int index,
T e)
add in interface java.util.List<T>index - the index where to append the element toe - the element to append to the listjava.lang.IndexOutOfBoundsException - if index is outside of the lists range@Deprecated
public boolean addAll(int index,
java.util.Collection<? extends T> c)
addAll in interface java.util.List<T>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,
ObjectCollection<T> c)
addAll in interface ObjectList<T>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 rangeList.addAll(int, java.util.Collection)public boolean addAll(int index,
ObjectList<T> c)
addAll in interface ObjectList<T>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 rangepublic boolean addAll(T[] e, int offset, int length)
ObjectCollectionaddAll in interface ObjectCollection<T>e - 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,
T[] a,
int offset,
int length)
addElements in interface ObjectList<T>from - 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 T[] getElements(int from, T[] a, int offset, int length)
getElements in interface ObjectList<T>from - 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 ObjectList<T>from - 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 <K> K[] extractElements(int from,
int to,
java.lang.Class<K> type)
extractElements in interface ObjectList<T>K - the keyType of elements maintained by this Collectionfrom - 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)type - the type of the OutputArray@Deprecated public boolean contains(java.lang.Object o)
@Deprecated public int indexOf(java.lang.Object o)
indexOf in interface java.util.List<T>indexOf in class AbstractObjectList<T>o - the element that is searched for@Deprecated public int lastIndexOf(java.lang.Object o)
lastIndexOf in interface java.util.List<T>lastIndexOf in class AbstractObjectList<T>o - the element that is searched forpublic void sort(java.util.Comparator<? super T> c)
sort in interface java.util.List<T>sort in interface ObjectList<T>c - the sorter of the elements, can be nullList.sort(Comparator)public void unstableSort(java.util.Comparator<? super T> c)
unstableSort in interface ObjectList<T>c - the sorter of the elements, can be nullList.sort(Comparator)public T get(int index)
get in interface java.util.List<T>index - the index of the element to fetchjava.lang.IndexOutOfBoundsException - if the index is out of rangepublic T peek(int index)
peek in interface Stack<T>index - of the element that should be providedjava.lang.ArrayIndexOutOfBoundsException - if the index is out of boundsStack.peek(int)public ObjectListIterator<T> listIterator(int index)
ObjectListlistIterator in interface java.util.List<T>listIterator in interface ObjectList<T>listIterator in class AbstractObjectList<T>List.listIterator(int)public ObjectList<T> subList(int fromIndex, int toIndex)
ObjectListsubList in interface java.util.List<T>subList in interface ObjectList<T>subList in class AbstractObjectList<T>List.subList(int, int)public void forEach(java.util.function.Consumer<? super T> action)
forEach in interface java.lang.Iterable<T>action - 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,
ObjectObjectConsumer<E,T> action)
ObjectIterableforEach in interface ObjectIterable<T>E - 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.Predicate<T> filter)
ObjectIterablematchesAny in interface ObjectIterable<T>filter - that should be appliedpublic boolean matchesNone(java.util.function.Predicate<T> filter)
ObjectIterablematchesNone in interface ObjectIterable<T>filter - that should be appliedpublic boolean matchesAll(java.util.function.Predicate<T> filter)
ObjectIterablematchesAll in interface ObjectIterable<T>filter - that should be appliedpublic T findFirst(java.util.function.Predicate<T> filter)
ObjectIterablefindFirst in interface ObjectIterable<T>filter - that should be appliedpublic <E> E reduce(E identity,
java.util.function.BiFunction<E,T,E> operator)
ObjectIterablereduce in interface ObjectIterable<T>E - the keyType of elements maintained by this Collectionidentity - the start valueoperator - the operation that should be appliedpublic T reduce(ObjectObjectUnaryOperator<T,T> operator)
ObjectIterablereduce in interface ObjectIterable<T>operator - the operation that should be appliedpublic int count(java.util.function.Predicate<T> filter)
ObjectIterablecount in interface ObjectIterable<T>filter - that should be appliedpublic T set(int index, T e)
set in interface java.util.List<T>index - the index of the element to sete - the value that should be setjava.lang.IndexOutOfBoundsException - if the index is out of rangepublic void replaceAll(java.util.function.UnaryOperator<T> o)
replaceAll in interface java.util.List<T>replaceAll in interface ObjectList<T>o - the action to replace the valuesjava.lang.NullPointerException - if o is nullpublic T remove(int index)
remove in interface java.util.List<T>index - the index of the element to fetchjava.lang.IndexOutOfBoundsException - if the index is out of rangepublic T swapRemove(int index)
ObjectListswapRemove in interface ObjectList<T>index - the index of the element to be removedpublic boolean remove(java.lang.Object type)
public T pop()
@Deprecated public boolean removeAll(java.util.Collection<?> c)
removeAll in interface java.util.Collection<T>removeAll in interface java.util.List<T>removeAll in class java.util.AbstractCollection<T>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<T>retainAll in interface java.util.List<T>retainAll in class java.util.AbstractCollection<T>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 T> filter)
removeIf in interface java.util.Collection<T>filter - the filter to remove elementspublic boolean removeAll(ObjectCollection<T> c)
removeAll in interface ObjectCollection<T>removeAll in class AbstractObjectCollection<T>c - the elements that should be removedjava.lang.NullPointerException - if the collection is nullCollection.removeAll(Collection)public boolean removeAll(ObjectCollection<T> c, java.util.function.Consumer<T> r)
ObjectCollectionremoveAll in interface ObjectCollection<T>removeAll in class AbstractObjectCollection<T>c - the collection of elements that should be removedr - elements that got removedCollection.removeAll(Collection)public boolean retainAll(ObjectCollection<T> c)
retainAll in interface ObjectCollection<T>retainAll in class AbstractObjectCollection<T>c - 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(ObjectCollection<T> c, java.util.function.Consumer<T> r)
ObjectCollectionretainAll in interface ObjectCollection<T>retainAll in class AbstractObjectCollection<T>c - the collection of elements that should be keptr - elements that got removedCollection.retainAll(Collection)public java.lang.Object[] toArray()
public <E> E[] toArray(E[] a)
toArray in interface java.util.Collection<T>toArray in interface java.util.List<T>toArray in class java.util.AbstractCollection<T>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 size()
public void size(int size)
size in interface ObjectList<T>size in class AbstractObjectList<T>size - 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 CopyOnWriteObjectArrayList<T> copy()
ObjectCollectioncopy in interface ObjectCollection<T>copy in interface ObjectList<T>copy in class AbstractObjectList<T>public ObjectSplititerator<T> spliterator()
spliterator in interface java.lang.Iterable<T>spliterator in interface java.util.Collection<T>spliterator in interface java.util.List<T>spliterator in interface ObjectCollection<T>spliterator in interface ObjectIterable<T>spliterator in interface ObjectList<T>