I am trying to implement Graham scan, and I want to do something like this:
private static void sortByPolar(Point[] points, Point r) {
Arrays.sort(points, (p, q) -> {
int compPolar = ccw(p, r, q);
int compDist = dist(p, r) - dist(q, r);
return compPolar == 0 ? compDist : compPolar;
});
where Point r is the bottommost point. However, I am struggling to implement this same idea in c++ because I can only pass in the function of compar and I don't know how that can access the lowest point.
struct compar {
vector<vector<int>> lowest;
bool operator()(vector<int> const& a, vector<int> const& b) {
cout<<lowest[0]<<endl; // throws an error, how do I get this function access to lowest?
return // TODO;
}
};
// in another function:
sort(points.begin(), points.end(), compar());