Chromium Code Reviews| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 typedef ValueArg ValueType; | 75 typedef ValueArg ValueType; |
| 76 | 76 |
| 77 typedef ListHashSetIterator<ValueType, inlineCapacity, HashArg> iterator ; | 77 typedef ListHashSetIterator<ValueType, inlineCapacity, HashArg> iterator ; |
| 78 typedef ListHashSetConstIterator<ValueType, inlineCapacity, HashArg> con st_iterator; | 78 typedef ListHashSetConstIterator<ValueType, inlineCapacity, HashArg> con st_iterator; |
| 79 friend class ListHashSetConstIterator<ValueType, inlineCapacity, HashArg >; | 79 friend class ListHashSetConstIterator<ValueType, inlineCapacity, HashArg >; |
| 80 | 80 |
| 81 typedef ListHashSetReverseIterator<ValueType, inlineCapacity, HashArg> r everse_iterator; | 81 typedef ListHashSetReverseIterator<ValueType, inlineCapacity, HashArg> r everse_iterator; |
| 82 typedef ListHashSetConstReverseIterator<ValueType, inlineCapacity, HashA rg> const_reverse_iterator; | 82 typedef ListHashSetConstReverseIterator<ValueType, inlineCapacity, HashA rg> const_reverse_iterator; |
| 83 friend class ListHashSetConstReverseIterator<ValueType, inlineCapacity, HashArg>; | 83 friend class ListHashSetConstReverseIterator<ValueType, inlineCapacity, HashArg>; |
| 84 | 84 |
| 85 typedef HashTableAddResult<iterator> AddResult; | 85 template<typename ValueType> struct HashTableAddResult { |
| 86 HashTableAddResult(void* iterator, bool isNewEntry) : iterator(iterator) , isNewEntry(isNewEntry) { } | |
| 87 void* iterator; | |
| 88 bool isNewEntry; | |
| 89 }; | |
| 90 typedef HashTableAddResult<ValueType> AddResult; | |
| 86 | 91 |
| 87 ListHashSet(); | 92 ListHashSet(); |
| 88 ListHashSet(const ListHashSet&); | 93 ListHashSet(const ListHashSet&); |
| 89 ListHashSet& operator=(const ListHashSet&); | 94 ListHashSet& operator=(const ListHashSet&); |
| 90 ~ListHashSet(); | 95 ~ListHashSet(); |
| 91 | 96 |
| 92 void swap(ListHashSet&); | 97 void swap(ListHashSet&); |
| 93 | 98 |
| 94 unsigned size() const; | 99 unsigned size() const; |
| 95 unsigned capacity() const; | 100 unsigned capacity() const; |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 729 return m_impl.template contains<BaseTranslator>(value); | 734 return m_impl.template contains<BaseTranslator>(value); |
| 730 } | 735 } |
| 731 | 736 |
| 732 template<typename T, size_t inlineCapacity, typename U> | 737 template<typename T, size_t inlineCapacity, typename U> |
| 733 typename ListHashSet<T, inlineCapacity, U>::AddResult ListHashSet<T, inlineC apacity, U>::add(const ValueType &value) | 738 typename ListHashSet<T, inlineCapacity, U>::AddResult ListHashSet<T, inlineC apacity, U>::add(const ValueType &value) |
| 734 { | 739 { |
| 735 createAllocatorIfNeeded(); | 740 createAllocatorIfNeeded(); |
| 736 typename ImplType::AddResult result = m_impl.template add<BaseTranslator >(value, m_allocator.get()); | 741 typename ImplType::AddResult result = m_impl.template add<BaseTranslator >(value, m_allocator.get()); |
| 737 if (result.isNewEntry) | 742 if (result.isNewEntry) |
| 738 appendNode(*result.iterator); | 743 appendNode(*result.iterator); |
| 739 return AddResult(makeIterator(*result.iterator), result.isNewEntry); | 744 return AddResult(result.iterator, result.isNewEntry); |
| 740 } | 745 } |
| 741 | 746 |
| 742 template<typename T, size_t inlineCapacity, typename U> | 747 template<typename T, size_t inlineCapacity, typename U> |
| 743 typename ListHashSet<T, inlineCapacity, U>::AddResult ListHashSet<T, inlineC apacity, U>::appendOrMoveToLast(const ValueType &value) | 748 typename ListHashSet<T, inlineCapacity, U>::AddResult ListHashSet<T, inlineC apacity, U>::appendOrMoveToLast(const ValueType &value) |
| 744 { | 749 { |
| 745 createAllocatorIfNeeded(); | 750 createAllocatorIfNeeded(); |
| 746 typename ImplType::AddResult result = m_impl.template add<BaseTranslator >(value, m_allocator.get()); | 751 typename ImplType::AddResult result = m_impl.template add<BaseTranslator >(value, m_allocator.get()); |
| 747 Node* node = *result.iterator; | 752 Node* node = *result.iterator; |
| 748 if (!result.isNewEntry) | 753 if (!result.isNewEntry) |
| 749 unlink(node); | 754 unlink(node); |
| 750 appendNode(node); | 755 appendNode(node); |
| 751 return AddResult(makeIterator(*result.iterator), result.isNewEntry); | 756 return AddResult(result.iterator, result.isNewEntry); |
| 752 } | 757 } |
| 753 | 758 |
| 754 template<typename T, size_t inlineCapacity, typename U> | 759 template<typename T, size_t inlineCapacity, typename U> |
| 755 typename ListHashSet<T, inlineCapacity, U>::AddResult ListHashSet<T, inlineC apacity, U>::prependOrMoveToFirst(const ValueType &value) | 760 typename ListHashSet<T, inlineCapacity, U>::AddResult ListHashSet<T, inlineC apacity, U>::prependOrMoveToFirst(const ValueType &value) |
| 756 { | 761 { |
| 757 createAllocatorIfNeeded(); | 762 createAllocatorIfNeeded(); |
| 758 typename ImplType::AddResult result = m_impl.template add<BaseTranslator >(value, m_allocator.get()); | 763 typename ImplType::AddResult result = m_impl.template add<BaseTranslator >(value, m_allocator.get()); |
| 759 Node* node = *result.iterator; | 764 Node* node = result.iterator; |
|
Mikhail
2014/02/04 09:57:41
IMO the semantic is incorrect: iterator should not
eseidel
2014/02/05 22:17:20
It's just the naming which is wrong. If this was
| |
| 760 if (!result.isNewEntry) | 765 if (!result.isNewEntry) |
| 761 unlink(node); | 766 unlink(node); |
| 762 prependNode(node); | 767 prependNode(node); |
| 763 return AddResult(makeIterator(*result.iterator), result.isNewEntry); | 768 return AddResult(result.iterator, result.isNewEntry); |
| 764 } | 769 } |
| 765 | 770 |
| 766 template<typename T, size_t inlineCapacity, typename U> | 771 template<typename T, size_t inlineCapacity, typename U> |
| 767 typename ListHashSet<T, inlineCapacity, U>::AddResult ListHashSet<T, inlineC apacity, U>::insertBefore(iterator it, const ValueType& newValue) | 772 typename ListHashSet<T, inlineCapacity, U>::AddResult ListHashSet<T, inlineC apacity, U>::insertBefore(iterator it, const ValueType& newValue) |
| 768 { | 773 { |
| 769 createAllocatorIfNeeded(); | 774 createAllocatorIfNeeded(); |
| 770 typename ImplType::AddResult result = m_impl.template add<BaseTranslator >(newValue, m_allocator.get()); | 775 typename ImplType::AddResult result = m_impl.template add<BaseTranslator >(newValue, m_allocator.get()); |
| 771 if (result.isNewEntry) | 776 if (result.isNewEntry) |
| 772 insertNodeBefore(it.node(), *result.iterator); | 777 insertNodeBefore(it.node(), *result.iterator); |
| 773 return AddResult(makeIterator(*result.iterator), result.isNewEntry); | 778 return AddResult(result.iterator, result.isNewEntry); |
| 774 } | 779 } |
| 775 | 780 |
| 776 template<typename T, size_t inlineCapacity, typename U> | 781 template<typename T, size_t inlineCapacity, typename U> |
| 777 typename ListHashSet<T, inlineCapacity, U>::AddResult ListHashSet<T, inlineC apacity, U>::insertBefore(const ValueType& beforeValue, const ValueType& newValu e) | 782 typename ListHashSet<T, inlineCapacity, U>::AddResult ListHashSet<T, inlineC apacity, U>::insertBefore(const ValueType& beforeValue, const ValueType& newValu e) |
| 778 { | 783 { |
| 779 createAllocatorIfNeeded(); | 784 createAllocatorIfNeeded(); |
| 780 return insertBefore(find(beforeValue), newValue); | 785 return insertBefore(find(beforeValue), newValue); |
| 781 } | 786 } |
| 782 | 787 |
| 783 template<typename T, size_t inlineCapacity, typename U> | 788 template<typename T, size_t inlineCapacity, typename U> |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 931 inline void deleteAllValues(const ListHashSet<T, inlineCapacity, U>& collect ion) | 936 inline void deleteAllValues(const ListHashSet<T, inlineCapacity, U>& collect ion) |
| 932 { | 937 { |
| 933 deleteAllValues<true, typename ListHashSet<T, inlineCapacity, U>::ValueT ype>(collection.m_impl); | 938 deleteAllValues<true, typename ListHashSet<T, inlineCapacity, U>::ValueT ype>(collection.m_impl); |
| 934 } | 939 } |
| 935 | 940 |
| 936 } // namespace WTF | 941 } // namespace WTF |
| 937 | 942 |
| 938 using WTF::ListHashSet; | 943 using WTF::ListHashSet; |
| 939 | 944 |
| 940 #endif /* WTF_ListHashSet_h */ | 945 #endif /* WTF_ListHashSet_h */ |
| OLD | NEW |