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

Side by Side Diff: third_party/WebKit/Source/wtf/HashFunctions.h

Issue 1436153002: Apply clang-format with Chromium-style without column limit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 10 matching lines...) Expand all
21 #ifndef WTF_HashFunctions_h 21 #ifndef WTF_HashFunctions_h
22 #define WTF_HashFunctions_h 22 #define WTF_HashFunctions_h
23 23
24 #include "wtf/OwnPtr.h" 24 #include "wtf/OwnPtr.h"
25 #include "wtf/RefPtr.h" 25 #include "wtf/RefPtr.h"
26 #include "wtf/StdLibExtras.h" 26 #include "wtf/StdLibExtras.h"
27 #include <stdint.h> 27 #include <stdint.h>
28 28
29 namespace WTF { 29 namespace WTF {
30 30
31 template <size_t size> struct IntTypes; 31 template <size_t size>
32 template <> struct IntTypes<1> { typedef int8_t SignedType; typedef uint8_t Unsi gnedType; }; 32 struct IntTypes;
33 template <> struct IntTypes<2> { typedef int16_t SignedType; typedef uint16_t Un signedType; }; 33 template <>
34 template <> struct IntTypes<4> { typedef int32_t SignedType; typedef uint32_t Un signedType; }; 34 struct IntTypes<1> {
35 template <> struct IntTypes<8> { typedef int64_t SignedType; typedef uint64_t Un signedType; }; 35 typedef int8_t SignedType;
36 typedef uint8_t UnsignedType;
37 };
38 template <>
39 struct IntTypes<2> {
40 typedef int16_t SignedType;
41 typedef uint16_t UnsignedType;
42 };
43 template <>
44 struct IntTypes<4> {
45 typedef int32_t SignedType;
46 typedef uint32_t UnsignedType;
47 };
48 template <>
49 struct IntTypes<8> {
50 typedef int64_t SignedType;
51 typedef uint64_t UnsignedType;
52 };
36 53
37 // integer hash function 54 // integer hash function
38 55
39 // Thomas Wang's 32 Bit Mix Function: http://www.cris.com/~Ttwang/tech/inthash.h tm 56 // Thomas Wang's 32 Bit Mix Function: http://www.cris.com/~Ttwang/tech/inthash.h tm
40 inline unsigned intHash(uint8_t key8) 57 inline unsigned intHash(uint8_t key8) {
41 { 58 unsigned key = key8;
42 unsigned key = key8; 59 key += ~(key << 15);
43 key += ~(key << 15); 60 key ^= (key >> 10);
44 key ^= (key >> 10); 61 key += (key << 3);
45 key += (key << 3); 62 key ^= (key >> 6);
46 key ^= (key >> 6); 63 key += ~(key << 11);
47 key += ~(key << 11); 64 key ^= (key >> 16);
48 key ^= (key >> 16); 65 return key;
49 return key;
50 } 66 }
51 67
52 // Thomas Wang's 32 Bit Mix Function: http://www.cris.com/~Ttwang/tech/inthash.h tm 68 // Thomas Wang's 32 Bit Mix Function: http://www.cris.com/~Ttwang/tech/inthash.h tm
53 inline unsigned intHash(uint16_t key16) 69 inline unsigned intHash(uint16_t key16) {
54 { 70 unsigned key = key16;
55 unsigned key = key16; 71 key += ~(key << 15);
56 key += ~(key << 15); 72 key ^= (key >> 10);
57 key ^= (key >> 10); 73 key += (key << 3);
58 key += (key << 3); 74 key ^= (key >> 6);
59 key ^= (key >> 6); 75 key += ~(key << 11);
60 key += ~(key << 11); 76 key ^= (key >> 16);
61 key ^= (key >> 16); 77 return key;
62 return key;
63 } 78 }
64 79
65 // Thomas Wang's 32 Bit Mix Function: http://www.cris.com/~Ttwang/tech/inthash.h tm 80 // Thomas Wang's 32 Bit Mix Function: http://www.cris.com/~Ttwang/tech/inthash.h tm
66 inline unsigned intHash(uint32_t key) 81 inline unsigned intHash(uint32_t key) {
67 { 82 key += ~(key << 15);
68 key += ~(key << 15); 83 key ^= (key >> 10);
69 key ^= (key >> 10); 84 key += (key << 3);
70 key += (key << 3); 85 key ^= (key >> 6);
71 key ^= (key >> 6); 86 key += ~(key << 11);
72 key += ~(key << 11); 87 key ^= (key >> 16);
73 key ^= (key >> 16); 88 return key;
74 return key;
75 } 89 }
76 90
77 // Thomas Wang's 64 bit Mix Function: http://www.cris.com/~Ttwang/tech/inthash.h tm 91 // Thomas Wang's 64 bit Mix Function: http://www.cris.com/~Ttwang/tech/inthash.h tm
78 inline unsigned intHash(uint64_t key) 92 inline unsigned intHash(uint64_t key) {
79 { 93 key += ~(key << 32);
80 key += ~(key << 32); 94 key ^= (key >> 22);
81 key ^= (key >> 22); 95 key += ~(key << 13);
82 key += ~(key << 13); 96 key ^= (key >> 8);
83 key ^= (key >> 8); 97 key += (key << 3);
84 key += (key << 3); 98 key ^= (key >> 15);
85 key ^= (key >> 15); 99 key += ~(key << 27);
86 key += ~(key << 27); 100 key ^= (key >> 31);
87 key ^= (key >> 31); 101 return static_cast<unsigned>(key);
88 return static_cast<unsigned>(key);
89 } 102 }
90 103
91 // Compound integer hash method: http://opendatastructures.org/versions/edition- 0.1d/ods-java/node33.html#SECTION00832000000000000000 104 // Compound integer hash method: http://opendatastructures.org/versions/edition- 0.1d/ods-java/node33.html#SECTION00832000000000000000
92 inline unsigned pairIntHash(unsigned key1, unsigned key2) 105 inline unsigned pairIntHash(unsigned key1, unsigned key2) {
93 { 106 unsigned shortRandom1 = 277951225; // A random 32-bit value.
94 unsigned shortRandom1 = 277951225; // A random 32-bit value. 107 unsigned shortRandom2 = 95187966; // A random 32-bit value.
95 unsigned shortRandom2 = 95187966; // A random 32-bit value. 108 uint64_t longRandom = 19248658165952622LL; // A random 64-bit value.
96 uint64_t longRandom = 19248658165952622LL; // A random 64-bit value. 109
97 110 uint64_t product = longRandom * (shortRandom1 * key1 + shortRandom2 * key2);
98 uint64_t product = longRandom * (shortRandom1 * key1 + shortRandom2 * key2); 111 unsigned highBits = static_cast<unsigned>(product >> (sizeof(uint64_t) - sizeo f(unsigned)));
99 unsigned highBits = static_cast<unsigned>(product >> (sizeof(uint64_t) - siz eof(unsigned))); 112 return highBits;
100 return highBits; 113 }
101 } 114
102 115 template <typename T>
103 template <typename T> struct IntHash { 116 struct IntHash {
104 static unsigned hash(T key) { return intHash(static_cast<typename IntTypes<s izeof(T)>::UnsignedType>(key)); } 117 static unsigned hash(T key) { return intHash(static_cast<typename IntTypes<siz eof(T)>::UnsignedType>(key)); }
105 static bool equal(T a, T b) { return a == b; } 118 static bool equal(T a, T b) { return a == b; }
106 static const bool safeToCompareToEmptyOrDeleted = true; 119 static const bool safeToCompareToEmptyOrDeleted = true;
107 }; 120 };
108 121
109 template <typename T> struct FloatHash { 122 template <typename T>
110 typedef typename IntTypes<sizeof(T)>::UnsignedType Bits; 123 struct FloatHash {
111 static unsigned hash(T key) 124 typedef typename IntTypes<sizeof(T)>::UnsignedType Bits;
112 { 125 static unsigned hash(T key) {
113 return intHash(bitwise_cast<Bits>(key)); 126 return intHash(bitwise_cast<Bits>(key));
114 } 127 }
115 static bool equal(T a, T b) 128 static bool equal(T a, T b) {
116 { 129 return bitwise_cast<Bits>(a) == bitwise_cast<Bits>(b);
117 return bitwise_cast<Bits>(a) == bitwise_cast<Bits>(b); 130 }
118 } 131 static const bool safeToCompareToEmptyOrDeleted = true;
119 static const bool safeToCompareToEmptyOrDeleted = true;
120 }; 132 };
121 133
122 // pointer identity hash function 134 // pointer identity hash function
123 135
124 template <typename T> struct PtrHash { 136 template <typename T>
125 static unsigned hash(T key) 137 struct PtrHash {
126 { 138 static unsigned hash(T key) {
127 #if COMPILER(MSVC) 139 #if COMPILER(MSVC)
128 #pragma warning(push) 140 #pragma warning(push)
129 #pragma warning(disable: 4244) // work around what seems to be a bug in MSVC's c onversion warnings 141 #pragma warning(disable : 4244) // work around what seems to be a bug in MSVC's conversion warnings
130 #endif 142 #endif
131 return IntHash<uintptr_t>::hash(reinterpret_cast<uintptr_t>(key)); 143 return IntHash<uintptr_t>::hash(reinterpret_cast<uintptr_t>(key));
132 #if COMPILER(MSVC) 144 #if COMPILER(MSVC)
133 #pragma warning(pop) 145 #pragma warning(pop)
134 #endif 146 #endif
135 } 147 }
136 static bool equal(T a, T b) { return a == b; } 148 static bool equal(T a, T b) { return a == b; }
137 static bool equal(std::nullptr_t, T b) { return b == 0; } 149 static bool equal(std::nullptr_t, T b) { return b == 0; }
138 static bool equal(T a, std::nullptr_t) { return a == 0; } 150 static bool equal(T a, std::nullptr_t) { return a == 0; }
139 static const bool safeToCompareToEmptyOrDeleted = true; 151 static const bool safeToCompareToEmptyOrDeleted = true;
140 }; 152 };
141 template <typename P> struct PtrHash<RefPtr<P>> : PtrHash<P*> { 153 template <typename P>
142 using PtrHash<P*>::hash; 154 struct PtrHash<RefPtr<P>> : PtrHash<P*> {
143 static unsigned hash(const RefPtr<P>& key) { return hash(key.get()); } 155 using PtrHash<P*>::hash;
144 static unsigned hash(const PassRefPtr<P>& key) { return hash(key.get()); } 156 static unsigned hash(const RefPtr<P>& key) { return hash(key.get()); }
145 using PtrHash<P*>::equal; 157 static unsigned hash(const PassRefPtr<P>& key) { return hash(key.get()); }
146 static bool equal(const RefPtr<P>& a, const RefPtr<P>& b) { return a == b; } 158 using PtrHash<P*>::equal;
147 static bool equal(P* a, const RefPtr<P>& b) { return a == b; } 159 static bool equal(const RefPtr<P>& a, const RefPtr<P>& b) { return a == b; }
148 static bool equal(const RefPtr<P>& a, P* b) { return a == b; } 160 static bool equal(P* a, const RefPtr<P>& b) { return a == b; }
149 static bool equal(const RefPtr<P>& a, const PassRefPtr<P>& b) { return a == b; } 161 static bool equal(const RefPtr<P>& a, P* b) { return a == b; }
150 }; 162 static bool equal(const RefPtr<P>& a, const PassRefPtr<P>& b) { return a == b; }
151 template <typename P> struct PtrHash<RawPtr<P>> : PtrHash<P*> { 163 };
152 using PtrHash<P*>::hash; 164 template <typename P>
153 static unsigned hash(const RawPtr<P>& key) { return hash(key.get()); } 165 struct PtrHash<RawPtr<P>> : PtrHash<P*> {
154 using PtrHash<P*>::equal; 166 using PtrHash<P*>::hash;
155 static bool equal(const RawPtr<P>& a, const RawPtr<P>& b) { return a == b; } 167 static unsigned hash(const RawPtr<P>& key) { return hash(key.get()); }
156 static bool equal(P* a, const RawPtr<P>& b) { return a == b; } 168 using PtrHash<P*>::equal;
157 static bool equal(const RawPtr<P>& a, P* b) { return a == b; } 169 static bool equal(const RawPtr<P>& a, const RawPtr<P>& b) { return a == b; }
158 }; 170 static bool equal(P* a, const RawPtr<P>& b) { return a == b; }
159 template <typename P> struct PtrHash<OwnPtr<P>> : PtrHash<P*> { 171 static bool equal(const RawPtr<P>& a, P* b) { return a == b; }
160 using PtrHash<P*>::hash; 172 };
161 static unsigned hash(const OwnPtr<P>& key) { return hash(key.get()); } 173 template <typename P>
162 static unsigned hash(const PassOwnPtr<P>& key) { return hash(key.get()); } 174 struct PtrHash<OwnPtr<P>> : PtrHash<P*> {
163 175 using PtrHash<P*>::hash;
164 static bool equal(const OwnPtr<P>& a, const OwnPtr<P>& b) 176 static unsigned hash(const OwnPtr<P>& key) { return hash(key.get()); }
165 { 177 static unsigned hash(const PassOwnPtr<P>& key) { return hash(key.get()); }
166 return a.get() == b.get(); 178
167 } 179 static bool equal(const OwnPtr<P>& a, const OwnPtr<P>& b) {
168 static bool equal(const OwnPtr<P>& a, P* b) { return a == b; } 180 return a.get() == b.get();
169 static bool equal(const OwnPtr<P>& a, const PassOwnPtr<P>& b) 181 }
170 { 182 static bool equal(const OwnPtr<P>& a, P* b) { return a == b; }
171 return a.get() == b.get(); 183 static bool equal(const OwnPtr<P>& a, const PassOwnPtr<P>& b) {
172 } 184 return a.get() == b.get();
185 }
173 }; 186 };
174 187
175 // default hash function for each type 188 // default hash function for each type
176 189
177 template <typename T> struct DefaultHash; 190 template <typename T>
178 191 struct DefaultHash;
179 template <typename T, typename U> struct PairHash { 192
180 static unsigned hash(const std::pair<T, U>& p) 193 template <typename T, typename U>
181 { 194 struct PairHash {
182 return pairIntHash(DefaultHash<T>::Hash::hash(p.first), DefaultHash<U>:: Hash::hash(p.second)); 195 static unsigned hash(const std::pair<T, U>& p) {
183 } 196 return pairIntHash(DefaultHash<T>::Hash::hash(p.first), DefaultHash<U>::Hash ::hash(p.second));
184 static bool equal(const std::pair<T, U>& a, const std::pair<T, U>& b) 197 }
185 { 198 static bool equal(const std::pair<T, U>& a, const std::pair<T, U>& b) {
186 return DefaultHash<T>::Hash::equal(a.first, b.first) && DefaultHash<U>:: Hash::equal(a.second, b.second); 199 return DefaultHash<T>::Hash::equal(a.first, b.first) && DefaultHash<U>::Hash ::equal(a.second, b.second);
187 } 200 }
188 static const bool safeToCompareToEmptyOrDeleted = DefaultHash<T>::Hash::safe ToCompareToEmptyOrDeleted 201 static const bool safeToCompareToEmptyOrDeleted = DefaultHash<T>::Hash::safeTo CompareToEmptyOrDeleted && DefaultHash<U>::Hash::safeToCompareToEmptyOrDeleted;
189 && DefaultHash<U>::Hash::safeToCompareToEmptyOrDeleted; 202 };
190 }; 203
191 204 template <typename T, typename U>
192 template <typename T, typename U> struct IntPairHash { 205 struct IntPairHash {
193 static unsigned hash(const std::pair<T, U>& p) { return pairIntHash(p.first, p.second); } 206 static unsigned hash(const std::pair<T, U>& p) { return pairIntHash(p.first, p .second); }
194 static bool equal(const std::pair<T, U>& a, const std::pair<T, U>& b) { retu rn PairHash<T, T>::equal(a, b); } 207 static bool equal(const std::pair<T, U>& a, const std::pair<T, U>& b) { return PairHash<T, T>::equal(a, b); }
195 static const bool safeToCompareToEmptyOrDeleted = PairHash<T, U>::safeToComp areToEmptyOrDeleted; 208 static const bool safeToCompareToEmptyOrDeleted = PairHash<T, U>::safeToCompar eToEmptyOrDeleted;
196 }; 209 };
197 210
198 // make IntHash the default hash function for many integer types 211 // make IntHash the default hash function for many integer types
199 212
200 template <> struct DefaultHash<short> { typedef IntHash<unsigned> Hash; }; 213 template <>
201 template <> struct DefaultHash<unsigned short> { typedef IntHash<unsigned> Hash; }; 214 struct DefaultHash<short> { typedef IntHash<unsigned> Hash; };
202 template <> struct DefaultHash<int> { typedef IntHash<unsigned> Hash; }; 215 template <>
203 template <> struct DefaultHash<unsigned> { typedef IntHash<unsigned> Hash; }; 216 struct DefaultHash<unsigned short> { typedef IntHash<unsigned> Hash; };
204 template <> struct DefaultHash<long> { typedef IntHash<unsigned long> Hash; }; 217 template <>
205 template <> struct DefaultHash<unsigned long> { typedef IntHash<unsigned long> H ash; }; 218 struct DefaultHash<int> { typedef IntHash<unsigned> Hash; };
206 template <> struct DefaultHash<long long> { typedef IntHash<unsigned long long> Hash; }; 219 template <>
207 template <> struct DefaultHash<unsigned long long> { typedef IntHash<unsigned lo ng long> Hash; }; 220 struct DefaultHash<unsigned> { typedef IntHash<unsigned> Hash; };
221 template <>
222 struct DefaultHash<long> { typedef IntHash<unsigned long> Hash; };
223 template <>
224 struct DefaultHash<unsigned long> { typedef IntHash<unsigned long> Hash; };
225 template <>
226 struct DefaultHash<long long> { typedef IntHash<unsigned long long> Hash; };
227 template <>
228 struct DefaultHash<unsigned long long> { typedef IntHash<unsigned long long> Has h; };
208 229
209 #if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) 230 #if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED)
210 template <> struct DefaultHash<wchar_t> { typedef IntHash<wchar_t> Hash; }; 231 template <>
232 struct DefaultHash<wchar_t> { typedef IntHash<wchar_t> Hash; };
211 #endif 233 #endif
212 234
213 template <> struct DefaultHash<float> { typedef FloatHash<float> Hash; }; 235 template <>
214 template <> struct DefaultHash<double> { typedef FloatHash<double> Hash; }; 236 struct DefaultHash<float> { typedef FloatHash<float> Hash; };
237 template <>
238 struct DefaultHash<double> { typedef FloatHash<double> Hash; };
215 239
216 // make PtrHash the default hash function for pointer types that don't specializ e 240 // make PtrHash the default hash function for pointer types that don't specializ e
217 241
218 template <typename P> struct DefaultHash<P*> { typedef PtrHash<P*> Hash; }; 242 template <typename P>
219 template <typename P> struct DefaultHash<RefPtr<P>> { typedef PtrHash<RefPtr<P>> Hash; }; 243 struct DefaultHash<P*> { typedef PtrHash<P*> Hash; };
220 template <typename P> struct DefaultHash<RawPtr<P>> { typedef PtrHash<RawPtr<P>> Hash; }; 244 template <typename P>
221 template <typename P> struct DefaultHash<OwnPtr<P>> { typedef PtrHash<OwnPtr<P>> Hash; }; 245 struct DefaultHash<RefPtr<P>> { typedef PtrHash<RefPtr<P>> Hash; };
246 template <typename P>
247 struct DefaultHash<RawPtr<P>> { typedef PtrHash<RawPtr<P>> Hash; };
248 template <typename P>
249 struct DefaultHash<OwnPtr<P>> { typedef PtrHash<OwnPtr<P>> Hash; };
222 250
223 // make IntPairHash the default hash function for pairs of (at most) 32-bit inte gers. 251 // make IntPairHash the default hash function for pairs of (at most) 32-bit inte gers.
224 252
225 template <> struct DefaultHash<std::pair<short, short>> { typedef IntPairHash<sh ort, short> Hash; }; 253 template <>
226 template <> struct DefaultHash<std::pair<short, unsigned short>> { typedef IntPa irHash<short, unsigned short> Hash; }; 254 struct DefaultHash<std::pair<short, short>> { typedef IntPairHash<short, short> Hash; };
227 template <> struct DefaultHash<std::pair<short, int>> { typedef IntPairHash<shor t, int> Hash; }; 255 template <>
228 template <> struct DefaultHash<std::pair<short, unsigned>> { typedef IntPairHash <short, unsigned> Hash; }; 256 struct DefaultHash<std::pair<short, unsigned short>> { typedef IntPairHash<short , unsigned short> Hash; };
229 template <> struct DefaultHash<std::pair<unsigned short, short>> { typedef IntPa irHash<unsigned short, short> Hash; }; 257 template <>
230 template <> struct DefaultHash<std::pair<unsigned short, unsigned short>> { type def IntPairHash<unsigned short, unsigned short> Hash; }; 258 struct DefaultHash<std::pair<short, int>> { typedef IntPairHash<short, int> Hash ; };
231 template <> struct DefaultHash<std::pair<unsigned short, int>> { typedef IntPair Hash<unsigned short, int> Hash; }; 259 template <>
232 template <> struct DefaultHash<std::pair<unsigned short, unsigned>> { typedef In tPairHash<unsigned short, unsigned> Hash; }; 260 struct DefaultHash<std::pair<short, unsigned>> { typedef IntPairHash<short, unsi gned> Hash; };
233 template <> struct DefaultHash<std::pair<int, short>> { typedef IntPairHash<int, short> Hash; }; 261 template <>
234 template <> struct DefaultHash<std::pair<int, unsigned short>> { typedef IntPair Hash<int, unsigned short> Hash; }; 262 struct DefaultHash<std::pair<unsigned short, short>> { typedef IntPairHash<unsig ned short, short> Hash; };
235 template <> struct DefaultHash<std::pair<int, int>> { typedef IntPairHash<int, i nt> Hash; }; 263 template <>
236 template <> struct DefaultHash<std::pair<int, unsigned>> { typedef IntPairHash<u nsigned, unsigned> Hash; }; 264 struct DefaultHash<std::pair<unsigned short, unsigned short>> { typedef IntPairH ash<unsigned short, unsigned short> Hash; };
237 template <> struct DefaultHash<std::pair<unsigned, short>> { typedef IntPairHash <unsigned, short> Hash; }; 265 template <>
238 template <> struct DefaultHash<std::pair<unsigned, unsigned short>> { typedef In tPairHash<unsigned, unsigned short> Hash; }; 266 struct DefaultHash<std::pair<unsigned short, int>> { typedef IntPairHash<unsigne d short, int> Hash; };
239 template <> struct DefaultHash<std::pair<unsigned, int>> { typedef IntPairHash<u nsigned, int> Hash; }; 267 template <>
240 template <> struct DefaultHash<std::pair<unsigned, unsigned>> { typedef IntPairH ash<unsigned, unsigned> Hash; }; 268 struct DefaultHash<std::pair<unsigned short, unsigned>> { typedef IntPairHash<un signed short, unsigned> Hash; };
269 template <>
270 struct DefaultHash<std::pair<int, short>> { typedef IntPairHash<int, short> Hash ; };
271 template <>
272 struct DefaultHash<std::pair<int, unsigned short>> { typedef IntPairHash<int, un signed short> Hash; };
273 template <>
274 struct DefaultHash<std::pair<int, int>> { typedef IntPairHash<int, int> Hash; };
275 template <>
276 struct DefaultHash<std::pair<int, unsigned>> { typedef IntPairHash<unsigned, uns igned> Hash; };
277 template <>
278 struct DefaultHash<std::pair<unsigned, short>> { typedef IntPairHash<unsigned, s hort> Hash; };
279 template <>
280 struct DefaultHash<std::pair<unsigned, unsigned short>> { typedef IntPairHash<un signed, unsigned short> Hash; };
281 template <>
282 struct DefaultHash<std::pair<unsigned, int>> { typedef IntPairHash<unsigned, int > Hash; };
283 template <>
284 struct DefaultHash<std::pair<unsigned, unsigned>> { typedef IntPairHash<unsigned , unsigned> Hash; };
241 285
242 // make PairHash the default hash function for pairs of arbitrary values. 286 // make PairHash the default hash function for pairs of arbitrary values.
243 287
244 template <typename T, typename U> struct DefaultHash<std::pair<T, U>> { typedef PairHash<T, U> Hash; }; 288 template <typename T, typename U>
245 289 struct DefaultHash<std::pair<T, U>> { typedef PairHash<T, U> Hash; };
246 } // namespace WTF 290
291 } // namespace WTF
247 292
248 using WTF::DefaultHash; 293 using WTF::DefaultHash;
249 using WTF::IntHash; 294 using WTF::IntHash;
250 using WTF::PtrHash; 295 using WTF::PtrHash;
251 296
252 #endif // WTF_HashFunctions_h 297 #endif // WTF_HashFunctions_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/HashCountedSet.h ('k') | third_party/WebKit/Source/wtf/HashIterators.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698