| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 class ListHashSetDestructorBase<Derived, Allocator, false> { | 67 class ListHashSetDestructorBase<Derived, Allocator, false> { |
| 68 public: | 68 public: |
| 69 ~ListHashSetDestructorBase() { static_cast<Derived*>(this)->finalize();
} | 69 ~ListHashSetDestructorBase() { static_cast<Derived*>(this)->finalize();
} |
| 70 protected: | 70 protected: |
| 71 typename Allocator::AllocatorProvider m_allocatorProvider; | 71 typename Allocator::AllocatorProvider m_allocatorProvider; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 // Note that for a ListHashSet you cannot specify the HashTraits as a | 74 // Note that for a ListHashSet you cannot specify the HashTraits as a |
| 75 // template argument. It uses the default hash traits for the ValueArg | 75 // template argument. It uses the default hash traits for the ValueArg |
| 76 // type. | 76 // type. |
| 77 template<typename ValueArg, size_t inlineCapacity = 256, typename HashArg =
typename DefaultHash<ValueArg>::Hash, typename AllocatorArg = ListHashSetAllocat
or<ValueArg, inlineCapacity> > class ListHashSet | 77 template<typename ValueArg, size_t inlineCapacity = 256, typename HashArg =
typename DefaultHash<ValueArg>::Hash, typename AllocatorArg = ListHashSetAllocat
or<ValueArg, inlineCapacity>> class ListHashSet |
| 78 : public ListHashSetDestructorBase<ListHashSet<ValueArg, inlineCapacity,
HashArg, AllocatorArg>, AllocatorArg, AllocatorArg::isGarbageCollected> { | 78 : public ListHashSetDestructorBase<ListHashSet<ValueArg, inlineCapacity,
HashArg, AllocatorArg>, AllocatorArg, AllocatorArg::isGarbageCollected> { |
| 79 typedef AllocatorArg Allocator; | 79 typedef AllocatorArg Allocator; |
| 80 WTF_USE_ALLOCATOR(ListHashSet, Allocator); | 80 WTF_USE_ALLOCATOR(ListHashSet, Allocator); |
| 81 | 81 |
| 82 typedef ListHashSetNode<ValueArg, Allocator> Node; | 82 typedef ListHashSetNode<ValueArg, Allocator> Node; |
| 83 typedef HashTraits<Node*> NodeTraits; | 83 typedef HashTraits<Node*> NodeTraits; |
| 84 typedef ListHashSetNodeHashFunctions<HashArg> NodeHash; | 84 typedef ListHashSetNodeHashFunctions<HashArg> NodeHash; |
| 85 typedef ListHashSetTranslator<HashArg> BaseTranslator; | 85 typedef ListHashSetTranslator<HashArg> BaseTranslator; |
| 86 | 86 |
| 87 typedef HashTable<Node*, Node*, IdentityExtractor, NodeHash, NodeTraits,
NodeTraits, typename Allocator::TableAllocator> ImplType; | 87 typedef HashTable<Node*, Node*, IdentityExtractor, NodeHash, NodeTraits,
NodeTraits, typename Allocator::TableAllocator> ImplType; |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 template<typename Translator> | 764 template<typename Translator> |
| 765 struct ListHashSetTranslatorAdapter { | 765 struct ListHashSetTranslatorAdapter { |
| 766 template<typename T> static unsigned hash(const T& key) { return Transla
tor::hash(key); } | 766 template<typename T> static unsigned hash(const T& key) { return Transla
tor::hash(key); } |
| 767 template<typename T, typename U> static bool equal(const T& a, const U&
b) { return Translator::equal(a->m_value, b); } | 767 template<typename T, typename U> static bool equal(const T& a, const U&
b) { return Translator::equal(a->m_value, b); } |
| 768 }; | 768 }; |
| 769 | 769 |
| 770 template<typename ValueType, size_t inlineCapacity, typename U, typename V> | 770 template<typename ValueType, size_t inlineCapacity, typename U, typename V> |
| 771 template<typename HashTranslator, typename T> | 771 template<typename HashTranslator, typename T> |
| 772 inline typename ListHashSet<ValueType, inlineCapacity, U, V>::iterator ListH
ashSet<ValueType, inlineCapacity, U, V>::find(const T& value) | 772 inline typename ListHashSet<ValueType, inlineCapacity, U, V>::iterator ListH
ashSet<ValueType, inlineCapacity, U, V>::find(const T& value) |
| 773 { | 773 { |
| 774 ImplTypeConstIterator it = m_impl.template find<ListHashSetTranslatorAda
pter<HashTranslator> >(value); | 774 ImplTypeConstIterator it = m_impl.template find<ListHashSetTranslatorAda
pter<HashTranslator>>(value); |
| 775 if (it == m_impl.end()) | 775 if (it == m_impl.end()) |
| 776 return end(); | 776 return end(); |
| 777 return makeIterator(*it); | 777 return makeIterator(*it); |
| 778 } | 778 } |
| 779 | 779 |
| 780 template<typename ValueType, size_t inlineCapacity, typename U, typename V> | 780 template<typename ValueType, size_t inlineCapacity, typename U, typename V> |
| 781 template<typename HashTranslator, typename T> | 781 template<typename HashTranslator, typename T> |
| 782 inline typename ListHashSet<ValueType, inlineCapacity, U, V>::const_iterator
ListHashSet<ValueType, inlineCapacity, U, V>::find(const T& value) const | 782 inline typename ListHashSet<ValueType, inlineCapacity, U, V>::const_iterator
ListHashSet<ValueType, inlineCapacity, U, V>::find(const T& value) const |
| 783 { | 783 { |
| 784 ImplTypeConstIterator it = m_impl.template find<ListHashSetTranslatorAda
pter<HashTranslator> >(value); | 784 ImplTypeConstIterator it = m_impl.template find<ListHashSetTranslatorAda
pter<HashTranslator>>(value); |
| 785 if (it == m_impl.end()) | 785 if (it == m_impl.end()) |
| 786 return end(); | 786 return end(); |
| 787 return makeConstIterator(*it); | 787 return makeConstIterator(*it); |
| 788 } | 788 } |
| 789 | 789 |
| 790 template<typename ValueType, size_t inlineCapacity, typename U, typename V> | 790 template<typename ValueType, size_t inlineCapacity, typename U, typename V> |
| 791 template<typename HashTranslator, typename T> | 791 template<typename HashTranslator, typename T> |
| 792 inline bool ListHashSet<ValueType, inlineCapacity, U, V>::contains(const T&
value) const | 792 inline bool ListHashSet<ValueType, inlineCapacity, U, V>::contains(const T&
value) const |
| 793 { | 793 { |
| 794 return m_impl.template contains<ListHashSetTranslatorAdapter<HashTransla
tor> >(value); | 794 return m_impl.template contains<ListHashSetTranslatorAdapter<HashTransla
tor>>(value); |
| 795 } | 795 } |
| 796 | 796 |
| 797 template<typename T, size_t inlineCapacity, typename U, typename V> | 797 template<typename T, size_t inlineCapacity, typename U, typename V> |
| 798 inline bool ListHashSet<T, inlineCapacity, U, V>::contains(ValuePeekInType v
alue) const | 798 inline bool ListHashSet<T, inlineCapacity, U, V>::contains(ValuePeekInType v
alue) const |
| 799 { | 799 { |
| 800 return m_impl.template contains<BaseTranslator>(value); | 800 return m_impl.template contains<BaseTranslator>(value); |
| 801 } | 801 } |
| 802 | 802 |
| 803 template<typename T, size_t inlineCapacity, typename U, typename V> | 803 template<typename T, size_t inlineCapacity, typename U, typename V> |
| 804 typename ListHashSet<T, inlineCapacity, U, V>::AddResult ListHashSet<T, inli
neCapacity, U, V>::add(ValuePassInType value) | 804 typename ListHashSet<T, inlineCapacity, U, V>::AddResult ListHashSet<T, inli
neCapacity, U, V>::add(ValuePassInType value) |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 { | 998 { |
| 999 static_assert(HashTraits<T>::weakHandlingFlag == NoWeakHandlingInCollect
ions, "ListHashSet does not support weakness"); | 999 static_assert(HashTraits<T>::weakHandlingFlag == NoWeakHandlingInCollect
ions, "ListHashSet does not support weakness"); |
| 1000 // This marks all the nodes and their contents live that can be | 1000 // This marks all the nodes and their contents live that can be |
| 1001 // accessed through the HashTable. That includes m_head and m_tail | 1001 // accessed through the HashTable. That includes m_head and m_tail |
| 1002 // so we do not have to explicitly trace them here. | 1002 // so we do not have to explicitly trace them here. |
| 1003 m_impl.trace(visitor); | 1003 m_impl.trace(visitor); |
| 1004 } | 1004 } |
| 1005 | 1005 |
| 1006 #if !ENABLE(OILPAN) | 1006 #if !ENABLE(OILPAN) |
| 1007 template<typename T, size_t U, typename V> | 1007 template<typename T, size_t U, typename V> |
| 1008 struct NeedsTracing<ListHashSet<T, U, V> > { | 1008 struct NeedsTracing<ListHashSet<T, U, V>> { |
| 1009 static const bool value = false; | 1009 static const bool value = false; |
| 1010 }; | 1010 }; |
| 1011 #endif | 1011 #endif |
| 1012 | 1012 |
| 1013 } // namespace WTF | 1013 } // namespace WTF |
| 1014 | 1014 |
| 1015 using WTF::ListHashSet; | 1015 using WTF::ListHashSet; |
| 1016 | 1016 |
| 1017 #endif /* WTF_ListHashSet_h */ | 1017 #endif /* WTF_ListHashSet_h */ |
| OLD | NEW |