35 #ifndef GOOGLE_PROTOBUF_STUBS_HASH_H__
36 #define GOOGLE_PROTOBUF_STUBS_HASH_H__
42 #if defined(HAVE_HASH_MAP) && defined(HAVE_HASH_SET)
62 template <
typename Key>
66 GOOGLE_LOG(FATAL) <<
"Should never be called.";
70 inline bool operator()(
const Key& a,
const Key& b)
const {
80 GOOGLE_LOG(FATAL) <<
"Should never be called.";
84 inline bool operator()(
const char* a,
const char* b)
const {
85 return strcmp(a, b) < 0;
89 template <
typename Key,
typename Data,
90 typename HashFcn = hash<Key>,
91 typename EqualKey =
int >
92 class hash_map :
public std::map<Key, Data, HashFcn> {
97 template <
typename Key,
98 typename HashFcn = hash<Key>,
99 typename EqualKey =
int >
100 class hash_set :
public std::set<Key, HashFcn> {
105 #elif defined(_MSC_VER) && !defined(_STLPORT_VERSION)
107 template <
typename Key>
108 struct hash :
public HASH_NAMESPACE::hash_compare<Key> {
115 inline bool operator()(
const char* a,
const char* b)
const {
116 return strcmp(a, b) < 0;
122 :
public HASH_NAMESPACE::hash_compare<const char*, CstringLess> {
125 template <
typename Key,
typename Data,
126 typename HashFcn = hash<Key>,
127 typename EqualKey =
int >
128 class hash_map :
public HASH_NAMESPACE::hash_map<
129 Key, Data, HashFcn> {
134 template <
typename Key,
135 typename HashFcn = hash<Key>,
136 typename EqualKey =
int >
137 class hash_set :
public HASH_NAMESPACE::hash_set<
145 template <
typename Key>
149 template <
typename Key>
151 inline size_t operator()(
const Key* key)
const {
152 return reinterpret_cast<size_t>(key);
160 inline size_t operator()(
const char* str)
const {
162 for (; *str !=
'\0'; str++) {
163 result = 5 * result + *str;
169 template <
typename Key,
typename Data,
170 typename HashFcn = hash<Key>,
171 typename EqualKey = std::equal_to<Key> >
172 class hash_map :
public HASH_NAMESPACE::HASH_MAP_CLASS<
173 Key, Data, HashFcn, EqualKey> {
178 template <
typename Key,
179 typename HashFcn = hash<Key>,
180 typename EqualKey = std::equal_to<Key> >
181 class hash_set :
public HASH_NAMESPACE::HASH_SET_CLASS<
182 Key, HashFcn, EqualKey> {
190 struct hash<string> {
195 static const size_t bucket_size = 4;
196 static const size_t min_buckets = 8;
197 inline size_t operator()(
const string& a,
const string& b)
const {
202 template <
typename First,
typename Second>
203 struct hash<pair<First, Second> > {
204 inline size_t operator()(
const pair<First, Second>& key)
const {
210 return first_hash * ((1 << 16) - 1) + second_hash;
213 static const size_t bucket_size = 4;
214 static const size_t min_buckets = 8;
216 const pair<First, Second>& b)
const {
225 return strcmp(a, b) == 0;
232 #endif // GOOGLE_PROTOBUF_STUBS_HASH_H__
hash_set(int=0)
Definition: hash.h:102
bool operator()(const char *a, const char *b) const
Definition: hash.h:84
int operator()(const Key &key)
Definition: hash.h:65
size_t operator()(const pair< First, Second > &key) const
Definition: hash.h:204
#define hash
Definition: private_namespace.h:186
bool operator()(const char *a, const char *b) const
Definition: hash.h:224
int operator()(const char *key)
Definition: hash.h:79
size_t operator()(const string &key) const
Definition: hash.h:191
#define GOOGLE_LOG(LEVEL)
Definition: common.h:706
size_t operator()(const string &a, const string &b) const
Definition: hash.h:197
Definition: BnetFileGenerator.h:47
#define const
Definition: zconf.h:217
hash_map(int=0)
Definition: hash.h:94
Data
Definition: molten_core.h:69
bool operator()(const Key &a, const Key &b) const
Definition: hash.h:70
size_t operator()(const pair< First, Second > &a, const pair< First, Second > &b) const
Definition: hash.h:215