Class GenericConsList<E extends Serializable>

java.lang.Object
edu.ksu.cis.viewer.GenericConsList<E>
Type Parameters:
E - the type of the elements in the head of each list
All Implemented Interfaces:
Serializable

public final class GenericConsList<E extends Serializable> extends Object implements Serializable
An immutable linear recursive structure with a head and a tail, which is a GenericConsList.
Author:
Rod Howell (rhowell@ksu.edu)
See Also:
  • Constructor Details

    • GenericConsList

      public GenericConsList()
      Constructs an empty GenericConsList.
    • GenericConsList

      public GenericConsList(E h, GenericConsList<E> lst)
      Constructs a Generic ConsList with the given head and tail. If the given tail is null, an empty GenericConsList is used in its place.
      Parameters:
      h - the head of the list
      lst - the tail of the list
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Returns true if this list is empty.
      Returns:
      whether this list is empty
    • getHead

      public E getHead() throws EmptyListException
      Returns the head of this list.
      Returns:
      the head of this list
      Throws:
      EmptyListException - If this list is empty.
    • getTail

      public GenericConsList<E> getTail() throws EmptyListException
      Returns the tail of the list.
      Returns:
      the tail of this list
      Throws:
      EmptyListException - If this list is empty.