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

Side by Side Diff: Source/wtf/LinkedHashSet.h

Issue 256743005: Add removeAll method to sets and maps and use them (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Moved implementation of removeAll to HashTable.h and shared it. Also added it to LinkedHashSet 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/wtf/HashTable.h ('k') | Source/wtf/ListHashSet.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2011, Benjamin Poulain <ikipou@gmail.com> 3 * Copyright (C) 2011, Benjamin Poulain <ikipou@gmail.com>
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // Add the value to the beginning of the collection. If the value was alread y in 233 // Add the value to the beginning of the collection. If the value was alread y in
234 // the list, it is moved to the beginning. 234 // the list, it is moved to the beginning.
235 AddResult prependOrMoveToFirst(ValuePeekInType); 235 AddResult prependOrMoveToFirst(ValuePeekInType);
236 236
237 AddResult insertBefore(ValuePeekInType beforeValue, ValuePeekInType newValue ); 237 AddResult insertBefore(ValuePeekInType beforeValue, ValuePeekInType newValue );
238 AddResult insertBefore(iterator it, ValuePeekInType newValue) { return m_imp l.template add<NodeHashFunctions>(newValue, it.node()); } 238 AddResult insertBefore(iterator it, ValuePeekInType newValue) { return m_imp l.template add<NodeHashFunctions>(newValue, it.node()); }
239 239
240 void remove(ValuePeekInType); 240 void remove(ValuePeekInType);
241 void remove(iterator); 241 void remove(iterator);
242 void clear() { m_impl.clear(); } 242 void clear() { m_impl.clear(); }
243 template<typename Collection>
244 void removeAll(const Collection& other) { WTF::removeAll(*this, other); }
243 245
244 void trace(typename Allocator::Visitor* visitor) { m_impl.trace(visitor); } 246 void trace(typename Allocator::Visitor* visitor) { m_impl.trace(visitor); }
245 247
246 int64_t modifications() const { return m_impl.modifications(); } 248 int64_t modifications() const { return m_impl.modifications(); }
247 void checkModifications(int64_t mods) const { m_impl.checkModifications(mods ); } 249 void checkModifications(int64_t mods) const { m_impl.checkModifications(mods ); }
248 250
249 private: 251 private:
250 Node* anchor() { return reinterpret_cast<Node*>(&m_anchor); } 252 Node* anchor() { return reinterpret_cast<Node*>(&m_anchor); }
251 const Node* anchor() const { return reinterpret_cast<const Node*>(&m_anchor) ; } 253 const Node* anchor() const { return reinterpret_cast<const Node*>(&m_anchor) ; }
252 Node* firstNode() { return reinterpret_cast<Node*>(m_anchor.m_next); } 254 Node* firstNode() { return reinterpret_cast<Node*>(m_anchor.m_next); }
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 iterator end = set.end(); 707 iterator end = set.end();
706 for (iterator it = set.begin(); it != end; ++it) 708 for (iterator it = set.begin(); it != end; ++it)
707 delete *it; 709 delete *it;
708 } 710 }
709 711
710 } 712 }
711 713
712 using WTF::LinkedHashSet; 714 using WTF::LinkedHashSet;
713 715
714 #endif /* WTF_LinkedHashSet_h */ 716 #endif /* WTF_LinkedHashSet_h */
OLDNEW
« no previous file with comments | « Source/wtf/HashTable.h ('k') | Source/wtf/ListHashSet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698