#include <iostream>
#include <unordered_map>
using namespace std;
int main() {
unordered_map<string, int> strs {
{ "one", 1 },
{ "two", 2 },
{ "three", 3 }
};
// 添え字でアクセス可能
cout << strs["one"] << endl;
cout << "-----" << endl;
// Iteratorで使う場合は fist, second で添え字と要素にアクセスする
for (unordered_map<string, int>::iterator it = strs.begin(); it != strs.end(); it++) {
cout << it->first << ":" << it->second << endl;
}
cout << "-----" << endl;
// 要素の追加もラク
strs["for"] = 4;
for (unordered_map<string, int>::iterator it = strs.begin(); it != strs.end(); it++) {
cout << it->first << ":" << it->second << endl;
}
return 0;
}