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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 struct PairHash | 277 struct PairHash |
278 : PairHashImpl<T, | 278 : PairHashImpl<T, |
279 U, | 279 U, |
280 std::is_integral<T>::value && std::is_integral<U>::value> {}; | 280 std::is_integral<T>::value && std::is_integral<U>::value> {}; |
281 | 281 |
282 template <typename T, typename U> | 282 template <typename T, typename U> |
283 struct DefaultHash<std::pair<T, U>> { | 283 struct DefaultHash<std::pair<T, U>> { |
284 using Hash = PairHash<T, U>; | 284 using Hash = PairHash<T, U>; |
285 }; | 285 }; |
286 | 286 |
| 287 template <typename T, typename U, typename V> |
| 288 struct TupleHash { |
| 289 static unsigned GetHash(const std::tuple<T, U, V>& p) { |
| 290 return HashInts(HashInts(DefaultHash<T>::Hash::GetHash(std::get<0>(p)), |
| 291 DefaultHash<U>::Hash::GetHash(std::get<1>(p))), |
| 292 DefaultHash<V>::Hash::GetHash(std::get<2>(p))); |
| 293 } |
| 294 static bool Equal(const std::tuple<T, U, V>& a, |
| 295 const std::tuple<T, U, V>& b) { |
| 296 return DefaultHash<T>::Hash::Equal(std::get<0>(a), std::get<0>(b)) && |
| 297 DefaultHash<U>::Hash::Equal(std::get<1>(a), std::get<1>(b)) && |
| 298 DefaultHash<V>::Hash::Equal(std::get<2>(a), std::get<2>(b)); |
| 299 } |
| 300 static const bool safe_to_compare_to_empty_or_deleted = |
| 301 DefaultHash<T>::Hash::safe_to_compare_to_empty_or_deleted && |
| 302 DefaultHash<U>::Hash::safe_to_compare_to_empty_or_deleted && |
| 303 DefaultHash<V>::Hash::safe_to_compare_to_empty_or_deleted; |
| 304 }; |
| 305 |
| 306 template <typename T, typename U, typename V> |
| 307 struct DefaultHash<std::tuple<T, U, V>> { |
| 308 using Hash = TupleHash<T, U, V>; |
| 309 }; |
| 310 |
287 } // namespace WTF | 311 } // namespace WTF |
288 | 312 |
289 using WTF::DefaultHash; | 313 using WTF::DefaultHash; |
290 using WTF::IntHash; | 314 using WTF::IntHash; |
291 using WTF::PtrHash; | 315 using WTF::PtrHash; |
292 | 316 |
293 #endif // WTF_HashFunctions_h | 317 #endif // WTF_HashFunctions_h |
OLD | NEW |