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

Unified Diff: Source/wtf/HashMap.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
« no previous file with comments | « Source/web/AssociatedURLLoader.cpp ('k') | Source/wtf/HashSet.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/HashMap.h
diff --git a/Source/wtf/HashMap.h b/Source/wtf/HashMap.h
index dd15c3d4f308ad1440dd113f8f66fcfa3ed81a32..035c88b54da64b2c23b3801b040c30bc9b2e4216 100644
--- a/Source/wtf/HashMap.h
+++ b/Source/wtf/HashMap.h
@@ -126,6 +126,8 @@ namespace WTF {
void remove(KeyPeekInType);
void remove(iterator);
void clear();
+ template<typename Collection>
+ void removeAll(const Collection& other);
MappedPassOutType take(KeyPeekInType); // efficient combination of get with remove
@@ -412,6 +414,18 @@ namespace WTF {
}
template<typename T, typename U, typename V, typename W, typename X, typename Y>
+ template<typename Collection>
+ inline void HashMap<T, U, V, W, X, Y>::removeAll(const Collection& other)
Mikhail 2014/04/25 11:02:26 I'm a bit concerned that this code is repeated at
Erik Corry 2014/04/25 12:00:31 Done.
+ {
+ 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, typename X, typename Y>
typename HashMap<T, U, V, W, X, Y>::MappedPassOutType
HashMap<T, U, V, W, X, Y>::take(KeyPeekInType key)
{
« no previous file with comments | « Source/web/AssociatedURLLoader.cpp ('k') | Source/wtf/HashSet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698