Interface Map<K,D>

Type Parameters:
K - The type of the keys.
D - The type of the data.
All Known Implementing Classes:
AVLtree, Dictionary, Hashtable, List, Searchtree, Skiplist, Splaytree, Treap

public interface Map<K,D>

A Map is a data structure to store data under key values, or just keys. For each key there can be at most one datum that is associated to that key. Maps provide methods to lookup data find(Object), to change the map insert(Object, Object), delete(Object), to iteratate over keys simpleiterator() and over both keys and data iterator(). Moreover, there are possibilities to display a map print() and to store a map in an array array().

Author:
Rossmanith

Method Summary
 Array<K> array()
          Converts this map into an array of all keys.
 void delete(K k)
          Removes the entry which stores the data for the key k.
 D find(K k)
          Looks up the data stored under the key k.
 void insert(K k, D d)
          Associates the data d to the key k in this map.
 boolean iselement(K k)
          Checks whether the key k is present in this map.
 boolean isempty()
          Checks, whether this map is empty, i.e., checks size() == 0.
 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()
          Returns the size of this map, i.e. the number of keys, under which data is stored.
 

Method Detail

insert

void insert(K k,
            D d)
Associates the data d to the key k in this map. A possible old entry for k will be deleted.

Parameters:
k - The key to store.
d - The data associated to the key k.

delete

void delete(K k)
Removes the entry which stores the data for the key k. Idle operations if there is no data stored for k.

Parameters:
k - The key to delete with its associated data.

find

D find(K k)
Looks up the data stored under the key k.

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

boolean iselement(K k)
Checks whether the key k is present in this map.

Parameters:
k - The key to look for.
Returns:
true, if k is contained in this map, and false, otherwise.

size

int size()
Returns the size of this map, i.e. the number of keys, under which data is stored.


isempty

boolean isempty()
Checks, whether this map is empty, i.e., checks size() == 0.


iterator

Iterator<K,D> iterator()
Creates a new iterator over all associations between keys and data.

Returns:
The Iterator over all keys with associated data.

simpleiterator

SimpleIterator<K> simpleiterator()
Creates a new iterator only over the keys.

Returns:
The SimpleIterator over all keys.

array

Array<K> array()
Converts this map into an array of all keys.

Returns:
A new array which contains all keys of this map.

print

void print()
Prints the map to stdout