| 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 * Copyright (C) 2011, Benjamin Poulain <ikipou@gmail.com> | 3 * Copyright (C) 2011, Benjamin Poulain <ikipou@gmail.com> |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 template<typename Value, typename ValueTraitsArg> | 300 template<typename Value, typename ValueTraitsArg> |
| 301 struct LinkedHashSetTraits : public SimpleClassHashTraits<LinkedHashSetNode<Valu
e> > { | 301 struct LinkedHashSetTraits : public SimpleClassHashTraits<LinkedHashSetNode<Valu
e> > { |
| 302 typedef LinkedHashSetNode<Value> Node; | 302 typedef LinkedHashSetNode<Value> Node; |
| 303 typedef ValueTraitsArg ValueTraits; | 303 typedef ValueTraitsArg ValueTraits; |
| 304 | 304 |
| 305 // The slot is empty when the m_next field is zero so it's safe to zero | 305 // The slot is empty when the m_next field is zero so it's safe to zero |
| 306 // the backing. | 306 // the backing. |
| 307 static const bool emptyValueIsZero = true; | 307 static const bool emptyValueIsZero = true; |
| 308 | 308 |
| 309 static const bool hasIsEmptyValueFunction = true; | 309 static const bool hasIsEmptyValueFunction = true; |
| 310 static bool isEmptyValue(const Node& value) { return !value.m_next; } | 310 static bool isEmptyValue(const Node& node) { return !node.m_next; } |
| 311 | 311 |
| 312 static const int deletedValue = -1; | 312 static const int deletedValue = -1; |
| 313 | 313 |
| 314 static void constructDeletedValue(Node& slot) { slot.m_next = reinterpret_ca
st<Node*>(deletedValue); } | 314 static void constructDeletedValue(Node& slot) { slot.m_next = reinterpret_ca
st<Node*>(deletedValue); } |
| 315 static bool isDeletedValue(const Node& slot) { return slot.m_next == reinter
pret_cast<Node*>(deletedValue); } | 315 static bool isDeletedValue(const Node& slot) { return slot.m_next == reinter
pret_cast<Node*>(deletedValue); } |
| 316 | 316 |
| 317 // We always need to call destructors, that's how we get linked and | 317 // We always need to call destructors, that's how we get linked and |
| 318 // unlinked from the chain. | 318 // unlinked from the chain. |
| 319 static const bool needsDestruction = true; | 319 static const bool needsDestruction = true; |
| 320 | 320 |
| 321 // Whether we need to trace and do weak processing depends on the traits of | 321 // Whether we need to trace and do weak processing depends on the traits of |
| 322 // the type inside the node. | 322 // the type inside the node. |
| 323 template<typename U = void> | 323 template<typename U = void> |
| 324 struct NeedsTracingLazily { | 324 struct NeedsTracingLazily { |
| 325 static const bool value = ValueTraits::template NeedsTracingLazily<>::va
lue; | 325 static const bool value = ValueTraits::template NeedsTracingLazily<>::va
lue; |
| 326 }; | 326 }; |
| 327 static const bool isWeak = ValueTraits::isWeak; | 327 static const bool isWeak = ValueTraits::isWeak; |
| 328 template<typename Visitor> |
| 329 static bool shouldRemoveFromCollection(Visitor* visitor, LinkedHashSetNode<V
alue>& node) |
| 330 { |
| 331 return ValueTraits::shouldRemoveFromCollection(visitor, node.m_value); |
| 332 } |
| 328 }; | 333 }; |
| 329 | 334 |
| 330 template<typename LinkedHashSetType> | 335 template<typename LinkedHashSetType> |
| 331 class LinkedHashSetIterator { | 336 class LinkedHashSetIterator { |
| 332 private: | 337 private: |
| 333 typedef typename LinkedHashSetType::Node Node; | 338 typedef typename LinkedHashSetType::Node Node; |
| 334 typedef typename LinkedHashSetType::Traits Traits; | 339 typedef typename LinkedHashSetType::Traits Traits; |
| 335 | 340 |
| 336 typedef typename LinkedHashSetType::Value& ReferenceType; | 341 typedef typename LinkedHashSetType::Value& ReferenceType; |
| 337 typedef typename LinkedHashSetType::Value* PointerType; | 342 typedef typename LinkedHashSetType::Value* PointerType; |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 iterator end = set.end(); | 713 iterator end = set.end(); |
| 709 for (iterator it = set.begin(); it != end; ++it) | 714 for (iterator it = set.begin(); it != end; ++it) |
| 710 delete *it; | 715 delete *it; |
| 711 } | 716 } |
| 712 | 717 |
| 713 } | 718 } |
| 714 | 719 |
| 715 using WTF::LinkedHashSet; | 720 using WTF::LinkedHashSet; |
| 716 | 721 |
| 717 #endif /* WTF_LinkedHashSet_h */ | 722 #endif /* WTF_LinkedHashSet_h */ |
| OLD | NEW |