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

Side by Side Diff: third_party/WebKit/Source/wtf/HashSet.h

Issue 2703833002: Migrate WTF::HashSet::remove() to ::erase() [part 2] (Closed)
Patch Set: Created 3 years, 10 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
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // static bool equal(const ValueType&, const T&); 101 // static bool equal(const ValueType&, const T&);
102 template <typename HashTranslator, typename T> 102 template <typename HashTranslator, typename T>
103 iterator find(const T&) const; 103 iterator find(const T&) const;
104 template <typename HashTranslator, typename T> 104 template <typename HashTranslator, typename T>
105 bool contains(const T&) const; 105 bool contains(const T&) const;
106 106
107 // The return value is a pair of an iterator to the new value's location, 107 // The return value is a pair of an iterator to the new value's location,
108 // and a bool that is true if an new entry was added. 108 // and a bool that is true if an new entry was added.
109 template <typename IncomingValueType> 109 template <typename IncomingValueType>
110 AddResult insert(IncomingValueType&&); 110 AddResult insert(IncomingValueType&&);
111 // TODO(pilgrim) remove this
112 // template <typename IncomingValueType>
113 // AddResult add(IncomingValueType&&);
114 111
115 // An alternate version of add() that finds the object by hashing and 112 // An alternate version of add() that finds the object by hashing and
116 // comparing with some other type, to avoid the cost of type conversion if 113 // comparing with some other type, to avoid the cost of type conversion if
117 // the object is already in the table. HashTranslator must have the 114 // the object is already in the table. HashTranslator must have the
118 // following function members: 115 // following function members:
119 // static unsigned hash(const T&); 116 // static unsigned hash(const T&);
120 // static bool equal(const ValueType&, const T&); 117 // static bool equal(const ValueType&, const T&);
121 // static translate(ValueType&, T&&, unsigned hashCode); 118 // static translate(ValueType&, T&&, unsigned hashCode);
122 template <typename HashTranslator, typename T> 119 template <typename HashTranslator, typename T>
123 AddResult addWithTranslator(T&&); 120 AddResult addWithTranslator(T&&);
124 121
125 void erase(ValuePeekInType); 122 void erase(ValuePeekInType);
126 void remove(iterator); 123 void erase(iterator);
127 void clear(); 124 void clear();
128 template <typename Collection> 125 template <typename Collection>
129 void removeAll(const Collection& toBeRemoved) { 126 void removeAll(const Collection& toBeRemoved) {
130 WTF::removeAll(*this, toBeRemoved); 127 WTF::removeAll(*this, toBeRemoved);
131 } 128 }
132 129
133 ValueType take(iterator); 130 ValueType take(iterator);
134 ValueType take(ValuePeekInType); 131 ValueType take(ValuePeekInType);
135 ValueType takeAny(); 132 ValueType takeAny();
136 133
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 inline typename HashSet<Value, HashFunctions, Traits, Allocator>::AddResult 265 inline typename HashSet<Value, HashFunctions, Traits, Allocator>::AddResult
269 HashSet<Value, HashFunctions, Traits, Allocator>::addWithTranslator(T&& value) { 266 HashSet<Value, HashFunctions, Traits, Allocator>::addWithTranslator(T&& value) {
270 // Forward only the first argument, because the second argument isn't actually 267 // Forward only the first argument, because the second argument isn't actually
271 // used in HashSetTranslatorAdapter. 268 // used in HashSetTranslatorAdapter.
272 return m_impl 269 return m_impl
273 .template addPassingHashCode<HashSetTranslatorAdapter<HashTranslator>>( 270 .template addPassingHashCode<HashSetTranslatorAdapter<HashTranslator>>(
274 std::forward<T>(value), value); 271 std::forward<T>(value), value);
275 } 272 }
276 273
277 template <typename T, typename U, typename V, typename W> 274 template <typename T, typename U, typename V, typename W>
278 inline void HashSet<T, U, V, W>::remove(iterator it) { 275 inline void HashSet<T, U, V, W>::erase(iterator it) {
279 m_impl.remove(it.m_impl); 276 m_impl.remove(it.m_impl);
280 } 277 }
281 278
282 template <typename T, typename U, typename V, typename W> 279 template <typename T, typename U, typename V, typename W>
283 inline void HashSet<T, U, V, W>::erase(ValuePeekInType value) { 280 inline void HashSet<T, U, V, W>::erase(ValuePeekInType value) {
284 remove(find(value)); 281 erase(find(value));
285 } 282 }
286 283
287 template <typename T, typename U, typename V, typename W> 284 template <typename T, typename U, typename V, typename W>
288 inline void HashSet<T, U, V, W>::clear() { 285 inline void HashSet<T, U, V, W>::clear() {
289 m_impl.clear(); 286 m_impl.clear();
290 } 287 }
291 288
292 template <typename T, typename U, typename V, typename W> 289 template <typename T, typename U, typename V, typename W>
293 inline auto HashSet<T, U, V, W>::take(iterator it) -> ValueType { 290 inline auto HashSet<T, U, V, W>::take(iterator it) -> ValueType {
294 if (it == end()) 291 if (it == end())
295 return ValueTraits::emptyValue(); 292 return ValueTraits::emptyValue();
296 293
297 ValueType result = std::move(const_cast<ValueType&>(*it)); 294 ValueType result = std::move(const_cast<ValueType&>(*it));
298 remove(it); 295 erase(it);
299 296
300 return result; 297 return result;
301 } 298 }
302 299
303 template <typename T, typename U, typename V, typename W> 300 template <typename T, typename U, typename V, typename W>
304 inline auto HashSet<T, U, V, W>::take(ValuePeekInType value) -> ValueType { 301 inline auto HashSet<T, U, V, W>::take(ValuePeekInType value) -> ValueType {
305 return take(find(value)); 302 return take(find(value));
306 } 303 }
307 304
308 template <typename T, typename U, typename V, typename W> 305 template <typename T, typename U, typename V, typename W>
(...skipping 15 matching lines...) Expand all
324 iterator end = collection.end(); 321 iterator end = collection.end();
325 for (unsigned i = 0; it != end; ++it, ++i) 322 for (unsigned i = 0; it != end; ++it, ++i)
326 vector[i] = *it; 323 vector[i] = *it;
327 } 324 }
328 325
329 } // namespace WTF 326 } // namespace WTF
330 327
331 using WTF::HashSet; 328 using WTF::HashSet;
332 329
333 #endif // WTF_HashSet_h 330 #endif // WTF_HashSet_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698