| 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_ListHashSet_h | 22 #ifndef WTF_ListHashSet_h |
| 23 #define WTF_ListHashSet_h | 23 #define WTF_ListHashSet_h |
| 24 | 24 |
| 25 #include "wtf/HashSet.h" | 25 #include "wtf/HashSet.h" |
| 26 #include "wtf/OwnPtr.h" | |
| 27 #include "wtf/PassOwnPtr.h" | |
| 28 #include "wtf/allocator/PartitionAllocator.h" | 26 #include "wtf/allocator/PartitionAllocator.h" |
| 27 #include <memory> |
| 29 | 28 |
| 30 namespace WTF { | 29 namespace WTF { |
| 31 | 30 |
| 32 // ListHashSet: Just like HashSet, this class provides a Set interface - a | 31 // ListHashSet: Just like HashSet, this class provides a Set interface - a |
| 33 // collection of unique objects with O(1) insertion, removal and test for | 32 // collection of unique objects with O(1) insertion, removal and test for |
| 34 // containership. However, it also has an order - iterating it will always give | 33 // containership. However, it also has an order - iterating it will always give |
| 35 // back values in the order in which they are added. | 34 // back values in the order in which they are added. |
| 36 | 35 |
| 37 // Unlike iteration of most WTF Hash data structures, iteration is guaranteed | 36 // Unlike iteration of most WTF Hash data structures, iteration is guaranteed |
| 38 // safe against mutation of the ListHashSet, except for removal of the item | 37 // safe against mutation of the ListHashSet, except for removal of the item |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 m_allocator->deallocate(node); | 260 m_allocator->deallocate(node); |
| 262 } | 261 } |
| 263 | 262 |
| 264 ListHashSetAllocator* get() const | 263 ListHashSetAllocator* get() const |
| 265 { | 264 { |
| 266 ASSERT(m_allocator); | 265 ASSERT(m_allocator); |
| 267 return m_allocator; | 266 return m_allocator; |
| 268 } | 267 } |
| 269 | 268 |
| 270 private: | 269 private: |
| 271 // Not using OwnPtr as this pointer should be deleted at | 270 // Not using std::unique_ptr as this pointer should be deleted at |
| 272 // releaseAllocator() method rather than at destructor. | 271 // releaseAllocator() method rather than at destructor. |
| 273 ListHashSetAllocator* m_allocator; | 272 ListHashSetAllocator* m_allocator; |
| 274 }; | 273 }; |
| 275 | 274 |
| 276 ListHashSetAllocator() | 275 ListHashSetAllocator() |
| 277 : m_freeList(pool()) | 276 : m_freeList(pool()) |
| 278 , m_isDoneWithInitialFreeList(false) | 277 , m_isDoneWithInitialFreeList(false) |
| 279 { | 278 { |
| 280 memset(m_pool.buffer, 0, sizeof(m_pool.buffer)); | 279 memset(m_pool.buffer, 0, sizeof(m_pool.buffer)); |
| 281 } | 280 } |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 // through the HashTable. That includes m_head and m_tail so we do not have | 1030 // through the HashTable. That includes m_head and m_tail so we do not have |
| 1032 // to explicitly trace them here. | 1031 // to explicitly trace them here. |
| 1033 m_impl.trace(visitor); | 1032 m_impl.trace(visitor); |
| 1034 } | 1033 } |
| 1035 | 1034 |
| 1036 } // namespace WTF | 1035 } // namespace WTF |
| 1037 | 1036 |
| 1038 using WTF::ListHashSet; | 1037 using WTF::ListHashSet; |
| 1039 | 1038 |
| 1040 #endif // WTF_ListHashSet_h | 1039 #endif // WTF_ListHashSet_h |
| OLD | NEW |