com.mhhe.clrs2e
Class LinearDLLDictionary

java.lang.Object
  |
  +--com.mhhe.clrs2e.LinkedList
        |
        +--com.mhhe.clrs2e.LinearDLL
              |
              +--com.mhhe.clrs2e.LinearDLLDictionary
All Implemented Interfaces:
Dictionary

public class LinearDLLDictionary
extends LinearDLL
implements Dictionary

A simple linear, doubly linked list without a sentinel but with a search method. All elements inserted must implement the Comparable interface.


Nested Class Summary
 
Nested classes inherited from class com.mhhe.clrs2e.LinearDLL
LinearDLL.LinearDLLIterator
 
Nested classes inherited from class com.mhhe.clrs2e.LinkedList
LinkedList.ListIterator, LinkedList.Node
 
Field Summary
 
Fields inherited from class com.mhhe.clrs2e.LinearDLL
head
 
Constructor Summary
LinearDLLDictionary()
           
 
Method Summary
 java.lang.Object insert(java.lang.Comparable o)
          Inserts an element at the head of the list.
 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.
 java.lang.Object search(java.lang.Comparable k)
          Searches for an element with a given key.
 
Methods inherited from class com.mhhe.clrs2e.LinearDLL
concatenate, delete, isEmpty, iterator
 
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
 
Methods inherited from interface com.mhhe.clrs2e.Dictionary
delete
 

Constructor Detail

LinearDLLDictionary

public LinearDLLDictionary()
Method Detail

insert

public java.lang.Object insert(java.lang.Comparable o)
Inserts an element at the head of the list. This form of insert is required by the Dictionary interface.

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

insert

public java.lang.Object insert(java.lang.Object o)
Inserts an element at the head of the list. The element inserted must be an object that implements the Comparable interface.

Overrides:
insert in class LinearDLL
Parameters:
o - The element to be inserted.
Returns:
A handle to the new element.
Throws:
java.lang.ClassCastException - if the element does not implement Comparable.

insertAfter

public java.lang.Object insertAfter(java.lang.Object o,
                                    java.lang.Object after)
Inserts an element after a given element. The element inserted must be an object that implements the Comparable interface.

Overrides:
insertAfter in class LinearDLL
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.
Throws:
java.lang.ClassCastException - if the element does not implement Comparable.

search

public java.lang.Object search(java.lang.Comparable k)
Searches for an element with a given key.

Specified by:
search in interface Dictionary
Parameters:
k - The key being searched for.
Returns:
A handle to the object found, or null if there is no match.