K
- The key type.V
- The value type.public interface Dictionary<K,V> extends java.lang.Iterable<Dictionary.Entry<K,V>>
Modifier and Type | Interface and Description |
---|---|
static interface |
Dictionary.Entry<K,V>
A simple interface for key-value pairs.
|
static class |
Dictionary.MissingKeyException
An exception to indicate that a key is not stored in the dictionary.
|
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.
|
void add(K key, V value)
V getValue(K key)
Dictionary.MissingKeyException
- if the key was not in the dictionary.void remove(K key)
Dictionary.MissingKeyException
- if the key was not in the dictionary.boolean contains(K key)
int size()
boolean isEmpty()
void clear()
java.util.Iterator<Dictionary.Entry<K,V>> iterator()
iterator
in interface java.lang.Iterable<Dictionary.Entry<K,V>>