diff options
author | Jocelyn Turcotte <jocelyn.turcotte@nokia.com> | 2010-04-06 10:36:47 (GMT) |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@nokia.com> | 2010-04-06 10:36:47 (GMT) |
commit | bb35b65bbfba82e0dd0ac306d3dab54436cdaff6 (patch) | |
tree | 8174cb262a960ff7b2e4aa8f1aaf154db71d2636 /src/3rdparty/webkit/JavaScriptCore/wtf/HashCountedSet.h | |
parent | 4b27d0d887269583a0f76e922948f8c25e96ab88 (diff) | |
download | Qt-bb35b65bbfba82e0dd0ac306d3dab54436cdaff6.zip Qt-bb35b65bbfba82e0dd0ac306d3dab54436cdaff6.tar.gz Qt-bb35b65bbfba82e0dd0ac306d3dab54436cdaff6.tar.bz2 |
Update src/3rdparty/webkit from trunk.
Imported from 839d8709327f925aacb3b6362c06152594def97e
in branch qtwebkit-2.0 of repository
git://gitorious.org/+qtwebkit-developers/webkit/qtwebkit.git
Rubber-stamped-by: Simon Hausmann
Diffstat (limited to 'src/3rdparty/webkit/JavaScriptCore/wtf/HashCountedSet.h')
-rw-r--r-- | src/3rdparty/webkit/JavaScriptCore/wtf/HashCountedSet.h | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/HashCountedSet.h b/src/3rdparty/webkit/JavaScriptCore/wtf/HashCountedSet.h index 165eb41..4ed75c5 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/HashCountedSet.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/HashCountedSet.h @@ -43,7 +43,7 @@ namespace WTF { int capacity() const; bool isEmpty() const; - // iterators iterate over pairs of values and counts + // Iterators iterate over pairs of values and counts. iterator begin(); iterator end(); const_iterator begin() const; @@ -54,21 +54,21 @@ namespace WTF { bool contains(const ValueType&) const; unsigned count(const ValueType&) const; - // increases the count if an equal value is already present - // the return value is a pair of an interator to the new value's location, - // and a bool that is true if an new entry was added + // Increases the count if an equal value is already present + // the return value is a pair of an interator to the new value's + // location, and a bool that is true if an new entry was added. std::pair<iterator, bool> add(const ValueType&); - // reduces the count of the value, and removes it if count - // goes down to zero - void remove(const ValueType&); - void remove(iterator); + // Reduces the count of the value, and removes it if count + // goes down to zero, returns true if the value is removed. + bool remove(const ValueType&); + bool remove(iterator); - // removes the value, regardless of its count + // Removes the value, regardless of its count. void removeAll(iterator); void removeAll(const ValueType&); - // clears the whole set + // Clears the whole set. void clear(); private: @@ -150,24 +150,27 @@ namespace WTF { } template<typename Value, typename HashFunctions, typename Traits> - inline void HashCountedSet<Value, HashFunctions, Traits>::remove(const ValueType& value) + inline bool HashCountedSet<Value, HashFunctions, Traits>::remove(const ValueType& value) { - remove(find(value)); + return remove(find(value)); } template<typename Value, typename HashFunctions, typename Traits> - inline void HashCountedSet<Value, HashFunctions, Traits>::remove(iterator it) + inline bool HashCountedSet<Value, HashFunctions, Traits>::remove(iterator it) { if (it == end()) - return; + return false; unsigned oldVal = it->second; - ASSERT(oldVal != 0); + ASSERT(oldVal); unsigned newVal = oldVal - 1; - if (newVal == 0) - m_impl.remove(it); - else + if (newVal) { it->second = newVal; + return false; + } + + m_impl.remove(it); + return true; } template<typename Value, typename HashFunctions, typename Traits> |