• <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>
            隨筆 - 3  文章 - 2  trackbacks - 0
            <2025年6月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            293012345

            常用鏈接

            留言簿

            隨筆分類(lèi)

            隨筆檔案

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            stdext::hash_map使用字符串(const char*)做key的話,不是只指定一個(gè)compare函數(shù)難么簡(jiǎn)單,要給定一個(gè)結(jié)構(gòu)體,其包括hash函數(shù),compare函數(shù),以及“桶設(shè)定”

            struct StringCompare 
            {
            //define hash function for strings 
                enum 
                { 
                    //parameters for hash table 
                    bucket_size = 4,  // 一個(gè)桶4byte長(zhǎng)度(因?yàn)閟izeof(char*)=4)
                    min_buckets = 8 // 最少存在8個(gè)桶
                };
                size_t operator()(const char* str) const 
                { 
                    unsigned int seed = 131; // 31 131 1313 13131 131313 etc..
            unsigned int hash = 0;
            while (*str)
            {
            hash = hash * seed + (*str++);
            }
            return (hash & 0x7FFFFFFF);
                }
                bool operator()(const char *s1, const char* s2) const 
                {    
                    if (strcmp(s1, s2) == 0)
                    {
                        return false;
                    }
                    else
                    {
                        return true;
                    }
                } 
            }; 

            然后

            stdext::hash_map<const char*, Your Data Type, StringCompare>

            posted on 2012-08-14 20:40 寰子 閱讀(445) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): The C++ programming language

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


            久久精品亚洲AV久久久无码| 久久精品成人国产午夜| 亚洲午夜福利精品久久| 精品一二三区久久aaa片| 久久精品国产亚洲综合色| 精品久久久久久久久久久久久久久| 欧美日韩中文字幕久久久不卡| 欧美大香线蕉线伊人久久| 久久精品国产欧美日韩| 久久婷婷五月综合97色| 日产久久强奸免费的看| 久久综合国产乱子伦精品免费| 国产精品亚洲美女久久久| 精品熟女少妇a∨免费久久| 一极黄色视频久久网站| 青草影院天堂男人久久| 久久亚洲私人国产精品vA| 亚洲成av人片不卡无码久久| 久久99国产精品一区二区| 久久强奷乱码老熟女网站| 婷婷久久综合九色综合九七| 91精品日韩人妻无码久久不卡| 亚洲精品国精品久久99热一| 日本久久中文字幕| 精品国产综合区久久久久久| 2021精品国产综合久久| 精品久久亚洲中文无码| 无码人妻少妇久久中文字幕| 精品人妻伦九区久久AAA片69| 久久中文字幕一区二区| 久久国产高潮流白浆免费观看| 久久精品国产99国产精品导航| 久久精品国产亚洲AV久| 亚洲精品午夜国产VA久久成人 | 国产精品青草久久久久婷婷| 亚洲精品蜜桃久久久久久| 国产精品久久久久久久久久影院| 久久人搡人人玩人妻精品首页 | 久久er热视频在这里精品| 国产精品99久久99久久久| 99国产精品久久|