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.
|
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
LinearDLLDictionary
public LinearDLLDictionary()
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.