| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * Copyright (C) 2011, Benjamin Poulain <ikipou@gmail.com> | 4 * Copyright (C) 2011, Benjamin Poulain <ikipou@gmail.com> |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // An alternate version of find() that finds the object by hashing and | 178 // An alternate version of find() that finds the object by hashing and |
| 179 // comparing with some other type, to avoid the cost of type conversion. | 179 // comparing with some other type, to avoid the cost of type conversion. |
| 180 // The HashTranslator interface is defined in HashSet. | 180 // The HashTranslator interface is defined in HashSet. |
| 181 template <typename HashTranslator, typename T> | 181 template <typename HashTranslator, typename T> |
| 182 iterator find(const T&); | 182 iterator find(const T&); |
| 183 template <typename HashTranslator, typename T> | 183 template <typename HashTranslator, typename T> |
| 184 const_iterator find(const T&) const; | 184 const_iterator find(const T&) const; |
| 185 template <typename HashTranslator, typename T> | 185 template <typename HashTranslator, typename T> |
| 186 bool contains(const T&) const; | 186 bool contains(const T&) const; |
| 187 | 187 |
| 188 // The return value of add is a pair of a pointer to the stored value, and a | 188 // The return value of insert is a pair of a pointer to the stored value, and |
| 189 // bool that is true if an new entry was added. | 189 // a bool that is true if an new entry was added. |
| 190 template <typename IncomingValueType> | |
| 191 AddResult add(IncomingValueType&&); | |
| 192 template <typename IncomingValueType> | 190 template <typename IncomingValueType> |
| 193 AddResult insert(IncomingValueType&&); | 191 AddResult insert(IncomingValueType&&); |
| 194 | 192 |
| 195 // Same as add() except that the return value is an iterator. Useful in | 193 // Same as insert() except that the return value is an iterator. Useful in |
| 196 // cases where it's needed to have the same return value as find() and where | 194 // cases where it's needed to have the same return value as find() and where |
| 197 // it's not possible to use a pointer to the storedValue. | 195 // it's not possible to use a pointer to the storedValue. |
| 198 template <typename IncomingValueType> | 196 template <typename IncomingValueType> |
| 199 iterator addReturnIterator(IncomingValueType&&); | 197 iterator addReturnIterator(IncomingValueType&&); |
| 200 | 198 |
| 201 // Add the value to the end of the collection. If the value was already in | 199 // Add the value to the end of the collection. If the value was already in |
| 202 // the list, it is moved to the end. | 200 // the list, it is moved to the end. |
| 203 template <typename IncomingValueType> | 201 template <typename IncomingValueType> |
| 204 AddResult appendOrMoveToLast(IncomingValueType&&); | 202 AddResult appendOrMoveToLast(IncomingValueType&&); |
| 205 | 203 |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 "Cannot put raw pointers to garbage-collected classes into " | 761 "Cannot put raw pointers to garbage-collected classes into " |
| 764 "an off-heap ListHashSet. Use HeapListHashSet<Member<T>> instead."); | 762 "an off-heap ListHashSet. Use HeapListHashSet<Member<T>> instead."); |
| 765 } | 763 } |
| 766 | 764 |
| 767 template <typename T, size_t inlineCapacity, typename U, typename V> | 765 template <typename T, size_t inlineCapacity, typename U, typename V> |
| 768 inline ListHashSet<T, inlineCapacity, U, V>::ListHashSet( | 766 inline ListHashSet<T, inlineCapacity, U, V>::ListHashSet( |
| 769 const ListHashSet& other) | 767 const ListHashSet& other) |
| 770 : m_head(nullptr), m_tail(nullptr) { | 768 : m_head(nullptr), m_tail(nullptr) { |
| 771 const_iterator end = other.end(); | 769 const_iterator end = other.end(); |
| 772 for (const_iterator it = other.begin(); it != end; ++it) | 770 for (const_iterator it = other.begin(); it != end; ++it) |
| 773 add(*it); | 771 insert(*it); |
| 774 } | 772 } |
| 775 | 773 |
| 776 template <typename T, size_t inlineCapacity, typename U, typename V> | 774 template <typename T, size_t inlineCapacity, typename U, typename V> |
| 777 inline ListHashSet<T, inlineCapacity, U, V>::ListHashSet(ListHashSet&& other) | 775 inline ListHashSet<T, inlineCapacity, U, V>::ListHashSet(ListHashSet&& other) |
| 778 : m_head(nullptr), m_tail(nullptr) { | 776 : m_head(nullptr), m_tail(nullptr) { |
| 779 swap(other); | 777 swap(other); |
| 780 } | 778 } |
| 781 | 779 |
| 782 template <typename T, size_t inlineCapacity, typename U, typename V> | 780 template <typename T, size_t inlineCapacity, typename U, typename V> |
| 783 inline ListHashSet<T, inlineCapacity, U, V>& | 781 inline ListHashSet<T, inlineCapacity, U, V>& |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 | 909 |
| 912 template <typename T, size_t inlineCapacity, typename U, typename V> | 910 template <typename T, size_t inlineCapacity, typename U, typename V> |
| 913 inline bool ListHashSet<T, inlineCapacity, U, V>::contains( | 911 inline bool ListHashSet<T, inlineCapacity, U, V>::contains( |
| 914 ValuePeekInType value) const { | 912 ValuePeekInType value) const { |
| 915 return m_impl.template contains<BaseTranslator>(value); | 913 return m_impl.template contains<BaseTranslator>(value); |
| 916 } | 914 } |
| 917 | 915 |
| 918 template <typename T, size_t inlineCapacity, typename U, typename V> | 916 template <typename T, size_t inlineCapacity, typename U, typename V> |
| 919 template <typename IncomingValueType> | 917 template <typename IncomingValueType> |
| 920 typename ListHashSet<T, inlineCapacity, U, V>::AddResult | 918 typename ListHashSet<T, inlineCapacity, U, V>::AddResult |
| 921 ListHashSet<T, inlineCapacity, U, V>::add(IncomingValueType&& value) { | 919 ListHashSet<T, inlineCapacity, U, V>::insert(IncomingValueType&& value) { |
| 922 createAllocatorIfNeeded(); | 920 createAllocatorIfNeeded(); |
| 923 // The second argument is a const ref. This is useful for the HashTable | 921 // The second argument is a const ref. This is useful for the HashTable |
| 924 // because it lets it take lvalues by reference, but for our purposes it's | 922 // because it lets it take lvalues by reference, but for our purposes it's |
| 925 // inconvenient, since it constrains us to be const, whereas the allocator | 923 // inconvenient, since it constrains us to be const, whereas the allocator |
| 926 // actually changes when it does allocations. | 924 // actually changes when it does allocations. |
| 927 auto result = m_impl.template add<BaseTranslator>( | 925 auto result = m_impl.template add<BaseTranslator>( |
| 928 std::forward<IncomingValueType>(value), *this->getAllocator()); | 926 std::forward<IncomingValueType>(value), *this->getAllocator()); |
| 929 if (result.isNewEntry) | 927 if (result.isNewEntry) |
| 930 appendNode(*result.storedValue); | 928 appendNode(*result.storedValue); |
| 931 return AddResult(*result.storedValue, result.isNewEntry); | 929 return AddResult(*result.storedValue, result.isNewEntry); |
| 932 } | 930 } |
| 933 | 931 |
| 934 template <typename T, size_t inlineCapacity, typename U, typename V> | 932 template <typename T, size_t inlineCapacity, typename U, typename V> |
| 935 template <typename IncomingValueType> | 933 template <typename IncomingValueType> |
| 936 typename ListHashSet<T, inlineCapacity, U, V>::AddResult | |
| 937 ListHashSet<T, inlineCapacity, U, V>::insert(IncomingValueType&& value) { | |
| 938 return add(value); | |
| 939 } | |
| 940 | |
| 941 template <typename T, size_t inlineCapacity, typename U, typename V> | |
| 942 template <typename IncomingValueType> | |
| 943 typename ListHashSet<T, inlineCapacity, U, V>::iterator | 934 typename ListHashSet<T, inlineCapacity, U, V>::iterator |
| 944 ListHashSet<T, inlineCapacity, U, V>::addReturnIterator( | 935 ListHashSet<T, inlineCapacity, U, V>::addReturnIterator( |
| 945 IncomingValueType&& value) { | 936 IncomingValueType&& value) { |
| 946 return makeIterator(add(std::forward<IncomingValueType>(value)).m_node); | 937 return makeIterator(insert(std::forward<IncomingValueType>(value)).m_node); |
| 947 } | 938 } |
| 948 | 939 |
| 949 template <typename T, size_t inlineCapacity, typename U, typename V> | 940 template <typename T, size_t inlineCapacity, typename U, typename V> |
| 950 template <typename IncomingValueType> | 941 template <typename IncomingValueType> |
| 951 typename ListHashSet<T, inlineCapacity, U, V>::AddResult | 942 typename ListHashSet<T, inlineCapacity, U, V>::AddResult |
| 952 ListHashSet<T, inlineCapacity, U, V>::appendOrMoveToLast( | 943 ListHashSet<T, inlineCapacity, U, V>::appendOrMoveToLast( |
| 953 IncomingValueType&& value) { | 944 IncomingValueType&& value) { |
| 954 createAllocatorIfNeeded(); | 945 createAllocatorIfNeeded(); |
| 955 auto result = m_impl.template add<BaseTranslator>( | 946 auto result = m_impl.template add<BaseTranslator>( |
| 956 std::forward<IncomingValueType>(value), *this->getAllocator()); | 947 std::forward<IncomingValueType>(value), *this->getAllocator()); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 // through the HashTable. That includes m_head and m_tail so we do not have | 1126 // through the HashTable. That includes m_head and m_tail so we do not have |
| 1136 // to explicitly trace them here. | 1127 // to explicitly trace them here. |
| 1137 m_impl.trace(visitor); | 1128 m_impl.trace(visitor); |
| 1138 } | 1129 } |
| 1139 | 1130 |
| 1140 } // namespace WTF | 1131 } // namespace WTF |
| 1141 | 1132 |
| 1142 using WTF::ListHashSet; | 1133 using WTF::ListHashSet; |
| 1143 | 1134 |
| 1144 #endif // WTF_ListHashSet_h | 1135 #endif // WTF_ListHashSet_h |
| OLD | NEW |