Class LinkedList

java.lang.Object
  |
  +--LinkedList

public class LinkedList
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

Instances of this class are nodes of a linked list.

A linked list is a chain of objects that have two object references associated with them. One is the head of the list, which is another data object. The other is the tail of the list, which is either null or another linked list.

See Also:
Serialized Form

Constructor Summary
LinkedList()
          This constructor creates a LinkedList with a null head and a null tail.
LinkedList(checkEqualityIF head)
          This constructor creates a LinkedList with the given head and a null tail.
LinkedList(checkEqualityIF head, LinkedList tail)
          This constructor creates a LinkedList with the given head and tail.
 
Method Summary
 java.util.Enumeration elements()
          Return an Enumeration of the data in this linked list (the heads).
 LinkedList find(checkEqualityIF target)
          Find an object in a linked list that is equal to the given object.
 checkEqualityIF getHead()
          Return the head of this linked list.
 LinkedList getTail()
          Return the tail of this linked list.
 int size()
          Return the number of nodes in this linked list
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LinkedList

public LinkedList()
This constructor creates a LinkedList with a null head and a null tail.

LinkedList

public LinkedList(checkEqualityIF head)
This constructor creates a LinkedList with the given head and a null tail.
Parameters:
head - The object that will be the head of this list

LinkedList

public LinkedList(checkEqualityIF head,
                  LinkedList tail)
This constructor creates a LinkedList with the given head and tail.
Parameters:
head - The object that will be the head of this list
tail - null or the rest of this linked list.
Method Detail

getHead

public checkEqualityIF getHead()
Return the head of this linked list.

getTail

public LinkedList getTail()
Return the tail of this linked list.

size

public int size()
Return the number of nodes in this linked list

elements

public java.util.Enumeration elements()
Return an Enumeration of the data in this linked list (the heads).

find

public LinkedList find(checkEqualityIF target)
Find an object in a linked list that is equal to the given object. Equality is normally determined by calling the given object's equals method. However, if the given object implements the checkEqualityIF interface, then equality may be determined by the == operator or by overriding the object's equals method.
Returns:
a LinkedList whose head is equal to the given object or null if the target is not found.