|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectopenlist.OpenList<Type>
public class OpenList<Type>
OpenList implements Scheme/Lisp-style lists, as immutable objects. An OpenList is either empty (NIL) or has a head and a tail, where the head is of some given type and tail is an OpenList of that type.
| Nested Class Summary | |
|---|---|
(package private) class |
OpenList.Neutralizer
A Function1arg that neutralizes an object, making the types of its elements Object. |
| Field Summary | |
|---|---|
protected Type |
head
the head element of an OpenList |
static OpenList |
NIL
the one and only empty OpenList. |
protected OpenList<Type> |
tail
the elements of an OpenList after the head. |
| Constructor Summary | |
|---|---|
protected |
OpenList(Type head,
OpenList<Type> tail)
the private constructor for an OpenList. |
| Method Summary | ||
|---|---|---|
OpenList<Type> |
append(OpenList<Type> M)
Append the argument to this list, creating a new list. |
|
static
|
append(OpenList<Type> L,
OpenList<Type> M)
Append the second list to the head, by creating a new list with the elements of the head copied. |
|
static
|
assoc(Object key,
OpenList<OpenList<Object>> alist)
Search the second argument for an element, which must be a list, the head element of which is equal to key. |
|
OpenList<Type> |
assoc(Type key)
Assuming this OpenList is an association list (list of non-empty lists), where the head elements are "key" values, search to find the head list that equals a given key. |
|
static java.lang.String |
categorize(java.lang.Object ob)
Categorize an object by creating a String description of its type, with a pre-specified indent of two spaces. |
|
static java.lang.String |
categorize(java.lang.Object ob,
java.lang.String indent)
Categorize an object by creating a String description of its type. |
|
static java.lang.String |
categorize(java.lang.Object ob,
java.lang.String indent,
java.lang.StringBuffer buffer)
Categorize an object by creating a String description of its type. |
|
OpenList<Type> |
cons(Type head)
Create an OpenList beginning with a new head and followed by this list. |
|
static
|
cons(Type head,
OpenList<Type> tail)
Create an OpenList from a head and a tail. |
|
java.util.Enumeration<Type> |
elements()
return a java.util.Enumeration of the elements of this OpenList |
|
boolean |
equals(java.lang.Object ob)
Return true if the argument equals this OpenList |
|
Type |
first()
Get the head element this, an OpenList. |
|
static
|
first(OpenList<Type> L)
Get the head element of a non-empty OpenList. |
|
Type |
foldl(Function2arg<Type> g,
Type unit)
Fold this list from the left using a 2-ary function. |
|
Type |
foldr(Function2arg<Type> g,
Type unit)
Fold this list from the right using a 2-ary function. |
|
Type |
fourth()
Returns the fourth element, provided the list has at least four elements. |
|
OpenList<Type> |
fromCollection(java.util.Collection<Type> collection)
Make an OpenList from the elements of a Collection. |
|
boolean |
isEmpty()
Determine whether or not this OpenList empty. |
|
static
|
isEmpty(OpenList<Type> L)
Determine whether or not the argument is empty. |
|
Type |
last()
returns the last element of a non-empty list. |
|
int |
length()
length() computes and returns the length of this OpenList |
|
static
|
list(Type... args)
Create an OpenList of an arbitrary number of elements. |
|
OpenList<java.lang.Object> |
map(Function1arg<Type> f)
Map a 1-ary function over this list of elements. |
|
OpenList<Type> |
member(Type sought)
Return the first prefix of this OpenList beginning with sought. |
|
OpenList<java.lang.Object> |
neutralize()
Make a neutralized version of an OpenList, in which each element has type Object. |
|
boolean |
nonEmpty()
Determine whether or not this OpenList is non-empty. |
|
static
|
nonEmpty(OpenList<Type> L)
Determine whether or not the argument is non-empty. |
|
Type |
nth(int n)
Returns the element at index n, n = 0, 1, 2, ... |
|
static OpenList |
OpenListFromArray(java.lang.Object[] array)
Create OpenList from array of things of a given Type |
|
static OpenList<java.lang.Integer> |
range(int m,
int n)
Create a list of Integer from m through n. |
|
OpenList<Type> |
rest()
Get the elements following the head this, an OpenList. |
|
static
|
rest(OpenList<Type> L)
Get the elements following the head of a non-empty OpenList. |
|
OpenList<Type> |
reverse()
Create the reverse of this OpenList. |
|
static
|
reverse(OpenList<Type> L)
Create the reverse of the argument OpenList. |
|
Type |
second()
Returns the second element, provided the list has at least two elements. |
|
Type |
third()
Returns the third element, provided the list has at least three elements. |
|
java.lang.Object[] |
toArray()
Create an array of elements of the same type as those in the OpenList |
|
void |
toCollection(java.util.Collection<Type> collection)
Add the elements of this OpenList to a Collection, without clearing the Collection first. |
|
java.lang.String |
toString()
Return a String representation of this 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 java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static OpenList NIL
protected Type head
protected OpenList<Type> tail
| Constructor Detail |
|---|
protected OpenList(Type head,
OpenList<Type> tail)
head - The head element in the list being constructed.tail - A list of all but the head element of the list being
constructed.| Method Detail |
|---|
public OpenList<Type> cons(Type head)
head - The head element in the list being constructed.
public Type first()
public OpenList<Type> rest()
public boolean isEmpty()
public boolean nonEmpty()
public int length()
public OpenList<Type> reverse()
public OpenList<Type> append(OpenList<Type> M)
M - the list to be appended to this OpenList
public boolean equals(java.lang.Object ob)
equals in class java.lang.Objectob -
public java.lang.Object[] toArray()
public void toCollection(java.util.Collection<Type> collection)
collection - the Collection to which the elements are added.public OpenList<Type> fromCollection(java.util.Collection<Type> collection)
collection - the Collection containing the elements
public java.lang.String toString()
toString in class java.lang.Object
public java.lang.String toString(java.lang.String start,
java.lang.String separator,
java.lang.String end)
public OpenList<Type> assoc(Type key)
key -
public OpenList<Type> member(Type sought)
sought -
public java.util.Enumeration<Type> elements()
public Type second()
public Type third()
public Type fourth()
public Type nth(int n)
public Type last()
public OpenList<java.lang.Object> map(Function1arg<Type> f)
f - the function to be mapped
public Type foldr(Function2arg<Type> g,
Type unit)
g - the function to be used for foldingunit - the unit for the function
public Type foldl(Function2arg<Type> g,
Type unit)
g - the function to be used for foldingunit - the unit for the function
public static java.lang.String categorize(java.lang.Object ob,
java.lang.String indent,
java.lang.StringBuffer buffer)
ob - the object to be categorizedindent - the String used for indentationbuffer - StringBuffer in which to put append the String representation
public static java.lang.String categorize(java.lang.Object ob,
java.lang.String indent)
ob - the object to be categorizedindent - the String used for indentation
public static java.lang.String categorize(java.lang.Object ob)
ob - the object to be categorized
public OpenList<java.lang.Object> neutralize()
public static <Type> OpenList cons(Type head,
OpenList<Type> tail)
head - The first element in the list being constructed.tail - A list of all but the first element of the list being constructed.
public static <Type> boolean isEmpty(OpenList<Type> L)
L - an OpenList
public static <Type> boolean nonEmpty(OpenList<Type> L)
L - an OpenList
public static <Type> Type first(OpenList<Type> L)
L - an OpenList
public static <Type> OpenList<Type> rest(OpenList<Type> L)
L - an OpenList
public static <Type> OpenList<Type> reverse(OpenList<Type> L)
L - the list to be reversed
public static <Type> OpenList<Type> append(OpenList<Type> L,
OpenList<Type> M)
L - the head list to be appendedM - the second list to be appended
public static <Object> OpenList<Object> assoc(Object key,
OpenList<OpenList<Object>> alist)
key - alist - to be searched
public static <Type> OpenList<Type> list(Type... args)
args - the elements
public static OpenList OpenListFromArray(java.lang.Object[] array)
array -
public static OpenList<java.lang.Integer> range(int m,
int n)
m - n -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||