Package edu.ksu.cis.viewer
Class ConsList
java.lang.Object
edu.ksu.cis.viewer.ConsList
An immutable linear recursive structure with a head, which is an Object, and
a tail, which is a ConsList.
- Author:
- Rod Howell (rhowell@ksu.edu)
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
ConsList
public ConsList()Constructs an empty ConsList. -
ConsList
Constructs a ConsList with the given head and tail. If the given tail isnull
, an empty ConsList is used in its place.- Parameters:
h
- the head of the listlst
- the tail of the list
-
-
Method Details
-
isEmpty
public boolean isEmpty()Returnstrue
if this list is empty.- Returns:
- whether this list is empty
-
getHead
Returns the head of this list.- Returns:
- the head of this list
- Throws:
EmptyListException
- If this list is empty.
-
getTail
Returns the tail of the list.- Returns:
- the tail of this list
- Throws:
EmptyListException
- If this list is empty.
-