ÃÑ ÆäÀÌÁö ¼ö : 3224
![]()
|
Facebook Joinc ±×·ì
Joinc QA »çÀÌÆ®
![]()
Tweet
joinc´Â Firefox¿Í chrome¿¡¼ Å×½ºÆ® Çß½À´Ï´Ù. IE¿¡¼´Â Å×À̺íÀÌ ±úÁö°Å³ª À̹ÌÁö°¡ º¸ÀÌÁö ¾ÊÀ» ¼ö ÀÖ½À´Ï´Ù. ƯÈ÷ ±¸±Û DocsÀ̹ÌÁöÀÇ °æ¿ì ¿¢¹Úó¸®µÉ ¼ö ÀÖ½À´Ï´Ù. Hashed Associative Container
ÇØ½¬ ¿¬°ü ÄÁÅ×À̳ʴ hash tableÀÇ ¿¬°ü ÄÁÅ×ÀÌ³Ê ±¸ÇöÀÌ´Ù. ÇØ½¬ ¿¬°ü ÄÁÅ×À̳ÊÀÇ ¿ø¼ÒµéÀº Á¤·ÄÀÌ µÇÁö ¾Ê´Â´Ù. Æò±ÕÀûÀ¸·Î »ó¼öŸÀÓ¿¡ ¿ø¼Ò¸¦ °Ë»öÇÒ ¼ö ÀÖÁö¸¸, ÃÖ¾ÇÀÇ °æ¿ì¿¡´Â ¼±Çü½Ã°£ÀÌ ¼ÒºñµÈ´Ù. ÇØ½¬ ¿¬°ü ÄÁÅ×À̳ÊÀÇ ¼º´ÉÀº ¼øÀüÈ÷ Hash ÇÔ¼ö¿¡ Á¿ìµÈ´Ù. ÄÄÆÄÀÏ
ÇØ½¬ ¿¬°ü ÄÁÅ×À̳ʴ std namespace¿¡ Æ÷ÇÔµÇÁö ¾Ê´Â´Ù. ¾Æ·¡¿Í °°ÀÌ namespace¸¦ ÁöÁ¤ÇØÁà¾ß ÇÑ´Ù. using namespace __gnu_cxx; hash_map
hash_mapÀº Ű¿Í µ¥ÀÌÅ͸¦ °¡Áö´Â °´Ã¼ÀÇ ÇØ½¬ ¿¬°ü ÄÁÅ×À̳ʴÙ. map°ú ¸¶Âù°¡Áö·Î Ű´Â À¯ÀÏÇÏ´Ù. hash_mapÀº "dictionaries"ÀÇ ±¸Çö¿¡ È¿°úÀûÀÎ ÄÁÅ×À̳ʴÙ.
¿¹Á¦#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 |
|
||||||||||
|
EmailÀ» ±âÀÔÇϸé, ´ñ±ÛÀÌ ¸ÞÀÏ·Î Àü´ÞµË´Ï´Ù. |
|