00001
00017 template <typename Key, typename T, typename Hash>
00018 HashMap<Key, T, Hash>::HashMap(int maxBuckets)
00019 {
00020 hash = Hash();
00021 resize(maxBuckets + 1);
00022 }
00023
00024 template <typename Key, typename T, typename Hash>
00025 T& HashMap<Key, T, Hash>::operator[](Key& key)
00026 {
00027 return at(hash(key))[key];
00028 }
00029
00030 template <typename Key, typename T, typename Hash>
00031 map<Key, T>::const_iterator HashMap<Key, T, Hash>::findItem(const Key& key)
00032 {
00033 map<Key, T>::const_iterator it;
00034 int index = hash(key);
00035 it = at(index).find(key);
00036
00037 return it;
00038 }
00039
00040 template <typename Key, typename T, typename Hash>
00041 void HashMap<Key, T, Hash>::insert(const Key& key,
00042 const T& item)
00043 {
00044 int index = hash(key);
00045 at(index).insert(make_pair(key, item));
00046 }
00047
00048 template <typename Key, typename T, typename Hash>
00049 int HashMap<Key, T, Hash>::erase(const Key& key)
00050 {
00051 int index = hash(key);
00052 return at(index).erase(key);
00053 }
00054