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 |
30 namespace WTF { | 41 namespace WTF { |
31 | 42 |
32 // LinkedHashSet: Just like HashSet, this class provides a Set | 43 // LinkedHashSet: Just like HashSet, this class provides a Set |
33 // interface - a collection of unique objects with O(1) insertion, | 44 // interface - a collection of unique objects with O(1) insertion, |
34 // removal and test for containership. However, it also has an | 45 // removal and test for containership. However, it also has an |
35 // order - iterating it will always give back values in the order | 46 // order - iterating it will always give back values in the order |
36 // in which they are added. | 47 // in which they are added. |
37 | 48 |
38 // Unlike ListHashSet, but like most WTF collections, iteration is NOT safe | 49 // Unlike ListHashSet, but like most WTF collections, iteration is NOT safe |
39 // against mutation of the LinkedHashSet. | 50 // against mutation of the LinkedHashSet. |
40 | 51 |
41 template<typename Value, typename HashFunctions, typename HashTraits, typename A
llocator> class LinkedHashSet; | 52 template<typename Value, typename HashFunctions, typename HashTraits, typename A
llocator> class LinkedHashSet; |
42 | 53 |
43 template<typename LinkedHashSet> class LinkedHashSetIterator; | 54 template<typename LinkedHashSet> class LinkedHashSetIterator; |
44 template<typename LinkedHashSet> class LinkedHashSetConstIterator; | 55 template<typename LinkedHashSet> class LinkedHashSetConstIterator; |
45 template<typename LinkedHashSet> class LinkedHashSetReverseIterator; | 56 template<typename LinkedHashSet> class LinkedHashSetReverseIterator; |
46 template<typename LinkedHashSet> class LinkedHashSetConstReverseIterator; | 57 template<typename LinkedHashSet> class LinkedHashSetConstReverseIterator; |
47 | 58 |
48 template<typename Value, typename HashFunctions, typename Allocator> struct Link
edHashSetTranslator; | 59 template<typename Value, typename HashFunctions, typename Allocator> struct Link
edHashSetTranslator; |
49 template<typename Value, typename Allocator> struct LinkedHashSetExtractor; | 60 template<typename Value, typename Allocator> struct LinkedHashSetExtractor; |
50 template<typename Value, typename ValueTraits, typename Allocator> struct Linked
HashSetTraits; | 61 template<typename Value, typename ValueTraits, typename Allocator> struct Linked
HashSetTraits; |
51 | 62 |
52 class LinkedHashSetNodeBase { | 63 class LinkedHashSetNodeBase { |
53 public: | 64 public: |
54 LinkedHashSetNodeBase() : m_prev(this), m_next(this) { } | 65 LinkedHashSetNodeBase() : m_prev(this), m_next(this) { } |
55 | 66 |
| 67 NO_LAZY_SWEEP_SANITIZE_ADDRESS_WTF |
56 void unlink() | 68 void unlink() |
57 { | 69 { |
58 if (!m_next) | 70 if (!m_next) |
59 return; | 71 return; |
60 ASSERT(m_prev); | 72 ASSERT(m_prev); |
61 ASSERT(m_next->m_prev == this); | 73 ASSERT(m_next->m_prev == this); |
62 ASSERT(m_prev->m_next == this); | 74 ASSERT(m_prev->m_next == this); |
63 m_next->m_prev = m_prev; | 75 m_next->m_prev = m_prev; |
64 m_prev->m_next = m_next; | 76 m_prev->m_next = m_next; |
65 } | 77 } |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 struct NeedsTracing<LinkedHashSet<T, U, V>> { | 748 struct NeedsTracing<LinkedHashSet<T, U, V>> { |
737 static const bool value = false; | 749 static const bool value = false; |
738 }; | 750 }; |
739 #endif | 751 #endif |
740 | 752 |
741 } | 753 } |
742 | 754 |
743 using WTF::LinkedHashSet; | 755 using WTF::LinkedHashSet; |
744 | 756 |
745 #endif /* WTF_LinkedHashSet_h */ | 757 #endif /* WTF_LinkedHashSet_h */ |
OLD | NEW |