|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--OpenList
OpenList is a type of uni-directional linked list that permits sharing of list tails. It implements the list abstraction used in many languages, such as rex, Lisp, etc.
| Field Summary | |
static java.lang.String |
defaultLeftParen
the default left paren used when a list is printed. |
static java.lang.String |
defaultRightParen
the default right paren used when a list is printed |
static java.lang.String |
defaultSpacer
the default space used when a list is printed |
private java.lang.Object |
First
the Object in the first cell of a non-empty list |
static java.lang.String |
firstException
exception message for first of empty list |
static OpenList |
nil
the one and only empty OpenList. |
static java.lang.String |
nthException
exception message for nth of a list |
private OpenList |
Rest
the rest of a list, defined to be an OpenList of all but the first cell |
static java.lang.String |
restException
exception message for rest of empty list |
static java.lang.String |
secondException
exception message for second of a list |
static java.lang.String |
thirdException
exception message for third of a list |
static java.lang.String |
wherePart
part of exception message for nth of a list |
| Constructor Summary | |
private |
OpenList(java.lang.Object _First,
OpenList _Rest)
Construct an OpenList from its first and rest. |
| Method Summary | |
OpenList |
append(OpenList L2)
Create a new list formed by elements of this list followed by those of the argument list. |
static OpenList |
append(OpenList L1,
OpenList L2)
Create a new list formed by elements of the first argument followed by those of the second. |
static OpenList |
assoc(java.lang.Object X,
OpenList L)
Find out whether the first argument occurs as the first element of any pair in the second argument, an association list. |
java.lang.Object |
clone()
Return a clone of this OpenList. |
OpenList |
cons(java.lang.Object _First)
Return a new OpenList constructed from this list and a first. |
static OpenList |
cons(java.lang.Object _First,
OpenList _Rest)
Return a new OpenList constructed from its first and rest. |
java.util.Enumeration |
elements()
Return an Enumeration of the elements of this OpenList. |
boolean |
equals(java.lang.Object Ob)
Return true if this list is equal to the argument list. |
static boolean |
equals(OpenList L1,
OpenList L2)
Return true if the two OpenLists are equal, in the sense of having the equal elements in both listss. |
static OpenList |
explode(java.lang.String s)
Explode the argument String into a list of Characters wrapping the characters of the String. |
java.lang.Object |
first()
Return the first of this non-empty OpenList. |
static java.lang.Object |
first(OpenList List)
Return the first of the argument, a non-empty OpenList. |
static OpenList |
fromArray(java.lang.Object[] a)
Create an OpenList from an array of Objects. |
java.lang.String |
implode()
Implode this OpenList into a single String. |
static java.lang.String |
implode(OpenList L)
Implode the contents of an OpenList into a single String. |
boolean |
isEmpty()
Return true if this list is empty, false otherwise. |
static boolean |
isEmpty(OpenList List)
Return true if the argument list is empty, false otherwise. |
(package private) static java.lang.String |
lconcat(OpenList L,
java.lang.String S)
lconcat concatenates the elements of an OpenList, interspersing a designated String between elements. |
(package private) java.lang.String |
lconcat(java.lang.String S)
lconcat concatenates the elements of this OpenList, interspersing a designated String between elements. |
int |
length()
Return the number of elements of this list. |
static int |
length(OpenList L)
Return the number of elements of the argument list. |
static OpenList |
list()
Return the list consisting of the argument objects, in this case the empty list. |
static OpenList |
list(java.lang.Object First)
Return the list consisting of the argument objects. |
static OpenList |
list(java.lang.Object First,
java.lang.Object Second)
Return the list consisting of the argument objects. |
static OpenList |
list(java.lang.Object First,
java.lang.Object Second,
java.lang.Object Third)
Return the list consisting of the argument objects. |
static OpenList |
list(java.lang.Object First,
java.lang.Object Second,
java.lang.Object Third,
java.lang.Object Fourth)
Return the list consisting of the argument objects. |
static OpenList |
list(java.lang.Object First,
java.lang.Object Second,
java.lang.Object Third,
java.lang.Object Fourth,
java.lang.Object Fifth)
Return the list consisting of the argument objects. |
static OpenList |
list(java.lang.Object First,
java.lang.Object Second,
java.lang.Object Third,
java.lang.Object Fourth,
java.lang.Object Fifth,
java.lang.Object Sixth)
Return the list consisting of the argument objects. |
static OpenList |
list(java.lang.Object First,
java.lang.Object Second,
java.lang.Object Third,
java.lang.Object Fourth,
java.lang.Object Fifth,
java.lang.Object Sixth,
java.lang.Object Seventh)
Return the list consisting of the argument objects. |
static void |
main(java.lang.String[] arg)
test program: exercises a variety of the defined methods, printing out results |
OpenList |
map(Function1 f)
Map a Function1 f over this OpenList. |
static OpenList |
map(Function1 f,
OpenList L)
Map a Function1 function object f over an OpenList L. |
static OpenList |
mappend(Function1 f,
OpenList L)
Map a Function1 function object f over an OpenList L, where the function is expected to produce a list for each object, then append the results together to get an overall list. |
boolean |
member(java.lang.Object Ob)
Return true if the first argument is a member (in the sense of being equals) of this OpenList |
static boolean |
member(java.lang.Object Ob,
OpenList L)
Return true if the first argument is a member (in the sense of being equals) of the second argument list |
boolean |
nonEmpty()
Return true if this list is non-empty, false otherwise. |
static boolean |
nonEmpty(OpenList List)
Return true if the argument list is non-empty, false otherwise. |
java.lang.Object |
nth(int n)
Return the nth element of this list, starting with n = 0, 1, 2, ... |
static java.lang.Object |
nth(int n,
OpenList L)
Return the nth element of the second argument list, starting with n = 0, 1, 2, ... |
OpenList |
prefix(int n)
Returns the first n elements of this OpenList. |
static OpenList |
prefix(int n,
OpenList L)
Returns the first n elements of an OpenList. |
static OpenList |
readLines(java.io.BufferedReader reader)
Read lines from a BufferedReader, each as a separate String. |
java.lang.Object |
reduce(Function2 b,
java.lang.Object u)
Reduce this OpenList using Function2 b and unit u. |
static java.lang.Object |
reduce(Function2 b,
java.lang.Object u,
OpenList L)
Reduce an OpenList using Function2 b and unit u. |
OpenList |
rest()
Return the rest, i.e. all a list of all but the first of this non-empty OpenList. |
static OpenList |
rest(OpenList List)
Return the rest, i.e. all a list of all but the first of the argument non-empty OpenList. |
OpenList |
reverse()
Return a new list containing the elements of the argument this list in reverse order. |
static OpenList |
reverse(OpenList L1)
Return a new list containing the elements of the argument list in reverse order. |
java.lang.Object |
second()
Return the second element of this OpenList, assuming it has one. |
static java.lang.Object |
second(OpenList L)
Return the second element of the argument OpenList, assuming it has one. |
static OpenList |
solidify(java.util.Enumeration E)
Create an OpenList of the elements from an Enumeration. |
OpenList |
sort(java.util.Comparator comparator)
Return a sorted version of this list, as determined by the Comparator, using the Quicksort algorithm |
java.lang.Object |
third()
Return the third element of this OpenList, assuming it has one. |
static java.lang.Object |
third(OpenList L)
Return the third element of the argument OpenList, assuming it has one. |
java.lang.Object[] |
toArray()
Return an array of the Objects in this OpenList. |
static java.lang.Object[] |
toArray(OpenList L)
Return an array of the Objects in the argument OpenList. |
java.lang.String |
toString()
Convert this OpenList to a String, using default punctuation. |
java.lang.String |
toString(java.lang.String leftParen,
java.lang.String spacer,
java.lang.String rightParen)
Convert this OpenList to a String, using the arguments as punctuation. |
| Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final OpenList nil
public static java.lang.String defaultLeftParen
public static java.lang.String defaultRightParen
public static java.lang.String defaultSpacer
public static java.lang.String firstException
public static java.lang.String restException
public static java.lang.String nthException
public static java.lang.String wherePart
public static java.lang.String secondException
public static java.lang.String thirdException
private java.lang.Object First
private OpenList Rest
| Constructor Detail |
private OpenList(java.lang.Object _First,
OpenList _Rest)
_First - the first Object in the list_Rest - list of the rest of the objects in the list| Method Detail |
public static OpenList cons(java.lang.Object _First,
OpenList _Rest)
_First - the first Object in the list_Rest - list of the rest of the objects in the list
public OpenList cons(java.lang.Object _First)
_First - the first Object in the list
public java.lang.Object first()
throws OpenListException
OpenListException - if this list happens to be empty
public static java.lang.Object first(OpenList List)
throws OpenListException
List - the list the rest of which is to be returned
OpenListException - if the argument happens to be empty
public OpenList rest()
throws OpenListException
OpenListException - if this list happens to be empty
public static OpenList rest(OpenList List)
throws OpenListException
List - the list the rest of which is to be returned
OpenListException - if the argument happens to be emptypublic boolean isEmpty()
public boolean nonEmpty()
public static boolean isEmpty(OpenList List)
List - the OpenList for which emptiness is to be determined
public static boolean nonEmpty(OpenList List)
List - the OpenList for which non-emptiness is to be determined
public static OpenList append(OpenList L1,
OpenList L2)
L1 - the list providing the initial elements of the resultL2 - the list providing the final elements of the result
public OpenList append(OpenList L2)
public static boolean member(java.lang.Object Ob,
OpenList L)
Ob - the object being tested for membershipL - the list in which membership is to be tested
public boolean member(java.lang.Object Ob)
Ob - the object being tested for membership
public static OpenList reverse(OpenList L1)
L1 - the list providing the elements
public OpenList reverse()
public static int length(OpenList L)
L - the list, the length of which is to be determined
public int length()
public static java.lang.Object nth(int n,
OpenList L)
throws OpenListException
n - the index (0, 1, 2, ...) of the desired element.L - the list from which the indexed item is selected
OpenListException - if there is no nth element
public java.lang.Object nth(int n)
throws OpenListException
n - the index (0, 1, 2, ...) of the desired element.
OpenListException - if there is no nth elementpublic OpenList prefix(int n)
n - the length of the desired prefix of this list.
public static OpenList prefix(int n,
OpenList L)
n - the length of the desired prefix of this list.L - the list, the prefix of which is to be extracted
public java.lang.Object second()
throws OpenListException
OpenListException - if there is no second element
public java.lang.Object third()
throws OpenListException
OpenListException - if there is no third element
public static java.lang.Object second(OpenList L)
throws OpenListException
L - an OpenList, the second element of which is to be extracted
OpenListException - if there is no second element
public static java.lang.Object third(OpenList L)
throws OpenListException
L - an OpenList, the third element of which is to be extracted
OpenListException - if there is no third elementpublic static OpenList list()
public static OpenList list(java.lang.Object First)
First - the first element in the resulting list
public static OpenList list(java.lang.Object First,
java.lang.Object Second)
First - the first element in the resulting listSecond - the second element in the resulting list
public static OpenList list(java.lang.Object First,
java.lang.Object Second,
java.lang.Object Third)
First - the first element in the resulting listSecond - the second element in the resulting listThird - the third element in the resulting list
public static OpenList list(java.lang.Object First,
java.lang.Object Second,
java.lang.Object Third,
java.lang.Object Fourth)
First - the first element in the resulting listSecond - the second element in the resulting listThird - the third element in the resulting listFourth - the fourth element in the resulting list
public static OpenList list(java.lang.Object First,
java.lang.Object Second,
java.lang.Object Third,
java.lang.Object Fourth,
java.lang.Object Fifth)
First - the first element in the resulting listSecond - the second element in the resulting listThird - the third element in the resulting listFourth - the fourth element in the resulting listFifth - the fifth element in the resulting list
public static OpenList list(java.lang.Object First,
java.lang.Object Second,
java.lang.Object Third,
java.lang.Object Fourth,
java.lang.Object Fifth,
java.lang.Object Sixth)
First - the first element in the resulting listSecond - the second element in the resulting listThird - the third element in the resulting listFourth - the fourth element in the resulting listFifth - the fifth element in the resulting listSixth - the sixth element in the resulting list
public static OpenList list(java.lang.Object First,
java.lang.Object Second,
java.lang.Object Third,
java.lang.Object Fourth,
java.lang.Object Fifth,
java.lang.Object Sixth,
java.lang.Object Seventh)
First - the first element in the resulting listSecond - the second element in the resulting listThird - the third element in the resulting listFourth - the fourth element in the resulting listFifth - the fifth element in the resulting listSixth - the sixth element in the resulting listSeventh - the seventh element in the resulting list
public static boolean equals(OpenList L1,
OpenList L2)
L1 - one of two OpenLists to be compared for equalityL2 - the other of two OpenLists to be compared for equality
public boolean equals(java.lang.Object Ob)
equals in class java.lang.ObjectOb - the Object to be compared with this for equality
public java.lang.Object clone()
clone in class java.lang.Object
public static OpenList map(Function1 f,
OpenList L)
f - a member of a class that implements the Function1 interface,
i.e. that provides a method Object apply(Object).L - a list, the elements of which will be arguments of f
public OpenList map(Function1 f)
f - a member of a class that implements the Function1 interface,
i.e. that provides a method Object apply(Object).
public static OpenList mappend(Function1 f,
OpenList L)
f - a member of a class that implements the Function1 interface,
i.e. that provides a method Object apply(Object).L - a list, the elements of which will be arguments of f
public static java.lang.Object reduce(Function2 b,
java.lang.Object u,
OpenList L)
b - a member of a class that implements the Function2 interface,
i.e. that provides a method Object apply(Object, Object).u - the unit for the function b. This will be the value returned
if L is the empty list.L - the list to be reduced by the function b.
public java.lang.Object reduce(Function2 b,
java.lang.Object u)
b - a member of a class that implements the Function2 interface,
i.e. that provides a method Object apply(Object, Object).u - the unit for the function b. This will be the value returned
public static OpenList assoc(java.lang.Object X,
OpenList L)
assoc(S, []) => []; assoc(S, [[S, T] | L]) => [S, T]; assoc(S, [_ | L]) => assoc(S, L);
public java.lang.String toString()
toString in class java.lang.Object
public java.lang.String toString(java.lang.String leftParen,
java.lang.String spacer,
java.lang.String rightParen)
leftParen - String that is output before the list elementsspacer - String that is output between list elementsrightParen - String that is output after the list elements
public static OpenList explode(java.lang.String s)
public static java.lang.String implode(OpenList L)
L - the list to be imploded
public java.lang.String implode()
public static java.lang.Object[] toArray(OpenList L)
L - the list of objects to be used as elements of the array
public java.lang.Object[] toArray()
public static OpenList fromArray(java.lang.Object[] a)
public OpenList sort(java.util.Comparator comparator)
comparator - used to determine whether one element is less than
another
public static OpenList readLines(java.io.BufferedReader reader)
throws java.io.IOException
reader - reads the lines that are compiled into a list
java.io.IOExceptionpublic java.util.Enumeration elements()
public static OpenList solidify(java.util.Enumeration E)
E - an Enumeration that provides the elements for a new OpenList
java.lang.String lconcat(java.lang.String S)
S - a String to be interspersed between the items of this list
static java.lang.String lconcat(OpenList L,
java.lang.String S)
L - an OpenList, the elements of which are to be concatenated.S - a String to be interspersed between the items of L.
public static void main(java.lang.String[] arg)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||