T - the type of elements maintained by this Collectionpublic class ObjectArrayList<T> extends AbstractObjectList<T> implements IObjectArray<T>, Stack<T>
This implementation is optimized to improve how data is processed with interfaces like IObjectArray, Stack
and with optimized functions that use type-specific implementations for primitives and optimized logic for bulkactions.
| Constructor and Description |
|---|
ObjectArrayList()
Creates a new ArrayList with a Empty array.
|
ObjectArrayList(java.util.Collection<? extends T> c)
Creates a new ArrayList a copy with the contents of the Collection.
|
ObjectArrayList(int size)
Creates a new ArrayList with the specific requested size
|
ObjectArrayList(ObjectCollection<T> c)
Creates a new ArrayList a copy with the contents of the Collection.
|
ObjectArrayList(ObjectList<T> l)
Creates a new ArrayList a copy with the contents of the List.
|
ObjectArrayList(T[] a)
Creates a new ArrayList with a Copy of the array
|
ObjectArrayList(T[] a,
int length)
Creates a new ArrayList with a Copy of the array with a custom length
|
ObjectArrayList(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)
Appends the specified elements to the index of the list.
|
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.
|
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.
if type-specific but still supported because of special edgecase Object-Comparason features
|
T[] |
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.
|
<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.
|
void |
forEach(java.util.function.Consumer<? super T> action)
A Type Specific foreach function that reduces (un)boxing
|
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.
if type-specific but still supported because of special edgecase Object-Comparason features
|
boolean |
isCastable()
Method to indicate if the function is save to use
|
int |
lastIndexOf(java.lang.Object o)
Deprecated.
if type-specific but still supported because of special edgecase Object-Comparason features
|
static <T> ObjectArrayList<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.
|
T |
remove(int index)
A Type-Specific remove function to reduce (un)boxing
|
boolean |
removeAll(java.util.Collection<?> c)
Deprecated.
if the collection is type-specific
|
boolean |
removeAll(ObjectCollection<T> c)
A function to remove all elements that were provided in the other collection
|
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.
if Type-Specific, use #remIf instead
|
void |
replaceAll(java.util.function.UnaryOperator<T> o)
A function to replace all values in the list
|
boolean |
retainAll(java.util.Collection<?> c)
Deprecated.
if the collection is type-specific
|
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
|
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
|
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
|
static <T> ObjectArrayList<T> |
wrap(T... a)
Creates a wrapped arraylist that uses the array as backing array
|
static <T> ObjectArrayList<T> |
wrap(T[] a,
int length)
Creates a wrapped arraylist that uses the array as backing array and a custom fill size
|
addAll, addAll, equals, hashCode, iterator, listIterator, listIterator, subListaddAll, containsAll, containsAny, containsAnyelementsclearAndTrim, trimaddElements, addElements, getElementscontainsAll, containsAny, containsAnypublic ObjectArrayList()
public ObjectArrayList(int size)
size - the minimum initial size of the Backing arraypublic ObjectArrayList(java.util.Collection<? extends T> c)
c - the elements that should be added into the listpublic ObjectArrayList(ObjectCollection<T> c)
c - the elements that should be added into the listpublic ObjectArrayList(ObjectList<T> l)
l - the elements that should be added into the listpublic ObjectArrayList(T[] a)
a - the array that should be copiedpublic ObjectArrayList(T[] a, int length)
a - the array that should be copiedlength - the desired length that should be copiedpublic ObjectArrayList(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> ObjectArrayList<T> wrap(T... a)
T - the type of elements maintained by this Collectiona - elements that should be wrappedpublic static <T> ObjectArrayList<T> wrap(T[] a, int length)
T - the type of elements maintained by this Collectiona - elements that should be wrappedlength - the size of the elements within the arraypublic static <T> ObjectArrayList<T> of(java.lang.Class<T> c)
T - the type of elements maintained by this Collectionc - the type of the arraypublic boolean add(T 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 rangepublic 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 rangepublic 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 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 type 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 OutputArraypublic boolean contains(java.lang.Object o)
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 forpublic 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 T[] elements()
elements in interface IObjectArray<T>java.lang.ClassCastException - if the return type does not match the underlying array. (Only for Object Implementations)public boolean isCastable()
IObjectArrayisCastable in interface IObjectArray<T>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;i<size;i++)
action.accept(data[i]);
public 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 pop()
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 nullpublic 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, ObjectArrayList#clear is called.java.lang.NullPointerException - if the collection is nullpublic 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 retainAll(ObjectCollection<T> c)
retainAll in interface ObjectCollection<T>retainAll in class AbstractObjectCollection<T>c - the elements that should be kept. If empty, ObjectArrayList#clear is called.java.lang.NullPointerException - if the collection is nullCollection.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 void ensureCapacity(int size)
ensureCapacity in interface IArraysize - the desired minimum capacitypublic 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>