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

Unified Diff: webrtc/base/analytics/percentile_filter.h

Issue 2512693002: Implement Theil-Sen's method for fitting a line to noisy data (used in bandwidth estimation). (Closed)
Patch Set: Remove PercentileFilter::Clear since no longer used. Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/base/analytics/percentile_filter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/analytics/percentile_filter.h
diff --git a/webrtc/base/analytics/percentile_filter.h b/webrtc/base/analytics/percentile_filter.h
index b3c8f8d1775f8df42b22b9a42d802ce454b9c1cb..7cfba5ad0039024e3de568de35cf81c4da361d57 100644
--- a/webrtc/base/analytics/percentile_filter.h
+++ b/webrtc/base/analytics/percentile_filter.h
@@ -33,9 +33,10 @@ class PercentileFilter {
// the size of the container.
void Insert(const T& value);
- // Remove one observation. The complexity of this operation is logarithmic in
- // the size of the container.
- void Erase(const T& value);
+ // Remove one observation or return false if |value| doesn't exist in the
+ // container. The complexity of this operation is logarithmic in the size of
+ // the container.
+ bool Erase(const T& value);
// Get the percentile value. The complexity of this operation is constant.
T GetPercentileValue() const;
@@ -76,11 +77,11 @@ void PercentileFilter<T>::Insert(const T& value) {
}
template <typename T>
-void PercentileFilter<T>::Erase(const T& value) {
+bool PercentileFilter<T>::Erase(const T& value) {
typename std::multiset<T>::const_iterator it = set_.lower_bound(value);
// Ignore erase operation if the element is not present in the current set.
if (it == set_.end() || *it != value)
- return;
+ return false;
if (it == percentile_it_) {
// If same iterator, update to the following element. Index is not
// affected.
@@ -92,6 +93,7 @@ void PercentileFilter<T>::Erase(const T& value) {
--percentile_index_;
}
UpdatePercentileIterator();
+ return true;
}
template <typename T>
« no previous file with comments | « no previous file | webrtc/base/analytics/percentile_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698