I am using struct as key value in mapping but it does not give desired result. I want to check collision while mapping elements of a structure. i.e. if i already have mapped same set of value show that there is a collision but it does not. what am i missing here
#include<iostream>
#include<map>
using namespace::std;
struct array{
int x,y,t;
friend bool operator < (const array& m,const array& n)
{ return (m.t<=n.t); }
}a[10];
int main(){
map<array, bool> m;
int i;
for (i=0;i<10;i++){
cin>>a[i].x>>a[i].y;
a[i].t=a[i].x+a[i].y;
// before mapping i check if i have already mapped a struct variable with same value
//i.e. collision than stop else map it
if(m[a[i]]){ cout<<"collision"; break;}
else m[a[i]]=1;
}
// this loop should print 1 if mapping of a[i] is done, else 0. and it always print zero :(
for(i=0;i<10;i++) cout<<m[a[i]];
}