What exactly does lower bound imply?
If I had to guess, I'd say this function returns the iterator at the last element with a value less than the one requested.
However, I notice that lower bound is nearly identical to upper bound.
In the case of upper bound, the only difference is strict inequality.
Is there a true lower bound selection function in stl that agrees with the traditional definition of the term?
EDIT: I was perplexed by the docs because there were too many negations.
The issue was that I kept getting the same iterator.
By subtracting 1 from the lower bound return value, I was able to solve the problem.
It's what I use for interpolation:
float operator()(double f) { SpectrumPoint* l=std::lower_bound(beginGet(),endGet(),(SpectrumPoint){float(f),0.0f} ,SpectrumPoint::CompareFreqLessThan); if(l>beginGet()) {--l;} SpectrumPoint* u=std::lower_bound(beginGet(),endGet(),(SpectrumPoint){float(f),0.0f} ,SpectrumPoint::CompareFreqLessThan); if(u==endGet()) {u=beginGet();} if(l==u) { if(u==endGet()) {return u->amp;} return l->amp; } double f_min=l->freq; double A_min=l->amp; double f_max=u->freq; double A_max=u->amp; double delta_f=f_max-f_min; double delta_A=A_max-A_min; return A_min + delta_A*(f-f_min)/delta_f; }