Package com.complexible.common.collect
Class NestedList<T>
java.lang.Object
com.complexible.common.collect.NestedList<T>
- All Implemented Interfaces:
Iterable<T>
An immutable linked list object with structure sharing.
- Since:
- 0.7
- Version:
- 0.7
- Author:
- Evren Sirin
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> NestedList<T> concat(Iterable<T> begin, NestedList<T> end) Returns a list that will be the concatenation of thebeginelements andendelements in iteration order.static <T> NestedList<T> concat(Iterator<T> begin, NestedList<T> end) Returns a list that will be the concatenation of thebeginelements andendelements in iteration order.static <T> NestedList<T> create(T first, NestedList<T> rest) Returns a list with the given first element and the rest list.first()booleanisNil()iterator()static <T> NestedList<T> nil()Returns the nil (empty) list.rest()static <T> NestedList<T> singleton(T element) Returns a list with a single element.intsize()toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
nil
Returns the nil (empty) list. -
singleton
Returns a list with a single element. The returned list's rest will benil(). -
create
Returns a list with the given first element and the rest list. -
concat
Returns a list that will be the concatenation of thebeginelements andendelements in iteration order. -
concat
Returns a list that will be the concatenation of thebeginelements andendelements in iteration order. -
first
-
rest
-
isNil
public boolean isNil() -
size
public int size() -
iterator
-
toString
-