G
Giulio Veronesi
Hi all,
struct MyStruct {
int x, y;
};
bool operator<(const MyStruct& a1, const MyStruct& a2)
{
return ( (a1.x < a2.x) ||
( (a1.x == a2.x) && (a2.y < a2.y) ) );
}
typedef set<MyStruct> MySet;
Which other operators have I to overload to manage MySet? More
precisaly, when I insert something in the set, if the x field is equal
to another x field of another structure previous inserted in the set,
the second one is not inserted. I would like that a structure is not
inserted if and only if both its x and y filed are equals to x and y of
another structure in the set.
Thanks in advance,
Giulio
struct MyStruct {
int x, y;
};
bool operator<(const MyStruct& a1, const MyStruct& a2)
{
return ( (a1.x < a2.x) ||
( (a1.x == a2.x) && (a2.y < a2.y) ) );
}
typedef set<MyStruct> MySet;
Which other operators have I to overload to manage MySet? More
precisaly, when I insert something in the set, if the x field is equal
to another x field of another structure previous inserted in the set,
the second one is not inserted. I would like that a structure is not
inserted if and only if both its x and y filed are equals to x and y of
another structure in the set.
Thanks in advance,
Giulio