Chromium Code Reviews| Index: components/metrics/leak_detector/ranked_set.cc |
| diff --git a/components/metrics/leak_detector/ranked_set.cc b/components/metrics/leak_detector/ranked_set.cc |
| index 5725fb5c01c83cb6f2a0c456096402375c032355..d2cbd64e15d50deb17c60c60d96789f6330682c6 100644 |
| --- a/components/metrics/leak_detector/ranked_set.cc |
| +++ b/components/metrics/leak_detector/ranked_set.cc |
| @@ -48,5 +48,17 @@ void RankedSet::Add(const ValueType& value, int count) { |
| entries_.erase(--entries_.end()); |
| } |
| +RankedSet::const_iterator RankedSet::Find(const ValueType& value) const { |
| + // Due to the unusual way the entries are stored, it is best to manually |
| + // iterate through them until an entry with a matching value is found. |
| + // e.g. std::find() would not work because it depends on exact matching by the |
| + // whole Entry struct. |
|
Will Harris
2016/04/09 20:10:23
can't you just implement the operators in Entry ra
Simon Que
2016/04/09 21:04:11
The operator would have to look something like:
Will Harris
2016/04/11 17:26:37
I think as long as it's commented (perhaps explain
Simon Que
2016/04/11 18:41:08
Done.
|
| + for (const_iterator iter = begin(); iter != end(); ++iter) { |
| + if (iter->value == value) |
| + return iter; |
| + } |
| + return end(); |
| +} |
| + |
| } // namespace leak_detector |
| } // namespace metrics |