| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 static unsigned hash(const RefPtr<T>& key) { return hash(key.get()); } | 148 static unsigned hash(const RefPtr<T>& key) { return hash(key.get()); } |
| 149 static unsigned hash(const PassRefPtr<T>& key) { return hash(key.get()); } | 149 static unsigned hash(const PassRefPtr<T>& key) { return hash(key.get()); } |
| 150 using PtrHash<T>::equal; | 150 using PtrHash<T>::equal; |
| 151 static bool equal(const RefPtr<T>& a, const RefPtr<T>& b) { return a == b; } | 151 static bool equal(const RefPtr<T>& a, const RefPtr<T>& b) { return a == b; } |
| 152 static bool equal(T* a, const RefPtr<T>& b) { return a == b; } | 152 static bool equal(T* a, const RefPtr<T>& b) { return a == b; } |
| 153 static bool equal(const RefPtr<T>& a, T* b) { return a == b; } | 153 static bool equal(const RefPtr<T>& a, T* b) { return a == b; } |
| 154 static bool equal(const RefPtr<T>& a, const PassRefPtr<T>& b) { return a ==
b; } | 154 static bool equal(const RefPtr<T>& a, const PassRefPtr<T>& b) { return a ==
b; } |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 template <typename T> | 157 template <typename T> |
| 158 struct RawPtrHash : PtrHash<T> { | |
| 159 using PtrHash<T>::hash; | |
| 160 static unsigned hash(const RawPtr<T>& key) { return hash(key.get()); } | |
| 161 using PtrHash<T>::equal; | |
| 162 static bool equal(const RawPtr<T>& a, const RawPtr<T>& b) { return a == b; } | |
| 163 static bool equal(T* a, const RawPtr<T>& b) { return a == b; } | |
| 164 static bool equal(const RawPtr<T>& a, T* b) { return a == b; } | |
| 165 }; | |
| 166 | |
| 167 template <typename T> | |
| 168 struct OwnPtrHash : PtrHash<T> { | 158 struct OwnPtrHash : PtrHash<T> { |
| 169 using PtrHash<T>::hash; | 159 using PtrHash<T>::hash; |
| 170 static unsigned hash(const OwnPtr<T>& key) { return hash(key.get()); } | 160 static unsigned hash(const OwnPtr<T>& key) { return hash(key.get()); } |
| 171 static unsigned hash(const PassOwnPtr<T>& key) { return hash(key.get()); } | 161 static unsigned hash(const PassOwnPtr<T>& key) { return hash(key.get()); } |
| 172 | 162 |
| 173 static bool equal(const OwnPtr<T>& a, const OwnPtr<T>& b) | 163 static bool equal(const OwnPtr<T>& a, const OwnPtr<T>& b) |
| 174 { | 164 { |
| 175 return a.get() == b.get(); | 165 return a.get() == b.get(); |
| 176 } | 166 } |
| 177 static bool equal(const OwnPtr<T>& a, T* b) { return a == b; } | 167 static bool equal(const OwnPtr<T>& a, T* b) { return a == b; } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 // Specializations for pointer types. | 213 // Specializations for pointer types. |
| 224 template <typename T> | 214 template <typename T> |
| 225 struct DefaultHash<T*> { | 215 struct DefaultHash<T*> { |
| 226 using Hash = PtrHash<T>; | 216 using Hash = PtrHash<T>; |
| 227 }; | 217 }; |
| 228 template <typename T> | 218 template <typename T> |
| 229 struct DefaultHash<RefPtr<T>> { | 219 struct DefaultHash<RefPtr<T>> { |
| 230 using Hash = RefPtrHash<T>; | 220 using Hash = RefPtrHash<T>; |
| 231 }; | 221 }; |
| 232 template <typename T> | 222 template <typename T> |
| 233 struct DefaultHash<RawPtr<T>> { | |
| 234 using Hash = RawPtrHash<T>; | |
| 235 }; | |
| 236 template <typename T> | |
| 237 struct DefaultHash<OwnPtr<T>> { | 223 struct DefaultHash<OwnPtr<T>> { |
| 238 using Hash = OwnPtrHash<T>; | 224 using Hash = OwnPtrHash<T>; |
| 239 }; | 225 }; |
| 240 template <typename T> | 226 template <typename T> |
| 241 struct DefaultHash<std::unique_ptr<T>> { | 227 struct DefaultHash<std::unique_ptr<T>> { |
| 242 using Hash = UniquePtrHash<T>; | 228 using Hash = UniquePtrHash<T>; |
| 243 }; | 229 }; |
| 244 | 230 |
| 245 // Specializations for pairs. | 231 // Specializations for pairs. |
| 246 | 232 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 using Hash = PairHash<T, U>; | 265 using Hash = PairHash<T, U>; |
| 280 }; | 266 }; |
| 281 | 267 |
| 282 } // namespace WTF | 268 } // namespace WTF |
| 283 | 269 |
| 284 using WTF::DefaultHash; | 270 using WTF::DefaultHash; |
| 285 using WTF::IntHash; | 271 using WTF::IntHash; |
| 286 using WTF::PtrHash; | 272 using WTF::PtrHash; |
| 287 | 273 |
| 288 #endif // WTF_HashFunctions_h | 274 #endif // WTF_HashFunctions_h |
| OLD | NEW |