/**
* Represents the empty list. Uses the Singleton pattern to model the
* uniqueness of the empty list.
* @author Dung X. Nguyen
* @version 1.1
* @since 01/25/02
* @Custom Copyright 2002 -All rights reserved
*/
public class EmptyList extends AList {
/**
* Singleton pattern.
*/
public final static EmptyList Singleton = new EmptyList();
/**
* Disables public instantiation of EmptyList.
*/
private EmptyList() {
}
/**
* Throws an IllegalArgumentException.
* @return does not return.
* @exception IllegalArgumentException.
*/
public Object getFirst() {
throw new IllegalArgumentException ("EmptyList has no first!");
}
/**
* Throws an IllegalArgumentException
* @return does not return.
* @exception IllegalArgumentException.
*/
public AList getRest() {
throw new IllegalArgumentException ("EmptyList has no rest!");
}
/**
* Computes a String representation of this EmptyList.
* @return "()".
*/
public String toString() {
return "()";
}
/**
* Computes the length of this EmptyList.
* @return 0
*/
public int getLength() {
return 0;
}
/**
* Computes the length of this EmptyList.
* @return 0.
*/
public int getLen() {
return 0;
}
/**
* The minimum of the Empty list can be thought of as +infinity.
* @return Integet.MAX_VALUE representing +infinity.
*/
public int getMinimum() {
return Integer.MAX_VALUE;
}
/**
* Returns the accumulated length, since this is the end of the list.
* @param acc the length of the list preceding this EmptyList.
* @return acc.
*/
protected int helpGetLen(int acc) {
return acc;
}
/**
* The minimum of the Empty list can be thought of as +infinity.
* @return Integet.MAX_VALUE representing +infinity.
*/
public int getMin() {
return Integer.MAX_VALUE;
}
/**
* Returns the accumlated minimum, since this is the end of the list.
* @param accMin the smallest int containing in the list preceding this NEList.
* @return tempMin.
*/
protected int helpGetMin(int tempMin) {
return tempMin;
}
}