com.github.andrewoma.dexx.collection
Interface List<E>

All Superinterfaces:
Iterable<E>, Traversable<E>
All Known Subinterfaces:
IndexedList<E>, LinkedList<E>
All Known Implementing Classes:
AbstractIndexedList, AbstractLinkedList, AbstractList, ArrayList, ConsList, Vector

public interface List<E>
extends Iterable<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:

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

get

E get(int i)
Returns the element at the specified index in this list (zero-based).

Throws:
IndexOutOfBoundsException - if the index is out of range

set

@NotNull
List<E> set(int i,
                    E elem)
Returns a list with the element set to the value specified at the index (zero-based).

Throws:
IndexOutOfBoundsException - if the index is out of range

append

@NotNull
List<E> append(E elem)
Returns a list with the specified element appended to the bottom of the list.


prepend

@NotNull
List<E> prepend(E elem)
Returns a list with the specified element prepended to the top of the list.


indexOf

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.


lastIndexOf

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.


first

@Nullable
E first()
Returns first element in the list or null if the list is empty.


last

@Nullable
E last()
Returns last element in the list or null if the list is empty.


tail

@NotNull
List<E> tail()
Returns a list containing all elements in the list, excluding the first element. An empty list is returned if the list is empty.


drop

@NotNull
List<E> drop(int number)
Returns a list containing all elements in this list, excluding the first number of elements.


take

@NotNull
List<E> take(int number)
Returns a list containing the first number of elements from this list.


range

@NotNull
List<E> range(int from,
                      boolean fromInclusive,
                      int to,
                      boolean toInclusive)
Returns a list containing a contiguous range of elements from this list.

Parameters:
from - starting index for the range (zero-based)
fromInclusive - if true, the element at the from index will be included
to - end index for the range (zero-based)
toInclusive - if true, the element at the to index will be included

asList

@NotNull
List<E> asList()
Returns an immutable view of this list as an instance of java.util.List.



Copyright © 2014. All Rights Reserved.