/**
* Represents a non-empty list.
* Implemented as a composite.
* @author Dung X. Nguyen
* @version 1.0
* @since 01/22/02
* @Custom Copyright 2002 -All rights reserved
*/
public class NEList extends AList {
private Object _first;
private AList _rest;
/**
* Initializes this NEList
to the given first and rest.
* @param dat the first data element of this NEList
.
* @param tail != null, the rest of this AList
.
*/
public NEList(Object dat, AList tail) {
_first = dat;
_rest = tail;
}
/**
* @return the first element of this NEList
.
*/
public Object getFirst() {
return _first;
}
/**
* @return the rest of this NEList
.
*/
public AList getRest() {
return _rest;
}
/**
* Returns a String representation of this NEList
.
* NOTE: There is an (unwanted) extra space before the closing parenthesis.
* This will be fixed in the next version.
* @return "(" followed by the String representation of first data element,
* followed by a space, followed by the String representation of the rest,
* followed by ")".
*/
public String toString() {
return "(" + _first + " " + _rest + ")";
}
}