public class ArrayList<E> extends AbstractIndexedList<E>
ArrayList is an IndexedList implementation backed by an array.
WARNING: All modifications copy the entire backing array. ArrayLists should only be
used where modifications are infrequent and access times are critical. ArrayList is also compact
in memory usage, so may be appropriate for small lists. If there is any doubt regarding access patterns
for a List then use a Vector instead.
| Constructor and Description |
|---|
ArrayList() |
| Modifier and Type | Method and Description |
|---|---|
ArrayList<E> |
append(E elem)
Returns a list with the specified element appended to the bottom of the list.
|
ArrayList<E> |
drop(int number)
Returns a list containing all elements in this list, excluding the first
number of elements. |
static <E> ArrayList<E> |
empty() |
static <E> BuilderFactory<E,ArrayList<E>> |
factory() |
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).
|
boolean |
isEmpty()
Returns true if this collection is empty.
|
java.util.Iterator<E> |
iterator() |
E |
last()
Returns last element in the list or
null if the list is empty. |
ArrayList<E> |
prepend(E elem)
Returns a list with the specified element prepended to the top of the list.
|
ArrayList<E> |
range(int from,
boolean fromInclusive,
int to,
boolean toInclusive)
Returns a list containing a contiguous range of elements from this list.
|
ArrayList<E> |
set(int i,
E elem)
Returns a list with the element set to the value specified at the index (zero-based).
|
int |
size()
Returns the size of the collection.
|
List<E> |
tail()
Returns a list containing all elements in the list, excluding the first element.
|
ArrayList<E> |
take(int number)
Returns a list containing the first
number of elements from this list. |
asList, equals, hashCode, indexOf, lastIndexOfforEachmakeString, makeString, to, toArray, toArray, toIndexedList, toSet, toSortedSet, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitasList, indexOf, lastIndexOfforEach, makeString, makeString, to, toArray, toArray, toIndexedList, toSet, toSortedSetpublic static <E> ArrayList<E> empty()
@NotNull public static <E> BuilderFactory<E,ArrayList<E>> factory()
@NotNull public ArrayList<E> set(int i, E elem)
List@NotNull public ArrayList<E> append(E elem)
List@NotNull public ArrayList<E> prepend(E elem)
List@NotNull public ArrayList<E> drop(int number)
Listnumber of elements.@NotNull public ArrayList<E> take(int number)
Listnumber of elements from this list.@NotNull public ArrayList<E> range(int from, boolean fromInclusive, int to, boolean toInclusive)
Listfrom - 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 includedpublic E get(int i)
List@Nullable public E first()
Listnull if the list is empty.@Nullable public E last()
Listnull if the list is empty.@NotNull public List<E> tail()
List@NotNull public java.util.Iterator<E> iterator()
public int size()
TraversableWarning: infinite collections are possible, as are collections that require traversal to calculate the size.
size in interface Traversable<E>size in class AbstractTraversable<E>public boolean isEmpty()
TraversableisEmpty in interface Traversable<E>isEmpty in class AbstractTraversable<E>