• <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波多野结衣| 国内高清久久久久久| 国产成人综合久久精品尤物| 伊人久久综合热线大杳蕉下载| 精品久久久久久无码中文字幕一区| 国产精品久久午夜夜伦鲁鲁| 成人亚洲欧美久久久久| 久久精品成人欧美大片| 亚洲?V乱码久久精品蜜桃| 人妻精品久久无码专区精东影业| 久久久青草久久久青草| 亚洲精品无码久久久久AV麻豆| 亚洲精品无码久久久久| 久久国产精品国语对白| 精品久久人人爽天天玩人人妻| 久久91亚洲人成电影网站| 欧美性猛交xxxx免费看久久久| 人妻少妇久久中文字幕一区二区| 久久国产精品波多野结衣AV| 国产一久久香蕉国产线看观看| 亚洲国产婷婷香蕉久久久久久| 伊人久久精品线影院| 久久精品视频一| 久久伊人色| 国产精品无码久久综合| 久久久九九有精品国产| 亚洲精品高清一二区久久| 久久国产精品成人免费| 久久婷婷综合中文字幕| 久久久久女教师免费一区| 精品一久久香蕉国产线看播放| 手机看片久久高清国产日韩| 久久久久亚洲av无码专区喷水| 国产亚洲色婷婷久久99精品91| 亚洲欧洲中文日韩久久AV乱码| 国产精品丝袜久久久久久不卡| 日本欧美国产精品第一页久久| 99久久99久久| 男女久久久国产一区二区三区| 亚洲精品高清国产一线久久| 少妇久久久久久被弄高潮|