K - The type for the keys of this dictionary.V - The type for the values associated with keys in this dictionary.
public class MysteryDictionaryImplementation<K,V> extends java.lang.Object implements Dictionary<K,V>
Dictionary.Entry<K,V>, Dictionary.MissingKeyException| Constructor and Description |
|---|
MysteryDictionaryImplementation() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(K key,
V value)
Sets the value associated with a given key.
|
void |
clear()
Removes all entries from this dictionary.
|
boolean |
contains(K key)
Returns whether a specific key is in this dictionary.
|
V |
getValue(K key)
Returns the value associated with a given key.
|
boolean |
isEmpty()
Returns true if this dictionary is empty.
|
java.util.Iterator<Dictionary.Entry<K,V>> |
iterator()
Returns an iterator over the key-value pairs in the dictionary.
|
void |
remove(K key)
Removes a specific entry from this dictionary.
|
int |
size()
Returns the size of this dictionary.
|
java.lang.String |
toString()
Returns, e.g., "{key1 → val1; key2 → val2; key3 → val3}".
|
public void add(K key, V value)
Dictionaryadd in interface Dictionary<K,V>public void remove(K key)
Dictionaryremove in interface Dictionary<K,V>public V getValue(K key)
DictionarygetValue in interface Dictionary<K,V>public boolean contains(K key)
Dictionarycontains in interface Dictionary<K,V>public boolean isEmpty()
DictionaryisEmpty in interface Dictionary<K,V>public int size()
Dictionarysize in interface Dictionary<K,V>public void clear()
Dictionaryclear in interface Dictionary<K,V>public java.util.Iterator<Dictionary.Entry<K,V>> iterator()
Dictionaryiterator in interface Dictionary<K,V>iterator in interface java.lang.Iterable<Dictionary.Entry<K,V>>public java.lang.String toString()
toString in class java.lang.Object