K
- class representing the key, should implement the Comparablepublic interface DictionaryADT<K extends java.lang.Comparable<K>>
extends java.lang.Iterable<K>
Modifier and Type | Method and Description |
---|---|
boolean |
delete(K key)
Deletes the given key from the Dictionary.
|
void |
insert(K key)
Inserts the given key into the Dictionary if the key is not already in
the Dictionary.
|
boolean |
isEmpty()
Returns true if and only if the Dictionary is empty.
|
java.util.Iterator<K> |
iterator()
Returns an iterator over the Dictionary that iterates over the keys
in the Dictionary in order from smallest to largest.
|
K |
lookup(K key)
Searches for the given key in the Dictionary and returns the key stored
in the Dictionary.
|
int |
size()
Returns the number of keys in the Dictionary.
|
int |
totalPathLength()
Returns the total path length.
|
void insert(K key) throws DuplicateException
key
- the key to insert into the DictionaryDuplicateException
- if the key is already in the Dictionaryjava.lang.IllegalArgumentException
- if the key is nullboolean delete(K key)
key
- the key to delete from the DictionaryK lookup(K key)
key
- the key to search forboolean isEmpty()
int size()
int totalPathLength()
java.util.Iterator<K> iterator()