Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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