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

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

Issue 1611343002: wtf reformat test Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pydent Created 4 years, 11 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
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 =
99 unsigned highBits = static_cast<unsigned>(product >> (sizeof(uint64_t) - siz eof(unsigned))); 112 static_cast<unsigned>(product >> (sizeof(uint64_t) - sizeof(unsigned)));
100 return highBits; 113 return highBits;
101 } 114 }
102 115
103 template <typename T> struct IntHash { 116 template <typename T>
104 static unsigned hash(T key) { return intHash(static_cast<typename IntTypes<s izeof(T)>::UnsignedType>(key)); } 117 struct IntHash {
105 static bool equal(T a, T b) { return a == b; } 118 static unsigned hash(T key) {
106 static const bool safeToCompareToEmptyOrDeleted = true; 119 return intHash(
107 }; 120 static_cast<typename IntTypes<sizeof(T)>::UnsignedType>(key));
108 121 }
109 template <typename T> struct FloatHash { 122 static bool equal(T a, T b) { return a == b; }
110 typedef typename IntTypes<sizeof(T)>::UnsignedType Bits; 123 static const bool safeToCompareToEmptyOrDeleted = true;
111 static unsigned hash(T key) 124 };
112 { 125
113 return intHash(bitwise_cast<Bits>(key)); 126 template <typename T>
114 } 127 struct FloatHash {
115 static bool equal(T a, T b) 128 typedef typename IntTypes<sizeof(T)>::UnsignedType Bits;
116 { 129 static unsigned hash(T key) { return intHash(bitwise_cast<Bits>(key)); }
117 return bitwise_cast<Bits>(a) == bitwise_cast<Bits>(b); 130 static bool equal(T a, T b) {
118 } 131 return bitwise_cast<Bits>(a) == bitwise_cast<Bits>(b);
119 static const bool safeToCompareToEmptyOrDeleted = true; 132 }
133 static const bool safeToCompareToEmptyOrDeleted = true;
120 }; 134 };
121 135
122 // pointer identity hash function 136 // pointer identity hash function
123 137
124 template <typename T> struct PtrHash { 138 template <typename T>
125 static unsigned hash(T key) 139 struct PtrHash {
126 { 140 static unsigned hash(T key) {
127 #if COMPILER(MSVC) 141 #if COMPILER(MSVC)
128 #pragma warning(push) 142 #pragma warning(push)
129 #pragma warning(disable: 4244) // work around what seems to be a bug in MSVC's c onversion warnings 143 #pragma warning( \
144 disable : 4244) // work around what seems to be a bug in MSVC's conversion warnings
130 #endif 145 #endif
131 return IntHash<uintptr_t>::hash(reinterpret_cast<uintptr_t>(key)); 146 return IntHash<uintptr_t>::hash(reinterpret_cast<uintptr_t>(key));
132 #if COMPILER(MSVC) 147 #if COMPILER(MSVC)
133 #pragma warning(pop) 148 #pragma warning(pop)
134 #endif 149 #endif
135 } 150 }
136 static bool equal(T a, T b) { return a == b; } 151 static bool equal(T a, T b) { return a == b; }
137 static bool equal(std::nullptr_t, T b) { return b == 0; } 152 static bool equal(std::nullptr_t, T b) { return b == 0; }
138 static bool equal(T a, std::nullptr_t) { return a == 0; } 153 static bool equal(T a, std::nullptr_t) { return a == 0; }
139 static const bool safeToCompareToEmptyOrDeleted = true; 154 static const bool safeToCompareToEmptyOrDeleted = true;
140 }; 155 };
141 template <typename P> struct PtrHash<RefPtr<P>> : PtrHash<P*> { 156 template <typename P>
142 using PtrHash<P*>::hash; 157 struct PtrHash<RefPtr<P>> : PtrHash<P*> {
143 static unsigned hash(const RefPtr<P>& key) { return hash(key.get()); } 158 using PtrHash<P*>::hash;
144 static unsigned hash(const PassRefPtr<P>& key) { return hash(key.get()); } 159 static unsigned hash(const RefPtr<P>& key) { return hash(key.get()); }
145 using PtrHash<P*>::equal; 160 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; } 161 using PtrHash<P*>::equal;
147 static bool equal(P* a, const RefPtr<P>& b) { return a == b; } 162 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; } 163 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; } 164 static bool equal(const RefPtr<P>& a, P* b) { return a == b; }
150 }; 165 static bool equal(const RefPtr<P>& a, const PassRefPtr<P>& b) {
151 template <typename P> struct PtrHash<RawPtr<P>> : PtrHash<P*> { 166 return a == b;
152 using PtrHash<P*>::hash; 167 }
153 static unsigned hash(const RawPtr<P>& key) { return hash(key.get()); } 168 };
154 using PtrHash<P*>::equal; 169 template <typename P>
155 static bool equal(const RawPtr<P>& a, const RawPtr<P>& b) { return a == b; } 170 struct PtrHash<RawPtr<P>> : PtrHash<P*> {
156 static bool equal(P* a, const RawPtr<P>& b) { return a == b; } 171 using PtrHash<P*>::hash;
157 static bool equal(const RawPtr<P>& a, P* b) { return a == b; } 172 static unsigned hash(const RawPtr<P>& key) { return hash(key.get()); }
158 }; 173 using PtrHash<P*>::equal;
159 template <typename P> struct PtrHash<OwnPtr<P>> : PtrHash<P*> { 174 static bool equal(const RawPtr<P>& a, const RawPtr<P>& b) { return a == b; }
160 using PtrHash<P*>::hash; 175 static bool equal(P* a, const RawPtr<P>& b) { return a == b; }
161 static unsigned hash(const OwnPtr<P>& key) { return hash(key.get()); } 176 static bool equal(const RawPtr<P>& a, P* b) { return a == b; }
162 static unsigned hash(const PassOwnPtr<P>& key) { return hash(key.get()); } 177 };
163 178 template <typename P>
164 static bool equal(const OwnPtr<P>& a, const OwnPtr<P>& b) 179 struct PtrHash<OwnPtr<P>> : PtrHash<P*> {
165 { 180 using PtrHash<P*>::hash;
166 return a.get() == b.get(); 181 static unsigned hash(const OwnPtr<P>& key) { return hash(key.get()); }
167 } 182 static unsigned hash(const PassOwnPtr<P>& key) { return hash(key.get()); }
168 static bool equal(const OwnPtr<P>& a, P* b) { return a == b; } 183
169 static bool equal(const OwnPtr<P>& a, const PassOwnPtr<P>& b) 184 static bool equal(const OwnPtr<P>& a, const OwnPtr<P>& b) {
170 { 185 return a.get() == b.get();
171 return a.get() == b.get(); 186 }
172 } 187 static bool equal(const OwnPtr<P>& a, P* b) { return a == b; }
188 static bool equal(const OwnPtr<P>& a, const PassOwnPtr<P>& b) {
189 return a.get() == b.get();
190 }
173 }; 191 };
174 192
175 // default hash function for each type 193 // default hash function for each type
176 194
177 template <typename T> struct DefaultHash; 195 template <typename T>
178 196 struct DefaultHash;
179 template <typename T, typename U> struct PairHash { 197
180 static unsigned hash(const std::pair<T, U>& p) 198 template <typename T, typename U>
181 { 199 struct PairHash {
182 return pairIntHash(DefaultHash<T>::Hash::hash(p.first), DefaultHash<U>:: Hash::hash(p.second)); 200 static unsigned hash(const std::pair<T, U>& p) {
183 } 201 return pairIntHash(DefaultHash<T>::Hash::hash(p.first),
184 static bool equal(const std::pair<T, U>& a, const std::pair<T, U>& b) 202 DefaultHash<U>::Hash::hash(p.second));
185 { 203 }
186 return DefaultHash<T>::Hash::equal(a.first, b.first) && DefaultHash<U>:: Hash::equal(a.second, b.second); 204 static bool equal(const std::pair<T, U>& a, const std::pair<T, U>& b) {
187 } 205 return DefaultHash<T>::Hash::equal(a.first, b.first) &&
188 static const bool safeToCompareToEmptyOrDeleted = DefaultHash<T>::Hash::safe ToCompareToEmptyOrDeleted 206 DefaultHash<U>::Hash::equal(a.second, b.second);
189 && DefaultHash<U>::Hash::safeToCompareToEmptyOrDeleted; 207 }
190 }; 208 static const bool safeToCompareToEmptyOrDeleted =
191 209 DefaultHash<T>::Hash::safeToCompareToEmptyOrDeleted &&
192 template <typename T, typename U> struct IntPairHash { 210 DefaultHash<U>::Hash::safeToCompareToEmptyOrDeleted;
193 static unsigned hash(const std::pair<T, U>& p) { return pairIntHash(p.first, p.second); } 211 };
194 static bool equal(const std::pair<T, U>& a, const std::pair<T, U>& b) { retu rn PairHash<T, T>::equal(a, b); } 212
195 static const bool safeToCompareToEmptyOrDeleted = PairHash<T, U>::safeToComp areToEmptyOrDeleted; 213 template <typename T, typename U>
214 struct IntPairHash {
215 static unsigned hash(const std::pair<T, U>& p) {
216 return pairIntHash(p.first, p.second);
217 }
218 static bool equal(const std::pair<T, U>& a, const std::pair<T, U>& b) {
219 return PairHash<T, T>::equal(a, b);
220 }
221 static const bool safeToCompareToEmptyOrDeleted =
222 PairHash<T, U>::safeToCompareToEmptyOrDeleted;
196 }; 223 };
197 224
198 // make IntHash the default hash function for many integer types 225 // make IntHash the default hash function for many integer types
199 226
200 template <> struct DefaultHash<short> { typedef IntHash<unsigned> Hash; }; 227 template <>
201 template <> struct DefaultHash<unsigned short> { typedef IntHash<unsigned> Hash; }; 228 struct DefaultHash<short> {
202 template <> struct DefaultHash<int> { typedef IntHash<unsigned> Hash; }; 229 typedef IntHash<unsigned> Hash;
203 template <> struct DefaultHash<unsigned> { typedef IntHash<unsigned> Hash; }; 230 };
204 template <> struct DefaultHash<long> { typedef IntHash<unsigned long> Hash; }; 231 template <>
205 template <> struct DefaultHash<unsigned long> { typedef IntHash<unsigned long> H ash; }; 232 struct DefaultHash<unsigned short> {
206 template <> struct DefaultHash<long long> { typedef IntHash<unsigned long long> Hash; }; 233 typedef IntHash<unsigned> Hash;
207 template <> struct DefaultHash<unsigned long long> { typedef IntHash<unsigned lo ng long> Hash; }; 234 };
235 template <>
236 struct DefaultHash<int> {
237 typedef IntHash<unsigned> Hash;
238 };
239 template <>
240 struct DefaultHash<unsigned> {
241 typedef IntHash<unsigned> Hash;
242 };
243 template <>
244 struct DefaultHash<long> {
245 typedef IntHash<unsigned long> Hash;
246 };
247 template <>
248 struct DefaultHash<unsigned long> {
249 typedef IntHash<unsigned long> Hash;
250 };
251 template <>
252 struct DefaultHash<long long> {
253 typedef IntHash<unsigned long long> Hash;
254 };
255 template <>
256 struct DefaultHash<unsigned long long> {
257 typedef IntHash<unsigned long long> Hash;
258 };
208 259
209 #if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED) 260 #if !COMPILER(MSVC) || defined(_NATIVE_WCHAR_T_DEFINED)
210 template <> struct DefaultHash<wchar_t> { typedef IntHash<wchar_t> Hash; }; 261 template <>
262 struct DefaultHash<wchar_t> {
263 typedef IntHash<wchar_t> Hash;
264 };
211 #endif 265 #endif
212 266
213 template <> struct DefaultHash<float> { typedef FloatHash<float> Hash; }; 267 template <>
214 template <> struct DefaultHash<double> { typedef FloatHash<double> Hash; }; 268 struct DefaultHash<float> {
269 typedef FloatHash<float> Hash;
270 };
271 template <>
272 struct DefaultHash<double> {
273 typedef FloatHash<double> Hash;
274 };
215 275
216 // make PtrHash the default hash function for pointer types that don't specializ e 276 // make PtrHash the default hash function for pointer types that don't specializ e
217 277
218 template <typename P> struct DefaultHash<P*> { typedef PtrHash<P*> Hash; }; 278 template <typename P>
219 template <typename P> struct DefaultHash<RefPtr<P>> { typedef PtrHash<RefPtr<P>> Hash; }; 279 struct DefaultHash<P*> {
220 template <typename P> struct DefaultHash<RawPtr<P>> { typedef PtrHash<RawPtr<P>> Hash; }; 280 typedef PtrHash<P*> Hash;
221 template <typename P> struct DefaultHash<OwnPtr<P>> { typedef PtrHash<OwnPtr<P>> Hash; }; 281 };
282 template <typename P>
283 struct DefaultHash<RefPtr<P>> {
284 typedef PtrHash<RefPtr<P>> Hash;
285 };
286 template <typename P>
287 struct DefaultHash<RawPtr<P>> {
288 typedef PtrHash<RawPtr<P>> Hash;
289 };
290 template <typename P>
291 struct DefaultHash<OwnPtr<P>> {
292 typedef PtrHash<OwnPtr<P>> Hash;
293 };
222 294
223 // make IntPairHash the default hash function for pairs of (at most) 32-bit inte gers. 295 // make IntPairHash the default hash function for pairs of (at most) 32-bit inte gers.
224 296
225 template <> struct DefaultHash<std::pair<short, short>> { typedef IntPairHash<sh ort, short> Hash; }; 297 template <>
226 template <> struct DefaultHash<std::pair<short, unsigned short>> { typedef IntPa irHash<short, unsigned short> Hash; }; 298 struct DefaultHash<std::pair<short, short>> {
227 template <> struct DefaultHash<std::pair<short, int>> { typedef IntPairHash<shor t, int> Hash; }; 299 typedef IntPairHash<short, short> Hash;
228 template <> struct DefaultHash<std::pair<short, unsigned>> { typedef IntPairHash <short, unsigned> Hash; }; 300 };
229 template <> struct DefaultHash<std::pair<unsigned short, short>> { typedef IntPa irHash<unsigned short, short> Hash; }; 301 template <>
230 template <> struct DefaultHash<std::pair<unsigned short, unsigned short>> { type def IntPairHash<unsigned short, unsigned short> Hash; }; 302 struct DefaultHash<std::pair<short, unsigned short>> {
231 template <> struct DefaultHash<std::pair<unsigned short, int>> { typedef IntPair Hash<unsigned short, int> Hash; }; 303 typedef IntPairHash<short, unsigned short> Hash;
232 template <> struct DefaultHash<std::pair<unsigned short, unsigned>> { typedef In tPairHash<unsigned short, unsigned> Hash; }; 304 };
233 template <> struct DefaultHash<std::pair<int, short>> { typedef IntPairHash<int, short> Hash; }; 305 template <>
234 template <> struct DefaultHash<std::pair<int, unsigned short>> { typedef IntPair Hash<int, unsigned short> Hash; }; 306 struct DefaultHash<std::pair<short, int>> {
235 template <> struct DefaultHash<std::pair<int, int>> { typedef IntPairHash<int, i nt> Hash; }; 307 typedef IntPairHash<short, int> Hash;
236 template <> struct DefaultHash<std::pair<int, unsigned>> { typedef IntPairHash<u nsigned, unsigned> Hash; }; 308 };
237 template <> struct DefaultHash<std::pair<unsigned, short>> { typedef IntPairHash <unsigned, short> Hash; }; 309 template <>
238 template <> struct DefaultHash<std::pair<unsigned, unsigned short>> { typedef In tPairHash<unsigned, unsigned short> Hash; }; 310 struct DefaultHash<std::pair<short, unsigned>> {
239 template <> struct DefaultHash<std::pair<unsigned, int>> { typedef IntPairHash<u nsigned, int> Hash; }; 311 typedef IntPairHash<short, unsigned> Hash;
240 template <> struct DefaultHash<std::pair<unsigned, unsigned>> { typedef IntPairH ash<unsigned, unsigned> Hash; }; 312 };
313 template <>
314 struct DefaultHash<std::pair<unsigned short, short>> {
315 typedef IntPairHash<unsigned short, short> Hash;
316 };
317 template <>
318 struct DefaultHash<std::pair<unsigned short, unsigned short>> {
319 typedef IntPairHash<unsigned short, unsigned short> Hash;
320 };
321 template <>
322 struct DefaultHash<std::pair<unsigned short, int>> {
323 typedef IntPairHash<unsigned short, int> Hash;
324 };
325 template <>
326 struct DefaultHash<std::pair<unsigned short, unsigned>> {
327 typedef IntPairHash<unsigned short, unsigned> Hash;
328 };
329 template <>
330 struct DefaultHash<std::pair<int, short>> {
331 typedef IntPairHash<int, short> Hash;
332 };
333 template <>
334 struct DefaultHash<std::pair<int, unsigned short>> {
335 typedef IntPairHash<int, unsigned short> Hash;
336 };
337 template <>
338 struct DefaultHash<std::pair<int, int>> {
339 typedef IntPairHash<int, int> Hash;
340 };
341 template <>
342 struct DefaultHash<std::pair<int, unsigned>> {
343 typedef IntPairHash<unsigned, unsigned> Hash;
344 };
345 template <>
346 struct DefaultHash<std::pair<unsigned, short>> {
347 typedef IntPairHash<unsigned, short> Hash;
348 };
349 template <>
350 struct DefaultHash<std::pair<unsigned, unsigned short>> {
351 typedef IntPairHash<unsigned, unsigned short> Hash;
352 };
353 template <>
354 struct DefaultHash<std::pair<unsigned, int>> {
355 typedef IntPairHash<unsigned, int> Hash;
356 };
357 template <>
358 struct DefaultHash<std::pair<unsigned, unsigned>> {
359 typedef IntPairHash<unsigned, unsigned> Hash;
360 };
241 361
242 // make PairHash the default hash function for pairs of arbitrary values. 362 // make PairHash the default hash function for pairs of arbitrary values.
243 363
244 template <typename T, typename U> struct DefaultHash<std::pair<T, U>> { typedef PairHash<T, U> Hash; }; 364 template <typename T, typename U>
245 365 struct DefaultHash<std::pair<T, U>> {
246 } // namespace WTF 366 typedef PairHash<T, U> Hash;
367 };
368
369 } // namespace WTF
247 370
248 using WTF::DefaultHash; 371 using WTF::DefaultHash;
249 using WTF::IntHash; 372 using WTF::IntHash;
250 using WTF::PtrHash; 373 using WTF::PtrHash;
251 374
252 #endif // WTF_HashFunctions_h 375 #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