• <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))。

            久久久久波多野结衣高潮| 亚洲第一极品精品无码久久| 97精品久久天干天天天按摩 | 久久无码人妻一区二区三区 | 国产A三级久久精品| 久久精品无码专区免费青青| 久久久久夜夜夜精品国产| 欧美国产成人久久精品| 无码日韩人妻精品久久蜜桃| 久久精品国产一区| 伊人精品久久久久7777| 国产精品久久国产精麻豆99网站| 精品一久久香蕉国产线看播放| 漂亮人妻被中出中文字幕久久| 亚洲乱亚洲乱淫久久| 久久婷婷色综合一区二区 | 久久青青色综合| 久久久久亚洲AV成人片| 亚洲国产成人久久一区久久| 99热成人精品热久久669| 久久久久国产精品嫩草影院| 精品多毛少妇人妻AV免费久久| 国产精品99精品久久免费| 久久中文字幕无码专区| 国产精品九九久久免费视频| 国产亚洲精品自在久久| 久久天天躁狠狠躁夜夜avapp| 国内精品久久久久久麻豆 | 欧美精品久久久久久久自慰| 四虎久久影院| 久久国产成人精品国产成人亚洲| 97精品国产91久久久久久| 伊人久久大香线蕉综合影院首页| 久久综合久久伊人| 日本亚洲色大成网站WWW久久| 久久93精品国产91久久综合| 欧美精品一本久久男人的天堂| 国产精品欧美久久久天天影视| 91久久精品91久久性色| 国产精品久久久久一区二区三区| 国产亚洲色婷婷久久99精品|