com.mhhe.clrs2e
Class LinearDLL

java.lang.Object
  |
  +--com.mhhe.clrs2e.LinkedList
        |
        +--com.mhhe.clrs2e.LinearDLL
Direct Known Subclasses:
LinearDLLDictionary

public class LinearDLL
extends LinkedList

A simple linear, doubly linked list without a sentinel from pages 205-206 of Introduction to Algorithms, Second edition.


Nested Class Summary
 class LinearDLL.LinearDLLIterator
          Inner class for an iterator.
 
Nested classes inherited from class com.mhhe.clrs2e.LinkedList
LinkedList.Node
 
Field Summary
protected  LinkedList.Node head
          The first node in the list.
 
Constructor Summary
LinearDLL()
          Makes an empty list.
 
Method Summary
 void concatenate(com.mhhe.clrs2e.LinkedList l)
          Concatenates another linked list onto the end of this list, destroying the other linked list.
 void delete(java.lang.Object handle)
          Removes an element.
 java.lang.Object insert(java.lang.Object o)
          Inserts an element at the head of the list.
 java.lang.Object insertAfter(java.lang.Object o, java.lang.Object after)
          Inserts an element after a given element.
 boolean isEmpty()
          Returns true if this list is empty, false otherwise.
 java.util.Iterator iterator()
          Creates and returns an Iterator object for this list.
 
Methods inherited from class com.mhhe.clrs2e.LinkedList
dereference, toArray, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

head

protected LinkedList.Node head
The first node in the list.

Constructor Detail

LinearDLL

public LinearDLL()
Makes an empty list.

Method Detail

insert

public java.lang.Object insert(java.lang.Object o)
Inserts an element at the head of the list.

Specified by:
insert in class LinkedList
Parameters:
o - The element to be inserted.
Returns:
A handle to the new element.

insertAfter

public java.lang.Object insertAfter(java.lang.Object o,
                                    java.lang.Object after)
Inserts an element after a given element.

Specified by:
insertAfter in class LinkedList
Parameters:
o - The element to be inserted.
after - The element after which the new element is to be inserted. If null, the new element is inserted at the head of the list.
Returns:
A handle to the new element.

delete

public void delete(java.lang.Object handle)
Removes an element.

Specified by:
delete in class LinkedList
Parameters:
handle - Handle to the element to remove.

isEmpty

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

Specified by:
isEmpty in class LinkedList

iterator

public java.util.Iterator iterator()
Creates and returns an Iterator object for this list.

Specified by:
iterator in class LinkedList

concatenate

public void concatenate(com.mhhe.clrs2e.LinkedList l)
Concatenates another linked list onto the end of this list, destroying the other linked list.

Specified by:
concatenate in class LinkedList
Parameters:
l - The linked list to be concatenated onto the end of this list.
Throws:
java.lang.ClassCastException - if l is not a LinearDLL object.