Map Iterator

容器中第一個元素的迭代器。

如果 map 物件是 const 限定的,則該函式返回 const_iterator。否則,它返回 iterator

// Create a map and insert some values
std::map<char,int> mymap;
mymap['b'] = 100;
mymap['a'] = 200;
mymap['c'] = 300;

// Iterate over all tuples
for (std::map<char,int>::iterator it = mymap.begin(); it != mymap.end(); ++it)
    std::cout << it->first << " => " << it->second << '\n';

輸出:

a => 200
b => 100
c => 300