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

Side by Side Diff: third_party/WebKit/Source/platform/wtf/HashCountedSet.h

Issue 2799573003: Migrate WTF::HashCountedSet::remove() to ::erase() (Closed)
Patch Set: Created 3 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
« no previous file with comments | « third_party/WebKit/Source/platform/loader/fetch/Resource.cpp ('k') | no next file » | 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, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // Increases the count if an equal value is already present the return value 86 // Increases the count if an equal value is already present the return value
87 // is a pair of an iterator to the new value's location, and a bool that is 87 // is a pair of an iterator to the new value's location, and a bool that is
88 // true if an new entry was added. 88 // true if an new entry was added.
89 AddResult insert(const ValueType&); 89 AddResult insert(const ValueType&);
90 90
91 // Generalized add(), adding the value N times. 91 // Generalized add(), adding the value N times.
92 AddResult insert(const ValueType&, unsigned); 92 AddResult insert(const ValueType&, unsigned);
93 93
94 // Reduces the count of the value, and removes it if count goes down to 94 // Reduces the count of the value, and removes it if count goes down to
95 // zero, returns true if the value is removed. 95 // zero, returns true if the value is removed.
96 bool remove(const ValueType& value) { return remove(find(value)); } 96 bool erase(const ValueType& value) { return erase(find(value)); }
97 bool remove(iterator); 97 bool erase(iterator);
98 98
99 // Removes the value, regardless of its count. 99 // Removes the value, regardless of its count.
100 void removeAll(const ValueType& value) { removeAll(find(value)); } 100 void removeAll(const ValueType& value) { removeAll(find(value)); }
101 void removeAll(iterator); 101 void removeAll(iterator);
102 102
103 // Clears the whole set. 103 // Clears the whole set.
104 void clear() { m_impl.clear(); } 104 void clear() { m_impl.clear(); }
105 105
106 Vector<Value> asVector() const; 106 Vector<Value> asVector() const;
107 107
(...skipping 15 matching lines...) Expand all
123 return result; 123 return result;
124 } 124 }
125 125
126 template <typename T, typename U, typename V, typename W> 126 template <typename T, typename U, typename V, typename W>
127 inline typename HashCountedSet<T, U, V, W>::AddResult 127 inline typename HashCountedSet<T, U, V, W>::AddResult
128 HashCountedSet<T, U, V, W>::insert(const ValueType& value) { 128 HashCountedSet<T, U, V, W>::insert(const ValueType& value) {
129 return insert(value, 1u); 129 return insert(value, 1u);
130 } 130 }
131 131
132 template <typename T, typename U, typename V, typename W> 132 template <typename T, typename U, typename V, typename W>
133 inline bool HashCountedSet<T, U, V, W>::remove(iterator it) { 133 inline bool HashCountedSet<T, U, V, W>::erase(iterator it) {
134 if (it == end()) 134 if (it == end())
135 return false; 135 return false;
136 136
137 unsigned oldVal = it->value; 137 unsigned oldVal = it->value;
138 DCHECK(oldVal); 138 DCHECK(oldVal);
139 unsigned newVal = oldVal - 1; 139 unsigned newVal = oldVal - 1;
140 if (newVal) { 140 if (newVal) {
141 it->value = newVal; 141 it->value = newVal;
142 return false; 142 return false;
143 } 143 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 Vector<T> vector; 179 Vector<T> vector;
180 copyToVector(*this, vector); 180 copyToVector(*this, vector);
181 return vector; 181 return vector;
182 } 182 }
183 183
184 } // namespace WTF 184 } // namespace WTF
185 185
186 using WTF::HashCountedSet; 186 using WTF::HashCountedSet;
187 187
188 #endif // WTF_HashCountedSet_h 188 #endif // WTF_HashCountedSet_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/loader/fetch/Resource.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698