[C++ STL] <unordered_map>

rhkr9080ยท2023๋…„ 2์›” 14์ผ
0

๐Ÿ”Ž Unordered map

  • Synopsis
#include <unordered_map>
  • ์„ ์–ธ
// unordered_map<key, value>
unordered_map<string, vector<string>> user_info;

user_info["minsu"].push_back("ID");
user_info["minsu"].push_back("PASSWORD");
user_info["minsu"].push_back("SCORE");
user_info["minsu"].push_back(to_string(88));

user_info["younghee"].push_back("ID");
user_info["younghee"].push_back("PASSWORD");
user_info["younghee"].push_back("SCORE");
user_info["younghee"].push_back(to_string(97));
  • empty( )
if (user_info.empty()) {
	cout << "This is Start. Unordered_map is Emptpy" << endl;
}
  • size( )
cout << "Unordered_map's size is : " << user_info.size() << endl;
  • count ( )
if (user_info.count("younghee")) {
	cout << user_info["younghee"][0] << " " << user_info["younghee"][1] << endl;
}
  • find( )
if (user_info.find("younghee") != user_info.end()) {
		cout << user_info["younghee"][0] << " " << user_info["younghee"][1] << endl;
}
profile
๊ณต๋ถ€๋ฐฉ

0๊ฐœ์˜ ๋Œ“๊ธ€