using namespace __gnu_cxx;
#include <iostream> #include <hash_map> #include <string.h> using namespace std; using namespace __gnu_cxx; struct eqstr { bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) == 0; } }; int main() { hash_map<const char*, int, hash<const char*>, eqstr> months; months["january"] = 31; months["february"] = 28; months["march"] = 31; months["april"] = 30; months["may"] = 31; months["june"] = 30; months["july"] = 31; months["august"] = 31; months["september"] = 30; months["october"] = 31; months["november"] = 30; months["december"] = 31; std::cout << "september -> " << months["september"] << endl; std::cout << "april -> " << months["april"] << endl; std::cout << "june -> " << months["june"] << endl; std::cout << "november -> " << months["november"] << endl; }
$ ./hash_map september -> 30 april -> 30 june -> 30 november -> 30
Copyrights © - Joinc, All Rights Reserved. Inherited From - Yundream Rebranded By - Joonphil
Hashed Associative Container
컴파일
hash_map
예제
hash_set
hash_multimap
hash_multiset
해쉬 연관 컨테이너의 사용에 대해서
Recent Posts
Archive Posts
Tags