●std::map
#include <map>
std::map<std::string, int> Handle;
1.要素を探す
if (Handle.count("田中") == 1)
{
// あるよ
}
else
{
// ないよ
}
2.要素の追加
Handle.insert(std::map<std::string, int>::value_type("鈴木", 80));
3.要素の走査(イテレータ)
std::map<std::string, int>::iterator itr = Handle.begin();
for ( ; itr != Handle.end(); itr++) {
// 各要素に対する処理
// *itr がその要素
}
#include <map>
std::map<std::string, int> Handle;
1.要素を探す
if (Handle.count("田中") == 1)
{
// あるよ
}
else
{
// ないよ
}
2.要素の追加
Handle.insert(std::map<std::string, int>::value_type("鈴木", 80));
3.要素の走査(イテレータ)
std::map<std::string, int>::iterator itr = Handle.begin();
for ( ; itr != Handle.end(); itr++) {
// 各要素に対する処理
// *itr がその要素
}