5
I have two Vectors, each with coordinates (x,y). I need to reverse the second vector, getting with (y, x) and merging with the first, but I can’t get repeat in the first field, so I thought I’d use a set.
However, I need the second value of the structure to be as large as possible. For example, if I have the following values: {(3, 2); (3, 10)}
, I need the pair to stay on the set (3,10).
It is possible to do this with set?
Example in pseudo-code:
vector<pair<int, int> > vector1 = {(10, 2); (10, 1); (3, 7)};
vector<pair<int, int> > vector2 = {(1, 3); (9, 10)};
Reversing the coordinates of the second vector would be with:
vector2 = {(3, 1); (10, 9)};
When mixing with the first vector, I want the values of the first field to be unique, while the values of the second are always the greatest. In case I wanted a set with the following values:
set1<pair<int, int> > set1 = {(10, 9); (3, 7)};
Your doubt is unclear. By vector and set you refer to
std::vector
andstd::set
? Can show an example of code?– Guilherme Bernal
Yes, William. I edited the post to try to explain the doubt better.
– user6635