Interface DictionaryADT

All Known Implementing Classes:
BinarySearchTree

public interface DictionaryADT


Method Summary
 boolean changeValue(java.lang.Object oldKey, java.lang.Object newValue)
          Associates a new value with an existing key in the Dictionary.
 java.lang.Object find(java.lang.Object key)
          Finds the value associated with the given key in the Dictionary.
 java.util.Comparator getComparator()
          Returns the comparator used to order this Dictionary.
 java.util.List getEntryList()
          Gets a List view of the data in the Dictionary.
 int getSize()
          Retrieves the number of elements in the Dictionary.
 boolean insert(java.lang.Object key, java.lang.Object value)
          Inserts a new key/value pair into the Dictionary.
 void print(java.io.PrintWriter writer)
          Pretty-print the tree for debugging purposes (optional).
 

Method Detail

getSize

public int getSize()
Retrieves the number of elements in the Dictionary.

Returns:
the the number of elements in the tree.

getComparator

public java.util.Comparator getComparator()
Returns the comparator used to order this Dictionary.

Returns:
The comparator used to order this Dictionary

find

public java.lang.Object find(java.lang.Object key)
Finds the value associated with the given key in the Dictionary.

Parameters:
key - The key to search for.
Returns:
The value object associated with the key or null if key is not in the BST.

getEntryList

public java.util.List getEntryList()
Gets a List view of the data in the Dictionary. The items in this list will be an implementation of the Map.Entry interface (specified in the java.util package).

Returns:
A list view of the data in this Dictionary.

print

public void print(java.io.PrintWriter writer)
Pretty-print the tree for debugging purposes (optional).

Parameters:
writer - The print writer to output the tree onto.
Throws:
java.lang.UnsupportedOperationException - if the underlying Dictionary does not want to define a pretty-print function, this exception is thrown.

insert

public boolean insert(java.lang.Object key,
                      java.lang.Object value)
Inserts a new key/value pair into the Dictionary. If the key previously existed in the tree, this will overwrite the old value with the new value.

Parameters:
key - key with which newValue will be associated.
value - the value to be associated with newKeyh
Returns:
true if this key did not previously exist in the tree, false otherwise.

changeValue

public boolean changeValue(java.lang.Object oldKey,
                           java.lang.Object newValue)
Associates a new value with an existing key in the Dictionary. This function assumes that the key is already in the tree.

Parameters:
oldKey - The key whose value will be changed.
newValue - The new value to associated with oldKey
Returns:
true if the data was changed. False otherwise.