package scheme; /** * Represents the empty list. * Implemented as a singleton, using the singleton pattern. * * @author Dung X. Nguyen * @version 1.0 * @since 09/10/00 * @Custom Copyright 2000 -All rights reserved */ public class EmptyList extends AList { public final static EmptyList Singleton = new EmptyList (); private EmptyList() { // NOTE: the constructor is private so that no external client can // instantiate an EmptyList. } /** * Throws an IllegalArgumentException. * @return does not return. * @exception IllegalArgumentException. */ public Object getFirst() { throw new IllegalArgumentException ("EmptyList.getFirst()"); } /** * Throws an IllegalArgumentException * @return does not return. * @exception IllegalArgumentException. */ public AList getRest() { throw new IllegalArgumentException ("EmptyList.getRest()"); } public String toString() { return ""; } /** * @return 0. */ public int length() { return 0; } /** * @return 0. */ public int getLength() { return 0; } /** * Returns the accumulated length, since this is the end of the list. * * @return int >= 0. */ protected int helpGetLength(int acc) { return acc; } /** * Returns Integet.MAX_VALUE representing +infinity. */ public int getMin() { return Integer.MAX_VALUE; } /** * Returns the temporary minimum, since this is the end of the list. */ protected int helpGetMin(int tempMin) { return tempMin; } }