I have two vectors , each with (x, y) coordinates. I need to invert the second vector , getting with (y, x) and merge with the first, but I can not get repetition in the first field, so I thought I'd use a set .
However, I need the second value of the structure to always be as large as possible. For example, if I have the following values: {(3, 2); (3, 10)}
, I need to set the pair (3,10) on the set.
Is it possible to do this with set?
Pseudo-code example:
vector<pair<int, int> > vector1 = {(10, 2); (10, 1); (3, 7)};
vector<pair<int, int> > vector2 = {(1, 3); (9, 10)};
Inverting the coordinates of the second vector, it would look like:
vector2 = {(3, 1); (10, 9)};
When merging with the first vector, I want the values of the first field to be unique, while the values of the second field are always the largest. In case I wanted a set with the following values:
set1<pair<int, int> > set1 = {(10, 9); (3, 7)};