00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _STRINGHASHER_
00019 #define _STRINGHASHER_
00020
00021 #include <hash_map>
00022 #include <string>
00023
00024 class StringHasher : public stdext::hash_compare<std::string>
00025 {
00026 public:
00027
00028 size_t operator()(const std::string& s) const
00029 {
00030 size_t hash = 0;
00031 for(std::string::const_iterator i = s.begin();
00032 i != s.end();
00033 ++i)
00034 {
00035 hash = 31 * hash + (*i);
00036 }
00037 return hash;
00038 }
00039
00040 bool operator()(const std::string& s1, const std::string& s2) const
00041 {
00042 return s1 < s2;
00043 }
00044
00045 };
00046
00047
00048 #endif