net.datastructures
Interface Dictionary<K,V>

All Known Implementing Classes:
AVLTree, BinarySearchTree, RBTree

public interface Dictionary<K,V>

An interface for a dictionary storing (key-value) pairs.

Author:
Michael Goodrich

Method Summary
 java.lang.Iterable<Entry<K,V>> entries()
          Returns an iterator containing all the entries in the dictionary.
 Entry<K,V> find(K key)
          Returns an entry containing the given key, or null if no such entry exists.
 java.lang.Iterable<Entry<K,V>> findAll(K key)
          Returns an iterator containing all the entries containing the given key, or an empty iterator if no such entries exist.
 Entry<K,V> insert(K key, V value)
          Inserts an item into the dictionary.
 boolean isEmpty()
          Returns whether the dictionary is empty.
 Entry<K,V> remove(Entry<K,V> e)
          Removes and returns the given entry from the dictionary.
 int size()
          Returns the number of entries in the dictionary.
 

Method Detail

size

int size()
Returns the number of entries in the dictionary.


isEmpty

boolean isEmpty()
Returns whether the dictionary is empty.


find

Entry<K,V> find(K key)
                throws InvalidKeyException
Returns an entry containing the given key, or null if no such entry exists.

Throws:
InvalidKeyException

findAll

java.lang.Iterable<Entry<K,V>> findAll(K key)
                                       throws InvalidKeyException
Returns an iterator containing all the entries containing the given key, or an empty iterator if no such entries exist.

Throws:
InvalidKeyException

insert

Entry<K,V> insert(K key,
                  V value)
                  throws InvalidKeyException
Inserts an item into the dictionary. Returns the newly created entry.

Throws:
InvalidKeyException

remove

Entry<K,V> remove(Entry<K,V> e)
                  throws InvalidEntryException
Removes and returns the given entry from the dictionary.

Throws:
InvalidEntryException

entries

java.lang.Iterable<Entry<K,V>> entries()
Returns an iterator containing all the entries in the dictionary.