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

Side by Side 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: 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/HashMap.h ('k') | Source/wtf/HashTable.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 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // with some other type, to avoid the cost of type conversion if the obj ect is already 92 // with some other type, to avoid the cost of type conversion if the obj ect is already
93 // in the table. HashTranslator must have the following function members : 93 // in the table. HashTranslator must have the following function members :
94 // static unsigned hash(const T&); 94 // static unsigned hash(const T&);
95 // static bool equal(const ValueType&, const T&); 95 // static bool equal(const ValueType&, const T&);
96 // static translate(ValueType&, const T&, unsigned hashCode); 96 // static translate(ValueType&, const T&, unsigned hashCode);
97 template<typename HashTranslator, typename T> AddResult add(const T&); 97 template<typename HashTranslator, typename T> AddResult add(const T&);
98 98
99 void remove(ValuePeekInType); 99 void remove(ValuePeekInType);
100 void remove(iterator); 100 void remove(iterator);
101 void clear(); 101 void clear();
102 template<typename Collection>
103 void removeAll(const Collection& toBeRemoved) { WTF::removeAll(*this, to BeRemoved); }
102 104
103 static bool isValidValue(ValuePeekInType); 105 static bool isValidValue(ValuePeekInType);
104 106
105 void trace(typename Allocator::Visitor* visitor) 107 void trace(typename Allocator::Visitor* visitor)
106 { 108 {
107 m_impl.trace(visitor); 109 m_impl.trace(visitor);
108 } 110 }
109 111
110 private: 112 private:
111 friend void deleteAllValues<>(const HashSet&); 113 friend void deleteAllValues<>(const HashSet&);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 iterator end = collection.end(); 262 iterator end = collection.end();
261 for (unsigned i = 0; it != end; ++it, ++i) 263 for (unsigned i = 0; it != end; ++it, ++i)
262 vector[i] = *it; 264 vector[i] = *it;
263 } 265 }
264 266
265 } // namespace WTF 267 } // namespace WTF
266 268
267 using WTF::HashSet; 269 using WTF::HashSet;
268 270
269 #endif /* WTF_HashSet_h */ 271 #endif /* WTF_HashSet_h */
OLDNEW
« no previous file with comments | « Source/wtf/HashMap.h ('k') | Source/wtf/HashTable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698