OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 | 5 |
6 // | 6 // |
7 // Deal with the differences between Microsoft and GNU implemenations | 7 // Deal with the differences between Microsoft and GNU implemenations |
8 // of hash_map. Allows all platforms to use |base::hash_map| and | 8 // of hash_map. Allows all platforms to use |base::hash_map| and |
9 // |base::hash_set|. | 9 // |base::hash_set|. |
10 // eg: | 10 // eg: |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 struct hash<string_type> { \ | 96 struct hash<string_type> { \ |
97 std::size_t operator()(const string_type& s) const { \ | 97 std::size_t operator()(const string_type& s) const { \ |
98 std::size_t result = 0; \ | 98 std::size_t result = 0; \ |
99 for (string_type::const_iterator i = s.begin(); i != s.end(); ++i) \ | 99 for (string_type::const_iterator i = s.begin(); i != s.end(); ++i) \ |
100 result = (result * 131) + *i; \ | 100 result = (result * 131) + *i; \ |
101 return result; \ | 101 return result; \ |
102 } \ | 102 } \ |
103 } | 103 } |
104 | 104 |
105 DEFINE_STRING_HASH(std::string); | 105 DEFINE_STRING_HASH(std::string); |
106 DEFINE_STRING_HASH(string16); | 106 DEFINE_STRING_HASH(base::string16); |
107 | 107 |
108 #undef DEFINE_STRING_HASH | 108 #undef DEFINE_STRING_HASH |
109 | 109 |
110 } // namespace BASE_HASH_NAMESPACE | 110 } // namespace BASE_HASH_NAMESPACE |
111 | 111 |
112 #else // COMPILER | 112 #else // COMPILER |
113 #error define BASE_HASH_NAMESPACE for your compiler | 113 #error define BASE_HASH_NAMESPACE for your compiler |
114 #endif // COMPILER | 114 #endif // COMPILER |
115 | 115 |
116 namespace base { | 116 namespace base { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 #else | 255 #else |
256 #error define hash<std::pair<Type1, Type2> > for your compiler | 256 #error define hash<std::pair<Type1, Type2> > for your compiler |
257 #endif // COMPILER | 257 #endif // COMPILER |
258 | 258 |
259 } | 259 } |
260 | 260 |
261 #undef DEFINE_PAIR_HASH_FUNCTION_START | 261 #undef DEFINE_PAIR_HASH_FUNCTION_START |
262 #undef DEFINE_PAIR_HASH_FUNCTION_END | 262 #undef DEFINE_PAIR_HASH_FUNCTION_END |
263 | 263 |
264 #endif // BASE_CONTAINERS_HASH_TABLES_H_ | 264 #endif // BASE_CONTAINERS_HASH_TABLES_H_ |
OLD | NEW |