public class CopyOnWriteShortArrayList extends AbstractShortList implements ITrimmable, ShortStack
This implementation is optimized to improve how data is processed with interfaces like ITrimmable, ShortStack
and with optimized functions that use type-specific implementations for primitives and optimized logic for bulkactions.
ISizeProvider.CollectionSize| Constructor and Description |
|---|
CopyOnWriteShortArrayList()
Creates a new ArrayList with a Empty array.
|
CopyOnWriteShortArrayList(java.util.Collection<? extends java.lang.Short> c)
Deprecated.
|
CopyOnWriteShortArrayList(short... a)
Creates a new ArrayList with a Copy of the array
|
CopyOnWriteShortArrayList(short[] a,
int length)
Creates a new ArrayList with a Copy of the array with a custom length
|
CopyOnWriteShortArrayList(short[] a,
int offset,
int length)
Creates a new ArrayList with a Copy of the array with in the custom range.
|
CopyOnWriteShortArrayList(ShortCollection c)
Creates a new ArrayList a copy with the contents of the Collection.
|
CopyOnWriteShortArrayList(ShortList l)
Creates a new ArrayList a copy with the contents of the List.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
short e)
Appends the specified element to the index of the list
|
boolean |
add(short e)
Appends the specified element to the end of this list.
|
boolean |
addAll(int index,
java.util.Collection<? extends java.lang.Short> c)
Deprecated.
|
boolean |
addAll(int index,
ShortCollection c)
Appends the specified elements to the index of the list.
|
boolean |
addAll(int index,
ShortList c)
Appends the specified elements to the index of the list.
|
boolean |
addAll(short[] e,
int offset,
int length)
A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
void |
addElements(int from,
short[] 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.
|
boolean |
contains(short e)
A Type Specific implementation of the Collection#contains function.
|
CopyOnWriteShortArrayList |
copy()
A Function that does a shallow clone of the Collection itself.
|
int |
count(ShortPredicate filter)
Helper function to reduce stream usage that allows to count the valid elements.
|
short[] |
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.ShortBuffer buffer)
Helper function that allows to fastFill a buffer reducing the duplication requirement
|
short |
findFirst(ShortPredicate filter)
Helper function to reduce stream usage that allows to filter for the first match.
|
<E> void |
forEach(E input,
ObjectShortConsumer<E> action)
Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.
|
void |
forEach(ShortConsumer action)
A Type Specific foreach function that reduces (un)boxing
|
short[] |
getElements(int from,
short[] a,
int offset,
int length)
A function to fast fetch elements from the list
|
short |
getShort(int index)
A Type-Specific get function to reduce (un)boxing
|
int |
indexOf(java.lang.Object o)
Deprecated.
|
int |
indexOf(short e)
A Type-Specific function to find the index of a given element
|
int |
lastIndexOf(java.lang.Object o)
Deprecated.
|
int |
lastIndexOf(short e)
A Type-Specific function to find the last index of a given element
|
ShortListIterator |
listIterator(int index)
A Type-Specific Iterator of listIterator
|
boolean |
matchesAll(ShortPredicate filter)
Helper function to reduce stream usage that allows to filter for all matches.
|
boolean |
matchesAny(ShortPredicate filter)
Helper function to reduce stream usage that allows to filter for any matches.
|
boolean |
matchesNone(ShortPredicate filter)
Helper function to reduce stream usage that allows to filter for no matches.
|
short |
peek(int index)
Provides the Selected Object from the stack.
|
short |
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(short e)
Appends the specified element to the end of this Stack.
|
short |
reduce(short identity,
ShortShortUnaryOperator operator)
Performs a reduction on the
elements of this Iterable
|
short |
reduce(ShortShortUnaryOperator 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 |
removeAll(java.util.Collection<?> c)
Deprecated.
|
boolean |
removeAll(ShortCollection c)
A function to remove all elements that were provided in the other collection
|
boolean |
removeAll(ShortCollection c,
ShortConsumer 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.Short> filter)
Deprecated.
|
short |
removeShort(int index)
A Type-Specific remove function to reduce (un)boxing
|
boolean |
remShort(short type)
A Type-Specific implementation of remove.
|
void |
replaceAll(java.util.function.UnaryOperator<java.lang.Short> o)
Deprecated.
|
void |
replaceShorts(java.util.function.IntUnaryOperator o)
A Type-Specific replace function to reduce (un)boxing
|
boolean |
retainAll(java.util.Collection<?> c)
Deprecated.
|
boolean |
retainAll(ShortCollection 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(ShortCollection c,
ShortConsumer r)
A Type-Specific retainAll function that reduces (un)boxing.
|
short |
set(int index,
short 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(ShortComparator c)
Sorts the elements specified by the Natural order either by using the Comparator or the elements
|
ShortSplititerator |
spliterator()
A Type Specific Type Splititerator to reduce boxing/unboxing
|
ShortList |
subList(int fromIndex,
int toIndex)
A Type-Specific List of subList
|
short |
swapRemove(int index)
A Highly Optimized remove function that removes the desired element.
|
java.lang.Object[] |
toArray()
Deprecated.
|
<E> E[] |
toArray(E[] a)
Deprecated.
|
short[] |
toShortArray(short[] 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(ShortComparator 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, swapRemoveShortadd, containsAll, containsAll, containsAny, containsAny, remove, toShortArrayclearAndTrim, trimisEmpty, topadd, addElements, addElements, addIfAbsent, addIfPresent, forEachIndexed, get, getElements, remove, remove, set, sort, synchronize, synchronize, unmodifiable, unstableSortaddAll, addAll, containsAll, containsAny, containsAny, parallelPrimitiveStream, pour, toShortArrayarrayflatMap, asAsync, distinct, filter, flatMap, forEach, limit, map, peek, pourAsList, pourAsSet, repeat, sortedofpublic CopyOnWriteShortArrayList()
@Deprecated public CopyOnWriteShortArrayList(java.util.Collection<? extends java.lang.Short> c)
c - the elements that should be added into the listpublic CopyOnWriteShortArrayList(ShortCollection c)
c - the elements that should be added into the listpublic CopyOnWriteShortArrayList(ShortList l)
l - the elements that should be added into the listpublic CopyOnWriteShortArrayList(short... a)
a - the array that should be copiedpublic CopyOnWriteShortArrayList(short[] a,
int length)
a - the array that should be copiedlength - the desired length that should be copiedpublic CopyOnWriteShortArrayList(short[] 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(short e)
add in interface ShortCollectionadd in interface ShortListadd in class AbstractShortListe - element to be appended to this listCollection.add(E))List.add(Object)public void push(short e)
push in interface ShortStacke - element to be appended to this StackStack.push(Object)public void add(int index,
short e)
@Deprecated
public boolean addAll(int index,
java.util.Collection<? extends java.lang.Short> c)
addAll in interface java.util.List<java.lang.Short>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,
ShortCollection c)
addAll in interface ShortListindex - 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,
ShortList c)
public boolean addAll(short[] e,
int offset,
int length)
ShortCollectionaddAll in interface ShortCollectione - 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,
short[] a,
int offset,
int length)
addElements in interface ShortListfrom - 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 short[] getElements(int from,
short[] a,
int offset,
int length)
getElements in interface ShortListfrom - 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 ShortListfrom - 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 short[] extractElements(int from,
int to)
extractElements in interface ShortListfrom - 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.ShortBuffer buffer)
ShortListfillBuffer in interface ShortListbuffer - where the data should be stored in.@Deprecated public boolean contains(java.lang.Object o)
contains in interface java.util.Collection<java.lang.Short>contains in interface java.util.List<java.lang.Short>contains in interface ShortCollectioncontains in interface ShortListcontains in class AbstractShortCollectiono - the element that is searched for@Deprecated public int indexOf(java.lang.Object o)
indexOf in interface java.util.List<java.lang.Short>indexOf in interface ShortListindexOf in class AbstractShortListo - the element that is searched for@Deprecated public int lastIndexOf(java.lang.Object o)
lastIndexOf in interface java.util.List<java.lang.Short>lastIndexOf in interface ShortListlastIndexOf in class AbstractShortListo - the element that is searched forpublic boolean contains(short e)
contains in interface ShortCollectioncontains in class AbstractShortCollectione - the element that is searched for.public int indexOf(short e)
indexOf in interface ShortListindexOf in class AbstractShortListe - the element that is searched forpublic int lastIndexOf(short e)
lastIndexOf in interface ShortListlastIndexOf in class AbstractShortListe - the element that is searched forpublic void sort(ShortComparator c)
sort in interface ShortListc - the sorter of the elements, can be nullList.sort(java.util.Comparator),
ShortArrays.stableSort(short[], ShortComparator)public void unstableSort(ShortComparator c)
unstableSort in interface ShortListc - the sorter of the elements, can be nullList.sort(java.util.Comparator),
ShortArrays.unstableSort(short[], ShortComparator)public short getShort(int index)
public short peek(int index)
peek in interface ShortStackindex - of the element that should be providedjava.lang.ArrayIndexOutOfBoundsException - if the index is out of boundsStack.peek(int)public ShortListIterator listIterator(int index)
ShortListlistIterator in interface java.util.List<java.lang.Short>listIterator in interface ShortListlistIterator in class AbstractShortListList.listIterator(int)public ShortList subList(int fromIndex, int toIndex)
ShortListsubList in interface java.util.List<java.lang.Short>subList in interface ShortListsubList in class AbstractShortListList.subList(int, int)public void forEach(ShortConsumer action)
forEach in interface ShortIterableaction - 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,
ObjectShortConsumer<E> action)
ShortIterableforEach in interface ShortIterableE - the generic type of the Objectinput - the object that should be includedaction - The action to be performed for each elementpublic boolean matchesAny(ShortPredicate filter)
ShortIterablematchesAny in interface ShortIterablefilter - that should be appliedpublic boolean matchesNone(ShortPredicate filter)
ShortIterablematchesNone in interface ShortIterablefilter - that should be appliedpublic boolean matchesAll(ShortPredicate filter)
ShortIterablematchesAll in interface ShortIterablefilter - that should be appliedpublic short findFirst(ShortPredicate filter)
ShortIterablefindFirst in interface ShortIterablefilter - that should be appliedpublic short reduce(short identity,
ShortShortUnaryOperator operator)
ShortIterablereduce in interface ShortIterableidentity - the start valueoperator - the operation that should be appliedpublic short reduce(ShortShortUnaryOperator operator)
ShortIterablereduce in interface ShortIterableoperator - the operation that should be appliedpublic int count(ShortPredicate filter)
ShortIterablecount in interface ShortIterablefilter - that should be appliedpublic short set(int index,
short e)
@Deprecated public void replaceAll(java.util.function.UnaryOperator<java.lang.Short> o)
replaceAll in interface java.util.List<java.lang.Short>replaceAll in interface ShortListo - the action to replace the valuesjava.lang.NullPointerException - if o is nullpublic void replaceShorts(java.util.function.IntUnaryOperator o)
replaceShorts in interface ShortListo - the action to replace the valuesjava.lang.NullPointerException - if o is nullpublic short removeShort(int index)
removeShort in interface ShortListindex - the index of the element to fetchjava.lang.IndexOutOfBoundsException - if the index is out of rangeList.remove(int)public short swapRemove(int index)
ShortListswapRemove in interface ShortListindex - the index of the element to be removedpublic boolean remShort(short type)
remShort in interface ShortCollectionremShort in class AbstractShortCollectiontype - the element that is searched forCollection.remove(Object)public short pop()
pop in interface ShortStackjava.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.Short>removeAll in interface java.util.List<java.lang.Short>removeAll in class java.util.AbstractCollection<java.lang.Short>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.Short>retainAll in interface java.util.List<java.lang.Short>retainAll in class java.util.AbstractCollection<java.lang.Short>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.Short> filter)
removeIf in interface java.util.Collection<java.lang.Short>removeIf in interface ShortCollectionfilter - the filter to remove elementspublic boolean removeAll(ShortCollection c)
removeAll in interface ShortCollectionremoveAll in class AbstractShortCollectionc - the elements that should be removedjava.lang.NullPointerException - if the collection is nullCollection.removeAll(Collection)public boolean removeAll(ShortCollection c, ShortConsumer r)
ShortCollectionremoveAll in interface ShortCollectionremoveAll in class AbstractShortCollectionc - the collection of elements that should be removedr - elements that got removedCollection.removeAll(Collection)public boolean retainAll(ShortCollection c)
retainAll in interface ShortCollectionretainAll in class AbstractShortCollectionc - 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(ShortCollection c, ShortConsumer r)
ShortCollectionretainAll in interface ShortCollectionretainAll in class AbstractShortCollectionc - 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 ShortCollectionfilter - the filter to remove elementsCollection.removeIf(Predicate)@Deprecated public java.lang.Object[] toArray()
toArray in interface java.util.Collection<java.lang.Short>toArray in interface java.util.List<java.lang.Short>toArray in class java.util.AbstractCollection<java.lang.Short>@Deprecated public <E> E[] toArray(E[] a)
toArray in interface java.util.Collection<java.lang.Short>toArray in interface java.util.List<java.lang.Short>toArray in class java.util.AbstractCollection<java.lang.Short>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 short[] toShortArray(short[] a)
AbstractShortCollectiontoShortArray in interface ShortCollectiontoShortArray in class AbstractShortCollectiona - 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.Short>size in interface java.util.List<java.lang.Short>size in interface ShortStacksize in interface ISizeProvidersize in class java.util.AbstractCollection<java.lang.Short>public void size(int size)
size in interface ShortListsize in class AbstractShortListsize - the requested amount of elements/room for elementspublic void clear()
clear in interface java.util.Collection<java.lang.Short>clear in interface java.util.List<java.lang.Short>clear in interface ShortStackclear in class java.util.AbstractCollection<java.lang.Short>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 CopyOnWriteShortArrayList copy()
ShortCollectioncopy in interface ShortCollectioncopy in interface ShortListcopy in class AbstractShortListpublic java.util.stream.IntStream primitiveStream()
primitiveStream in interface ShortCollectionpublic ShortSplititerator spliterator()
spliterator in interface java.lang.Iterable<java.lang.Short>spliterator in interface java.util.Collection<java.lang.Short>spliterator in interface java.util.List<java.lang.Short>spliterator in interface ShortCollectionspliterator in interface ShortIterablespliterator in interface ShortList