Opus5
Class LinkedList

java.lang.Object
  |
  +--Opus5.LinkedList

public class LinkedList
extends java.lang.Object

A linear, singly-linked list of Objects.

Version:
$Id: LinkedList.java,v 3.2 1998/07/28 01:40:45 brpreiss Exp $
Author:
Bruno R. Preiss, P.Eng.

Inner Class Summary
 class LinkedList.Element
          An element of a linked list.
 
Field Summary
protected  LinkedList.Element head
          The head of the linked list.
protected  LinkedList.Element tail
          The tail of the linked list.
 
Constructor Summary
LinkedList()
          Constructs an empty LinkedList.
 
Method Summary
 void append(java.lang.Object item)
          Appends to this list a list element that contains the specified object.
 void assign(LinkedList list)
          Assigns to this linked list the value of the specified linked list.
 void extract(java.lang.Object item)
          Extracts from this linked list the list element that contains the specified object.
 java.lang.Object getFirst()
          Returns the object contained in the first list element.
 LinkedList.Element getHead()
          Returns the head of this linked list.
 java.lang.Object getLast()
          Returns the object contained in the last list element.
 LinkedList.Element getTail()
          Returns the tail of this linked list.
 boolean isEmpty()
          Tests if this linked list is empty.
 void prepend(java.lang.Object item)
          Prepends to this list a list element that contains the specified object.
 void purge()
          Empties this linked list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

head

protected LinkedList.Element head
The head of the linked list.

tail

protected LinkedList.Element tail
The tail of the linked list.
Constructor Detail

LinkedList

public LinkedList()
Constructs an empty LinkedList.
Method Detail

purge

public void purge()
Empties this linked list.

getHead

public LinkedList.Element getHead()
Returns the head of this linked list.
Returns:
the head of this linked list.

getTail

public LinkedList.Element getTail()
Returns the tail of this linked list.
Returns:
the tail of this linked list.

isEmpty

public boolean isEmpty()
Tests if this linked list is empty.
Returns:
True if this linked list is empty; false otherwise.

getFirst

public java.lang.Object getFirst()
Returns the object contained in the first list element.
Returns:
The object contained in the first list element.
Throws:
ContainerEmptyException - If this list is empty.

getLast

public java.lang.Object getLast()
Returns the object contained in the last list element.
Returns:
The object contained in the first list element.
Throws:
ContainerEmptyException - If this list is empty.

prepend

public void prepend(java.lang.Object item)
Prepends to this list a list element that contains the specified object.
Parameters:
item - The object to be prepended.

append

public void append(java.lang.Object item)
Appends to this list a list element that contains the specified object.
Parameters:
item - The object to be appended.

assign

public void assign(LinkedList list)
Assigns to this linked list the value of the specified linked list. First, the this linked list is purged. Then, each of the objects contained in the specified linked list are appended one-by-one to this linked list.
Parameters:
list - The linked list to assign to this linked list.

extract

public void extract(java.lang.Object item)
Extracts from this linked list the list element that contains the specified object.
Parameters:
item - The object to be extracted from this linked list.
Throws:
java.lang.IllegalArgumentException - If the object to extract is not found in this linked list.