Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

OpenList Class Reference

List of all members.

Public Methods

OpenList cons (Object _First)
Object first () throws OpenListException
OpenList rest () throws OpenListException
boolean isEmpty ()
boolean nonEmpty ()
OpenList append (OpenList L2)
boolean member (Object Ob)
OpenList reverse ()
int length ()
Object nth (int n) throws OpenListException
OpenList prefix (int n)
Object second () throws OpenListException
Object third () throws OpenListException
boolean equals (Object Ob)
String toString ()
String toString (String leftParen, String spacer, String rightParen)
String implode ()
Object [] toArray ()
OpenList sort (java.util.Comparator comparator)

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)
boolean member (Object Ob, OpenList L)
OpenList reverse (OpenList L1)
int length (OpenList L)
Object nth (int n, OpenList L) throws OpenListException
OpenList prefix (int n, OpenList L)
Object second (OpenList L) throws OpenListException
Object third (OpenList L) throws OpenListException
OpenList list ()
OpenList list (Object First)
OpenList list (Object First, Object Second)
OpenList list (Object First, Object Second, Object Third)
OpenList list (Object First, Object Second, Object Third, Object Fourth)
OpenList list (Object First, Object Second, Object Third, Object Fourth, Object Fifth)
OpenList list (Object First, Object Second, Object Third, Object Fourth, Object Fifth, Object Sixth)
OpenList list (Object First, Object Second, Object Third, Object Fourth, Object Fifth, Object Sixth, Object Seventh)
boolean equals (OpenList L1, OpenList L2)
OpenList explode (String s)
String implode (OpenList L)
Object [] toArray (OpenList L)
OpenList fromArray (Object a[])
void main (String arg[])

Static Public Attributes

final OpenList nil = cons(null, null)
String defaultLeftParen = "["
String defaultRightParen = "]"
String defaultSpacer = ", "
String firstException = "first() of empty list"
String restException = "rest() of empty list"
String nthException = "nth of an OpenList of length "
String wherePart = ", where n == "
String secondException = "second of an OpenList, where length() = "
String thirdException = "third of an OpenList, where length() = "

Detailed Description

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.

Definition at line 16 of file OpenList.java.


Member Function Documentation

OpenList OpenList::append ( OpenList L2 ) [inline]
 

Create a new list formed by elements of this list followed by those of the argument list.

Parameters:
L   the list providing the final elements of the result
Returns:
the list containing the elements of this list followed by those of the second

Definition at line 281 of file OpenList.java.

OpenList OpenList::append ( OpenList L1,
OpenList L2 ) [inline, static]
 

Create a new list formed by elements of the first argument followed by those of the second.

Parameters:
L1   the list providing the initial elements of the result
L2   the list providing the final elements of the result
Returns:
the list containing the elements of the first list followed by those of the second

Definition at line 259 of file OpenList.java.

Referenced by append(), and main().

OpenList OpenList::cons ( Object _First ) [inline]
 

Return a new OpenList constructed from this list and a first.

Parameters:
_First   the first Object in the list
Returns:
new OpenList from first and rest

Definition at line 127 of file OpenList.java.

OpenList OpenList::cons ( Object _First,
OpenList _Rest ) [inline, static]
 

Return a new OpenList constructed from its first and rest.

Parameters:
_First   the first Object in the list
_Rest   list of the rest of the objects in the list
Returns:
new OpenList from first and rest

Definition at line 114 of file OpenList.java.

Referenced by append(), explode(), fromArray(), list(), main(), prefix(), and reverse().

boolean OpenList::equals ( Object Ob ) [inline]
 

Return true if this list is equal to the argument list.

Parameters:
Ob   the Object to be compared with this for equality
Returns:
true if the argument is an OpenList equal to this one.

Definition at line 723 of file OpenList.java.

boolean OpenList::equals ( OpenList L1,
OpenList L2 ) [inline, static]
 

Return true if the two OpenLists are equal, in the sense of having the equal elements in both listss.

Parameters:
L1   one of two OpenLists to be compared for equality
L2   the other of two OpenLists to be compared for equality
Returns:
true if the arguments are equal, false otherwise

Definition at line 693 of file OpenList.java.

Referenced by equals(), and main().

OpenList OpenList::explode ( String s ) [inline, static]
 

Explode the argument String into a list of Characters wrapping the characters of the String.

Parameters:
String   to be exploded
Returns:
OpenList containing the characters of the String

Definition at line 788 of file OpenList.java.

Referenced by main().

Object OpenList::first ( OpenList List ) [inline, static]
 

Return the first of the argument, a non-empty OpenList.

Parameters:
List   the list the rest of which is to be returned
Returns:
first of the argument list
Exceptions:
OpenListException   if the argument happens to be empty

Definition at line 158 of file OpenList.java.

Object OpenList::first ( ) [inline]
 

Return the first of this non-empty OpenList.

Returns:
first of this list
Exceptions:
OpenListException   if this list happens to be empty

Definition at line 140 of file OpenList.java.

Referenced by append(), equals(), implode(), member(), nth(), prefix(), reverse(), toArray(), and toString().

OpenList OpenList::fromArray ( Object a[] ) [inline, static]
 

Create an OpenList from an array of Objects.

Returns:
an OpenList containing the Objects in the argument array

Definition at line 882 of file OpenList.java.

Referenced by sort().

String OpenList::implode ( ) [inline]
 

Implode this OpenList into a single String. The list can contain any Objects, not just Characters. The toString method is used to get the character representation of the object. No parentheses or spacing is added around or between the elements of the outer list.

Returns:
String representing the imploded list.

Definition at line 836 of file OpenList.java.

Referenced by main().

String OpenList::implode ( OpenList L ) [inline, static]
 

Implode the contents of an OpenList into a single String. The list can contain any Objects, not just Characters. The toString method is used to get the character representation of the object. No parentheses or spacing is added around or between the elements of the outer list. If these are wanted, use the toString method rather than implode.

Parameters:
L   the list to be imploded
Returns:
String representing the imploded list.

Definition at line 813 of file OpenList.java.

boolean OpenList::isEmpty ( OpenList List ) [inline, static]
 

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.

Parameters:
List   the OpenList for which emptiness is to be determined
Returns:
true if the argument list is empty, false otherwise

Definition at line 230 of file OpenList.java.

boolean OpenList::isEmpty ( ) [inline]
 

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.

Returns:
true if this list is empty, false otherwise

Definition at line 204 of file OpenList.java.

Referenced by append(), equals(), first(), isEmpty(), prefix(), and rest().

int OpenList::length ( ) [inline]
 

Return the number of elements of this list.

Returns:
the number of elements of this list

Definition at line 382 of file OpenList.java.

Referenced by main(), nth(), second(), third(), and toArray().

int OpenList::length ( OpenList L ) [inline, static]
 

Return the number of elements of the argument list.

Parameters:
L   the list, the length of which is to be determined
Returns:
the number of elements of the argument list

Definition at line 363 of file OpenList.java.

OpenList OpenList::list ( Object First,
Object Second,
Object Third,
Object Fourth,
Object Fifth,
Object Sixth,
Object Seventh ) [inline, static]
 

Return the list consisting of the argument objects.

Parameters:
First   the first element in the resulting list
Second   the second element in the resulting list
Third   the third element in the resulting list
Fourth   the fourth element in the resulting list
Fifth   the fifth element in the resulting list
Sixth   the sixth element in the resulting list
Seventh   the seventh element in the resulting list
Returns:
the list consisting of the argument objects

Definition at line 672 of file OpenList.java.

OpenList OpenList::list ( Object First,
Object Second,
Object Third,
Object Fourth,
Object Fifth,
Object Sixth ) [inline, static]
 

Return the list consisting of the argument objects.

Parameters:
First   the first element in the resulting list
Second   the second element in the resulting list
Third   the third element in the resulting list
Fourth   the fourth element in the resulting list
Fifth   the fifth element in the resulting list
Sixth   the sixth element in the resulting list
Returns:
the list consisting of the argument objects

Definition at line 648 of file OpenList.java.

OpenList OpenList::list ( Object First,
Object Second,
Object Third,
Object Fourth,
Object Fifth ) [inline, static]
 

Return the list consisting of the argument objects.

Parameters:
First   the first element in the resulting list
Second   the second element in the resulting list
Third   the third element in the resulting list
Fourth   the fourth element in the resulting list
Fifth   the fifth element in the resulting list
Returns:
the list consisting of the argument objects

Definition at line 626 of file OpenList.java.

OpenList OpenList::list ( Object First,
Object Second,
Object Third,
Object Fourth ) [inline, static]
 

Return the list consisting of the argument objects.

Parameters:
First   the first element in the resulting list
Second   the second element in the resulting list
Third   the third element in the resulting list
Fourth   the fourth element in the resulting list
Returns:
the list consisting of the argument objects

Definition at line 606 of file OpenList.java.

OpenList OpenList::list ( Object First,
Object Second,
Object Third ) [inline, static]
 

Return the list consisting of the argument objects.

Parameters:
First   the first element in the resulting list
Second   the second element in the resulting list
Third   the third element in the resulting list
Returns:
the list consisting of the argument objects

Definition at line 590 of file OpenList.java.

OpenList OpenList::list ( Object First,
Object Second ) [inline, static]
 

Return the list consisting of the argument objects.

Parameters:
First   the first element in the resulting list
Second   the second element in the resulting list
Returns:
the list consisting of the argument objects

Definition at line 574 of file OpenList.java.

OpenList OpenList::list ( Object First ) [inline, static]
 

Return the list consisting of the argument objects.

Parameters:
First   the first element in the resulting list
Returns:
the list consisting of the argument objects

Definition at line 560 of file OpenList.java.

OpenList OpenList::list ( ) [inline, static]
 

Return the list consisting of the argument objects, in this case the empty list.

Returns:
the list consisting of the argument objects

Definition at line 547 of file OpenList.java.

Referenced by list().

void OpenList::main ( String arg[] ) [inline, static]
 

test program: exercises a variety of the defined methods, printing out results

Definition at line 941 of file OpenList.java.

boolean OpenList::member ( Object Ob ) [inline]
 

Return true if the first argument is a member (in the sense of being equals) of this OpenList

Parameters:
Ob   the object being tested for membership
Returns:
true if the first argument is a member of this list, false otherwise

Definition at line 317 of file OpenList.java.

boolean OpenList::member ( Object Ob,
OpenList L ) [inline, static]
 

Return true if the first argument is a member (in the sense of being equals) of the second argument list

Parameters:
Ob   the object being tested for membership
L   the list in which membership is to be tested
Returns:
true if the first argument is a member of the second, false otherwise

Definition at line 297 of file OpenList.java.

Referenced by member().

boolean OpenList::nonEmpty ( OpenList List ) [inline, static]
 

Return true if the argument list is non-empty, false otherwise.

Parameters:
List   the OpenList for which non-emptiness is to be determined
Returns:
true if the argument list is non-empty, false otherwise

Definition at line 243 of file OpenList.java.

boolean OpenList::nonEmpty ( ) [inline]
 

Return true if this list is non-empty, false otherwise.

Returns:
true if this list is non-empty, false otherwise

Definition at line 215 of file OpenList.java.

Referenced by equals(), implode(), length(), member(), nonEmpty(), reverse(), toArray(), and toString().

Object OpenList::nth ( int n ) [inline]
 

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.

Parameters:
n   the index (0, 1, 2, ...) of the desired element.
Returns:
the nth element of this list
Exceptions:
OpenListException   if there is no nth element

Definition at line 430 of file OpenList.java.

Object OpenList::nth ( int n,
OpenList L ) [inline, static]
 

Return the nth element of the second argument list, starting with n = 0, 1, 2, ... If there is no nth element, throws an OpenListException so indicating.

Parameters:
n   the index (0, 1, 2, ...) of the desired element.
L   the list from which the indexed item is selected
Returns:
the nth element of this list
Exceptions:
OpenListException   if there is no nth element

Definition at line 400 of file OpenList.java.

Referenced by main(), nth(), second(), and third().

OpenList OpenList::prefix ( int n,
OpenList L ) [inline, static]
 

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.

Parameters:
n   the length of the desired prefix of this list.
L   the list, the prefix of which is to be extracted
Returns:
the prefix of this list of the desired length, or the entire list itself if the list is not as long as desired.

Definition at line 466 of file OpenList.java.

OpenList OpenList::prefix ( int n ) [inline]
 

Returns the first n elements of this OpenList. If there aren't n elements in the list, returns the entire list. If n <= 0, returns nil.

Parameters:
n   the length of the desired prefix of this list.
Returns:
the prefix of this list of the desired length, or the entire list itself if the list is not as long as desired.

Definition at line 445 of file OpenList.java.

Referenced by main(), and prefix().

OpenList OpenList::rest ( OpenList List ) [inline, static]
 

Return the rest, i.e. all a list of all but the first of the argument non-empty OpenList.

ameter List the list the rest of which is to be returned
Returns:
rest of the argument list
Exceptions:
OpenListException   if the argument happens to be empty

Definition at line 191 of file OpenList.java.

OpenList OpenList::rest ( ) [inline]
 

Return the rest, i.e. all a list of all but the first of this non-empty OpenList.

Returns:
rest of this list
Exceptions:
OpenListException   if this list happens to be empty

Definition at line 172 of file OpenList.java.

Referenced by append(), equals(), implode(), length(), member(), nth(), prefix(), reverse(), toArray(), and toString().

OpenList OpenList::reverse ( ) [inline]
 

Return a new list containing the elements of the argument this list in reverse order.

Returns:
the reverse of this list

Definition at line 351 of file OpenList.java.

Referenced by main().

OpenList OpenList::reverse ( OpenList L1 ) [inline, static]
 

Return a new list containing the elements of the argument list in reverse order.

Parameters:
L1   the list providing the elements
Returns:
the reverse of the argument list

Definition at line 331 of file OpenList.java.

Object OpenList::second ( OpenList L ) [inline, static]
 

Return the second element of the argument OpenList, assuming it has one.

Parameters:
L   an OpenList, the second element of which is to be extracted
Returns:
the second element L
Exceptions:
OpenListException   if there is no second element

Definition at line 520 of file OpenList.java.

Object OpenList::second ( ) [inline]
 

Return the second element of this OpenList, assuming it has one.

Returns:
the second element of this OpenList
Exceptions:
OpenListException   if there is no second element

Definition at line 479 of file OpenList.java.

Referenced by second().

OpenList OpenList::sort ( java.util.Comparator comparator ) [inline]
 

Return a sorted version of this list, as determined by the Comparator, using the Quicksort algorithm

Parameters:
comparator   used to determine whether one element is less than another
Returns:
the list consisting of the Objects in the original list in order as determined by the comparator

Definition at line 905 of file OpenList.java.

Object OpenList::third ( OpenList L ) [inline, static]
 

Return the third element of the argument OpenList, assuming it has one.

Parameters:
L   an OpenList, the third element of which is to be extracted
Returns:
the second element L
Exceptions:
OpenListException   if there is no third element

Definition at line 534 of file OpenList.java.

Object OpenList::third ( ) [inline]
 

Return the third element of this OpenList, assuming it has one.

Returns:
the third element of this OpenList
Exceptions:
OpenListException   if there is no third element

Definition at line 499 of file OpenList.java.

Referenced by third().

Object[] OpenList::toArray ( ) [inline]
 

Return an array of the Objects in this OpenList.

Returns:
an array of the Objects in this OpenList

Definition at line 870 of file OpenList.java.

Object [] OpenList::toArray ( OpenList L ) [inline, static]
 

Return an array of the Objects in the argument OpenList.

Parameters:
L   the list of objects to be used as elements of the array
Returns:
an array of the Objects in the argument OpenList

Definition at line 849 of file OpenList.java.

Referenced by sort().

String OpenList::toString ( String leftParen,
String spacer,
String rightParen ) [inline]
 

Convert this OpenList to a String, using the arguments as punctuation.

Parameters:
leftParen   String that is output before the list elements
spacer   String that is output between list elements
rightParen   String that is output after the list elements
Returns:
String representing OpenList

Definition at line 754 of file OpenList.java.

String OpenList::toString ( ) [inline]
 

Convert this OpenList to a String, using default punctuation.

Returns:
String representing this OpenList

Definition at line 739 of file OpenList.java.


Member Data Documentation

String OpenList::defaultLeftParen = "[" [static]
 

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 38 of file OpenList.java.

String OpenList::defaultRightParen = "]" [static]
 

the default right paren used when a list is printed

Definition at line 43 of file OpenList.java.

String OpenList::defaultSpacer = ", " [static]
 

the default space used when a list is printed

Definition at line 48 of file OpenList.java.

String OpenList::firstException = "first() of empty list" [static]
 

exception message for first of empty list

Definition at line 53 of file OpenList.java.

final OpenList OpenList::nil = cons(null, null) [static]
 

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. We do not create other empty lists so that our implementation of isEmpty() works by comparing references.

Definition at line 27 of file OpenList.java.

String OpenList::nthException = "nth of an OpenList of length " [static]
 

exception message for nth of a list

Definition at line 63 of file OpenList.java.

String OpenList::restException = "rest() of empty list" [static]
 

exception message for rest of empty list

Definition at line 58 of file OpenList.java.

String OpenList::secondException = "second of an OpenList, where length() = " [static]
 

exception message for second of a list

Definition at line 73 of file OpenList.java.

String OpenList::thirdException = "third of an OpenList, where length() = " [static]
 

exception message for third of a list

Definition at line 78 of file OpenList.java.

String OpenList::wherePart = ", where n == " [static]
 

part of exception message for nth of a list

Definition at line 68 of file OpenList.java.


The documentation for this class was generated from the following file:
Generated at Mon Feb 17 12:14:54 2003 for OpenList by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001