comparison data/model/RangeSummarisableTimeValueModel.h @ 1053:48e4ffa9fb48 cxx11

Minor simplification; could use more
author Chris Cannam
date Wed, 11 Mar 2015 11:52:05 +0000
parents cc27f35aa75c
children 54af1e21705c
comparison
equal deleted inserted replaced
1052:e603b44510c3 1053:48e4ffa9fb48
39 39
40 class Range 40 class Range
41 { 41 {
42 public: 42 public:
43 Range() : 43 Range() :
44 m_min(0.f), m_max(0.f), m_absmean(0.f) { } 44 m_new(true), m_min(0.f), m_max(0.f), m_absmean(0.f) { }
45 Range(const Range &r) : 45 Range(const Range &r) :
46 m_min(r.m_min), m_max(r.m_max), m_absmean(r.m_absmean) { } 46 m_new(true), m_min(r.m_min), m_max(r.m_max), m_absmean(r.m_absmean) { }
47 Range(float min, float max, float absmean) : 47 Range(float min, float max, float absmean) :
48 m_min(min), m_max(max), m_absmean(absmean) { } 48 m_new(true), m_min(min), m_max(max), m_absmean(absmean) { }
49 49
50 float min() const { return m_min; } 50 float min() const { return m_min; }
51 float max() const { return m_max; } 51 float max() const { return m_max; }
52 float absmean() const { return m_absmean; } 52 float absmean() const { return m_absmean; }
53 53
54 void setMin(float min) { m_min = min; } 54 void setMin(float min) { m_min = min; m_new = false; }
55 void setMax(float max) { m_max = max; } 55 void setMax(float max) { m_max = max; m_new = false; }
56 void setAbsmean(float absmean) { m_absmean = absmean; } 56 void setAbsmean(float absmean) { m_absmean = absmean; }
57 57
58 void sample(float s) {
59 if (m_new) {
60 m_min = s;
61 m_max = s;
62 m_new = false;
63 } else {
64 if (s < m_min) m_min = s;
65 if (s > m_max) m_max = s;
66 }
67 }
68
58 private: 69 private:
70 bool m_new;
59 float m_min; 71 float m_min;
60 float m_max; 72 float m_max;
61 float m_absmean; 73 float m_absmean;
62 }; 74 };
63 75