Is there built in method to remove duplicates of pair vector if 2 pairs, {x,y} and {y,x} are also considered as duplicate?
for example,if I have vector like it:
{{1,2},{4,3},{2,1},{5,6},{1,2},{3,4},{0,1}}
I want to remove duplicate to become:
{{1,2},{4,3},{5,6},{0,1}}
is there any built in function to handle the case that {x,y} and {y,x} are identical?
If not, what is the simplest way to do this?
I considered to use for loop something like that but not works:
vector<int> isRemove;
int count=0;
for(pair<int,int> a : p){
isRemove.push_back(0);
for(pair<int,int> b : p){
if((a.first==b.first && a.second==b.second) || (a.first==b.second && a.second==b.first)){
isRemove[count]=1;
break;
}
}
count++;
}
for(int i=isRemove.size()-1;i>=0;i--){
printf("%d\n",isRemove[i]);
if(isRemove[i]){
p.erase(p.begin()+i);
}
}
is there any simpler method else?