Class ConsList<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.AbstractLinkedList<E>
com.github.andrewoma.dexx.collection.ConsList<E>
- All Implemented Interfaces:
Iterable<E>, LinkedList<E>, List<E>, Traversable<E>, Iterable<E>
ConsList is a functional LinkedList implementation
that constructs a list by prepending an element to another list.
WARNING: Appending to a ConsList results in copying the entire list - always
use a Builder when appending. Likewise,
operations like set(int, Object) will result in copying portions of the list.
If there is any doubt as to the access patterns for using a List, 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> ConsList<E> empty()static <E> @NotNull BuilderFactory<E, ConsList<E>> factory()iterator()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).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
isEmpty, makeString, makeString, size, to, toArray, toArray, toIndexedList, toSet, toSortedSet, toStringMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface Traversable
forEach, isEmpty, makeString, makeString, size, to, toArray, toArray, toIndexedList, toSet, toSortedSet
-
Field Details
-
EMPTY
-
-
Constructor Details
-
ConsList
public ConsList()
-
-
Method Details
-
factory
-
empty
-
prepend
-
append
-
iterator
-
range
@NotNull public abstract @NotNull ConsList<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
-
tail
-
take
-
drop
-
set
-