• <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>
            posts - 311, comments - 0, trackbacks - 0, articles - 0
              C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理
            #include "stdafx.h"
            #include 
            "boost/unordered_map.hpp"
            #include 
            <iostream>
            #include 
            <map>
            #include 
            "time.h"

            using namespace std;
            int _tmain(int argc, _TCHAR* argv[])
            {
                {
                time_t first_time 
            = time(0);
                boost::unordered_map
            <intint> test_hash;
                
            for (int i = 0; i < 50000000; i++)
                {
                    test_hash.insert(std::pair
            <intint>(i, i));
                }
                cout 
            << test_hash.size() << endl;
                
                time_t second_time 
            = time(0);

                
            for (int i = 0; i< 50000001++i)
                {
                    boost::unordered_map
            <intint>::iterator iter = test_hash.find(i);
                    
            if (iter == test_hash.end())
                    {
                        cout 
            << "false" << endl;
                    }
                }
                time_t third_time 
            = time(0);
                cout 
            << "second - first " << second_time - first_time << endl;
                cout 
            << "third - second " << third_time - second_time << endl;
                }

                {
                time_t first_time 
            = time(0);
                std::map
            <intint> test_hash;
                
            for (int i = 0; i < 50000000; i++)
                {
                    test_hash.insert(std::pair
            <intint>(i, i));
                }
                cout 
            << test_hash.size() << endl;

                time_t second_time 
            = time(0);

                
            for (int i = 0; i< 50000001++i)
                {
                    std::map
            <intint>::iterator iter = test_hash.find(i);
                    
            if (iter == test_hash.end())
                    {
                        cout 
            << "false" << endl;
                    }
                }
                time_t third_time 
            = time(0);
                cout 
            << "second - first " << second_time - first_time << endl;
                cout 
            << "third - second " << third_time - second_time << endl;
                }
                
            return 0;
            }

            執(zhí)行結(jié)果:

            50000000
            false
            second - first 12
            third - second 3
            50000000
            false
            second - first 52
            third - second 15

             

            運(yùn)行環(huán)境:

            windows -- vs --  Release -- win32

             

            內(nèi)存消耗: boost::unordered_map 消耗 1.2 G, std::map 1.5 G

             

            結(jié)論: unordered_map 查找效率快五倍,插入更快,節(jié)省一定內(nèi)存。如果沒有必要排序的話,盡量使用 hash_map(unordered_map 就是 boost 里面的 hash_map 實(shí)現(xiàn))。

            久久人人爽人人爽人人片AV不| 四虎国产精品免费久久5151| 四虎亚洲国产成人久久精品| 狠狠精品久久久无码中文字幕| 久久精品国产69国产精品亚洲| 久久久久亚洲?V成人无码| 亚洲AV乱码久久精品蜜桃| 久久综合精品国产一区二区三区| 久久亚洲精品人成综合网| 精品久久久久中文字| 国产成年无码久久久久毛片| 亚洲精品成人网久久久久久| …久久精品99久久香蕉国产| 一本一本久久A久久综合精品| 99国产精品久久| 久久无码AV中文出轨人妻| 精品久久久久久国产潘金莲| 久久久久亚洲av毛片大| 国产一久久香蕉国产线看观看| 亚洲精品成人网久久久久久| 中文字幕亚洲综合久久2| 99精品久久精品一区二区| 久久影院午夜理论片无码 | 久久婷婷五月综合97色一本一本| 国产亚洲美女精品久久久| 精品久久久久久中文字幕人妻最新| 欧美色综合久久久久久| 久久精品国产福利国产秒| 久久精品国产亚洲77777| 久久精品无码专区免费青青| 蜜桃麻豆www久久国产精品| 国产福利电影一区二区三区,免费久久久久久久精 | 久久青青草原亚洲av无码app| 久久一区二区免费播放| 精品久久久久久国产免费了| 久久久久久免费一区二区三区| 午夜精品久久久久久毛片| 伊人久久大香线蕉av不变影院| 亚洲精品午夜国产va久久| 久久久久亚洲精品天堂| 香蕉久久夜色精品升级完成|