Interface Dictionary<K,V>

Type Parameters:
K - The key type.
V - The value type.

public interface Dictionary<K,V>

An interface for the Dictionary ADT.


Method Summary
 V add(K key, V value)
          Adds a new entry to this dictionary.
 void clear()
          Removes all entries from this dictionary.
 boolean contains(K key)
          Sees whether a specific entry is in this dictionary.
 Set<DictPair<K,V>> getEntrySet()
          Returns a Set of the key-value pairs stored in the dictionary.
 Set<K> getKeySet()
          Returns a Set that contains all the keys stored in the dictionary.
 V getValue(K key)
          Retrieves from this dictionary the value associated with a given key.
 boolean isEmpty()
          Sees whether this dictionary is empty.
 V remove(K key)
          Removes a specific entry from this dictionary.
 int size()
          Gets the size of this dictionary.
 

Method Detail

add

V add(K key,
      V value)
Adds a new entry to this dictionary. If the given key already exists in the dictionary, replaces the corresponding value.

Returns:
Either null if the new entry was added to the dictionary or the value that was associated with key if that value was replaced.

remove

V remove(K key)
Removes a specific entry from this dictionary.

Parameters:
key - The key of the entry to be removed.
Returns:
Either the value that was associated with the key, or null if the key was not in the dictionary.

getValue

V getValue(K key)
Retrieves from this dictionary the value associated with a given key.

Returns:
Either the value that is associated with the search key or null if no such object exists.

contains

boolean contains(K key)
Sees whether a specific entry is in this dictionary.

Returns:
true If key is associated with an entry in the dictionary.

getKeySet

Set<K> getKeySet()
Returns a Set that contains all the keys stored in the dictionary.


getEntrySet

Set<DictPair<K,V>> getEntrySet()
Returns a Set of the key-value pairs stored in the dictionary.


size

int size()
Gets the size of this dictionary.


isEmpty

boolean isEmpty()
Sees whether this dictionary is empty.


clear

void clear()
Removes all entries from this dictionary.