Class NestedList<T>

java.lang.Object
com.complexible.common.collect.NestedList<T>
All Implemented Interfaces:
Iterable<T>

public class NestedList<T> extends Object implements Iterable<T>
An immutable linked list object with structure sharing.
Since:
0.7
Version:
0.7
Author:
Evren Sirin
  • Method Details

    • nil

      public static <T> NestedList<T> nil()
      Returns the nil (empty) list.
    • singleton

      public static <T> NestedList<T> singleton(T element)
      Returns a list with a single element. The returned list's rest will be nil().
    • create

      public static <T> NestedList<T> create(T first, NestedList<T> rest)
      Returns a list with the given first element and the rest list.
    • concat

      public static <T> NestedList<T> concat(Iterable<T> begin, NestedList<T> end)
      Returns a list that will be the concatenation of the begin elements and end elements in iteration order.
    • concat

      public static <T> NestedList<T> concat(Iterator<T> begin, NestedList<T> end)
      Returns a list that will be the concatenation of the begin elements and end elements in iteration order.
    • first

      public T first()
    • rest

      public NestedList<T> rest()
    • isNil

      public boolean isNil()
    • size

      public int size()
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • toString

      public String toString()
      Overrides:
      toString in class Object