text cover

Data Abstraction and Problem Solving with C++

Walls and Mirrors

by Frank M. Carrano

Addison Wesley Logo

HashMap< Key, T, Hash > Class Template Reference

#include <HashMap.h>

Inheritance diagram for HashMap< Key, T, Hash >:

Inheritance graph
[legend]
List of all members.

Detailed Description

template<typename Key, typename T, typename Hash>
class HashMap< Key, T, Hash >

Definition at line 24 of file HashMap.h.

Public Member Functions

 HashMap (const int maxBuckets)
T & operator[] (Key &key)
map< Key, T >::const_iterator findItem (const Key &key)
void insert (const Key &key, const T &item)
int erase (const Key &k)

Public Attributes

Hash hash


Constructor & Destructor Documentation

template<typename Key, typename T, typename Hash>
HashMap< Key, T, Hash >::HashMap const int  maxBuckets  ) 
 

Constructor

Precondition:
The HashMap is empty.
Postcondition:
The HashMap is initialized to hold maxBuckets. The Hash template parameter is assigned to the hash variable.

Definition at line 18 of file HashMap.cpp.

References HashMap< Key, T, Hash >::hash.


Member Function Documentation

template<typename Key, typename T, typename Hash>
T & HashMap< Key, T, Hash >::operator[] Key &  key  ) 
 

Overloads the subscript operator for the HashMap class

Precondition:
The HashMap contains a hash for type T.
Postcondition:
The value of a hashed key is returned.

Definition at line 25 of file HashMap.cpp.

References HashMap< Key, T, Hash >::hash.

template<typename Key, typename T, typename Hash>
map< Key, T >::const_iterator HashMap< Key, T, Hash >::findItem const Key &  key  ) 
 

Hashes the key to find the vector index. Finds the map element using the key as the index.

Precondition:
The HashMap contains a hash for type T.
Postcondition:
An iterator to the (key, item) pair is returned. If the item is not in the map, the iterator points to the end of the map.

Definition at line 31 of file HashMap.cpp.

References HashMap< Key, T, Hash >::hash.

template<typename Key, typename T, typename Hash>
void HashMap< Key, T, Hash >::insert const Key &  key,
const T &  item
 

Hashes the key to find the vector index. Inserts the (key, item) pair into the map at that index.

Precondition:
The HashMap contains a hash for the type T.
Postcondition:
The (key, item) pair is inserted at the hashed index.

Definition at line 41 of file HashMap.cpp.

References HashMap< Key, T, Hash >::hash.

template<typename Key, typename T, typename Hash>
int HashMap< Key, T, Hash >::erase const Key &  k  ) 
 

Removes the item with the Key k in the hash table.

Precondition:
The HashMap contains a hash for the type T.
Postcondition:
The (key, item) pair at the hashed index is removed. The number of items removed is returned (either 0 or 1).

Definition at line 49 of file HashMap.cpp.

References HashMap< Key, T, Hash >::hash.


Member Data Documentation

template<typename Key, typename T, typename Hash>
Hash HashMap< Key, T, Hash >::hash
 

The hash function object.

Definition at line 62 of file HashMap.h.

Referenced by HashMap< Key, T, Hash >::erase(), HashMap< Key, T, Hash >::findItem(), HashMap< Key, T, Hash >::HashMap(), HashMap< Key, T, Hash >::insert(), and HashMap< Key, T, Hash >::operator[]().


The documentation for this class was generated from the following files:

Generated on Sun Aug 27 22:18:13 2006 for AWLogo by  doxygen 1.4.6