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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 typedef ListHashSetIterator<ListHashSet> iterator; | 80 typedef ListHashSetIterator<ListHashSet> iterator; |
81 typedef ListHashSetConstIterator<ListHashSet> const_iterator; | 81 typedef ListHashSetConstIterator<ListHashSet> const_iterator; |
82 friend class ListHashSetIterator<ListHashSet>; | 82 friend class ListHashSetIterator<ListHashSet>; |
83 friend class ListHashSetConstIterator<ListHashSet>; | 83 friend class ListHashSetConstIterator<ListHashSet>; |
84 | 84 |
85 typedef ListHashSetReverseIterator<ListHashSet> reverse_iterator; | 85 typedef ListHashSetReverseIterator<ListHashSet> reverse_iterator; |
86 typedef ListHashSetConstReverseIterator<ListHashSet> const_reverse_iterator; | 86 typedef ListHashSetConstReverseIterator<ListHashSet> const_reverse_iterator; |
87 friend class ListHashSetReverseIterator<ListHashSet>; | 87 friend class ListHashSetReverseIterator<ListHashSet>; |
88 friend class ListHashSetConstReverseIterator<ListHashSet>; | 88 friend class ListHashSetConstReverseIterator<ListHashSet>; |
89 | 89 |
90 template <typename ValueType> struct HashTableAddResult final { | 90 struct AddResult final { |
91 STACK_ALLOCATED(); | 91 STACK_ALLOCATED(); |
92 HashTableAddResult(Node* storedValue, bool isNewEntry) : storedValue(sto
redValue), isNewEntry(isNewEntry) { } | 92 friend class ListHashSet<ValueArg, inlineCapacity, HashArg, AllocatorArg
>; |
93 Node* storedValue; | 93 AddResult(Node* node, bool isNewEntry) |
| 94 : storedValue(&node->m_value) |
| 95 , isNewEntry(isNewEntry) |
| 96 , m_node(node) { } |
| 97 ValueType* storedValue; |
94 bool isNewEntry; | 98 bool isNewEntry; |
| 99 private: |
| 100 Node* m_node; |
95 }; | 101 }; |
96 typedef HashTableAddResult<ValueType> AddResult; | |
97 | 102 |
98 ListHashSet(); | 103 ListHashSet(); |
99 ListHashSet(const ListHashSet&); | 104 ListHashSet(const ListHashSet&); |
100 ListHashSet(ListHashSet&&); | 105 ListHashSet(ListHashSet&&); |
101 ListHashSet& operator=(const ListHashSet&); | 106 ListHashSet& operator=(const ListHashSet&); |
102 ListHashSet& operator=(ListHashSet&&); | 107 ListHashSet& operator=(ListHashSet&&); |
103 void finalize(); | 108 void finalize(); |
104 | 109 |
105 void swap(ListHashSet&); | 110 void swap(ListHashSet&); |
106 | 111 |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 // actually changes when it does allocations. | 839 // actually changes when it does allocations. |
835 auto result = m_impl.template add<BaseTranslator>(value, *this->allocator())
; | 840 auto result = m_impl.template add<BaseTranslator>(value, *this->allocator())
; |
836 if (result.isNewEntry) | 841 if (result.isNewEntry) |
837 appendNode(*result.storedValue); | 842 appendNode(*result.storedValue); |
838 return AddResult(*result.storedValue, result.isNewEntry); | 843 return AddResult(*result.storedValue, result.isNewEntry); |
839 } | 844 } |
840 | 845 |
841 template <typename T, size_t inlineCapacity, typename U, typename V> | 846 template <typename T, size_t inlineCapacity, typename U, typename V> |
842 typename ListHashSet<T, inlineCapacity, U, V>::iterator ListHashSet<T, inlineCap
acity, U, V>::addReturnIterator(ValuePassInType value) | 847 typename ListHashSet<T, inlineCapacity, U, V>::iterator ListHashSet<T, inlineCap
acity, U, V>::addReturnIterator(ValuePassInType value) |
843 { | 848 { |
844 return makeIterator(add(value).storedValue); | 849 return makeIterator(add(value).m_node); |
845 } | 850 } |
846 | 851 |
847 template <typename T, size_t inlineCapacity, typename U, typename V> | 852 template <typename T, size_t inlineCapacity, typename U, typename V> |
848 typename ListHashSet<T, inlineCapacity, U, V>::AddResult ListHashSet<T, inlineCa
pacity, U, V>::appendOrMoveToLast(ValuePassInType value) | 853 typename ListHashSet<T, inlineCapacity, U, V>::AddResult ListHashSet<T, inlineCa
pacity, U, V>::appendOrMoveToLast(ValuePassInType value) |
849 { | 854 { |
850 createAllocatorIfNeeded(); | 855 createAllocatorIfNeeded(); |
851 auto result = m_impl.template add<BaseTranslator>(value, *this->allocator())
; | 856 auto result = m_impl.template add<BaseTranslator>(value, *this->allocator())
; |
852 Node* node = *result.storedValue; | 857 Node* node = *result.storedValue; |
853 if (!result.isNewEntry) | 858 if (!result.isNewEntry) |
854 unlink(node); | 859 unlink(node); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 struct NeedsTracing<ListHashSet<T, U, V>> { | 1038 struct NeedsTracing<ListHashSet<T, U, V>> { |
1034 static const bool value = false; | 1039 static const bool value = false; |
1035 }; | 1040 }; |
1036 #endif | 1041 #endif |
1037 | 1042 |
1038 } // namespace WTF | 1043 } // namespace WTF |
1039 | 1044 |
1040 using WTF::ListHashSet; | 1045 using WTF::ListHashSet; |
1041 | 1046 |
1042 #endif // WTF_ListHashSet_h | 1047 #endif // WTF_ListHashSet_h |
OLD | NEW |