Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(694)

Side by Side Diff: Source/wtf/LinkedHashSet.h

Issue 319593004: Oilpan:Allow custom handling of classes that contain weak pointers that are embedded in collections. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove 'typename' that Win compiler does not like Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/wtf/HashTraits.h ('k') | Source/wtf/ListHashSet.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 WeakHandlingFlag weakHandlingFlag = ValueTraits::weakHandlingFl ag;
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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 return; 668 return;
664 m_impl.remove(it.node()); 669 m_impl.remove(it.node());
665 } 670 }
666 671
667 template<typename T, typename U, typename V, typename W> 672 template<typename T, typename U, typename V, typename W>
668 inline void LinkedHashSet<T, U, V, W>::remove(ValuePeekInType value) 673 inline void LinkedHashSet<T, U, V, W>::remove(ValuePeekInType value)
669 { 674 {
670 remove(find(value)); 675 remove(find(value));
671 } 676 }
672 677
673 template<typename T>
674 struct IsWeak<LinkedHashSetNode<T> > {
675 static const bool value = IsWeak<T>::value;
676 };
677
678 inline void swap(LinkedHashSetNodeBase& a, LinkedHashSetNodeBase& b) 678 inline void swap(LinkedHashSetNodeBase& a, LinkedHashSetNodeBase& b)
679 { 679 {
680 swap(a.m_prev, b.m_prev); 680 swap(a.m_prev, b.m_prev);
681 swap(a.m_next, b.m_next); 681 swap(a.m_next, b.m_next);
682 if (b.m_next) { 682 if (b.m_next) {
683 b.m_next->m_prev = &b; 683 b.m_next->m_prev = &b;
684 b.m_prev->m_next = &b; 684 b.m_prev->m_next = &b;
685 } 685 }
686 if (a.m_next) { 686 if (a.m_next) {
687 a.m_next->m_prev = &a; 687 a.m_next->m_prev = &a;
(...skipping 20 matching lines...) Expand all
708 iterator end = set.end(); 708 iterator end = set.end();
709 for (iterator it = set.begin(); it != end; ++it) 709 for (iterator it = set.begin(); it != end; ++it)
710 delete *it; 710 delete *it;
711 } 711 }
712 712
713 } 713 }
714 714
715 using WTF::LinkedHashSet; 715 using WTF::LinkedHashSet;
716 716
717 #endif /* WTF_LinkedHashSet_h */ 717 #endif /* WTF_LinkedHashSet_h */
OLDNEW
« no previous file with comments | « Source/wtf/HashTraits.h ('k') | Source/wtf/ListHashSet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698