Changeset 56435 in webkit for trunk/JavaScriptCore/wtf/HashCountedSet.h
- Timestamp:
- Mar 24, 2010, 12:11:51 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/HashCountedSet.h
r48732 r56435 44 44 bool isEmpty() const; 45 45 46 // iterators iterate over pairs of values and counts46 // Iterators iterate over pairs of values and counts. 47 47 iterator begin(); 48 48 iterator end(); … … 55 55 unsigned count(const ValueType&) const; 56 56 57 // increases the count if an equal value is already present58 // 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 added57 // 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 59 // location, and a bool that is true if an new entry was added. 60 60 std::pair<iterator, bool> add(const ValueType&); 61 61 62 // reduces the count of the value, and removes it if count63 // goes down to zero 64 voidremove(const ValueType&);65 voidremove(iterator);62 // Reduces the count of the value, and removes it if count 63 // goes down to zero, returns true if the value is removed. 64 bool remove(const ValueType&); 65 bool remove(iterator); 66 66 67 // removes the value, regardless of its count67 // Removes the value, regardless of its count. 68 68 void removeAll(iterator); 69 69 void removeAll(const ValueType&); 70 70 71 // clears the whole set71 // Clears the whole set. 72 72 void clear(); 73 73 … … 151 151 152 152 template<typename Value, typename HashFunctions, typename Traits> 153 inline voidHashCountedSet<Value, HashFunctions, Traits>::remove(const ValueType& value)154 { 155 re move(find(value));156 } 157 158 template<typename Value, typename HashFunctions, typename Traits> 159 inline voidHashCountedSet<Value, HashFunctions, Traits>::remove(iterator it)153 inline bool HashCountedSet<Value, HashFunctions, Traits>::remove(const ValueType& value) 154 { 155 return remove(find(value)); 156 } 157 158 template<typename Value, typename HashFunctions, typename Traits> 159 inline bool HashCountedSet<Value, HashFunctions, Traits>::remove(iterator it) 160 160 { 161 161 if (it == end()) 162 return ;162 return false; 163 163 164 164 unsigned oldVal = it->second; 165 ASSERT(oldVal != 0);165 ASSERT(oldVal); 166 166 unsigned newVal = oldVal - 1; 167 if (newVal == 0) 168 m_impl.remove(it); 169 else 167 if (newVal) { 170 168 it->second = newVal; 169 return false; 170 } 171 172 m_impl.remove(it); 173 return true; 171 174 } 172 175
Note:
See TracChangeset
for help on using the changeset viewer.