• <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++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理
            #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;
            }

            執行結果:

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

             

            運行環境:

            windows -- vs --  Release -- win32

             

            內存消耗: boost::unordered_map 消耗 1.2 G, std::map 1.5 G

             

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

            精品一区二区久久| 久久久精品国产免大香伊| 久久AV高清无码| 国产亚洲美女精品久久久久狼| 久久久久久免费一区二区三区 | 97超级碰碰碰碰久久久久| 久久精品国产精品亚洲下载| 国产成人综合久久精品红| 久久精品草草草| 亚洲中文字幕无码久久2020| 久久久综合香蕉尹人综合网| 久久亚洲国产成人精品性色| 久久毛片一区二区| 国产精品九九久久精品女同亚洲欧美日韩综合区| 久久e热在这里只有国产中文精品99 | 精品久久久久中文字幕日本| 国产精品久久久久天天影视| 国产精品99久久久精品无码| 精品久久久久久国产免费了| 俺来也俺去啦久久综合网| 精品国产99久久久久久麻豆| 久久精品国产精品亚洲| 9999国产精品欧美久久久久久| 精品久久久久香蕉网| 亚洲人成网亚洲欧洲无码久久| 色偷偷88欧美精品久久久| 国内精品久久久久久久涩爱| 韩国三级中文字幕hd久久精品 | 久久这里只有精品视频99| 久久99精品九九九久久婷婷| 久久精品9988| 国产免费福利体检区久久| 精品久久久无码中文字幕| 99久久夜色精品国产网站| 久久这里只有精品久久| 香蕉久久一区二区不卡无毒影院| 欧美激情精品久久久久| 91精品免费久久久久久久久| 精品久久人人爽天天玩人人妻 | 人妻无码中文久久久久专区| 久久国产免费观看精品3|