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 using namespace std.
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.
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.
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.