| 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..f8945d7014030ee250d1280eeeafa0e96154ed86 100644
|
| --- a/components/metrics/leak_detector/ranked_set.cc
|
| +++ b/components/metrics/leak_detector/ranked_set.cc
|
| @@ -48,5 +48,20 @@ void RankedSet::Add(const ValueType& value, int count) {
|
| entries_.erase(--entries_.end());
|
| }
|
|
|
| +RankedSet::const_iterator RankedSet::Find(const ValueType& value) const {
|
| + // The entries are stored sorted by |count|, but this function looks for an
|
| + // entry with a particular |value| field. Thus, std::set::find() will not
|
| + // work. Nor would std::find(), which matches by both |count| and |value| --
|
| + // the count is unknown to the caller of this function.
|
| + //
|
| + // The most straightforward way is to iterate through the set until a matching
|
| + // value is found.
|
| + for (const_iterator iter = begin(); iter != end(); ++iter) {
|
| + if (iter->value == value)
|
| + return iter;
|
| + }
|
| + return end();
|
| +}
|
| +
|
| } // namespace leak_detector
|
| } // namespace metrics
|
|
|