2 of 2
replaced http://stackoverflow.com/ with https://stackoverflow.com/
ByDistance
looks very ad-hoc. If you movedist
toPoint
(where it really belongs) as a member function,ByDistance
is not required at all, e.g:temp.erase(remove_if(temp.begin(), temp.end(), [&reference, distanceThreshold](Point& p){ return reference.dist(p > distanceThreshold; }), temp.end());
and
sort(temp.begin(), temp.end(), [&reference](const Point& p1, const Point& p2) { return reference.dist(p1) < reference.dist(p2); }); );
I don't see a need to create yet another
vector
withvector<Point> result(sz);
You may reuse
temp
withtemp.resize()
instead.Mandatory advisory against using namespace std.
vnp
- 58.7k
- 4
- 55
- 144
default