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)
Dictionary
add
in interface Dictionary<K,V>
public void remove(K key)
Dictionary
remove
in interface Dictionary<K,V>
public V getValue(K key)
Dictionary
getValue
in interface Dictionary<K,V>
public boolean contains(K key)
Dictionary
contains
in interface Dictionary<K,V>
public boolean isEmpty()
Dictionary
isEmpty
in interface Dictionary<K,V>
public int size()
Dictionary
size
in interface Dictionary<K,V>
public void clear()
Dictionary
clear
in interface Dictionary<K,V>
public java.util.Iterator<Dictionary.Entry<K,V>> iterator()
Dictionary
iterator
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