OLD | NEW |
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 template <typename T> struct IntHash { | 104 template <typename T> struct IntHash { |
105 static unsigned hash(T key) { return hashInt(static_cast<typename IntTypes<s
izeof(T)>::UnsignedType>(key)); } | 105 static unsigned hash(T key) { return hashInt(static_cast<typename IntTypes<s
izeof(T)>::UnsignedType>(key)); } |
106 static bool equal(T a, T b) { return a == b; } | 106 static bool equal(T a, T b) { return a == b; } |
107 static const bool safeToCompareToEmptyOrDeleted = true; | 107 static const bool safeToCompareToEmptyOrDeleted = true; |
108 }; | 108 }; |
109 | 109 |
110 template <typename T> struct FloatHash { | 110 template <typename T> struct FloatHash { |
111 typedef typename IntTypes<sizeof(T)>::UnsignedType Bits; | 111 typedef typename IntTypes<sizeof(T)>::UnsignedType Bits; |
112 static unsigned hash(T key) | 112 static unsigned hash(T key) |
113 { | 113 { |
114 return hashInt(bitwise_cast<Bits>(key)); | 114 return hashInt(bitwiseCast<Bits>(key)); |
115 } | 115 } |
116 static bool equal(T a, T b) | 116 static bool equal(T a, T b) |
117 { | 117 { |
118 return bitwise_cast<Bits>(a) == bitwise_cast<Bits>(b); | 118 return bitwiseCast<Bits>(a) == bitwiseCast<Bits>(b); |
119 } | 119 } |
120 static const bool safeToCompareToEmptyOrDeleted = true; | 120 static const bool safeToCompareToEmptyOrDeleted = true; |
121 }; | 121 }; |
122 | 122 |
123 // pointer identity hash function | 123 // pointer identity hash function |
124 | 124 |
125 template <typename T> | 125 template <typename T> |
126 struct PtrHash { | 126 struct PtrHash { |
127 static unsigned hash(T* key) | 127 static unsigned hash(T* key) |
128 { | 128 { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 using Hash = PairHash<T, U>; | 243 using Hash = PairHash<T, U>; |
244 }; | 244 }; |
245 | 245 |
246 } // namespace WTF | 246 } // namespace WTF |
247 | 247 |
248 using WTF::DefaultHash; | 248 using WTF::DefaultHash; |
249 using WTF::IntHash; | 249 using WTF::IntHash; |
250 using WTF::PtrHash; | 250 using WTF::PtrHash; |
251 | 251 |
252 #endif // WTF_HashFunctions_h | 252 #endif // WTF_HashFunctions_h |
OLD | NEW |