com.mhhe.clrs2e
Interface Dictionary

All Known Implementing Classes:
BinarySearchTree, BTree, ChainedHashTable, DirectAddressTable, LinearDLLDictionary, OpenAddressingHashTable, SentinelDLLDictionary, SortableSentinelDLL

public interface Dictionary

Interface for dictionary data structures, defined on page 197 of Introduction to Algorithms, Second edition. Any object inserted into a dictionary must implement the Comparable interface. In addition, for specific implementations of the Dictionary interface, there may be stronger restrictions on inserted objects, such as having to implement the DynamicSetElement interface.


Method Summary
 void delete(java.lang.Object handle)
          Removes an element.
 java.lang.Object insert(java.lang.Comparable o)
          Inserts an element that implements Comparable.
 java.lang.Object search(java.lang.Comparable k)
          Searches for an element with a given key.
 

Method Detail

insert

public java.lang.Object insert(java.lang.Comparable o)
Inserts an element that implements Comparable.

Parameters:
o - The element to insert.
Returns:
A handle to the inserted element.

delete

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

Parameters:
handle - A handle to the element to remove.

search

public java.lang.Object search(java.lang.Comparable k)
Searches for an element with a given key. Depending on the type of element inserted into the dictionary, the type of the key given to this method may be the same as the type of the objects inserted, or the type of the key given to this method may be a different type than the type of the objects inserted but still can be compared to the type of the inserted objects. For example, see DynamicSetElement.Helper.compareTo(com.mhhe.clrs2e.DynamicSetElement, java.lang.Object).

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