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, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
19 * | 19 * |
20 */ | 20 */ |
21 | 21 |
22 #ifndef WTF_LinkedHashSet_h | 22 #ifndef WTF_LinkedHashSet_h |
23 #define WTF_LinkedHashSet_h | 23 #define WTF_LinkedHashSet_h |
24 | 24 |
25 #include "wtf/DefaultAllocator.h" | 25 #include "wtf/DefaultAllocator.h" |
26 #include "wtf/HashSet.h" | 26 #include "wtf/HashSet.h" |
27 #include "wtf/OwnPtr.h" | 27 #include "wtf/OwnPtr.h" |
28 #include "wtf/PassOwnPtr.h" | 28 #include "wtf/PassOwnPtr.h" |
29 | 29 |
30 // TODO(sof): See NO_SANITIZE_ADDRESS comment in platform/heap/AddressSanitizer.
h | |
31 // on the Windows toolchain special case; that comment also covers why we | |
32 // temporarily need this NO_LAZY_SWEEP_SANITIZE_ADDRESS_WTF annotation. | |
33 // (macro repeatedly defined here so as to avoid introducing an improper | |
34 // wtf/ => platform/ dependency.) | |
35 #if defined(ADDRESS_SANITIZER) && ENABLE(OILPAN) && (!OS(WIN) || COMPILER(CLANG)
) | |
36 #define NO_LAZY_SWEEP_SANITIZE_ADDRESS_WTF __attribute__((no_sanitize_address)) | |
37 #else | |
38 #define NO_LAZY_SWEEP_SANITIZE_ADDRESS_WTF | |
39 #endif | |
40 | |
41 namespace WTF { | 30 namespace WTF { |
42 | 31 |
43 // LinkedHashSet: Just like HashSet, this class provides a Set | 32 // LinkedHashSet: Just like HashSet, this class provides a Set |
44 // interface - a collection of unique objects with O(1) insertion, | 33 // interface - a collection of unique objects with O(1) insertion, |
45 // removal and test for containership. However, it also has an | 34 // removal and test for containership. However, it also has an |
46 // order - iterating it will always give back values in the order | 35 // order - iterating it will always give back values in the order |
47 // in which they are added. | 36 // in which they are added. |
48 | 37 |
49 // Unlike ListHashSet, but like most WTF collections, iteration is NOT safe | 38 // Unlike ListHashSet, but like most WTF collections, iteration is NOT safe |
50 // against mutation of the LinkedHashSet. | 39 // against mutation of the LinkedHashSet. |
51 | 40 |
52 template<typename Value, typename HashFunctions, typename HashTraits, typename A
llocator> class LinkedHashSet; | 41 template<typename Value, typename HashFunctions, typename HashTraits, typename A
llocator> class LinkedHashSet; |
53 | 42 |
54 template<typename LinkedHashSet> class LinkedHashSetIterator; | 43 template<typename LinkedHashSet> class LinkedHashSetIterator; |
55 template<typename LinkedHashSet> class LinkedHashSetConstIterator; | 44 template<typename LinkedHashSet> class LinkedHashSetConstIterator; |
56 template<typename LinkedHashSet> class LinkedHashSetReverseIterator; | 45 template<typename LinkedHashSet> class LinkedHashSetReverseIterator; |
57 template<typename LinkedHashSet> class LinkedHashSetConstReverseIterator; | 46 template<typename LinkedHashSet> class LinkedHashSetConstReverseIterator; |
58 | 47 |
59 template<typename Value, typename HashFunctions, typename Allocator> struct Link
edHashSetTranslator; | 48 template<typename Value, typename HashFunctions, typename Allocator> struct Link
edHashSetTranslator; |
60 template<typename Value, typename Allocator> struct LinkedHashSetExtractor; | 49 template<typename Value, typename Allocator> struct LinkedHashSetExtractor; |
61 template<typename Value, typename ValueTraits, typename Allocator> struct Linked
HashSetTraits; | 50 template<typename Value, typename ValueTraits, typename Allocator> struct Linked
HashSetTraits; |
62 | 51 |
63 class LinkedHashSetNodeBase { | 52 class LinkedHashSetNodeBase { |
64 public: | 53 public: |
65 LinkedHashSetNodeBase() : m_prev(this), m_next(this) { } | 54 LinkedHashSetNodeBase() : m_prev(this), m_next(this) { } |
66 | 55 |
67 NO_LAZY_SWEEP_SANITIZE_ADDRESS_WTF | |
68 void unlink() | 56 void unlink() |
69 { | 57 { |
70 if (!m_next) | 58 if (!m_next) |
71 return; | 59 return; |
72 ASSERT(m_prev); | 60 ASSERT(m_prev); |
73 ASSERT(m_next->m_prev == this); | 61 ASSERT(m_next->m_prev == this); |
74 ASSERT(m_prev->m_next == this); | 62 ASSERT(m_prev->m_next == this); |
75 m_next->m_prev = m_prev; | 63 m_next->m_prev = m_prev; |
76 m_prev->m_next = m_next; | 64 m_prev->m_next = m_next; |
77 } | 65 } |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 struct NeedsTracing<LinkedHashSet<T, U, V>> { | 736 struct NeedsTracing<LinkedHashSet<T, U, V>> { |
749 static const bool value = false; | 737 static const bool value = false; |
750 }; | 738 }; |
751 #endif | 739 #endif |
752 | 740 |
753 } | 741 } |
754 | 742 |
755 using WTF::LinkedHashSet; | 743 using WTF::LinkedHashSet; |
756 | 744 |
757 #endif /* WTF_LinkedHashSet_h */ | 745 #endif /* WTF_LinkedHashSet_h */ |
OLD | NEW |