public abstract class ConsList<E> extends AbstractLinkedList<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.
| Constructor and Description |
|---|
ConsList() |
| Modifier and Type | Method and Description |
|---|---|
abstract ConsList<E> |
append(E elem)
Returns a list with the specified element appended to the bottom of the list.
|
abstract ConsList<E> |
drop(int number)
Returns a list containing all elements in this list, excluding the first
number of elements. |
static <E> ConsList<E> |
empty() |
static <E> BuilderFactory<E,ConsList<E>> |
factory() |
java.util.Iterator<E> |
iterator() |
ConsList<E> |
prepend(E elem)
Returns a list with the specified element prepended to the top of the list.
|
abstract ConsList<E> |
range(int from,
boolean fromInclusive,
int to,
boolean toInclusive)
Returns a list containing a contiguous range of elements from this list.
|
abstract ConsList<E> |
set(int i,
E elem)
Returns a list with the element set to the value specified at the index (zero-based).
|
abstract ConsList<E> |
tail()
Returns a list containing all elements in the list, excluding the first element.
|
abstract ConsList<E> |
take(int number)
Returns a list containing the first
number of elements from this list. |
asList, equals, hashCode, indexOf, lastIndexOfforEachisEmpty, makeString, makeString, size, to, toArray, toArray, toIndexedList, toSet, toSortedSet, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitasList, first, get, indexOf, last, lastIndexOfforEach, isEmpty, makeString, makeString, size, to, toArray, toArray, toIndexedList, toSet, toSortedSet@NotNull public static <E> BuilderFactory<E,ConsList<E>> factory()
public static <E> ConsList<E> empty()
@NotNull public ConsList<E> prepend(E elem)
List@NotNull public abstract ConsList<E> append(E elem)
List@NotNull public java.util.Iterator<E> iterator()
@NotNull public abstract ConsList<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 included@NotNull public abstract ConsList<E> tail()
List@NotNull public abstract ConsList<E> take(int number)
Listnumber of elements from this list.@NotNull public abstract ConsList<E> drop(int number)
Listnumber of elements.