TARRAY - array type (useful for primitive arrays, otherwise it should be T[])T - single type - as it isn't possible to use primitive types as generic, you will give an immutable like
Float or Byte.public class ArrSegList<TARRAY,T> extends Object implements List<T>
SegmentList instead!
Because of constraint java generics, it is not possible to use with primitives as generics directly. that's why we
use the TARRAY (normally a primitive array like float[]). If you don't use primitive arrays, the TARRAY type will be
nothing more than T[].
Most List interface methods are implemented - but not sublists and iterations! It is possible to add segments
itself. if they have the size of segmentation, they may be add directly.
Use: - standard constructing (e.g. for float): new ArrSegList(float.class) - add(Object)to add a single object -addSegment(Object)to add a primitive array -get(int)-toArray()to get all segments wrapped into a new array.
| Modifier and Type | Field and Description |
|---|---|
protected SegmentList<TARRAY,T> |
seg
segmentation list - holding all segments
|
protected int |
segmentation
size of segmentation arrays
|
| Constructor and Description |
|---|
ArrSegList()
constructor
|
ArrSegList(Class<T> type) |
ArrSegList(Class<T> type,
int segmentation,
int capacity)
constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
T element) |
boolean |
add(T newItem)
adds a new element to the segmentation array
|
boolean |
addAll(Collection<? extends T> c) |
boolean |
addAll(int index,
Collection<? extends T> c) |
boolean |
addSegment(TARRAY newSegment)
add
|
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
T |
get(int index)
gets the value at the given array index
|
TARRAY |
getLastSegment()
getLastSegment
|
int |
indexOf(Object o) |
boolean |
isEmpty() |
Iterator<T> |
iterator() |
int |
lastIndexOf(Object o) |
ListIterator<T> |
listIterator() |
ListIterator<T> |
listIterator(int index) |
T |
remove(int index) |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
T |
set(int index,
T element) |
int |
size()
size
|
List<T> |
subList(int fromIndex,
int toIndex) |
Object[] |
toArray()
creates one new primitive array holding all stored elements. please use
toSegmentArray() instead, if you
not have to use the list-interface. |
<T> T[] |
toArray(T[] a) |
TARRAY |
toSegmentArray()
creates one new primitive array holding all stored elements
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitequals, hashCode, replaceAll, sort, spliteratorparallelStream, removeIf, streamprotected SegmentList<TARRAY,T> seg
protected int segmentation
public T get(int index)
public final TARRAY getLastSegment()
public boolean add(T newItem)
public boolean addSegment(TARRAY newSegment)
newSegment - new segmentpublic int size()
public TARRAY toSegmentArray()
public Object[] toArray()
toSegmentArray() instead, if you
not have to use the list-interface.public boolean isEmpty()
public boolean contains(Object o)
public <T> T[] toArray(T[] a)
public boolean remove(Object o)
public boolean containsAll(Collection<?> c)
containsAll in interface Collection<T>containsAll in interface List<T>public boolean addAll(Collection<? extends T> c)
public boolean addAll(int index,
Collection<? extends T> c)
public boolean removeAll(Collection<?> c)
public boolean retainAll(Collection<?> c)
public void clear()
public int lastIndexOf(Object o)
lastIndexOf in interface List<T>public ListIterator<T> listIterator()
listIterator in interface List<T>public ListIterator<T> listIterator(int index)
listIterator in interface List<T>Copyright © 2012–2018. All rights reserved.