Using STL Map
I'm considering using the STL map structure for a project but I'm not sure if I can do what I would like to do. Is it possible to use an interator and step through the map, printing out both the key and the value? I know how to easily get the value, but I'm not sure if you can get the key using an iterator or not.
Code:
std::map<K, V>::const_iterator e = my_map.end();
for (std::map<K, V>::const_iterator i = my_map.begin(); i != e; ++i) {
K key = (*i).first;
V value = (*i).second;
}
