00001 00004 #ifndef HASHING_H 00005 #define HASHING_H 00006 00007 #ifdef __GNUC__ 00008 #include <ext/hash_map> 00009 #else 00010 #include <hash_map> 00011 #endif 00012 00013 #include<iostream> 00014 00015 using namespace std; 00016 00017 namespace std 00018 { 00019 using namespace __gnu_cxx; 00020 } 00021 00022 00023 template<typename T1, typename T2> 00024 00028 class Hazy_Hashmap { 00029 private: 00030 00031 public: 00033 Hazy_Hashmap() {} 00035 hash_map<T1,T2> map; 00036 00043 void insertPair(T1 key, T2 element) {map[key] = element;} 00044 00053 T2 findKeyValue(T1 key, bool &found) 00054 { 00055 typename hash_map<T1, T2>::iterator it = map.find(key); 00056 00057 if(it != map.end()) { 00058 found = true; 00059 return it->second; 00060 } 00061 else { 00062 found = false; 00063 return 0; 00064 } 00065 }; 00066 00074 void replaceValue(T1 key, T2 element) {map[key] = element;} 00075 00079 void clear() {map.clear();}; 00080 00086 int size() {return map.size();} 00087 }; 00088 00089 #endif