| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv
ed. |
| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 static const unsigned minimumTableSize = 1; | 57 static const unsigned minimumTableSize = 1; |
| 58 #else | 58 #else |
| 59 static const unsigned minimumTableSize = 8; | 59 static const unsigned minimumTableSize = 8; |
| 60 #endif | 60 #endif |
| 61 | 61 |
| 62 template<typename U = void> | 62 template<typename U = void> |
| 63 struct NeedsTracingLazily { | 63 struct NeedsTracingLazily { |
| 64 static const bool value = NeedsTracing<T>::value; | 64 static const bool value = NeedsTracing<T>::value; |
| 65 }; | 65 }; |
| 66 static const bool isWeak = IsWeak<T>::value; | 66 static const bool isWeak = IsWeak<T>::value; |
| 67 template<typename Visitor> |
| 68 static bool shouldRemoveFromCollection(Visitor*, T&) { return false; } |
| 67 }; | 69 }; |
| 68 | 70 |
| 69 // Default integer traits disallow both 0 and -1 as keys (max value instead
of -1 for unsigned). | 71 // Default integer traits disallow both 0 and -1 as keys (max value instead
of -1 for unsigned). |
| 70 template<typename T> struct GenericHashTraitsBase<true, T> : GenericHashTrai
tsBase<false, T> { | 72 template<typename T> struct GenericHashTraitsBase<true, T> : GenericHashTrai
tsBase<false, T> { |
| 71 static const bool emptyValueIsZero = true; | 73 static const bool emptyValueIsZero = true; |
| 72 static const bool needsDestruction = false; | 74 static const bool needsDestruction = false; |
| 73 static void constructDeletedValue(T& slot) { slot = static_cast<T>(-1);
} | 75 static void constructDeletedValue(T& slot) { slot = static_cast<T>(-1);
} |
| 74 static bool isDeletedValue(T value) { return value == static_cast<T>(-1)
; } | 76 static bool isDeletedValue(T value) { return value == static_cast<T>(-1)
; } |
| 75 }; | 77 }; |
| 76 | 78 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 template<typename U = void> | 271 template<typename U = void> |
| 270 struct NeedsTracingLazily { | 272 struct NeedsTracingLazily { |
| 271 static const bool value = ShouldBeTraced<KeyTraits>::value || Should
BeTraced<ValueTraits>::value; | 273 static const bool value = ShouldBeTraced<KeyTraits>::value || Should
BeTraced<ValueTraits>::value; |
| 272 }; | 274 }; |
| 273 static const bool isWeak = KeyTraits::isWeak || ValueTraits::isWeak; | 275 static const bool isWeak = KeyTraits::isWeak || ValueTraits::isWeak; |
| 274 | 276 |
| 275 static const unsigned minimumTableSize = KeyTraits::minimumTableSize; | 277 static const unsigned minimumTableSize = KeyTraits::minimumTableSize; |
| 276 | 278 |
| 277 static void constructDeletedValue(TraitType& slot) { KeyTraits::construc
tDeletedValue(slot.key); } | 279 static void constructDeletedValue(TraitType& slot) { KeyTraits::construc
tDeletedValue(slot.key); } |
| 278 static bool isDeletedValue(const TraitType& value) { return KeyTraits::i
sDeletedValue(value.key); } | 280 static bool isDeletedValue(const TraitType& value) { return KeyTraits::i
sDeletedValue(value.key); } |
| 281 template<typename Visitor> |
| 282 static bool shouldRemoveFromCollection(Visitor* visitor, TraitType& pair
) |
| 283 { |
| 284 return KeyTraits::shouldRemoveFromCollection(visitor, pair.key) |
| 285 || ValueTraits::shouldRemoveFromCollection(visitor, pair.value); |
| 286 } |
| 279 }; | 287 }; |
| 280 | 288 |
| 281 template<typename Key, typename Value> | 289 template<typename Key, typename Value> |
| 282 struct HashTraits<KeyValuePair<Key, Value> > : public KeyValuePairHashTraits
<HashTraits<Key>, HashTraits<Value> > { }; | 290 struct HashTraits<KeyValuePair<Key, Value> > : public KeyValuePairHashTraits
<HashTraits<Key>, HashTraits<Value> > { }; |
| 283 | 291 |
| 284 template<typename T> | 292 template<typename T> |
| 285 struct NullableHashTraits : public HashTraits<T> { | 293 struct NullableHashTraits : public HashTraits<T> { |
| 286 static const bool emptyValueIsZero = false; | 294 static const bool emptyValueIsZero = false; |
| 287 static T emptyValue() { return reinterpret_cast<T>(1); } | 295 static T emptyValue() { return reinterpret_cast<T>(1); } |
| 288 }; | 296 }; |
| 289 | 297 |
| 290 } // namespace WTF | 298 } // namespace WTF |
| 291 | 299 |
| 292 using WTF::HashTraits; | 300 using WTF::HashTraits; |
| 293 using WTF::PairHashTraits; | 301 using WTF::PairHashTraits; |
| 294 using WTF::NullableHashTraits; | 302 using WTF::NullableHashTraits; |
| 295 using WTF::SimpleClassHashTraits; | 303 using WTF::SimpleClassHashTraits; |
| 296 | 304 |
| 297 #endif // WTF_HashTraits_h | 305 #endif // WTF_HashTraits_h |
| OLD | NEW |