openlist.incremental
Class IncrementalList<Type>

java.lang.Object
  extended by openlist.OpenList<Type>
      extended by openlist.incremental.IncrementalList<Type>

public class IncrementalList<Type>
extends OpenList<Type>

An IncrementalList is a special case of OpenList that can be expanded incrementally from the tail forward. For example, it can be used to represent infinite lists.


Field Summary
(package private)  Growable<Type> growable
          IncrementalLists are non-empty, by definition.
 
Fields inherited from class openlist.OpenList
head, NIL, tail
 
Constructor Summary
IncrementalList(Type head, Growable<Type> growable)
          The constructor for IncrementalList
 
Method Summary
 IncrementalList<Type> cons(Type head)
          A version of cons that produces an IncrementalList from this IncrementalList and a new first element
 void ensureGrown()
          Make sure that the Growable part has grown at least one level so that, e.g.
 boolean grown()
          Indicate whether or not the Growable part has grown
 OpenList<java.lang.Object> map(Function1arg<Type> f)
          Map a 1-ary function over this list of elements.
 OpenList<Type> rest()
          Get the elements following the head this, an OpenList.
 java.lang.String toString(java.lang.String start, java.lang.String separator, java.lang.String end)
          Return a String representation of this OpenList.
 
Methods inherited from class openlist.OpenList
append, append, assoc, assoc, categorize, categorize, categorize, cons, elements, equals, first, first, foldl, foldr, fourth, fromCollection, isEmpty, isEmpty, last, length, list, member, neutralize, nonEmpty, nonEmpty, nth, OpenListFromArray, range, rest, reverse, reverse, second, third, toArray, toCollection, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

growable

Growable<Type> growable
IncrementalLists are non-empty, by definition. They use the head of the underlying OpenList. Their rest is generated by an object satisfying the Growable interface. When grow() is called on the Growable, the next element of the list is generated, and the current Growable is replaced.

Constructor Detail

IncrementalList

public IncrementalList(Type head,
                       Growable<Type> growable)
The constructor for IncrementalList

Parameters:
head - the first element of the list
growable - produces the rest of the elements of the list
Method Detail

cons

public IncrementalList<Type> cons(Type head)
A version of cons that produces an IncrementalList from this IncrementalList and a new first element

Overrides:
cons in class OpenList<Type>
Parameters:
head -
Returns:
a new IncrementalList beginning with the given first element followed by this IncrementalList

rest

public OpenList<Type> rest()
Description copied from class: OpenList
Get the elements following the head this, an OpenList.

Overrides:
rest in class OpenList<Type>
Returns:
the rest of this IncrementalList

ensureGrown

public void ensureGrown()
Make sure that the Growable part has grown at least one level so that, e.g. rest() can be executed.


grown

public boolean grown()
Indicate whether or not the Growable part has grown

Returns:
indication whether grown or not

map

public OpenList<java.lang.Object> map(Function1arg<Type> f)
Map a 1-ary function over this list of elements.

Overrides:
map in class OpenList<Type>
Parameters:
f - the function to be mapped
Returns:
the resulting OpenList

toString

public java.lang.String toString(java.lang.String start,
                                 java.lang.String separator,
                                 java.lang.String end)
Return a String representation of this OpenList. Parentheses are used to delimit the list itself. Lists-of-lists are returned as S expression Strings.

Overrides:
toString in class OpenList<Type>
Returns:
a String representation of this OpenList.