Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(596)

Side by Side Diff: base/hash_tables.h

Issue 7549003: Optimize phishing page term feature extraction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unnecesary macros in wide_string_piece_unittest.cc Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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:
11 // base::hash_map<int> my_map; 11 // base::hash_map<int> my_map;
12 // base::hash_set<int> my_set; 12 // base::hash_set<int> my_set;
13 // 13 //
14 // NOTE: It is an explicit non-goal of this class to provide a generic hash 14 // NOTE: It is an explicit non-goal of this class to provide a generic hash
15 // function for pointers. If you want to hash a pointers to a particular class, 15 // function for pointers. If you want to hash a pointers to a particular class,
16 // please define the template specialization elsewhere (for example, in its 16 // please define the template specialization elsewhere (for example, in its
17 // header file) and keep it specific to just pointers to that class. This is 17 // header file) and keep it specific to just pointers to that class. This is
18 // because identity hashes are not desirable for all types that might show up 18 // because identity hashes are not desirable for all types that might show up
19 // in containers as pointers. 19 // in containers as pointers.
20 20
21 #ifndef BASE_HASH_TABLES_H_ 21 #ifndef BASE_HASH_TABLES_H_
22 #define BASE_HASH_TABLES_H_ 22 #define BASE_HASH_TABLES_H_
23 #pragma once 23 #pragma once
24 24
25 #include "build/build_config.h" 25 #include "build/build_config.h"
26 26
27 #include "base/string16.h" 27 #include "base/string16.h"
28 #include "base/string_piece.h"
29 #include "base/wide_string_piece.h"
28 30
29 #if defined(COMPILER_MSVC) 31 #if defined(COMPILER_MSVC)
30 #include <hash_map> 32 #include <hash_map>
31 #include <hash_set> 33 #include <hash_set>
32 34
33 #define BASE_HASH_NAMESPACE stdext 35 #define BASE_HASH_NAMESPACE stdext
34 36
35 #elif defined(COMPILER_GCC) 37 #elif defined(COMPILER_GCC)
36 #if defined(OS_ANDROID) 38 #if defined(OS_ANDROID)
37 #define BASE_HASH_NAMESPACE std 39 #define BASE_HASH_NAMESPACE std
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 std::size_t operator()(const string_type& s) const { \ 98 std::size_t operator()(const string_type& s) const { \
97 std::size_t result = 0; \ 99 std::size_t result = 0; \
98 for (string_type::const_iterator i = s.begin(); i != s.end(); ++i) \ 100 for (string_type::const_iterator i = s.begin(); i != s.end(); ++i) \
99 result = (result * 131) + *i; \ 101 result = (result * 131) + *i; \
100 return result; \ 102 return result; \
101 } \ 103 } \
102 } 104 }
103 105
104 DEFINE_STRING_HASH(std::string); 106 DEFINE_STRING_HASH(std::string);
105 DEFINE_STRING_HASH(string16); 107 DEFINE_STRING_HASH(string16);
108 DEFINE_STRING_HASH(base::StringPiece);
109 DEFINE_STRING_HASH(base::WideStringPiece);
106 110
107 #undef DEFINE_STRING_HASH 111 #undef DEFINE_STRING_HASH
108 112
109 } // namespace BASE_HASH_NAMESPACE 113 } // namespace BASE_HASH_NAMESPACE
110 114
111 #else // COMPILER 115 #else // COMPILER
112 #error define BASE_HASH_NAMESPACE for your compiler 116 #error define BASE_HASH_NAMESPACE for your compiler
113 #endif // COMPILER 117 #endif // COMPILER
114 118
115 namespace base { 119 namespace base {
116 using BASE_HASH_NAMESPACE::hash_map; 120 using BASE_HASH_NAMESPACE::hash_map;
117 using BASE_HASH_NAMESPACE::hash_set; 121 using BASE_HASH_NAMESPACE::hash_set;
118 } 122 }
119 123
120 #endif // BASE_HASH_TABLES_H_ 124 #endif // BASE_HASH_TABLES_H_
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | base/i18n/case_conversion.h » ('j') | base/wide_string_piece_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698