Public Methods | |
| Object | first () throws OpenListException |
| OpenList | rest () throws OpenListException |
| boolean | isEmpty () |
| boolean | nonEmpty () |
| int | length () |
| Object | nth (int n) throws OpenListException |
| OpenList | prefix (int n) |
| String | toString () |
| String | toString (String leftParen, String spacer, String rightParen) |
Static Public Methods | |
| OpenList | cons (Object _First, OpenList _Rest) |
| Object | first (OpenList List) throws OpenListException |
| OpenList | rest (OpenList List) throws OpenListException |
| boolean | isEmpty (OpenList List) |
| boolean | nonEmpty (OpenList List) |
| OpenList | append (OpenList L1, OpenList L2) |
| OpenList | reverse (OpenList L1) |
| void | main (String arg[]) |
Static Public Attributes | |
| String | defaultLeftParen = "[" |
| String | defaultRightParen = "]" |
| String | defaultSpacer = ", " |
| final OpenList | nil = cons(null, null) |
| String | firstOfOpenListException = "first() of empty list" |
| String | restOfOpenListException = "rest() of empty list" |
Definition at line 13 of file OpenList.java.
|
|
Create a new list formed by elements of the first argument followed by those of the second.
Definition at line 222 of file OpenList.java. Referenced by main(). |
|
|
Return a new OpenList constructed from its first and rest.
Definition at line 89 of file OpenList.java. |
|
|
Return the first of the argument, a non-empty OpenList.
Definition at line 120 of file OpenList.java. |
|
|
Return the first of this non-empty OpenList.
Definition at line 102 of file OpenList.java. Referenced by append(), nth(), prefix(), reverse(), and toString(). |
|
|
Return true if the argument list is empty, false otherwise. Note: Done by comparing this list to nil, which should be the only way to determine whether the list is empty.
Definition at line 193 of file OpenList.java. |
|
|
Return true if this list is empty, false otherwise. Note: Done by comparing this list to nil, which should be the only way to determine whether the list is empty.
Definition at line 167 of file OpenList.java. Referenced by append(), first(), isEmpty(), prefix(), and rest(). |
|
|
Return the number of elements of this list.
Definition at line 262 of file OpenList.java. |
|
|
test program: exercises a variety of the defined methods, printing out results Definition at line 383 of file OpenList.java. |
|
|
Return true if the argument list is non-empty, false otherwise.
Definition at line 206 of file OpenList.java. |
|
|
Return true if this list is non-empty, false otherwise.
Definition at line 178 of file OpenList.java. Referenced by length(), nonEmpty(), reverse(), and toString(). |
|
|
Return the nth element of this list, starting with n = 0, 1, 2, ... If there is no nth element, throws an EmptyList exception so indicating.
Definition at line 285 of file OpenList.java. Referenced by main(). |
|
|
Returns the first n elements of an OpenList. If there aren't n elements in the list, returns the entire list. If n <= 0, returns nil.
Definition at line 318 of file OpenList.java. Referenced by main(). |
|
|
Return the rest, i.e. all a list of all but the first of the argument non-empty OpenList.
Definition at line 154 of file OpenList.java. |
|
|
Return the rest, i.e. all a list of all but the first of this non-empty OpenList.
Definition at line 135 of file OpenList.java. Referenced by append(), length(), nth(), prefix(), reverse(), and toString(). |
|
|
Return a new list containing the elements of the argument list in reverse order.
Definition at line 243 of file OpenList.java. Referenced by main(). |
|
|
Convert this OpenList to a String, using the arguments as punctuation.
Definition at line 352 of file OpenList.java. |
|
|
Convert this OpenList to a String, using default punctuation.
Definition at line 335 of file OpenList.java. |
|
|
the default left paren used when a list is printed. Defaults are used when the toString() method is called, i.e. whenever an OpenList is automatically cast to a String, as in printing. To use different punctuation, or no punctuation, use the three-argument toString, and supply the punctuation you want. Definition at line 23 of file OpenList.java. |
|
|
the default right paren used when a list is printed Definition at line 28 of file OpenList.java. |
|
|
the default space used when a list is printed Definition at line 33 of file OpenList.java. |
|
|
exception message for first of empty list Definition at line 48 of file OpenList.java. |
|
|
the one and only empty OpenList. Do not create any others. This list is represented by a unique cell allocated for the purpose. The first and rest are not intended to be used. We do not use null for this list, so that we can call methods on it. Definition at line 43 of file OpenList.java. |
|
|
exception message for rest of empty list Definition at line 53 of file OpenList.java. |
1.2.6 written by Dimitri van Heesch,
© 1997-2001