datastructures

net.datastructures
Interface Dictionary

All Known Implementing Classes:
AVLTree, BinarySearchTree, RBTree

public interface Dictionary

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

Author:
Michael Goodrich

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

Method Detail

size

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


isEmpty

public boolean isEmpty()
Returns whether the dictionary is empty.


find

public Entry find(Object key)
           throws InvalidKeyException
Returns an entry containing the given key, or null if no such entry exists.

Throws:
InvalidKeyException

findAll

public Iterator findAll(Object 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

public Entry insert(Object key,
                    Object value)
             throws InvalidKeyException
Inserts an item into the dictionary. Returns the newly created entry.

Throws:
InvalidKeyException

remove

public Entry remove(Entry e)
             throws InvalidEntryException
Removes and returns the given entry from the dictionary.

Throws:
InvalidEntryException

entries

public Iterator entries()
Returns an iterator containing all the entries in the dictionary.


datastructures