| 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 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 | 810 |
| 811 template <typename T, size_t inlineCapacity, typename U, typename V> | 811 template <typename T, size_t inlineCapacity, typename U, typename V> |
| 812 inline T& ListHashSet<T, inlineCapacity, U, V>::front() { | 812 inline T& ListHashSet<T, inlineCapacity, U, V>::front() { |
| 813 DCHECK(!isEmpty()); | 813 DCHECK(!isEmpty()); |
| 814 return m_head->m_value; | 814 return m_head->m_value; |
| 815 } | 815 } |
| 816 | 816 |
| 817 template <typename T, size_t inlineCapacity, typename U, typename V> | 817 template <typename T, size_t inlineCapacity, typename U, typename V> |
| 818 inline void ListHashSet<T, inlineCapacity, U, V>::removeFirst() { | 818 inline void ListHashSet<T, inlineCapacity, U, V>::removeFirst() { |
| 819 DCHECK(!isEmpty()); | 819 DCHECK(!isEmpty()); |
| 820 m_impl.remove(m_head); | 820 m_impl.erase(m_head); |
| 821 unlinkAndDelete(m_head); | 821 unlinkAndDelete(m_head); |
| 822 } | 822 } |
| 823 | 823 |
| 824 template <typename T, size_t inlineCapacity, typename U, typename V> | 824 template <typename T, size_t inlineCapacity, typename U, typename V> |
| 825 inline const T& ListHashSet<T, inlineCapacity, U, V>::front() const { | 825 inline const T& ListHashSet<T, inlineCapacity, U, V>::front() const { |
| 826 DCHECK(!isEmpty()); | 826 DCHECK(!isEmpty()); |
| 827 return m_head->m_value; | 827 return m_head->m_value; |
| 828 } | 828 } |
| 829 | 829 |
| 830 template <typename T, size_t inlineCapacity, typename U, typename V> | 830 template <typename T, size_t inlineCapacity, typename U, typename V> |
| 831 inline T& ListHashSet<T, inlineCapacity, U, V>::back() { | 831 inline T& ListHashSet<T, inlineCapacity, U, V>::back() { |
| 832 DCHECK(!isEmpty()); | 832 DCHECK(!isEmpty()); |
| 833 return m_tail->m_value; | 833 return m_tail->m_value; |
| 834 } | 834 } |
| 835 | 835 |
| 836 template <typename T, size_t inlineCapacity, typename U, typename V> | 836 template <typename T, size_t inlineCapacity, typename U, typename V> |
| 837 inline const T& ListHashSet<T, inlineCapacity, U, V>::back() const { | 837 inline const T& ListHashSet<T, inlineCapacity, U, V>::back() const { |
| 838 DCHECK(!isEmpty()); | 838 DCHECK(!isEmpty()); |
| 839 return m_tail->m_value; | 839 return m_tail->m_value; |
| 840 } | 840 } |
| 841 | 841 |
| 842 template <typename T, size_t inlineCapacity, typename U, typename V> | 842 template <typename T, size_t inlineCapacity, typename U, typename V> |
| 843 inline void ListHashSet<T, inlineCapacity, U, V>::pop_back() { | 843 inline void ListHashSet<T, inlineCapacity, U, V>::pop_back() { |
| 844 DCHECK(!isEmpty()); | 844 DCHECK(!isEmpty()); |
| 845 m_impl.remove(m_tail); | 845 m_impl.erase(m_tail); |
| 846 unlinkAndDelete(m_tail); | 846 unlinkAndDelete(m_tail); |
| 847 } | 847 } |
| 848 | 848 |
| 849 template <typename T, size_t inlineCapacity, typename U, typename V> | 849 template <typename T, size_t inlineCapacity, typename U, typename V> |
| 850 inline typename ListHashSet<T, inlineCapacity, U, V>::iterator | 850 inline typename ListHashSet<T, inlineCapacity, U, V>::iterator |
| 851 ListHashSet<T, inlineCapacity, U, V>::find(ValuePeekInType value) { | 851 ListHashSet<T, inlineCapacity, U, V>::find(ValuePeekInType value) { |
| 852 ImplTypeIterator it = m_impl.template find<BaseTranslator>(value); | 852 ImplTypeIterator it = m_impl.template find<BaseTranslator>(value); |
| 853 if (it == m_impl.end()) | 853 if (it == m_impl.end()) |
| 854 return end(); | 854 return end(); |
| 855 return makeIterator(*it); | 855 return makeIterator(*it); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 IncomingValueType&& newValue) { | 989 IncomingValueType&& newValue) { |
| 990 createAllocatorIfNeeded(); | 990 createAllocatorIfNeeded(); |
| 991 return insertBefore(find(beforeValue), | 991 return insertBefore(find(beforeValue), |
| 992 std::forward<IncomingValueType>(newValue)); | 992 std::forward<IncomingValueType>(newValue)); |
| 993 } | 993 } |
| 994 | 994 |
| 995 template <typename T, size_t inlineCapacity, typename U, typename V> | 995 template <typename T, size_t inlineCapacity, typename U, typename V> |
| 996 inline void ListHashSet<T, inlineCapacity, U, V>::erase(iterator it) { | 996 inline void ListHashSet<T, inlineCapacity, U, V>::erase(iterator it) { |
| 997 if (it == end()) | 997 if (it == end()) |
| 998 return; | 998 return; |
| 999 m_impl.remove(it.getNode()); | 999 m_impl.erase(it.getNode()); |
| 1000 unlinkAndDelete(it.getNode()); | 1000 unlinkAndDelete(it.getNode()); |
| 1001 } | 1001 } |
| 1002 | 1002 |
| 1003 template <typename T, size_t inlineCapacity, typename U, typename V> | 1003 template <typename T, size_t inlineCapacity, typename U, typename V> |
| 1004 inline void ListHashSet<T, inlineCapacity, U, V>::clear() { | 1004 inline void ListHashSet<T, inlineCapacity, U, V>::clear() { |
| 1005 deleteAllNodes(); | 1005 deleteAllNodes(); |
| 1006 m_impl.clear(); | 1006 m_impl.clear(); |
| 1007 m_head = nullptr; | 1007 m_head = nullptr; |
| 1008 m_tail = nullptr; | 1008 m_tail = nullptr; |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 template <typename T, size_t inlineCapacity, typename U, typename V> | 1011 template <typename T, size_t inlineCapacity, typename U, typename V> |
| 1012 auto ListHashSet<T, inlineCapacity, U, V>::take(iterator it) -> ValueType { | 1012 auto ListHashSet<T, inlineCapacity, U, V>::take(iterator it) -> ValueType { |
| 1013 if (it == end()) | 1013 if (it == end()) |
| 1014 return ValueTraits::emptyValue(); | 1014 return ValueTraits::emptyValue(); |
| 1015 | 1015 |
| 1016 m_impl.remove(it.getNode()); | 1016 m_impl.erase(it.getNode()); |
| 1017 ValueType result = std::move(it.getNode()->m_value); | 1017 ValueType result = std::move(it.getNode()->m_value); |
| 1018 unlinkAndDelete(it.getNode()); | 1018 unlinkAndDelete(it.getNode()); |
| 1019 | 1019 |
| 1020 return result; | 1020 return result; |
| 1021 } | 1021 } |
| 1022 | 1022 |
| 1023 template <typename T, size_t inlineCapacity, typename U, typename V> | 1023 template <typename T, size_t inlineCapacity, typename U, typename V> |
| 1024 auto ListHashSet<T, inlineCapacity, U, V>::take(ValuePeekInType value) | 1024 auto ListHashSet<T, inlineCapacity, U, V>::take(ValuePeekInType value) |
| 1025 -> ValueType { | 1025 -> ValueType { |
| 1026 return take(find(value)); | 1026 return take(find(value)); |
| 1027 } | 1027 } |
| 1028 | 1028 |
| 1029 template <typename T, size_t inlineCapacity, typename U, typename V> | 1029 template <typename T, size_t inlineCapacity, typename U, typename V> |
| 1030 auto ListHashSet<T, inlineCapacity, U, V>::takeFirst() -> ValueType { | 1030 auto ListHashSet<T, inlineCapacity, U, V>::takeFirst() -> ValueType { |
| 1031 DCHECK(!isEmpty()); | 1031 DCHECK(!isEmpty()); |
| 1032 m_impl.remove(m_head); | 1032 m_impl.erase(m_head); |
| 1033 ValueType result = std::move(m_head->m_value); | 1033 ValueType result = std::move(m_head->m_value); |
| 1034 unlinkAndDelete(m_head); | 1034 unlinkAndDelete(m_head); |
| 1035 | 1035 |
| 1036 return result; | 1036 return result; |
| 1037 } | 1037 } |
| 1038 | 1038 |
| 1039 template <typename T, size_t inlineCapacity, typename U, typename Allocator> | 1039 template <typename T, size_t inlineCapacity, typename U, typename Allocator> |
| 1040 void ListHashSet<T, inlineCapacity, U, Allocator>::unlink(Node* node) { | 1040 void ListHashSet<T, inlineCapacity, U, Allocator>::unlink(Node* node) { |
| 1041 if (!node->m_prev) { | 1041 if (!node->m_prev) { |
| 1042 DCHECK_EQ(node, m_head); | 1042 DCHECK_EQ(node, m_head); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 // 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 |
| 1127 // to explicitly trace them here. | 1127 // to explicitly trace them here. |
| 1128 m_impl.trace(visitor); | 1128 m_impl.trace(visitor); |
| 1129 } | 1129 } |
| 1130 | 1130 |
| 1131 } // namespace WTF | 1131 } // namespace WTF |
| 1132 | 1132 |
| 1133 using WTF::ListHashSet; | 1133 using WTF::ListHashSet; |
| 1134 | 1134 |
| 1135 #endif // WTF_ListHashSet_h | 1135 #endif // WTF_ListHashSet_h |
| OLD | NEW |