public class ByteArrayList extends AbstractByteList implements IByteArray, ByteStack
This implementation is optimized to improve how data is processed with interfaces like IByteArray, ByteStack
and with optimized functions that use type-specific implementations for primitives and optimized logic for bulkactions.
| Constructor and Description |
|---|
ByteArrayList()
Creates a new ArrayList with a Empty array.
|
ByteArrayList(byte[] a)
Creates a new ArrayList with a Copy of the array
|
ByteArrayList(byte[] a,
int length)
Creates a new ArrayList with a Copy of the array with a custom length
|
ByteArrayList(byte[] a,
int offset,
int length)
Creates a new ArrayList with a Copy of the array with in the custom range.
|
ByteArrayList(ByteCollection c)
Creates a new ArrayList a copy with the contents of the Collection.
|
ByteArrayList(ByteList l)
Creates a new ArrayList a copy with the contents of the List.
|
ByteArrayList(java.util.Collection<? extends java.lang.Byte> c)
Creates a new ArrayList a copy with the contents of the Collection.
|
ByteArrayList(int size)
Creates a new ArrayList with the specific requested size
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(byte e)
Appends the specified element to the end of this list.
|
void |
add(int index,
byte e)
Appends the specified element to the index of the list
|
boolean |
addAll(int index,
ByteCollection c)
Appends the specified elements to the index of the list.
|
boolean |
addAll(int index,
ByteList c)
Appends the specified elements to the index of the list.
|
boolean |
addAll(int index,
java.util.Collection<? extends java.lang.Byte> c)
Deprecated.
|
void |
addElements(int from,
byte[] 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(byte e)
A Type Specific implementation of the Collection#contains function.
|
boolean |
contains(java.lang.Object o)
Deprecated.
if type-specific but still supported because of special edgecase Object-Comparason features
|
byte[] |
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.
|
byte[] |
extractElements(int from,
int to)
A function to fast extract elements out of the list, this removes the elements that were fetched.
|
void |
forEach(ByteConsumer action)
A Type Specific foreach function that reduces (un)boxing
|
byte |
getByte(int index)
A Type-Specific get function to reduce (un)boxing
|
byte[] |
getElements(int from,
byte[] a,
int offset,
int length)
A function to fast fetch elements from the list
|
int |
indexOf(byte e)
A Type-Specific function to find the index of a given element
|
int |
indexOf(java.lang.Object o)
Deprecated.
if type-specific but still supported because of special edgecase Object-Comparason features
|
int |
lastIndexOf(byte e)
A Type-Specific function to find the last index of a given element
|
int |
lastIndexOf(java.lang.Object o)
Deprecated.
if type-specific but still supported because of special edgecase Object-Comparason features
|
byte |
peekByte(int index)
Provides the Selected Object from the stack.
|
byte |
popByte()
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 |
pushByte(byte e)
Appends the specified element to the end of this Stack.
|
boolean |
remByte(byte type)
A Type-Specific implementation of remove.
|
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(ByteCollection c)
A function to remove all elements that were provided in the other collection
|
boolean |
removeAll(java.util.Collection<?> c)
Deprecated.
if the collection is type-specific
|
byte |
removeByte(int index)
A Type-Specific remove function to reduce (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.Byte> filter)
Deprecated.
if Type-Specific, use #remIf instead
|
void |
replaceAll(java.util.function.UnaryOperator<java.lang.Byte> o)
Deprecated.
|
void |
replaceBytes(java.util.function.IntUnaryOperator o)
A Type-Specific replace function to reduce (un)boxing
|
boolean |
retainAll(ByteCollection 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(java.util.Collection<?> c)
Deprecated.
if the collection is type-specific
|
byte |
set(int index,
byte 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(ByteComparator c)
Sorts the elements specified by the Natural order either by using the Comparator or the elements
|
ByteSplititerator |
spliterator()
A Type Specific Type Splititerator to reduce boxing/unboxing
|
java.lang.Object[] |
toArray()
Deprecated.
|
<E> E[] |
toArray(E[] a)
Deprecated.
|
byte[] |
toByteArray(byte[] 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(ByteComparator c)
Sorts the elements specified by the Natural order either by using the Comparator or the elements using a unstable sort
|
static ByteArrayList |
wrap(byte... a)
Creates a wrapped arraylist that uses the array as backing array
|
static ByteArrayList |
wrap(byte[] a,
int length)
Creates a wrapped arraylist that uses the array as backing array and a custom fill size
|
add, addAll, addAll, equals, hashCode, iterator, listIterator, listIterator, subListadd, addAll, containsAll, containsAny, containsAny, remove, toByteArrayelementsclearAndTrim, trimpeek, pop, push, top, topByteadd, addElements, addElements, get, getElements, remove, remove, set, sort, unstableSortcontainsAll, containsAny, containsAny, parallelPrimitiveStream, toByteArrayforEachpublic ByteArrayList()
public ByteArrayList(int size)
size - the minimum initial size of the Backing arraypublic ByteArrayList(java.util.Collection<? extends java.lang.Byte> c)
c - the elements that should be added into the listpublic ByteArrayList(ByteCollection c)
c - the elements that should be added into the listpublic ByteArrayList(ByteList l)
l - the elements that should be added into the listpublic ByteArrayList(byte[] a)
a - the array that should be copiedpublic ByteArrayList(byte[] a,
int length)
a - the array that should be copiedlength - the desired length that should be copiedpublic ByteArrayList(byte[] 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 ByteArrayList wrap(byte... a)
a - elements that should be wrappedpublic static ByteArrayList wrap(byte[] a, int length)
a - elements that should be wrappedlength - the size of the elements within the arraypublic boolean add(byte e)
add in interface ByteCollectionadd in interface ByteListadd in class AbstractByteListe - element to be appended to this listCollection.add(E))List.add(Object)public void pushByte(byte e)
pushByte in interface ByteStacke - element to be appended to this StackStack.push(Object)public void add(int index,
byte e)
@Deprecated
public boolean addAll(int index,
java.util.Collection<? extends java.lang.Byte> c)
addAll in interface java.util.List<java.lang.Byte>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(int index,
ByteCollection c)
addAll in interface ByteListindex - 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,
ByteList c)
public void addElements(int from,
byte[] a,
int offset,
int length)
addElements in interface ByteListfrom - 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 byte[] getElements(int from,
byte[] a,
int offset,
int length)
getElements in interface ByteListfrom - 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 ByteListfrom - 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 byte[] extractElements(int from,
int to)
extractElements in interface ByteListfrom - 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)@Deprecated public boolean contains(java.lang.Object o)
contains in interface java.util.Collection<java.lang.Byte>contains in interface java.util.List<java.lang.Byte>contains in interface ByteCollectioncontains in interface ByteListcontains in class AbstractByteCollectiono - the element that is searched for@Deprecated public int indexOf(java.lang.Object o)
indexOf in interface java.util.List<java.lang.Byte>indexOf in interface ByteListindexOf in class AbstractByteListo - the element that is searched for@Deprecated public int lastIndexOf(java.lang.Object o)
lastIndexOf in interface java.util.List<java.lang.Byte>lastIndexOf in interface ByteListlastIndexOf in class AbstractByteListo - the element that is searched forpublic boolean contains(byte e)
contains in interface ByteCollectioncontains in class AbstractByteCollectione - the element that is searched for.public int indexOf(byte e)
indexOf in interface ByteListindexOf in class AbstractByteListe - the element that is searched forpublic int lastIndexOf(byte e)
lastIndexOf in interface ByteListlastIndexOf in class AbstractByteListe - the element that is searched forpublic void sort(ByteComparator c)
sort in interface ByteListc - the sorter of the elements, can be nullList.sort(java.util.Comparator),
ByteArrays.stableSort(byte[], ByteComparator)public void unstableSort(ByteComparator c)
unstableSort in interface ByteListc - the sorter of the elements, can be nullList.sort(java.util.Comparator),
ByteArrays.unstableSort(byte[], ByteComparator)public byte getByte(int index)
public byte peekByte(int index)
peekByte in interface ByteStackindex - of the element that should be providedjava.lang.ArrayIndexOutOfBoundsException - if the index is out of boundsStack.peek(int)public byte[] elements()
elements in interface IByteArrayjava.lang.ClassCastException - if the return type does not match the underlying array. (Only for Object Implementations)public void forEach(ByteConsumer action)
forEach in interface ByteIterableaction - 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 byte set(int index,
byte e)
@Deprecated public void replaceAll(java.util.function.UnaryOperator<java.lang.Byte> o)
replaceAll in interface java.util.List<java.lang.Byte>replaceAll in interface ByteListo - the action to replace the valuesjava.lang.NullPointerException - if o is nullpublic void replaceBytes(java.util.function.IntUnaryOperator o)
replaceBytes in interface ByteListo - the action to replace the valuesjava.lang.NullPointerException - if o is nullpublic byte removeByte(int index)
removeByte in interface ByteListindex - the index of the element to fetchjava.lang.IndexOutOfBoundsException - if the index is out of rangeList.remove(int)public boolean remByte(byte type)
remByte in interface ByteCollectionremByte in class AbstractByteCollectiontype - the element that is searched forCollection.remove(Object)public byte popByte()
popByte in interface ByteStackjava.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.Byte>removeAll in interface java.util.List<java.lang.Byte>removeAll in class java.util.AbstractCollection<java.lang.Byte>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.Byte>retainAll in interface java.util.List<java.lang.Byte>retainAll in class java.util.AbstractCollection<java.lang.Byte>c - the elements that should be kept. If empty, ByteArrayList#clear is called.java.lang.NullPointerException - if the collection is null@Deprecated public boolean removeIf(java.util.function.Predicate<? super java.lang.Byte> filter)
removeIf in interface java.util.Collection<java.lang.Byte>removeIf in interface ByteCollectionfilter - the filter to remove elementspublic boolean removeAll(ByteCollection c)
removeAll in interface ByteCollectionremoveAll in class AbstractByteCollectionc - the elements that should be removedjava.lang.NullPointerException - if the collection is nullCollection.removeAll(Collection)public boolean retainAll(ByteCollection c)
retainAll in interface ByteCollectionretainAll in class AbstractByteCollectionc - the elements that should be kept. If empty, ByteArrayList#clear is called.java.lang.NullPointerException - if the collection is nullCollection.retainAll(Collection)public boolean remIf(java.util.function.IntPredicate filter)
remIf in interface ByteCollectionfilter - the filter to remove elementsCollection.removeIf(Predicate)@Deprecated public java.lang.Object[] toArray()
toArray in interface java.util.Collection<java.lang.Byte>toArray in interface java.util.List<java.lang.Byte>toArray in class java.util.AbstractCollection<java.lang.Byte>@Deprecated public <E> E[] toArray(E[] a)
toArray in interface java.util.Collection<java.lang.Byte>toArray in interface java.util.List<java.lang.Byte>toArray in class java.util.AbstractCollection<java.lang.Byte>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 byte[] toByteArray(byte[] a)
AbstractByteCollectiontoByteArray in interface ByteCollectiontoByteArray in class AbstractByteCollectiona - 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.Byte>size in interface java.util.List<java.lang.Byte>size in interface Stack<java.lang.Byte>size in class java.util.AbstractCollection<java.lang.Byte>public void size(int size)
size in interface ByteListsize in class AbstractByteListsize - 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 java.util.stream.IntStream primitiveStream()
primitiveStream in interface ByteCollectionpublic ByteSplititerator spliterator()
spliterator in interface java.lang.Iterable<java.lang.Byte>spliterator in interface java.util.Collection<java.lang.Byte>spliterator in interface java.util.List<java.lang.Byte>spliterator in interface ByteCollectionspliterator in interface ByteIterablespliterator in interface ByteList