/**
* Represents an abstract Scheme-like list, an immutable linear recursive
* structure of data. Has abstract methods to provide its internal data and
* structure to the client. Since an AList has an internal structure that is
* isomorphic to itself, it's best to implement it using the composite pattern.
* @author Dung X. Nguyen
* @version 1.1
* @since 01/25/02
* @Custom Copyright 2002 -All rights reserved
*/
public abstract class AList {
/**
* Returns the first element in this AList, if any.
* The behavior for the empty list is undefined.
* @return behavior relegated to concrete subclasses.
*/
public abstract Object getFirst();
/**
* Returns the tail ("rest") of this AList, if any.
* The behavior for the empty list is undefined.
* @return behavior relegated to concrete subclasses.
*/
public abstract AList getRest();
/**
* Computes and returns the number of elements in this AList.
* @return int >= 0.
*/
public abstract int getLength();
/**
* Computes and returns the minimum of this AList, assuming it contains
* Integer objects.
* @return behavior relegated to concrete subclasses.
*/
public abstract int getMinimum();
/**
* Computes the length of this AList. Uses helpGetLen.
* @return int >= 0.
*/
public abstract int getLen();
/**
* Uses the accumulated length of the original list to help compute the
* length of the original list.
* @param acc the accumlated length of the original list.
* @return behavior relegated to concrete subclasses.
*/
protected abstract int helpGetLen(int acc);
/**
* Computes the minimum of this AList, assuming it contains Integer objects.
* Uses helpGetMin.
* @return behavior relegated to concrete subclasses.
*/
public abstract int getMin();
/**
* Computes the minimum of the preceding list and this AList using the
* accumlated minimum.
* @param accMin the smallest int containing in the list preceding this AList.
* @return behavior relegated to concrete subclasses.
*/
protected abstract int helpGetMin(int accMin);
}