Package com.complexible.common.collect

# 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 Summary

  Modifier and Type
  Method
  Description
  `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.
  `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.
  `static <T> NestedList<T>`
  `create(T first, NestedList<T> rest)`
  Returns a list with the given first element and the rest list.
  `T`
  `first()`
  `boolean`
  `isNil()`
  `Iterator<T>`
  `iterator()`
  `static <T> NestedList<T>`
  `nil()`
  Returns the nil (empty) list.
  `NestedList<T>`
  `rest()`
  `static <T> NestedList<T>`
  `singleton(T element)`
  Returns a list with a single element.
  `int`
  `size()`
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface java.lang.Iterable

  `forEach, spliterator`

- ## 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`