• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            newplan

            阿基米德在洗澡時(shí)發(fā)現(xiàn)浮力原理,高興得來不及穿上褲子,跑到街上大喊:Eureka(我找到了)。
            posts - 39, comments - 26, trackbacks - 0, articles - 4
              C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理
            /*
             *用來測(cè)試STL hash_map 
             *簡(jiǎn)單例子2008.5.5
            */
            #include  
            <cstdlib>
            #include  
            <iostream>
            #include  
            <string>
            #include  
            <hash_map.h>/*因?yàn)閔ash_map暫不為CPP標(biāo)準(zhǔn)所以沒辦法寫為<hash_map>*/
            /*-------------------------------------------*/
            using  std::cout;
            using  std::endl;
            using  std::string;
            /*-------------------------------------------*/
            /*函數(shù)類
             *作為hash_map的hash函數(shù) 
             *string沒有默認(rèn)的hash函數(shù) 
             
            */ 
            class str_hash{
                  
            public:
                   size_t 
            operator()(const string& str) const
                    {
                            unsigned 
            long __h = 0;
                            
            for (size_t i = 0 ; i < str.size() ; i ++)
                            __h 
            = 5*__h + str[i];
                            
            return size_t(__h);
                    }
            };
            /*-------------------------------------------*/
            /*函數(shù)類 
             *作為hash_map的比較函數(shù) )
             *(查找的時(shí)候不同的key往往可能對(duì)用到相同的hash值
            */ 
            class str_compare
            {
                  
            public:
                         
            bool operator()(const string& str1,const string& str2)const
                         {
            return   str1==str2;}
            };
            /*-------------------------------------------*/
            int 
            main(
            int argc, char *argv[])
            {  
                hash_map
            <string,string,str_hash,str_compare>  myhash;
                
                myhash[
            "google"]="newplan";
               
                myhash[
            "baidu"]="zhaoziming";
               
                
            if(myhash.find("google")!=myhash.end())
                  cout
            <<myhash["google"]<<endl;
                
                system(
            "PAUSE");
                
                
            return EXIT_SUCCESS;
            }
            /*-------------------------------------------*/

            Feedback

            # re: STL HASH_MAP簡(jiǎn)單應(yīng)用  回復(fù)  更多評(píng)論   

            2008-08-12 12:58 by 陳盛
            我在.net2005上怎么運(yùn)行不了你的代碼?編譯不通過,說:
            錯(cuò)誤 1 fatal error C1083: Cannot open include file: 'hash_map.h': No such file or directory f:\private\vc++\testhashmap\testhashmap\testhashmap.cpp 8
            另外,我想問一下,怎么根據(jù)keyvalue對(duì)hash_map進(jìn)行排序。
            我的郵箱:crasyman@163.com,能否把你的可執(zhí)行的工程傳給我?

            # re: STL HASH_MAP簡(jiǎn)單應(yīng)用  回復(fù)  更多評(píng)論   

            2008-09-27 17:16 by rubby
            fatal error C1083: Cannot open include file: 'hash_map.h': No such file or directory

            # re: STL HASH_MAP簡(jiǎn)單應(yīng)用  回復(fù)  更多評(píng)論   

            2008-12-08 14:38 by xiong
            你好! 我是在vc6下想用hashmap ,要加stlport 但還是不能用。能告訴我你是怎樣讓hashmap能用的嗎?謝謝你啦~我郵箱xiongzhanying@126.com

            # re: STL HASH_MAP簡(jiǎn)單應(yīng)用  回復(fù)  更多評(píng)論   

            2008-12-13 19:10 by 山泉彎延
            我的運(yùn)行環(huán)境是DEV,你可以子DEV的安裝包中找到該文件HASH_MAP.H,至于其他的IDE我還沒有去考慮過,不過你可以馬上查@xiong

            # re: STL HASH_MAP簡(jiǎn)單應(yīng)用[未登錄]  回復(fù)  更多評(píng)論   

            2009-04-24 08:48 by kevin
            at VS 2005,

            #include <iostream>
            #include <string>
            #include <hash_map>

            using namespace stdext;
            using namespace std;

            int _tmain(int argc, _TCHAR* argv[])
            {
            hash_map<string,string> myhash;

            myhash["google"]="newplan";

            myhash["baidu"]="zhaoziming";

            if(myhash.find("google")!=myhash.end())
            cout<<myhash["google"]<<endl;

            system("PAUSE");

            return EXIT_SUCCESS;
            }

            # re: STL HASH_MAP簡(jiǎn)單應(yīng)用  回復(fù)  更多評(píng)論   

            2009-09-29 23:58 by fall
            VS2008環(huán)境下即使添加了using namespace stdext;這句話好像還是不行。
            添加了上面那句話后錯(cuò)誤信息更多,而且是hash函數(shù)內(nèi)部的錯(cuò)誤,請(qǐng)教樓主一下,這個(gè)問題該怎么解決?謝謝

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            久久国产精品成人片免费| 亚洲AV日韩AV天堂久久| 日日狠狠久久偷偷色综合0| 久久久久久国产精品美女| 久久久久久一区国产精品| 亚洲午夜精品久久久久久app| 亚洲国产精品久久电影欧美| 狠狠88综合久久久久综合网| 国产精品成人99久久久久 | 亚洲国产成人精品无码久久久久久综合| 久久精品无码一区二区app| 国内精品久久国产| 97久久久久人妻精品专区| 久久久99精品成人片中文字幕| 久久亚洲日韩看片无码| 国产精品一久久香蕉国产线看 | 久久AV高清无码| 久久国产热这里只有精品| 精产国品久久一二三产区区别| 久久久91精品国产一区二区三区 | 中文字幕无码免费久久| www亚洲欲色成人久久精品| 国产精品久久久久久五月尺| 国产一久久香蕉国产线看观看| 四虎影视久久久免费观看| 国产精品一区二区久久精品| 欧美亚洲国产精品久久高清| 精品九九久久国内精品| 中文精品久久久久人妻不卡| 久久综合给合综合久久| 色综合色天天久久婷婷基地| 99久久夜色精品国产网站| 青青热久久国产久精品 | 国内精品久久国产大陆| 一本一道久久a久久精品综合| 91精品观看91久久久久久| 亚洲精品无码成人片久久| 无码8090精品久久一区| a级毛片无码兔费真人久久| 国产成人久久精品一区二区三区| 77777亚洲午夜久久多人|