I want to run the c++ function nth_element on a vector of structs but I'm not sure how to get it to work.
Here is my current code:
struct Point {
int x, y, color;
};
bool compareByY (const Point &a, const Point &b)
{
return a.y < b.y;
}
nth_element(points.begin(), points.size() + points.size()/2, points.end(), compareByY);
Aucun commentaire:
Enregistrer un commentaire