|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface List<E>
List defines an sequence of elements where the order is preserved.
There are two sub-interfaces of List that define very different performance characteristics:
IndexedList: Guarantees fast random access to elements in the List via indexes.
LinkedList: Guarantees fast prepend(Object) and tail() operations.
The performance of other operations is unspecified - care must be taken to use specific implementations using the appropriate access patterns.
| Method Summary | |
|---|---|
List<E> |
append(E elem)
Returns a list with the specified element appended to the bottom of the list. |
List<E> |
asList()
Returns an immutable view of this list as an instance of java.util.List. |
List<E> |
drop(int number)
Returns a list containing all elements in this list, excluding the first number of elements. |
E |
first()
Returns first element in the list or null if the list is empty. |
E |
get(int i)
Returns the element at the specified index in this list (zero-based). |
int |
indexOf(E elem)
Returns the index of the first occurrence of the specified element in the list or -1 if there are no occurrences. |
E |
last()
Returns last element in the list or null if the list is empty. |
int |
lastIndexOf(E elem)
Returns the index of the last occurrence of the specified element in the list or -1 if there are no occurrences. |
List<E> |
prepend(E elem)
Returns a list with the specified element prepended to the top of the list. |
List<E> |
range(int from,
boolean fromInclusive,
int to,
boolean toInclusive)
Returns a list containing a contiguous range of elements from this list. |
List<E> |
set(int i,
E elem)
Returns a list with the element set to the value specified at the index (zero-based). |
List<E> |
tail()
Returns a list containing all elements in the list, excluding the first element. |
List<E> |
take(int number)
Returns a list containing the first number of elements from this list. |
| Methods inherited from interface com.github.andrewoma.dexx.collection.Iterable |
|---|
iterator |
| Methods inherited from interface com.github.andrewoma.dexx.collection.Traversable |
|---|
forEach, isEmpty, makeString, makeString, size, to, toArray, toArray, toIndexedList, toSet, toSortedSet |
| Method Detail |
|---|
E get(int i)
IndexOutOfBoundsException - if the index is out of range
@NotNull
List<E> set(int i,
E elem)
IndexOutOfBoundsException - if the index is out of range@NotNull List<E> append(E elem)
@NotNull List<E> prepend(E elem)
int indexOf(E elem)
int lastIndexOf(E elem)
@Nullable E first()
null if the list is empty.
@Nullable E last()
null if the list is empty.
@NotNull List<E> tail()
@NotNull List<E> drop(int number)
number of elements.
@NotNull List<E> take(int number)
number of elements from this list.
@NotNull
List<E> range(int from,
boolean fromInclusive,
int to,
boolean toInclusive)
from - starting index for the range (zero-based)fromInclusive - if true, the element at the from index will be includedto - end index for the range (zero-based)toInclusive - if true, the element at the to index will be included@NotNull List<E> asList()
java.util.List.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||