A
Allerdyce.John
I have a vector of Pair of int:
typedef pair<int, int> MyPair;
typedef vector <MyPair > MyVector
I would like to remove entries if their first are equal, or if their
value is swap ( first of first pair equals to seconds of second pair):
bool equals(MyPair src, MyPair dest ) {
if (( src.first == dest.first) && ( src.second == dest.second))
return true;
if (( src.first == dest.second) && ( src.second == dest.first))
return true;
return false;
}
I think I want to use the 'unique' algorithm and use the above 'equals'
function as the binary predicate.
But before I use the 'unique' algorithm, I need to sort my list. But
for my purpose, I am not sure how to sort my list. base on the 'first'
value? or base on the second value?
Thank you for any pointers.
typedef pair<int, int> MyPair;
typedef vector <MyPair > MyVector
I would like to remove entries if their first are equal, or if their
value is swap ( first of first pair equals to seconds of second pair):
bool equals(MyPair src, MyPair dest ) {
if (( src.first == dest.first) && ( src.second == dest.second))
return true;
if (( src.first == dest.second) && ( src.second == dest.first))
return true;
return false;
}
I think I want to use the 'unique' algorithm and use the above 'equals'
function as the binary predicate.
But before I use the 'unique' algorithm, I need to sort my list. But
for my purpose, I am not sure how to sort my list. base on the 'first'
value? or base on the second value?
Thank you for any pointers.