Maybe the code is clearer with an std::find_ifexplicit predicate?
class further_away_than
{
double dist;
public:
further_away_than(double dist) : dist(dist) {}
bool operator()(const pair<int, double>& p)
{
return p.second > dist;
}
};
#include <algorithm>
i = find_if(nabors.begin(), nabors.end(), further_away_than(dist));
I don’t know, I'm just a fan of STL :)
source
share