Map
map is same as python dictionary .
Function-
insert()-
map<int, int> m;
m.insert(pair<int, int>(3, 100)); //(key,value)
Print all the value from beginning to end-
map<int, int>::iterator it;
for (it = m.begin(); it != m.end(); ++it) {
cout << '\t' << it->first << '\t' << it->second << '\n';
}
find()- It return iterator reference to the corresponding key
Iterator it=m.find(key)
it->first=key
it->second=value
if key not present then it gives m.end() reference.
erase()-
Remove the corresponding key value.
m.erase(key);
Comments
Post a Comment