Class Dictionary<K,D>

java.lang.Object
  extended by Dictionary<K,D>
Type Parameters:
K - The type of the keys.
D - The type of the data.
All Implemented Interfaces:
Map<K,D>
Direct Known Subclasses:
Hashtable, List, Searchtree, Skiplist

public abstract class Dictionary<K,D>
extends java.lang.Object
implements Map<K,D>

A dictionary provides some default implementations of methods that are required for the Map-interface. Only Map.insert(Object, Object), Map.delete(Object), and Map.iterator() have to be implemented for subclasses of Dictionary, however, other methods may also be implemented to improve efficiency.

Author:
Rossmanith

Constructor Summary
Dictionary()
           
 
Method Summary
 Array<K> array()
          Converts this map into an array of all keys.
abstract  void delete(K k)
          Removes the entry which stores the data for the key k.
 D find(K k)
          Linear time implementation of Map.find(Object).
abstract  void insert(K k, D d)
          Associates the data d to the key k in this map.
 boolean iselement(K k)
          Linear time implementation of Map.iselement(Object).
 boolean isempty()
          Constant time implementation of Map.isempty() provided that creation of an Iterator with iterator() costs only constant time.
abstract  Iterator<K,D> iterator()
          Creates a new iterator over all associations between keys and data.
 void print()
          Prints the map to stdout
 SimpleIterator<K> simpleiterator()
          Creates a new iterator only over the keys.
 int size()
          Linear time implementation of Map.size()
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Dictionary

public Dictionary()
Method Detail

insert

public abstract void insert(K k,
                            D d)
Description copied from interface: Map
Associates the data d to the key k in this map. A possible old entry for k will be deleted.

Specified by:
insert in interface Map<K,D>
Parameters:
k - The key to store.
d - The data associated to the key k.

delete

public abstract void delete(K k)
Description copied from interface: Map
Removes the entry which stores the data for the key k. Idle operations if there is no data stored for k.

Specified by:
delete in interface Map<K,D>
Parameters:
k - The key to delete with its associated data.

iterator

public abstract Iterator<K,D> iterator()
Description copied from interface: Map
Creates a new iterator over all associations between keys and data.

Specified by:
iterator in interface Map<K,D>
Returns:
The Iterator over all keys with associated data.

find

public D find(K k)
Linear time implementation of Map.find(Object).

Specified by:
find in interface Map<K,D>
Parameters:
k - The key under which the data is stored.
Returns:
The data, which is stored under the key k, or null, if there is no data associated to k.

iselement

public boolean iselement(K k)
Linear time implementation of Map.iselement(Object).

Specified by:
iselement in interface Map<K,D>
Parameters:
k - The key to look for.
Returns:
true, if k is contained in this map, and false, otherwise.

isempty

public boolean isempty()
Constant time implementation of Map.isempty() provided that creation of an Iterator with iterator() costs only constant time.

Specified by:
isempty in interface Map<K,D>

size

public int size()
Linear time implementation of Map.size()

Specified by:
size in interface Map<K,D>

simpleiterator

public SimpleIterator<K> simpleiterator()
Description copied from interface: Map
Creates a new iterator only over the keys.

Specified by:
simpleiterator in interface Map<K,D>
Returns:
The SimpleIterator over all keys.

array

public Array<K> array()
Description copied from interface: Map
Converts this map into an array of all keys.

Specified by:
array in interface Map<K,D>
Returns:
A new array which contains all keys of this map.

print

public void print()
Description copied from interface: Map
Prints the map to stdout

Specified by:
print in interface Map<K,D>