Overte C++ Documentation
MovingPercentile.h
1 //
2 // MovingPercentile.h
3 // libraries/shared/src
4 //
5 // Created by Yixin Wang on 6/4/2014
6 //
7 // Distributed under the Apache License, Version 2.0.
8 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
9 //
10 
11 #ifndef hifi_MovingPercentile_h
12 #define hifi_MovingPercentile_h
13 
14 #include <qlist.h>
15 
16 class MovingPercentile {
17 
18 public:
19  MovingPercentile(int numSamples, float percentile = 0.5f);
20 
21  void updatePercentile(qint64 sample);
22  qint64 getValueAtPercentile() const { return _valueAtPercentile; }
23 
24 private:
25  const int _numSamples;
26  const float _percentile;
27 
28  QList<qint64> _samplesSorted;
29  QList<int> _sampleIds; // incrementally assigned, is cyclic
30  int _newSampleId;
31 
32  int _indexOfPercentile;
33  qint64 _valueAtPercentile;
34 };
35 
36 #endif