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) |
{ |