Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Unified Diff: Source/wtf/HashSet.h

Issue 256743005: Add removeAll method to sets and maps and use them (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/wtf/HashSet.h
diff --git a/Source/wtf/HashSet.h b/Source/wtf/HashSet.h
index 090f1cf589c60a5cfb82ec99c8b7ad30e8589f28..02c099f947f128faf32e2ccc739ce199213eafd7 100644
--- a/Source/wtf/HashSet.h
+++ b/Source/wtf/HashSet.h
@@ -99,6 +99,8 @@ namespace WTF {
void remove(ValuePeekInType);
void remove(iterator);
void clear();
+ template<typename Collection>
+ void removeAll(const Collection& other);
static bool isValidValue(ValuePeekInType);
@@ -218,6 +220,18 @@ namespace WTF {
}
template<typename T, typename U, typename V, typename W>
+ template<typename Collection>
+ inline void HashSet<T, U, V, W>::removeAll(const Collection& other)
+ {
+ if (other.isEmpty() || isEmpty())
+ return;
+ typedef typename Collection::const_iterator CollectionIterator;
+ CollectionIterator otherEnd(other.end());
+ for (CollectionIterator it(other.begin()); it != otherEnd; ++it)
+ remove(*it);
+ }
+
+ template<typename T, typename U, typename V, typename W>
inline bool HashSet<T, U, V, W>::isValidValue(ValuePeekInType value)
{
if (ValueTraits::isDeletedValue(value))
« Source/wtf/HashMap.h ('K') | « Source/wtf/HashMap.h ('k') | Source/wtf/ListHashSet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698