std::set , . . , .
std::set - . std::less<Key> , Key - , ( Point). , operator <, . , , (std::less<Point> ), :
Point pt1(args);
Point pt2(args);
if (pt1 < pt2)
dosomething();
:
operator <
operator < Point. pt1 < pt2 , std::less<Point> . , x, y, :
struct Point
{
int x,y;
bool operator <(const Point& pt) const
{
return (x < pt.x) || ((!(pt.x < x)) && (y < pt.y));
}
};
, std::less<Point>. , , , .
struct CmpPoint
{
bool operator()(const Point& lhs, const Point& rhs) const
{
return (lhs.x < rhs.x) || ((!(rhs.x < lhs.x)) && (lhs.y < rhs.y));
}
};
std::set :
std::set<Point,CmpPoint> mySet;
-, : Point, .
operator <
, operator <. -. std::less<Point> .
bool operator <(const Point& lhs, const Point& rhs)
{
return (lhs.x < rhs.x) || ((!(rhs.x < lhs.x)) && (lhs.y < rhs.y));
}
, -, , . : operator <, std::less<Point>. , , .
; operator <. , Point . , . , .