Class Cons<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>
-
- com.github.andrewoma.dexx.collection.Cons<E>
-
- All Implemented Interfaces:
Iterable<E>,LinkedList<E>,List<E>,Traversable<E>,java.lang.Iterable<E>
class Cons<E> extends ConsList<E>
Cons constructs a new list by prepending a new element to an existing list
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull ConsList<E>append(E elem)Returns a list with the specified element appended to the bottom of the list.@NotNull ConsList<E>drop(int number)Returns a list containing all elements in this list, excluding the firstnumberof elements.Efirst()Returns first element in the list ornullif the list is empty.Eget(int i)Returns the element at the specified index in this list (zero-based).booleanisEmpty()Returns true if this collection is empty.Elast()Returns last element in the list ornullif the list is empty.@NotNull ConsList<E>range(int from, boolean fromInclusive, int to, boolean toInclusive)Returns a list containing a contiguous range of elements from this list.@NotNull ConsList<E>set(int i, E elem)Returns a list with the element set to the value specified at the index (zero-based).@NotNull ConsList<E>tail()Returns a list containing all elements in the list, excluding the first element.@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.ConsList
empty, factory, iterator, prepend
-
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
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, indexOf, lastIndexOf
-
Methods inherited from interface com.github.andrewoma.dexx.collection.Traversable
forEach, makeString, makeString, size, to, toArray, toArray, toIndexedList, toSet, toSortedSet
-
-
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
Description copied from interface:TraversableReturns true if this collection is empty.- Specified by:
isEmptyin interfaceTraversable<E>- Overrides:
isEmptyin classAbstractTraversable<E>
-
first
@Nullable public E first()
Description copied from interface:ListReturns first element in the list ornullif the list is empty.
-
tail
@NotNull public @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.
-
set
@NotNull public @NotNull ConsList<E> set(int i, E elem)
Description copied from interface:ListReturns a list with the element set to the value specified at the index (zero-based).
-
append
@NotNull public @NotNull ConsList<E> append(E elem)
Description copied from interface:ListReturns a list with the specified element appended to the bottom of the list.
-
drop
@NotNull public @NotNull ConsList<E> drop(int number)
Description copied from interface:ListReturns a list containing all elements in this list, excluding the firstnumberof elements.
-
take
@NotNull public @NotNull ConsList<E> take(int number)
Description copied from interface:ListReturns a list containing the firstnumberof elements from this list.
-
range
@NotNull public @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.- Specified by:
rangein interfaceLinkedList<E>- Specified by:
rangein interfaceList<E>- Specified by:
rangein classConsList<E>- 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
public E get(int i)
Description copied from interface:ListReturns the element at the specified index in this list (zero-based).
-
-