现在的位置: 首页 > 综合 > 正文

STL chips

2013年08月02日 ⁄ 综合 ⁄ 共 1223字 ⁄ 字号 评论关闭

 


 

hash_map和map的选择,hash_map善于查找,map善于添加和删除,这个没问题,关键是数据:

http://blog.sina.com.cn/s/blog_5378b2830100c5a4.html

关键数据如下:10万级

        hash_map(10万) map(10万) hash_map(20万) map(20万) hash_map(30万) map(30万)
添加   93                         47                 156                         94                203                         172

历 16                          15                 16                    
      16                16                           15
查找  0                            0                   32                        
  31                31                           32
删除 8422                       32                 33765                     63                76016                     78

百万级:

              hash_map(100万) map(100万) hash_map(200万) map(200万) hash_map(300万) map(300万)
遍历        94                            31                   203                           32                   297                          47
查找    
   94                            234                 188                           531                 281                          875

 

 


 

如果使用vector的第一个元素,使用front()比operator[0]要更好。

operator[]里面操作比front多太多了.

vector的swap函数也很不错,是把里面所有的东西进行交换,内部实现是:

 

抱歉!评论已关闭.