edu.ksu.cis.viewer
Class ConsList

java.lang.Object
  extended byedu.ksu.cis.viewer.ConsList

public final class ConsList
extends Object

An immutable linear recursive structure with a head, which is an Object, and a tail, which is a ConsList.

Author:
Rod Howell (howell@cis.ksu.edu)

Constructor Summary
ConsList()
          Constructs an empty ConsList.
ConsList(Object h, ConsList lst)
          Constructs a ConsList with the given head and tail.
 
Method Summary
 Object getHead()
          Returns the head of this list.
 ConsList getTail()
          Returns the tail of the list.
 boolean isEmpty()
          Returns true if this list is empty.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConsList

public ConsList()
Constructs an empty ConsList.


ConsList

public ConsList(Object h,
                ConsList lst)
Constructs a ConsList with the given head and tail. If the given tail is null, an empty ConsList is used in its place.

Parameters:
h - the head of the list
lst - the tail of the list
Method Detail

isEmpty

public boolean isEmpty()
Returns true if this list is empty.


getHead

public Object getHead()
               throws EmptyListException
Returns the head of this list.

Throws:
EmptyListException - If this list is empty.

getTail

public ConsList getTail()
                 throws EmptyListException
Returns the tail of the list.

Throws:
EmptyListException - If this list is empty.