Class ArrayList<E>
java.lang.Object
com.github.andrewoma.dexx.collection.internal.base.AbstractTraversable<E>
com.github.andrewoma.dexx.collection.internal.base.AbstractIterable<E>
com.github.andrewoma.dexx.collection.internal.base.AbstractList<E>
com.github.andrewoma.dexx.collection.internal.base.AbstractIndexedList<E>
com.github.andrewoma.dexx.collection.ArrayList<E>
- All Implemented Interfaces:
IndexedList<E>, Iterable<E>, List<E>, Traversable<E>, Iterable<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.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a list with the specified element appended to the bottom of the list.drop(int number) Returns a list containing all elements in this list, excluding the firstnumberof elements.static <E> ArrayList<E> empty()static <E> @NotNull BuilderFactory<E, ArrayList<E>> factory()first()Returns first element in the list ornullif the list is empty.get(int i) Returns the element at the specified index in this list (zero-based).booleanisEmpty()Returns true if this collection is empty.iterator()last()Returns last element in the list ornullif the list is empty.Returns a list with the specified element prepended to the top of the list.range(int from, boolean fromInclusive, int to, boolean toInclusive) Returns a list containing a contiguous range of elements from this list.Returns a list with the element set to the value specified at the index (zero-based).intsize()Returns the size of the collection.tail()Returns a list containing all elements in the list, excluding the first element.take(int number) Returns a list containing the firstnumberof elements from this list.Methods inherited from class AbstractList
asList, equals, hashCode, indexOf, lastIndexOfMethods inherited from class AbstractIterable
forEachMethods inherited from class AbstractTraversable
makeString, makeString, to, toArray, toArray, toIndexedList, toSet, toSortedSet, toStringMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface List
asList, indexOf, lastIndexOfMethods inherited from interface Traversable
forEach, makeString, makeString, to, toArray, toArray, toIndexedList, toSet, toSortedSet
-
Field Details
-
EMPTY
-
elements
-
-
Constructor Details
-
ArrayList
public ArrayList() -
ArrayList
ArrayList(Object[] elements)
-
-
Method Details
-
empty
-
factory
-
set
-
append
-
prepend
-
drop
-
take
-
range
@NotNull public @NotNull ArrayList<E> range(int from, boolean fromInclusive, int to, boolean toInclusive) Description copied from interface:ListReturns 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 thefromindex will be includedto- end index for the range (zero-based)toInclusive- if true, the element at thetoindex will be included
-
get
-
first
-
last
-
tail
-
iterator
-
size
public int size()Description copied from interface:TraversableReturns the size of the collection.Warning: infinite collections are possible, as are collections that require traversal to calculate the size.
- Specified by:
sizein interfaceTraversable<E>- Overrides:
sizein classAbstractTraversable<E>
-
isEmpty
public boolean isEmpty()Description copied from interface:TraversableReturns true if this collection is empty.- Specified by:
isEmptyin interfaceTraversable<E>- Overrides:
isEmptyin classAbstractTraversable<E>
-