I have a map which I have declared as follows:
map<int, bool> index; and I insert values into the map as:
int x; cin>>x; index[x]=true; However,
cout<<index[y]; // for any number y not inindexgives me 0
- As I get the value
0when I check for a key which is not present in the map, how can I reliably find out if a key is present in the map or not? - I'm using a map for trying to find out if two sets are disjoint or not, and for the same I am using a map, and two vectors to store the input. Is this shabby in any way? Some other data structure I should be using?