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>,java.lang.Iterable<E>
public abstract class ConsList<E> extends AbstractLinkedList<E>
ConsListis a functionalLinkedListimplementation that constructs a list by prepending an element to another list.WARNING: Appending to a
ConsListresults in copying the entire list - always use aBuilderwhen appending. Likewise, operations likeset(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 aVectorinstead.
-
-
Constructor Summary
Constructors Constructor Description ConsList()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract @NotNull ConsList<E>append(E elem)Returns a list with the specified element appended to the bottom of the list.abstract @NotNull ConsList<E>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()@NotNull java.util.Iterator<E>iterator()@NotNull ConsList<E>prepend(E elem)Returns a list with the specified element prepended to the top of the list.abstract @NotNull ConsList<E>range(int from, boolean fromInclusive, int to, boolean toInclusive)Returns a list containing a contiguous range of elements from this list.abstract @NotNull ConsList<E>set(int i, E elem)Returns a list with the element set to the value specified at the index (zero-based).abstract @NotNull ConsList<E>tail()Returns a list containing all elements in the list, excluding the first element.abstract @NotNull ConsList<E>take(int number)Returns a list containing the firstnumberof elements from this list.-
Methods inherited from class com.github.andrewoma.dexx.collection.internal.base.AbstractList
asList, equals, hashCode, indexOf, lastIndexOf
-
Methods inherited from class com.github.andrewoma.dexx.collection.internal.base.AbstractIterable
forEach
-
Methods inherited from class com.github.andrewoma.dexx.collection.internal.base.AbstractTraversable
isEmpty, makeString, makeString, size, to, toArray, toArray, toIndexedList, toSet, toSortedSet, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.andrewoma.dexx.collection.List
asList, first, get, indexOf, last, lastIndexOf
-
Methods inherited from interface com.github.andrewoma.dexx.collection.Traversable
forEach, isEmpty, makeString, makeString, size, to, toArray, toArray, toIndexedList, toSet, toSortedSet
-
-
-
-
Field Detail
-
EMPTY
private static final ConsList<java.lang.Object> EMPTY
-
-
Method Detail
-
factory
@NotNull public static <E> @NotNull BuilderFactory<E,ConsList<E>> factory()
-
empty
public static <E> ConsList<E> empty()
-
prepend
@NotNull public @NotNull ConsList<E> prepend(E elem)
Description copied from interface:ListReturns a list with the specified element prepended to the top of the list.
-
append
@NotNull public abstract @NotNull ConsList<E> append(E elem)
Description copied from interface:ListReturns a list with the specified element appended to the bottom of the list.
-
iterator
@NotNull public @NotNull java.util.Iterator<E> 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
@NotNull public abstract @NotNull ConsList<E> tail()
Description copied from interface:ListReturns a list containing all elements in the list, excluding the first element. An empty list is returned if the list is empty.
-
take
@NotNull public abstract @NotNull ConsList<E> take(int number)
Description copied from interface:ListReturns a list containing the firstnumberof elements from this list.
-
drop
@NotNull public abstract @NotNull ConsList<E> drop(int number)
Description copied from interface:ListReturns a list containing all elements in this list, excluding the firstnumberof elements.
-
-