| 1 | /* |
| 2 | * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Library General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 2 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Library General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Library General Public License |
| 15 | * along with this library; see the file COPYING.LIB. If not, write to |
| 16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 | * Boston, MA 02110-1301, USA. |
| 18 | * |
| 19 | */ |
| 20 | |
| 21 | #ifndef WTF_HashCountedSet_h |
| 22 | #define WTF_HashCountedSet_hcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashCountedSet.h:22:9`! |
| 23 | |
| 24 | #include "Assertions.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h`/ |
| 25 | #include "FastAllocBase.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastAllocBase.h`/ |
| 26 | #include "HashMap.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashMap.h`/ |
| 27 | #include "Vector.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Vector.h`/ |
| 28 | |
| 29 | namespace WTFcxx . . $ `<built-in>:467:9`! { |
| 30 | |
| 31 | template<typename Value, typename HashFunctions = typename DefaultHashcxx . . $ QTWTF/DefaultHash#<Value>::Hash, |
| 32 | typename Traits = HashTraitscxx . . $ QTWTF/HashTraits#<Value> > class HashCountedSetcxx . . $ QTWTF/HashCountedSet# : public FastAllocBasecxx . . $ QTWTF/FastAllocBase# { |
| 33 | private: |
| 34 | typedef HashMap<Value, unsigned, HashFunctions, Traits> ImplTypecxx . . $ QTWTF/HashCountedSet#ImplType#; |
| 35 | public: |
| 36 | typedef Value ValueTypecxx . . $ QTWTF/HashCountedSet#ValueType#; |
| 37 | typedef typename ImplType::iterator iteratorcxx . . $ QTWTF/HashCountedSet#iterator#; |
| 38 | typedef typename ImplType::const_iterator const_iteratorcxx . . $ QTWTF/HashCountedSet#const_iterator#; |
| 39 | |
| 40 | HashCountedSetcxx . . $ QTWTF/HashCountedSet#`HashCountedSet<Value, HashFunctions, Traits>`(49f6e7a06ebc5aa8).() {} |
| 41 | |
| 42 | int sizecxx . . $ QTWTF/HashCountedSet#size(455f465bc33b4cdf).() const; |
| 43 | int capacitycxx . . $ QTWTF/HashCountedSet#capacity(455f465bc33b4cdf).() const; |
| 44 | bool isEmptycxx . . $ QTWTF/HashCountedSet#isEmpty(50ce9a9e25b4a850).() const; |
| 45 | |
| 46 | // iterators iterate over pairs of values and counts |
| 47 | iteratorcxx . . $ QTWTF/HashCountedSet#iterator# begincxx . . $ QTWTF/HashCountedSet#begin(b126dc7c1de90089).(); |
| 48 | iteratorcxx . . $ QTWTF/HashCountedSet#iterator# endcxx . . $ QTWTF/HashCountedSet#end(b126dc7c1de90089).(); |
| 49 | const_iteratorcxx . . $ QTWTF/HashCountedSet#const_iterator# begincxx . . $ QTWTF/HashCountedSet#begin(455f465bc33b4cdf).() const; |
| 50 | const_iteratorcxx . . $ QTWTF/HashCountedSet#const_iterator# endcxx . . $ QTWTF/HashCountedSet#end(455f465bc33b4cdf).() const; |
| 51 | |
| 52 | iteratorcxx . . $ QTWTF/HashCountedSet#iterator# findcxx . . $ QTWTF/HashCountedSet#find(dd8e59d271e40448).(const ValueTypecxx . . $ QTWTF/HashCountedSet#ValueType#&); |
| 53 | const_iteratorcxx . . $ QTWTF/HashCountedSet#const_iterator# findcxx . . $ QTWTF/HashCountedSet#find(c2b0757e04f7eab3).(const ValueTypecxx . . $ QTWTF/HashCountedSet#ValueType#&) const; |
| 54 | bool containscxx . . $ QTWTF/HashCountedSet#contains(8877ebe272b9620d).(const ValueTypecxx . . $ QTWTF/HashCountedSet#ValueType#&) const; |
| 55 | unsigned countcxx . . $ QTWTF/HashCountedSet#count(43679800656cdbcd).(const ValueTypecxx . . $ QTWTF/HashCountedSet#ValueType#&) const; |
| 56 | |
| 57 | // increases the count if an equal value is already present |
| 58 | // the return value is a pair of an interator to the new value's location, |
| 59 | // and a bool that is true if an new entry was added |
| 60 | stdcxx . . $ std/::paircxx . . $ std/pair#<iteratorcxx . . $ QTWTF/HashCountedSet#iterator#, bool> addcxx . . $ QTWTF/HashCountedSet#add(d27602b47f80864).(const ValueTypecxx . . $ QTWTF/HashCountedSet#ValueType#&); |
| 61 | |
| 62 | // reduces the count of the value, and removes it if count |
| 63 | // goes down to zero |
| 64 | void removecxx . . $ QTWTF/HashCountedSet#remove(77d9f17553126ecb).(const ValueTypecxx . . $ QTWTF/HashCountedSet#ValueType#&); |
| 65 | void removecxx . . $ QTWTF/HashCountedSet#remove(d4f767463ce0a6b3).(iteratorcxx . . $ QTWTF/HashCountedSet#iterator#); |
| 66 | |
| 67 | // removes the value, regardless of its count |
| 68 | void removeAllcxx . . $ QTWTF/HashCountedSet#removeAll(d4f767463ce0a6b3).(iteratorcxx . . $ QTWTF/HashCountedSet#iterator#); |
| 69 | void removeAllcxx . . $ QTWTF/HashCountedSet#removeAll(77d9f17553126ecb).(const ValueTypecxx . . $ QTWTF/HashCountedSet#ValueType#&); |
| 70 | |
| 71 | // clears the whole set |
| 72 | void clearcxx . . $ QTWTF/HashCountedSet#clear(49f6e7a06ebc5aa8).(); |
| 73 | |
| 74 | private: |
| 75 | ImplTypecxx . . $ QTWTF/HashCountedSet#ImplType# m_implcxx . . $ QTWTF/HashCountedSet#m_impl.; |
| 76 | }; |
| 77 | |
| 78 | template<typename Value, typename HashFunctions, typename Traits> |
| 79 | inline int HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::sizecxx . . $ QTWTF/HashCountedSet#size(455f465bc33b4cdf).() const |
| 80 | { |
| 81 | return m_implcxx . . $ QTWTF/HashCountedSet#m_impl..size(); |
| 82 | } |
| 83 | |
| 84 | template<typename Value, typename HashFunctions, typename Traits> |
| 85 | inline int HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::capacitycxx . . $ QTWTF/HashCountedSet#capacity(455f465bc33b4cdf).() const |
| 86 | { |
| 87 | return m_implcxx . . $ QTWTF/HashCountedSet#m_impl..capacity(); |
| 88 | } |
| 89 | |
| 90 | template<typename Value, typename HashFunctions, typename Traits> |
| 91 | inline bool HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::isEmptycxx . . $ QTWTF/HashCountedSet#isEmpty(50ce9a9e25b4a850).() const |
| 92 | { |
| 93 | return sizecxx . . $ QTWTF/HashCountedSet#size(455f465bc33b4cdf).() ==cxx . . $ QTWTF/`operator==`(8bba44cd2316e962). 0; |
| 94 | } |
| 95 | |
| 96 | template<typename Value, typename HashFunctions, typename Traits> |
| 97 | inline typename HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::iteratorcxx . . $ QTWTF/HashCountedSet#iterator# HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::begincxx . . $ QTWTF/HashCountedSet#begin(b126dc7c1de90089).() |
| 98 | { |
| 99 | return m_implcxx . . $ QTWTF/HashCountedSet#m_impl..begin(); |
| 100 | } |
| 101 | |
| 102 | template<typename Value, typename HashFunctions, typename Traits> |
| 103 | inline typename HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::iteratorcxx . . $ QTWTF/HashCountedSet#iterator# HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::endcxx . . $ QTWTF/HashCountedSet#end(b126dc7c1de90089).() |
| 104 | { |
| 105 | return m_implcxx . . $ QTWTF/HashCountedSet#m_impl..end(); |
| 106 | } |
| 107 | |
| 108 | template<typename Value, typename HashFunctions, typename Traits> |
| 109 | inline typename HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::const_iteratorcxx . . $ QTWTF/HashCountedSet#const_iterator# HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::begincxx . . $ QTWTF/HashCountedSet#begin(455f465bc33b4cdf).() const |
| 110 | { |
| 111 | return m_implcxx . . $ QTWTF/HashCountedSet#m_impl..begin(); |
| 112 | } |
| 113 | |
| 114 | template<typename Value, typename HashFunctions, typename Traits> |
| 115 | inline typename HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::const_iteratorcxx . . $ QTWTF/HashCountedSet#const_iterator# HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::endcxx . . $ QTWTF/HashCountedSet#end(455f465bc33b4cdf).() const |
| 116 | { |
| 117 | return m_implcxx . . $ QTWTF/HashCountedSet#m_impl..end(); |
| 118 | } |
| 119 | |
| 120 | template<typename Value, typename HashFunctions, typename Traits> |
| 121 | inline typename HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::iteratorcxx . . $ QTWTF/HashCountedSet#iterator# HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::findcxx . . $ QTWTF/HashCountedSet#find(dd8e59d271e40448).(const ValueTypecxx . . $ QTWTF/HashCountedSet#ValueType#& value) |
| 122 | { |
| 123 | return m_implcxx . . $ QTWTF/HashCountedSet#m_impl..find(value); |
| 124 | } |
| 125 | |
| 126 | template<typename Value, typename HashFunctions, typename Traits> |
| 127 | inline typename HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::const_iteratorcxx . . $ QTWTF/HashCountedSet#const_iterator# HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::findcxx . . $ QTWTF/HashCountedSet#find(c2b0757e04f7eab3).(const ValueTypecxx . . $ QTWTF/HashCountedSet#ValueType#& value) const |
| 128 | { |
| 129 | return m_implcxx . . $ QTWTF/HashCountedSet#m_impl..find(value); |
| 130 | } |
| 131 | |
| 132 | template<typename Value, typename HashFunctions, typename Traits> |
| 133 | inline bool HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::containscxx . . $ QTWTF/HashCountedSet#contains(8877ebe272b9620d).(const ValueTypecxx . . $ QTWTF/HashCountedSet#ValueType#& value) const |
| 134 | { |
| 135 | return m_implcxx . . $ QTWTF/HashCountedSet#m_impl..contains(value); |
| 136 | } |
| 137 | |
| 138 | template<typename Value, typename HashFunctions, typename Traits> |
| 139 | inline unsigned HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::countcxx . . $ QTWTF/HashCountedSet#count(43679800656cdbcd).(const ValueTypecxx . . $ QTWTF/HashCountedSet#ValueType#& value) const |
| 140 | { |
| 141 | return m_implcxx . . $ QTWTF/HashCountedSet#m_impl..get(value); |
| 142 | } |
| 143 | |
| 144 | template<typename Value, typename HashFunctions, typename Traits> |
| 145 | inline stdcxx . . $ std/::paircxx . . $ std/pair#<typename HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::iteratorcxx . . $ QTWTF/HashCountedSet#iterator#, bool> HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::addcxx . . $ QTWTF/HashCountedSet#add(d27602b47f80864).(const ValueTypecxx . . $ QTWTF/HashCountedSet#ValueType# &value) |
| 146 | { |
| 147 | paircxx . . $ QTWTF/pair#<iteratorcxx . . $ QTWTF/HashCountedSet#iterator#, bool> result = m_impl.add(value, 0); |
| 148 | ++result.first->second; |
| 149 | return result; |
| 150 | } |
| 151 | |
| 152 | template<typename Value, typename HashFunctions, typename Traits> |
| 153 | inline void HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::removecxx . . $ QTWTF/HashCountedSet#remove(77d9f17553126ecb).(const ValueTypecxx . . $ QTWTF/HashCountedSet#ValueType#& value) |
| 154 | { |
| 155 | removecxx . . $ QTWTF/HashCountedSet#remove(d4f767463ce0a6b3).(findcxx . . $ QTWTF/HashCountedSet#find(dd8e59d271e40448).(value)); |
| 156 | } |
| 157 | |
| 158 | template<typename Value, typename HashFunctions, typename Traits> |
| 159 | inline void HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::removecxx . . $ QTWTF/HashCountedSet#remove(d4f767463ce0a6b3).(iteratorcxx . . $ QTWTF/HashCountedSet#iterator# it) |
| 160 | { |
| 161 | if (it ==cxx . . $ QTWTF/`operator==`(b1a6445b02f80637). endcxx . . $ QTWTF/HashCountedSet#end(455f465bc33b4cdf).()) |
| 162 | return; |
| 163 | |
| 164 | unsigned oldVal = it->second; |
| 165 | ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(oldVal != 0); |
| 166 | unsigned newVal = oldVal - 1; |
| 167 | if (newVal == 0) |
| 168 | m_implcxx . . $ QTWTF/HashCountedSet#m_impl..remove(it); |
| 169 | else |
| 170 | it->second = newVal; |
| 171 | } |
| 172 | |
| 173 | template<typename Value, typename HashFunctions, typename Traits> |
| 174 | inline void HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::removeAllcxx . . $ QTWTF/HashCountedSet#removeAll(77d9f17553126ecb).(const ValueTypecxx . . $ QTWTF/HashCountedSet#ValueType#& value) |
| 175 | { |
| 176 | removeAllcxx . . $ QTWTF/HashCountedSet#removeAll(d4f767463ce0a6b3).(findcxx . . $ QTWTF/HashCountedSet#find(dd8e59d271e40448).(value)); |
| 177 | } |
| 178 | |
| 179 | template<typename Value, typename HashFunctions, typename Traits> |
| 180 | inline void HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::removeAllcxx . . $ QTWTF/HashCountedSet#removeAll(d4f767463ce0a6b3).(iteratorcxx . . $ QTWTF/HashCountedSet#iterator# it) |
| 181 | { |
| 182 | if (it ==cxx . . $ QTWTF/`operator==`(b1a6445b02f80637). endcxx . . $ QTWTF/HashCountedSet#end(455f465bc33b4cdf).()) |
| 183 | return; |
| 184 | |
| 185 | m_implcxx . . $ QTWTF/HashCountedSet#m_impl..remove(it); |
| 186 | } |
| 187 | |
| 188 | template<typename Value, typename HashFunctions, typename Traits> |
| 189 | inline void HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::clearcxx . . $ QTWTF/HashCountedSet#clear(49f6e7a06ebc5aa8).() |
| 190 | { |
| 191 | m_implcxx . . $ QTWTF/HashCountedSet#m_impl..clear(); |
| 192 | } |
| 193 | |
| 194 | template<typename Value, typename HashFunctions, typename Traits, typename VectorType> |
| 195 | inline void copyToVectorcxx . . $ QTWTF/copyToVector(d78b21ff400a0f20).(const HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>& collection, VectorType& vector) |
| 196 | { |
| 197 | typedef typename HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::const_iterator iteratorcxx . . $ QTWTF/copyToVector(d78b21ff400a0f20).iterator#; |
| 198 | |
| 199 | vector.resize(collection.sizecxx . . $ QTWTF/HashCountedSet#size(455f465bc33b4cdf).()); |
| 200 | |
| 201 | iteratorcxx . . $ QTWTF/copyToVector(d78b21ff400a0f20).iterator# it = collection.begincxx . . $ QTWTF/HashCountedSet#begin(455f465bc33b4cdf).(); |
| 202 | iteratorcxx . . $ QTWTF/copyToVector(d78b21ff400a0f20).iterator# end = collection.endcxx . . $ QTWTF/HashCountedSet#end(455f465bc33b4cdf).(); |
| 203 | for (unsigned i = 0; it !=cxx . . $ QTWTF/`operator!=`(533d91b32a0a6cc1). end; ++it, ++i) |
| 204 | vector[i] = *it; |
| 205 | } |
| 206 | |
| 207 | template<typename Value, typename HashFunctions, typename Traits> |
| 208 | inline void copyToVectorcxx . . $ QTWTF/copyToVector(b9b5bd7643b7d118).(const HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>& collection, Vector<Value>& vector) |
| 209 | { |
| 210 | typedef typename HashCountedSetcxx . . $ QTWTF/HashCountedSet#<Value, HashFunctions, Traits>::const_iterator iteratorcxx . . $ QTWTF/copyToVector(b9b5bd7643b7d118).iterator#; |
| 211 | |
| 212 | vector.resize(collection.sizecxx . . $ QTWTF/HashCountedSet#size(455f465bc33b4cdf).()); |
| 213 | |
| 214 | iteratorcxx . . $ QTWTF/copyToVector(b9b5bd7643b7d118).iterator# it = collection.begincxx . . $ QTWTF/HashCountedSet#begin(455f465bc33b4cdf).(); |
| 215 | iteratorcxx . . $ QTWTF/copyToVector(b9b5bd7643b7d118).iterator# end = collection.endcxx . . $ QTWTF/HashCountedSet#end(455f465bc33b4cdf).(); |
| 216 | for (unsigned i = 0; it !=cxx . . $ QTWTF/`operator!=`(71c3251785761d81). end; ++it, ++i) |
| 217 | vector[i] = (*it).first; |
| 218 | } |
| 219 | |
| 220 | |
| 221 | } // namespace khtml |
| 222 | |
| 223 | using WTFcxx . . $ QTWTF/::HashCountedSetcxx . . $ HashCountedSet#; |
| 224 | |
| 225 | #endif /* WTF_HashCountedSet_h */ |