00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 #ifndef HashString_h
00011 #define HashString_h
00012 
00013 
00014 #include <string>
00015 
00016 #if (__GNUC__ == 3)
00017 #include <ext/hash_map>
00018 #include <ext/hash_set>
00019   #if (__GNUC_MINOR__ >= 1)
00020   using namespace __gnu_cxx;
00021   #endif
00022 #else
00023 #include <hash_map>
00024 #include <hash_set>
00025 #endif
00026 
00028 class StringEqual
00029 {
00030  public:
00031   size_t operator()(string const &s1, string const &s2) const
00032     {
00033       return (s1 == s2);
00034     }
00035 };
00036 
00038 class hashString
00039 {
00040  public:
00041   size_t operator()(string const &str) const
00042     {
00043       hash<char const *> h;      
00044       return (h(str.c_str()));
00045     }
00046 };
00047 
00049 class StringPairEqual
00050 {
00051  public:
00052   size_t operator()(pair<string,string> const &sp1, pair<string,string> const &sp2) const
00053     {
00054       return (sp1.first == sp2.first && sp1.second == sp2.second);
00055     }
00056 };
00057 
00062 class hashStringPair
00063 {
00064  public:
00065   size_t operator()(pair<string,string> const &sp) const
00066     {
00067       hash<char const *> h;
00068       return (h((sp.first+sp.second).c_str()));
00069     }
00070 };
00071 
00073 class PointerEqual
00074 {
00075  public:
00076   size_t operator()(void*  const &p1, void* const &p2) const
00077     {
00078       return (p1 == p2);
00079     }
00080 };
00081 
00083 class hashPointer
00084 {
00085  public:
00086   size_t operator()(void* const &p) const
00087     {
00088       return (size_t)p;
00089     }
00090 };
00091 
00092 
00093 #endif