OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_RTC_BASE_MOVING_MAX_COUNTER_H_ | 11 #ifndef WEBRTC_RTC_BASE_MOVING_MAX_COUNTER_H_ |
12 #define WEBRTC_RTC_BASE_MOVING_MAX_COUNTER_H_ | 12 #define WEBRTC_RTC_BASE_MOVING_MAX_COUNTER_H_ |
13 | 13 |
14 #include <stdint.h> | 14 #include <stdint.h> |
15 | 15 |
16 #include <deque> | 16 #include <deque> |
17 #include <limits> | 17 #include <limits> |
18 #include <utility> | 18 #include <utility> |
19 | 19 |
| 20 #include "webrtc/api/optional.h" |
20 #include "webrtc/rtc_base/checks.h" | 21 #include "webrtc/rtc_base/checks.h" |
21 #include "webrtc/rtc_base/constructormagic.h" | 22 #include "webrtc/rtc_base/constructormagic.h" |
22 #include "webrtc/rtc_base/optional.h" | |
23 | 23 |
24 namespace rtc { | 24 namespace rtc { |
25 | 25 |
26 // Implements moving max: can add samples to it and calculate maximum over some | 26 // Implements moving max: can add samples to it and calculate maximum over some |
27 // fixed moving window. | 27 // fixed moving window. |
28 // | 28 // |
29 // Window size is configured at constructor. | 29 // Window size is configured at constructor. |
30 // Samples can be added with |Add()| and max over current window is returned by | 30 // Samples can be added with |Add()| and max over current window is returned by |
31 // |MovingMax|. |current_time_ms| in successive calls to Add and MovingMax | 31 // |MovingMax|. |current_time_ms| in successive calls to Add and MovingMax |
32 // should never decrease as if it's a wallclock time. | 32 // should never decrease as if it's a wallclock time. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 auto it = samples_.begin(); | 107 auto it = samples_.begin(); |
108 while (it != samples_.end() && it->first < window_begin_ms) { | 108 while (it != samples_.end() && it->first < window_begin_ms) { |
109 ++it; | 109 ++it; |
110 } | 110 } |
111 samples_.erase(samples_.begin(), it); | 111 samples_.erase(samples_.begin(), it); |
112 } | 112 } |
113 | 113 |
114 } // namespace rtc | 114 } // namespace rtc |
115 | 115 |
116 #endif // WEBRTC_RTC_BASE_MOVING_MAX_COUNTER_H_ | 116 #endif // WEBRTC_RTC_BASE_MOVING_MAX_COUNTER_H_ |
OLD | NEW |