E
- type of elements stored in the listpublic abstract class IList<E> extends java.util.AbstractList<E> implements ICollection<E>, IListable<E>, java.util.List<E>, java.util.RandomAccess, java.lang.Cloneable, java.io.Serializable
IList
is the abstract class which offers all interfaces implemented by ArrayList.
It also offers additional methods which are then available in all implementations of GapList
and BigList
.List
,
Deque
,
ArrayList
,
LinkedList
,
Serialized FormModifier and Type | Class and Description |
---|---|
protected static class |
IList.IListableFromArray<E>
Wrapper to treat an array as
IListable . |
protected static class |
IList.IListableFromCollection<E>
Wrapper to treat a
Collection as IListable . |
protected static class |
IList.IListableFromList<E>
Wrapper to treat a
List as IListable . |
protected static class |
IList.IListableFromMult<E>
Wrapper to treat a repeated element as
IListable . |
Constructor and Description |
---|
IList() |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E elem) |
void |
add(int index,
E elem)
Inserts the specified element at the specified position in this list.
|
boolean |
addAll(java.util.Collection<? extends E> coll)
Adds all of the elements in the specified collection into this list.
|
boolean |
addAll(IList<? extends E> list)
Adds all of the elements in the specified list into this list.
|
boolean |
addAll(int index,
java.util.Collection<? extends E> coll)
Inserts all of the elements in the specified collection into this
list, starting at the specified position.
|
boolean |
addAll(int index,
IList<? extends E> list)
Inserts all of the elements in the specified list into this
list, starting at the specified position.
|
boolean |
addArray(E... elems)
Adds all specified elements into this list.
|
boolean |
addArray(E[] elems,
int offset,
int length) |
boolean |
addArray(int index,
E... elems)
Inserts the specified elements into this list,
starting at the specified position.
|
boolean |
addArray(int index,
E[] elems,
int offset,
int length) |
void |
addFirst(E elem)
See
Deque.addFirst(E) |
boolean |
addIfAbsent(E elem)
Add elements to the end if it is not already contained in the list.
|
void |
addLast(E elem)
See
Deque.addLast(E) |
boolean |
addMult(int len,
E elem)
Adds element multiple time to list.
|
boolean |
addMult(int index,
int len,
E elem)
Inserts element multiple time to list, starting at the specified position.
|
java.util.Deque<E> |
asDeque() |
protected IListable<? extends E> |
asIListable(java.util.Collection<? extends E> coll)
Return correct IListable for passed collection.
|
abstract <K> int |
binarySearch(int index,
int len,
K key,
java.util.Comparator<? super K> comparator)
Searches the specified range for an object using the binary search algorithm.
|
<K> int |
binarySearch(K key,
java.util.Comparator<? super K> comparator)
Searches the specified range for an object using the binary* search algorithm.
|
abstract int |
capacity()
Returns capacity of this list.
|
protected void |
checkIndex(int index)
Check that specified index is valid for getting/setting elements.
|
protected void |
checkIndexAdd(int index)
Check that specified index is valid for adding elements.
|
protected void |
checkLength(int len)
Check that specified length is valid (>= 0).
|
protected void |
checkLengths(int len1,
int len2)
Check that both specified lengths are valid (>= 0) and equal.
|
protected void |
checkNonNull(java.lang.Object obj)
Check that object is not null.
|
protected void |
checkRange(int index,
int len)
Check that specified range is valid.
|
void |
clear() |
IList<E> |
clone()
Returns a shallow copy of this list.
|
boolean |
contains(java.lang.Object elem) |
boolean |
containsAll(java.util.Collection<?> coll) |
boolean |
containsAny(java.util.Collection<?> coll)
Returns true if any of the elements of the specified collection is contained in the list.
|
boolean |
containsIf(java.util.function.Predicate<? super E> predicate)
Determines whether the list contains a matching element.
|
abstract IList<E> |
copy()
Returns a shallow copy of this list.
|
void |
copy(int srcIndex,
int dstIndex,
int len)
Copy specified elements.
|
int |
count(E elem)
Counts how many times the specified element is contained in the list.
|
int |
countIf(java.util.function.Predicate<? super E> predicate)
Counts how many elements in the list match the predicate.
|
IList<E> |
crop()
Returns a copy this list but without elements.
|
java.util.Iterator<E> |
descendingIterator()
See
Deque.descendingIterator() |
protected abstract boolean |
doAdd(int index,
E elem)
Helper method for adding an element to the list.
|
protected boolean |
doAddAll(int index,
IListable<? extends E> list)
Helper method for adding multiple elements to the list.
|
protected abstract void |
doAssign(IList<E> that)
Assign this list the content of the that list.
|
protected void |
doClear() |
protected abstract void |
doClone(IList<E> that)
Initialize this object after the bitwise copy has been made by Object.clone().
|
protected abstract IList<E> |
doCreate(int capacity)
Create list with specified capacity.
|
protected <T> T[] |
doCreateArray(java.lang.Class<T> clazz,
int len)
Create array.
|
protected abstract void |
doEnsureCapacity(int minCapacity)
Increases the capacity of this list instance, if
necessary, to ensure that it can hold at least the number of elements
specified by the minimum capacity argument.
|
protected abstract E |
doGet(int index)
Helper method for getting an element from the list.
|
protected <T> void |
doGetAll(T[] array,
int index,
int len)
Helper method to fill the specified elements in an array.
|
protected int |
doIndexOf(java.lang.Object elem,
int fromIndex)
Returns the index of the first occurrence of the specified element in this list,
starting the search at the specified position.
|
protected int |
doIndexOfIf(java.util.function.Predicate<? super E> predicate,
int fromIndex)
Returns the index of the first element which matches the specified predicate in this list,
starting the search at the specified position.
|
protected void |
doInitAll(IListable<? extends E> list) |
protected int |
doLastIndexOf(java.lang.Object elem,
int fromIndex)
Returns the index of the last occurrence of the specified element in this list,
starting the search at the specified position.
|
protected int |
doLastIndexOfIf(java.util.function.Predicate<? super E> predicate,
int fromIndex)
Returns the index of the last occurrence of the specified element in this list,
starting the search at the specified position.
|
protected void |
doModify()
This method is called internally before elements are allocated or freed.
|
protected void |
doPutAll(int index,
IListable<? extends E> list) |
protected abstract E |
doRemove(int index)
Helper method to remove an element.
|
protected void |
doRemoveAll(int index,
int len)
Remove specified range of elements from list.
|
protected boolean |
doReplace(int index,
int len,
IListable<? extends E> list) |
protected abstract E |
doReSet(int index,
E elem)
Sets an element at specified position.
|
protected void |
doRotate(int index,
int len,
int distance)
Internal method to rotate specified elements in the list.
|
protected abstract E |
doSet(int index,
E elem)
Helper method for setting an element in the list.
|
void |
drag(int srcIndex,
int dstIndex,
int len)
Drag specified elements.
|
E |
element()
See
Deque.element() |
void |
ensureCapacity(int minCapacity)
Increases the capacity of this instance, if necessary, to ensure that it can hold at least the number of
elements specified by the minimum capacity argument.
|
boolean |
equals(java.lang.Object obj) |
IList<E> |
extract(int index,
int len)
Removes specified range of elements from list and return them.
|
IList<E> |
extractIf(java.util.function.Predicate<? super E> predicate)
Removes and returns all elements in the list which match the predicate.
|
void |
fill(E elem)
Fill list.
|
IList<E> |
filter(java.util.function.Predicate<? super E> predicate)
Create a new list by applying the specified filter to all elements.
|
<R> IList<R> |
filterMap(java.util.function.Predicate<E> filter,
java.util.function.Function<E,R> func)
Create a new list by applying the specified filter first and then the mapping function to all elements selected.
|
<R,C extends java.util.Collection<R>> |
flatMap(java.util.function.Function<E,C> func)
Create a new list by applying the specified mapping function to all elements.
|
E |
get(int index)
Return element at specified position
|
IList<E> |
getAll(E elem)
Returns all elements in the list equal to the specified element.
|
IList<E> |
getAll(int index,
int len)
Returns specified range of elements from list.
|
protected abstract E |
getDefaultElem() |
java.util.Set<E> |
getDistinct()
Returns distinct elements in the list.
|
E |
getFirst()
Returns the first element stored in the collection.
|
E |
getFirstOrNull()
Returns the first element stored in the collection.
|
E |
getIf(java.util.function.Predicate<? super E> predicate)
Get first element in the list which matches the predicate.
|
E |
getLast()
See
Deque.getLast() |
E |
getLastOrNull()
Returns the last element stored in the list.
|
E |
getSingle()
Returns the only element stored in the collection.
|
E |
getSingleOrNull()
Returns the only element stored in the collection or null if the collection is empty.
|
int |
hashCode() |
abstract IList<E> |
immutableList()
Returns an immutable copy of this list.
|
int |
indexOf(java.lang.Object elem) |
int |
indexOf(java.lang.Object elem,
int fromIndex)
Returns the index of the first occurrence of the specified element in this list,
starting the search at the specified position.
|
int |
indexOfIf(java.util.function.Predicate<? super E> predicate)
Returns the index of the first element which matches the specified predicate in this list.
|
int |
indexOfIf(java.util.function.Predicate<? super E> predicate,
int fromIndex)
Returns the index of the first element which matches the specified predicate in this list,
starting the search at the specified position.
|
void |
initAll(java.util.Collection<? extends E> coll)
Initializes the list so it will afterwards only contain the elements of the collection.
|
void |
initAll(IList<? extends E> list)
Initializes the list so it will afterwards only contain the elements of the collection.
|
void |
initArray(E... elems)
Initializes the list so it will afterwards only contain the elements of the array.
|
void |
initMult(int len,
E elem)
Initializes the list so it will afterwards have a size of
len and contain only the element elem . |
boolean |
isEmpty() |
abstract boolean |
isReadOnly()
Returns true if this list is either unmodifiable or immutable, false otherwise.
|
java.util.Iterator<E> |
iterator() |
int |
lastIndexOf(java.lang.Object elem) |
int |
lastIndexOf(java.lang.Object elem,
int fromIndex)
Returns the index of the last occurrence of the specified element in this list,
starting the search at the specified position.
|
int |
lastIndexOfIf(java.util.function.Predicate<? super E> predicate)
Returns the index of the last element which matches the specified predicate in this list.
|
int |
lastIndexOfIf(java.util.function.Predicate<? super E> predicate,
int fromIndex)
Returns the index of the last occurrence of the specified element in this list,
starting the search at the specified position.
|
java.util.ListIterator<E> |
listIterator() |
java.util.ListIterator<E> |
listIterator(int index) |
<R> IList<R> |
map(java.util.function.Function<E,R> func)
Create a new list by applying the specified mapping function to all elements.
|
<R> IList<R> |
mapFilter(java.util.function.Function<E,R> func,
java.util.function.Predicate<R> filter)
Create a new list by applying the specified mapping function to all elements and then filtering it.
|
void |
move(int srcIndex,
int dstIndex,
int len)
Move specified elements.
|
boolean |
offer(E elem)
See
Deque.offer(E) |
boolean |
offerFirst(E elem)
See
Deque.offerFirst(E) |
boolean |
offerLast(E elem)
See
Deque.offerLast(E) |
E |
peek()
See
Deque.peek() |
E |
peekFirst()
See
Deque.peekFirst() |
E |
peekLast()
See
Deque.peekLast() |
E |
poll()
See
Deque.poll() |
E |
pollFirst()
See
Deque.pollFirst() |
E |
pollLast()
See
Deque.pollLast() |
E |
pop()
See
Deque.pop() |
void |
push(E elem)
See
Deque.push(E) |
E |
put(int index,
E elem)
Sets or adds the element.
|
void |
putAll(int index,
java.util.Collection<? extends E> coll)
Set or add the specified elements.
|
void |
putAll(int index,
IList<? extends E> list)
Set or add the specified elements.
|
void |
putArray(int index,
E... elems)
Set or add the specified elements.
|
void |
putMult(int index,
int len,
E elem)
Set or add the specified element multiple times.
|
E |
remove()
See
Deque.remove() |
E |
remove(int index) |
void |
remove(int index,
int len)
Remove specified range of elements from list.
|
boolean |
remove(java.lang.Object elem) |
boolean |
removeAll(java.util.Collection<?> coll) |
IList<E> |
removeAll(E elem)
Removes all equal elements.
|
boolean |
removeAll(IList<?> coll) |
E |
removeFirst()
See
Deque.removeFirst() |
boolean |
removeFirstOccurrence(java.lang.Object elem)
See
Deque.removeFirstOccurrence(java.lang.Object) |
boolean |
removeIf(java.util.function.Predicate<? super E> predicate)
Removes all elements in the list which match the predicate.
|
E |
removeLast()
See
Deque.removeLast() |
boolean |
removeLastOccurrence(java.lang.Object elem)
See
Deque.removeLastOccurrence(java.lang.Object) |
protected void |
replace(int index,
int len,
IListable<? extends E> list) |
void |
replaceAll(int index,
int len,
java.util.Collection<? extends E> coll)
Replaces the specified range with new elements.
|
void |
replaceAll(int index,
int len,
IList<? extends E> list)
Replaces the specified range with new elements.
|
void |
replaceArray(int index,
int len,
E... elems)
Replaces the specified range with new elements.
|
void |
replaceMult(int index,
int len,
int numElems,
E elem)
Replaces the specified range with new elements.
|
void |
resize(int len,
E elem)
Resizes the list so it will afterwards have a size of
len . |
void |
retain(int index,
int len)
Retain specified range of elements from list, the other elements are removed.
|
boolean |
retainAll(java.util.Collection<?> coll) |
boolean |
retainAll(IList<?> coll) |
boolean |
retainIf(java.util.function.Predicate<? super E> predicate)
Retains all elements in the list which match the predicate.
|
void |
reverse()
Reverses the order of all elements in the specified list.
|
void |
reverse(int index,
int len)
Reverses the order of the specified elements in the list.
|
void |
rotate(int distance)
Rotate specified elements in the list.
|
void |
rotate(int index,
int len,
int distance)
Rotate specified elements in the list.
|
E |
set(int index,
E elem) |
void |
setAll(int index,
java.util.Collection<? extends E> coll)
Sets the specified elements.
|
void |
setAll(int index,
IList<? extends E> list)
Sets the specified elements.
|
void |
setArray(int index,
E... elems)
Sets the specified elements.
|
void |
setArray(int index,
E[] elems,
int offset,
int length) |
void |
setMult(int index,
int len,
E elem)
Sets the element multiple times.
|
abstract int |
size()
Return size of list
|
void |
sort(java.util.Comparator<? super E> comparator)
Sort elements in the list using the specified comparator.
|
abstract void |
sort(int index,
int len,
java.util.Comparator<? super E> comparator)
Sort specified elements in the list using the specified comparator.
|
void |
swap(int index1,
int index2,
int len)
Swap the specified elements in the list.
|
java.lang.Object[] |
toArray() |
<T> T[] |
toArray(java.lang.Class<T> clazz)
Returns an array containing the elements in this list.
|
<T> T[] |
toArray(java.lang.Class<T> clazz,
int index,
int len)
Returns an array containing the specified elements in this list.
|
java.lang.Object[] |
toArray(int index,
int len)
Returns an array containing the specified elements in this list.
|
<T> T[] |
toArray(T[] array) |
<T> T[] |
toArray(T[] array,
int index,
int len)
Returns an array containing the specified elements in this list.
|
java.lang.String |
toString() |
static <E> void |
transferCopy(IList<E> src,
int srcIndex,
int srcLen,
IList<? super E> dst,
int dstIndex,
int dstLen)
Copies elements from one list to another.
|
static <E> void |
transferMove(IList<E> src,
int srcIndex,
int srcLen,
IList<? super E> dst,
int dstIndex,
int dstLen)
Moves elements from one list to another by setting it to null in the source list.
|
static <E> void |
transferRemove(IList<E> src,
int srcIndex,
int srcLen,
IList<? super E> dst,
int dstIndex,
int dstLen)
Moves elements from one list to another by removing it from the source list.
|
static <E> void |
transferSwap(IList<E> src,
int srcIndex,
IList<E> dst,
int dstIndex,
int len)
Swaps elements from two lists.
|
void |
transform(java.util.function.UnaryOperator<E> op)
Change the list by applying the specified operator to all elements.
|
IList<E> |
transformedList(java.util.function.UnaryOperator<E> op)
Create a new list by applying the specified transforming operator to all elements.
|
abstract void |
trimToSize()
An application can use this operation to minimize the storage of an instance.
|
abstract IList<E> |
unmodifiableList()
Returns an unmodifiable view of this list.
|
public java.util.Deque<E> asDeque()
Deque
public abstract IList<E> copy()
copy
in interface ICollection<E>
public IList<E> clone()
copy()
to .clone
in class java.lang.Object
public IList<E> crop()
crop
in interface ICollection<E>
public abstract boolean isReadOnly()
public abstract IList<E> unmodifiableList()
immutableList()
to get an immutable copy of a list.public abstract IList<E> immutableList()
unmodifiableList()
to get unmodifiable view of a list.protected abstract void doClone(IList<E> that)
that
- source objectpublic void clear()
protected void doClear()
public void resize(int len, E elem)
len
.
If the list must grow, the specified element elem
will be used for filling.len
- new size of listelem
- element which will be used for extending the listjava.lang.IndexOutOfBoundsException
- if the range is invalidpublic abstract int size()
IListable
public abstract int capacity()
public E get(int index)
IListable
protected abstract E doGet(int index)
index
- index of element to returnprotected abstract E doSet(int index, E elem)
index
- index where element will be placedelem
- element to setpublic E put(int index, E elem)
index
- index where element will be placedelem
- element to putjava.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index > size())protected abstract E doReSet(int index, E elem)
index
- index where element will be placedelem
- element to setprotected abstract E getDefaultElem()
protected void doModify()
public boolean add(E elem)
public void add(int index, E elem)
protected abstract boolean doAdd(int index, E elem)
index
- index where element should be added
(-1 means it is up to the implementation to choose the index)elem
- element to addpublic E remove(int index)
protected abstract E doRemove(int index)
index
- index of element to removepublic void ensureCapacity(int minCapacity)
minCapacity
- the desired minimum capacityprotected abstract void doEnsureCapacity(int minCapacity)
minCapacity
- the desired minimum capacitypublic abstract void trimToSize()
public boolean equals(java.lang.Object obj)
public int hashCode()
public java.lang.String toString()
toString
in class java.util.AbstractCollection<E>
public boolean isEmpty()
public int count(E elem)
elem
- element to countpublic int countIf(java.util.function.Predicate<? super E> predicate)
ICollection
countIf
in interface ICollection<E>
predicate
- a predicate which returns true
for elements to be countedpublic E getSingle()
ICollection
NoSuchElementException
is thrown.getSingle
in interface ICollection<E>
public E getSingleOrNull()
ICollection
NoSuchElementException
is thrown.getSingleOrNull
in interface ICollection<E>
public IList<E> getAll(E elem)
elem
- element to look forpublic E getIf(java.util.function.Predicate<? super E> predicate)
getIf
in interface ICollection<E>
predicate
- a predicate which returns true
for elements to be selectedpublic java.util.Set<E> getDistinct()
public <R> IList<R> map(java.util.function.Function<E,R> func)
ICollection
IList
, typically GapList
unless the original type is BigList
.map
in interface ICollection<E>
func
- mapping functionpublic <R,C extends java.util.Collection<R>> IList<R> flatMap(java.util.function.Function<E,C> func)
ICollection
IList
, typically GapList
unless the original type is BigList
.flatMap
in interface ICollection<E>
func
- mapping functionpublic <R> IList<R> mapFilter(java.util.function.Function<E,R> func, java.util.function.Predicate<R> filter)
ICollection
IList
, typically GapList
unless the original type is BigList
.mapFilter
in interface ICollection<E>
func
- mapping functionfilter
- filter predicatepublic <R> IList<R> filterMap(java.util.function.Predicate<E> filter, java.util.function.Function<E,R> func)
ICollection
IList
, typically GapList
unless the original type is BigList
.filterMap
in interface ICollection<E>
filter
- filter predicatefunc
- mapping functionpublic IList<E> transformedList(java.util.function.UnaryOperator<E> op)
op
- transforming operatorpublic void transform(java.util.function.UnaryOperator<E> op)
op
- transforming operatorpublic IList<E> filter(java.util.function.Predicate<? super E> predicate)
filter
in interface ICollection<E>
predicate
- predicate used for filteringpublic boolean retainIf(java.util.function.Predicate<? super E> predicate)
predicate
- a predicate which returns true
for elements to be retainedtrue
if the list was changedpublic boolean removeIf(java.util.function.Predicate<? super E> predicate)
removeIf
in interface java.util.Collection<E>
predicate
- a predicate which returns true
for elements to be removedtrue
if the list was changedpublic IList<E> extractIf(java.util.function.Predicate<? super E> predicate)
predicate
- predicatepublic int indexOf(java.lang.Object elem)
public int indexOf(java.lang.Object elem, int fromIndex)
elem
- element to search forfromIndex
- start index for searchindexOf(Object)
protected int doIndexOf(java.lang.Object elem, int fromIndex)
public int indexOfIf(java.util.function.Predicate<? super E> predicate)
predicate
- predicate used to search for the elementindexOf(Object)
public int indexOfIf(java.util.function.Predicate<? super E> predicate, int fromIndex)
predicate
- predicate used to search for the elementindexOf(Object)
protected int doIndexOfIf(java.util.function.Predicate<? super E> predicate, int fromIndex)
public int lastIndexOf(java.lang.Object elem)
public int lastIndexOf(java.lang.Object elem, int fromIndex)
elem
- element to search forfromIndex
- start index for searchlastIndexOf(Object)
protected int doLastIndexOf(java.lang.Object elem, int fromIndex)
public int lastIndexOfIf(java.util.function.Predicate<? super E> predicate)
predicate
- predicate used to search for the elementlastIndexOf(Object)
public int lastIndexOfIf(java.util.function.Predicate<? super E> predicate, int fromIndex)
predicate
- predicate used to search for the elementfromIndex
- start index for searchlastIndexOf(Object)
protected int doLastIndexOfIf(java.util.function.Predicate<? super E> predicate, int fromIndex)
public boolean remove(java.lang.Object elem)
public boolean contains(java.lang.Object elem)
public boolean containsIf(java.util.function.Predicate<? super E> predicate)
containsIf
in interface ICollection<E>
predicate
- predicate used to search elementpublic boolean addIfAbsent(E elem)
elem
- element to addpublic boolean containsAny(java.util.Collection<?> coll)
coll
- collection with elements to be containedpublic boolean containsAll(java.util.Collection<?> coll)
public IList<E> removeAll(E elem)
elem
- elementpublic boolean removeAll(java.util.Collection<?> coll)
public boolean removeAll(IList<?> coll)
removeAll(Collection)
public boolean retainAll(java.util.Collection<?> coll)
public boolean retainAll(IList<?> coll)
retainAll(Collection)
public java.lang.Object[] toArray()
public <T> T[] toArray(T[] array)
public <T> T[] toArray(java.lang.Class<T> clazz)
clazz
- class for array elementspublic java.lang.Object[] toArray(int index, int len)
index
- index of first element to copylen
- number of elements to copyList.toArray()
public <T> T[] toArray(T[] array, int index, int len)
array
- the array into which the elements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purposeindex
- index of first element to copylen
- number of elements to copyList.toArray(Object[])
public <T> T[] toArray(java.lang.Class<T> clazz, int index, int len)
clazz
- class for array elementsindex
- index of first element to copylen
- number of elements to copyprotected <T> T[] doCreateArray(java.lang.Class<T> clazz, int len)
clazz
- class for array elementslen
- array lengthprotected <T> void doGetAll(T[] array, int index, int len)
T
- type of elements stored in the listarray
- array to store the list elementsindex
- index of first element to copylen
- number of elements to copyprotected boolean doAddAll(int index, IListable<? extends E> list)
index
- index where element should be added (-1 is valid for adding at the end)list
- list with elements to addpublic java.util.Iterator<E> iterator()
public java.util.ListIterator<E> listIterator()
public java.util.ListIterator<E> listIterator(int index)
public java.util.Iterator<E> descendingIterator()
Deque.descendingIterator()
public E peek()
Deque.peek()
public E element()
Deque.element()
public E poll()
Deque.poll()
public E remove()
Deque.remove()
public boolean offer(E elem)
Deque.offer(E)
public E getFirst()
ICollection
NoSuchElementException
is thrown.getFirst
in interface ICollection<E>
public E getFirstOrNull()
ICollection
getFirstOrNull
in interface ICollection<E>
public E getLast()
Deque.getLast()
public E getLastOrNull()
public void addFirst(E elem)
Deque.addFirst(E)
public void addLast(E elem)
Deque.addLast(E)
public E removeFirst()
Deque.removeFirst()
public E removeLast()
Deque.removeLast()
public boolean offerFirst(E elem)
Deque.offerFirst(E)
public boolean offerLast(E elem)
Deque.offerLast(E)
public E peekFirst()
Deque.peekFirst()
public E peekLast()
Deque.peekLast()
public E pollFirst()
Deque.pollFirst()
public E pollLast()
Deque.pollLast()
public E pop()
Deque.pop()
public void push(E elem)
Deque.push(E)
public boolean removeFirstOccurrence(java.lang.Object elem)
Deque.removeFirstOccurrence(java.lang.Object)
public boolean removeLastOccurrence(java.lang.Object elem)
Deque.removeLastOccurrence(java.lang.Object)
public static <E> void transferCopy(IList<E> src, int srcIndex, int srcLen, IList<? super E> dst, int dstIndex, int dstLen)
copy(int, int, int)
.E
- type of elements stored in the listsrc
- source listsrcIndex
- index of first element in source listsrcLen
- number of elements to copydst
- destination listdstIndex
- index of first element in destination listdstLen
- number of elements to replace in destination listjava.lang.IndexOutOfBoundsException
- if the ranges are invalidpublic static <E> void transferMove(IList<E> src, int srcIndex, int srcLen, IList<? super E> dst, int dstIndex, int dstLen)
move(int, int, int)
.E
- type of elements stored in the listsrc
- source listsrcIndex
- index of first element in source listsrcLen
- number of elements to copydst
- destination listdstIndex
- index of first element in destination listdstLen
- number of elements to replace in destination listjava.lang.IndexOutOfBoundsException
- if the ranges are invalidpublic static <E> void transferRemove(IList<E> src, int srcIndex, int srcLen, IList<? super E> dst, int dstIndex, int dstLen)
drag(int, int, int)
.E
- type of elements stored in the listsrc
- source listsrcIndex
- index of first element in source listsrcLen
- number of elements to copydst
- destination listdstIndex
- index of first element in destination listdstLen
- number of elements to replace in destination listjava.lang.IndexOutOfBoundsException
- if the ranges are invalidpublic static <E> void transferSwap(IList<E> src, int srcIndex, IList<E> dst, int dstIndex, int len)
swap(int, int, int)
.E
- type of elements stored in the listsrc
- first listsrcIndex
- index of first element in first listdst
- second listdstIndex
- index of first element in second listlen
- number of elements to swapjava.lang.IndexOutOfBoundsException
- if the ranges are invalidprotected abstract IList<E> doCreate(int capacity)
capacity
- initial capacity (use -1 for default capacity)protected abstract void doAssign(IList<E> that)
that
- list to copy content frompublic IList<E> getAll(int index, int len)
index
- index of first element to retrievelen
- number of elements to retrievepublic IList<E> extract(int index, int len)
index
- index of first element to retrievelen
- number of elements to retrievepublic void retain(int index, int len)
index
- index of first element to retainlen
- number of elements to retainjava.lang.IndexOutOfBoundsException
- if the range is invalidpublic void remove(int index, int len)
index
- index of first element to removelen
- number of elements to removejava.lang.IndexOutOfBoundsException
- if the range is invalidprotected void doRemoveAll(int index, int len)
index
- index of first element to removelen
- number of elements to removepublic boolean addAll(IList<? extends E> list)
list
- collection containing elements to be added to this listjava.lang.NullPointerException
- if the specified list is nullpublic boolean addAll(int index, IList<? extends E> list)
index
- index at which to insert the first element from the
specified collectionlist
- list containing elements to be inserted into this listjava.lang.IndexOutOfBoundsException
- if the index is invalidjava.lang.NullPointerException
- if the specified collection is nullpublic boolean addAll(java.util.Collection<? extends E> coll)
addAll
in interface java.util.Collection<E>
addAll
in interface java.util.List<E>
addAll
in class java.util.AbstractCollection<E>
coll
- collection containing elements to be added to this listjava.lang.NullPointerException
- if the specified collection is nullpublic boolean addAll(int index, java.util.Collection<? extends E> coll)
addAll
in interface java.util.List<E>
addAll
in class java.util.AbstractList<E>
index
- index at which to insert the first element from the
specified collectioncoll
- collection containing elements to be inserted into this listjava.lang.IndexOutOfBoundsException
- if the index is invalidjava.lang.NullPointerException
- if the specified collection is nullpublic boolean addArray(E... elems)
elems
- elements to be added to this listpublic boolean addArray(E[] elems, int offset, int length)
public boolean addArray(int index, E[] elems, int offset, int length)
public boolean addArray(int index, E... elems)
index
- index at which to insert the first element from the
specified collectionelems
- elements to be inserted into this listjava.lang.IndexOutOfBoundsException
- if the index is invalidpublic boolean addMult(int len, E elem)
elem
- element to be added to this listpublic boolean addMult(int index, int len, E elem)
index
- index at which to insert the first element from the
specified collectionelem
- element to be inserted into this listjava.lang.IndexOutOfBoundsException
- if the index is invalidpublic void setAll(int index, IList<? extends E> list)
index
- index of first element to setlist
- list with elements to setpublic void setAll(int index, java.util.Collection<? extends E> coll)
index
- index of first element to setcoll
- collection with elements to setjava.lang.IndexOutOfBoundsException
- if the range is invalidpublic void setArray(int index, E... elems)
index
- index of first element to setelems
- array with elements to setjava.lang.IndexOutOfBoundsException
- if the range is invalidpublic void setArray(int index, E[] elems, int offset, int length)
public void setMult(int index, int len, E elem)
index
- index of first element to setelem
- element to setpublic void putAll(int index, IList<? extends E> list)
index
- index of first element to set or addlist
- list with elements to set or addpublic void putAll(int index, java.util.Collection<? extends E> coll)
index
- index of first element to set or addcoll
- collection with elements to set or addpublic void putArray(int index, E... elems)
index
- index of first element to set or addelems
- array with elements to set or addpublic void putMult(int index, int len, E elem)
index
- index of first element to set or addlen
- element to set or addpublic void initAll(IList<? extends E> list)
list
- list with elementsjava.lang.IndexOutOfBoundsException
- if the length is invalidpublic void initAll(java.util.Collection<? extends E> coll)
coll
- collection with elementsjava.lang.IndexOutOfBoundsException
- if the length is invalidprotected IListable<? extends E> asIListable(java.util.Collection<? extends E> coll)
public void initArray(E... elems)
elems
- array with elementsjava.lang.IndexOutOfBoundsException
- if the length is invalidpublic void initMult(int len, E elem)
len
and contain only the element elem
.
The list will grow or shrink as needed.len
- length of listelem
- element which the list will containjava.lang.IndexOutOfBoundsException
- if the length is invalidpublic void replaceAll(int index, int len, java.util.Collection<? extends E> coll)
index
- index of first element to replace, use -1 for the position after the last element (this.size())len
- number of elements to replace, use -1 for getting behavior of putAll()coll
- collection with elements which replace the old elements, use null if elements should only be removedjava.lang.IndexOutOfBoundsException
- if the range is invalidpublic void replaceArray(int index, int len, E... elems)
index
- index of first element to replace, use -1 for the position after the last element (this.size())len
- number of elements to replace, use -1 for getting behavior of putAll()elems
- array with elements which replace the old elements, use null if elements should only be removedjava.lang.IndexOutOfBoundsException
- if the range is invalidpublic void replaceMult(int index, int len, int numElems, E elem)
index
- index of first element to replace, use -1 for the position after the last element (this.size())len
- number of elements to replace, use -1 for getting behavior of putAll()numElems
- number of time element has to be addedelem
- element to addjava.lang.IndexOutOfBoundsException
- if the range is invalidpublic void replaceAll(int index, int len, IList<? extends E> list)
index
- index of first element to replace, use -1 for the position after the last element (this.size())len
- number of elements to replace, use -1 for getting behavior of putAll()list
- list with elements which replace the old elements, use null if elements should only be removedjava.lang.IndexOutOfBoundsException
- if the range is invalidpublic void fill(E elem)
elem
- element used for fillingpublic void copy(int srcIndex, int dstIndex, int len)
srcIndex
- index of first source element to copydstIndex
- index of first destination element to copylen
- number of elements to copyjava.lang.IndexOutOfBoundsException
- if the ranges are invalidpublic void move(int srcIndex, int dstIndex, int len)
srcIndex
- index of first source element to movedstIndex
- index of first destination element to movelen
- number of elements to movejava.lang.IndexOutOfBoundsException
- if the ranges are invalidpublic void drag(int srcIndex, int dstIndex, int len)
srcIndex
- index of first source element to movedstIndex
- index of first destination element to movelen
- number of elements to movejava.lang.IndexOutOfBoundsException
- if the ranges are invalidpublic void swap(int index1, int index2, int len)
index1
- index of first element in first range to swapindex2
- index of first element in second range to swaplen
- number of elements to swapjava.lang.IndexOutOfBoundsException
- if the ranges are invalidpublic void reverse()
public void reverse(int index, int len)
index
- index of first element to reverselen
- number of elements to reversejava.lang.IndexOutOfBoundsException
- if the ranges are invalidpublic void rotate(int distance)
distance
- distance to move the elementspublic void rotate(int index, int len, int distance)
index
- index of first element to rotatelen
- number of elements to rotatedistance
- distance to move the elementsjava.lang.IndexOutOfBoundsException
- if the ranges are invalidprotected void doRotate(int index, int len, int distance)
index
- index of first element to rotatelen
- number of elements to rotatedistance
- distance to move the elementspublic void sort(java.util.Comparator<? super E> comparator)
sort
in interface java.util.List<E>
comparator
- comparator to use for sorting
(null means the elements natural ordering should be used)Arrays.sort(int[])
public abstract void sort(int index, int len, java.util.Comparator<? super E> comparator)
index
- index of first element to sortlen
- number of elements to sortcomparator
- comparator to use for sorting
(null means the elements natural ordering should be used)java.lang.IndexOutOfBoundsException
- if the range is invalidArrays.sort(int[])
public <K> int binarySearch(K key, java.util.Comparator<? super K> comparator)
Note that the method is defined to work with an arbitrary type <K>. This allows to search directly for a key field in the object without the need to construct an object containing the key:
persons.binarySearch("john", new SearchByName());
class SearchByName implements Comparator<Object> {
public int compare(Object o1, Object o2) {
String s1 = (o1 instanceof String) ? (String) o1 : ((Name) o1).getName();
String s2 = (o2 instanceof String) ? (String) o2 : ((Name) o2).getName();
return s1.compareTo(s2);
}
}
key
- the value to be searched forcomparator
- the comparator by which the list is ordered.
A null value indicates that the elements'
natural ordering should be used.Arrays.binarySearch(long[], long)
public abstract <K> int binarySearch(int index, int len, K key, java.util.Comparator<? super K> comparator)
Note that the method is defined to work with an arbitrary type <K>. This allows to search directly for a key field in the object without the need to construct an object containing the key:
persons.binarySearch("john", new SearchByName());
class SearchByName implements Comparator<Object> {
public int compare(Object o1, Object o2) {
String s1 = (o1 instanceof String) ? (String) o1 : ((Name) o1).getName();
String s2 = (o2 instanceof String) ? (String) o2 : ((Name) o2).getName();
return s1.compareTo(s2);
}
}
/
index
- index of first element to searchlen
- number of elements to searchkey
- the value to be searched forcomparator
- the comparator by which the list is ordered.
A null value indicates that the elements'
natural ordering should be used.java.lang.IndexOutOfBoundsException
- if the range is invalidArrays.binarySearch(long[], long)
protected void checkIndex(int index)
index
- index to checkjava.lang.IndexOutOfBoundsException
- if index is invalidprotected void checkIndexAdd(int index)
index
- index to checkjava.lang.IndexOutOfBoundsException
- if index is invalidprotected void checkRange(int index, int len)
index
- start index of range to checklen
- number of elements in range to checkjava.lang.IndexOutOfBoundsException
- if index is invalidprotected void checkLength(int len)
len
- length to checkjava.lang.IndexOutOfBoundsException
- if length is invalidprotected void checkLengths(int len1, int len2)
len1
- length to checklen2
- length to checkjava.lang.IndexOutOfBoundsException
- if lengths are invalidprotected void checkNonNull(java.lang.Object obj)
obj
- object to checkjava.lang.NullPointerException
- if object is null