Tags:
create new tag
, view all tags

实验环境

  • 操作系统 fedora9
  • 编译器版本 gcc4.3

实验方式

  • 各种map使用插入和查找,比较速度和相关性能

代码

  • 下面测试说明了速度之间的比较:

map类型 插入速度 插入和查找速度
hashmap 0m0.123s 0m0.369s
map 0m0.190s 0m0.681s
unordered_map 0m0.123s 0m0.315s

  • 为什么要使用unordered_map代替hash_map?
    • 因为标准化的推进,unordered_map原来属于boost分支和std::tr1中,而hash_map属于非标准容器。
    • 另外,使用之后,感觉速度和hash_map差不多,但是支持string做key,也可以使用复杂的对象作为key。
    • gxx需要添加编译选项:--std=gnu++0x或者--std=c++0x
    • 在/usr/include/c++/4.3.0/backward/backward_warning.h文件中,明确写道:

This file includes at least one deprecated or antiquated header which \ may be removed without further notice at a future date. Please use a \ non-deprecated interface with equivalent functionality instead. For a \ listing of replacement headers and interfaces, consult the file \ backward_warning.h. To disable this warning use -Wno-deprecated. 


/* A list of valid replacements is as follows:

Use: Instead of:
, basic_stringbuf , strstreambuf
, basic_istringstream , istrstream
, basic_ostringstream , ostrstream
, basic_stringstream , strstream
, unordered_set , hash_set
, unordered_multiset , hash_multiset
, unordered_map , hash_map
, unordered_multimap , hash_multimap
, bind , binder1st
, bind , binder2nd
, bind , bind1st
, bind , bind2nd
, unique_ptr , auto_ptr
*/

-- CnAngel - 2009.03.18

Topic attachments
I Attachment Action Size Date Who Comment
Unknown file formatgz map_compare.tar.gz manage 1.0 K 2009-03-18 - 15:36 CnAngel  
Topic revision: r2 - 2011-04-10 - CnAngel
 
This site is powered by the TWiki collaboration platformCopyright © 2008-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback 京ICP备05049167号