|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Dictionary
This class implements the dictionary ADT using a singly linked list. The dictionary ADT consists of a set of ordered pairs (K,I). The key K is unique but the information portion I need not be. This implementation stores K and I as java Strings. This implementation attempts to improve on the average case run-time that would normally be associated with a linked implementation. It uses a heuristic-- a rule that results in behavior that may not be exactly predictable, but which there is reason to believe will be good in general. The heuristic employed is called the Move-to-Front Heuristic: after each successful search, move the item that was sought to the front of the list.
Constructor Summary | |
Dictionary()
The constructor initializes an empty dictionary. |
Method Summary | |
java.lang.Object |
clone()
This method makes a copy of the dictionary and returns a reference to the user of the class. |
boolean |
delete(SetElement x)
This method deletes the ordered pair (K,I) represented by the parameter x. |
void |
insert(SetElement x)
This method inserts the new element x (or, replaces an existing one) in the dictionary. |
boolean |
isEmpty()
This method returns true if the dictionary is empty and false otherwise. |
SetElement |
lookUp(SetElement x)
This method searches the dictionary for the key K found in the parameter x. |
static void |
main(java.lang.String[] a)
Test drive the class Dictionary. |
java.lang.String |
toString()
This method returns a Java String representing the current state of the dictionary object. |
Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public Dictionary()
Method Detail |
public boolean isEmpty()
public boolean delete(SetElement x)
public void insert(SetElement x)
public SetElement lookUp(SetElement x)
public java.lang.Object clone()
public java.lang.String toString()
public static void main(java.lang.String[] a)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |