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

Side by Side 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: 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/web/AssociatedURLLoader.cpp ('k') | Source/wtf/HashSet.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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 AddResult set(KeyPeekInType, MappedPassInType); 119 AddResult set(KeyPeekInType, MappedPassInType);
120 120
121 // does nothing if key is already present 121 // does nothing if key is already present
122 // return value is a pair of the iterator to the key location, 122 // return value is a pair of the iterator to the key location,
123 // and a boolean that's true if a new value was actually added 123 // and a boolean that's true if a new value was actually added
124 AddResult add(KeyPeekInType, MappedPassInType); 124 AddResult add(KeyPeekInType, MappedPassInType);
125 125
126 void remove(KeyPeekInType); 126 void remove(KeyPeekInType);
127 void remove(iterator); 127 void remove(iterator);
128 void clear(); 128 void clear();
129 template<typename Collection>
130 void removeAll(const Collection& toBeRemoved) { WTF::removeAll(*this, to BeRemoved); }
129 131
130 MappedPassOutType take(KeyPeekInType); // efficient combination of get w ith remove 132 MappedPassOutType take(KeyPeekInType); // efficient combination of get w ith remove
131 133
132 // An alternate version of find() that finds the object by hashing and c omparing 134 // An alternate version of find() that finds the object by hashing and c omparing
133 // with some other type, to avoid the cost of type conversion. HashTrans lator 135 // with some other type, to avoid the cost of type conversion. HashTrans lator
134 // must have the following function members: 136 // must have the following function members:
135 // static unsigned hash(const T&); 137 // static unsigned hash(const T&);
136 // static bool equal(const ValueType&, const T&); 138 // static bool equal(const ValueType&, const T&);
137 template<typename HashTranslator, typename T> iterator find(const T&); 139 template<typename HashTranslator, typename T> iterator find(const T&);
138 template<typename HashTranslator, typename T> const_iterator find(const T&) const; 140 template<typename HashTranslator, typename T> const_iterator find(const T&) const;
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 iterator end = collection.end().values(); 509 iterator end = collection.end().values();
508 for (unsigned i = 0; it != end; ++it, ++i) 510 for (unsigned i = 0; it != end; ++it, ++i)
509 vector[i] = *it; 511 vector[i] = *it;
510 } 512 }
511 513
512 } // namespace WTF 514 } // namespace WTF
513 515
514 using WTF::HashMap; 516 using WTF::HashMap;
515 517
516 #endif /* WTF_HashMap_h */ 518 #endif /* WTF_HashMap_h */
OLDNEW
« 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