Last active
January 8, 2017 16:35
-
-
Save deque-blog/1a6b6063670964775c7c128a7c50ff0b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct VariationCount | |
{ | |
boost::optional<double> m_initial; | |
int m_count; | |
}; | |
struct CountVariationBiggerThan | |
{ | |
CountVariationBiggerThan(double limit) : m_limit(limit) {} | |
double m_limit; | |
VariationCount operator()() const { return VariationCount{}; } | |
VariationCount operator()(VariationCount gap, double val) const | |
{ | |
if (!gap.m_initial) | |
return VariationCount { val, 0 }; | |
if (abs(val - *gap.m_initial) > m_limit) | |
gap.m_count++; | |
return gap; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment