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

Unified Diff: Source/wtf/ListHashSet.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/ListHashSet.h
diff --git a/Source/wtf/ListHashSet.h b/Source/wtf/ListHashSet.h
index f1624dc359e89877301233181e522c994fe237fd..b08057f5e2312a54f7aa20cc1baf1780728a6d38 100644
--- a/Source/wtf/ListHashSet.h
+++ b/Source/wtf/ListHashSet.h
@@ -156,6 +156,8 @@ namespace WTF {
void remove(ValuePeekInType);
void remove(iterator);
void clear();
+ template<typename Collection>
+ void removeAll(const Collection& other);
private:
void unlink(Node*);
@@ -838,6 +840,18 @@ namespace WTF {
}
template<typename T, size_t inlineCapacity, typename U>
+ template<typename Collection>
+ inline void ListHashSet<T, inlineCapacity, U>::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, size_t inlineCapacity, typename U>
void ListHashSet<T, inlineCapacity, U>::unlink(Node* node)
{
if (!node->m_prev) {

Powered by Google App Engine
This is Rietveld 408576698