C++中的hash_map——Linux下g++和Windows下VC++下头文件,命名空间
2012-03-18 10:20
537 查看
在Linux下g++的形式:
头文件:: #include <ext/hash_map>
命名空间:: using namespace __gnu_cxx;
使用上和map区别不大,差别主要在性能上。
map采用红黑树的方式,而hash_map采用哈希的方法,
插入:: 所以map的插入和删除速率要比hash_map高,hash_map要做冲突处理。
查找:: 但是查找上hash_map就要比map的性能高很多,因为是哈希,所以可以直接按照内容找到。
使用方法::
使用方法上和map没有什么大的区别,
#include <ext/hash_map>
using namespace __gnu_cxx;
hash_map<key_type,value_type> obj;
hash_map<key_type,value_type>::iterator iter = obj.begin();
在Windows下VC++的形式:
和map的使用方法一样,没有命名空间,直接#include <hash_map>就可以使用了,就像直接#include <map>一样。
头文件:: #include <ext/hash_map>
命名空间:: using namespace __gnu_cxx;
使用上和map区别不大,差别主要在性能上。
map采用红黑树的方式,而hash_map采用哈希的方法,
插入:: 所以map的插入和删除速率要比hash_map高,hash_map要做冲突处理。
查找:: 但是查找上hash_map就要比map的性能高很多,因为是哈希,所以可以直接按照内容找到。
使用方法::
使用方法上和map没有什么大的区别,
#include <ext/hash_map>
using namespace __gnu_cxx;
hash_map<key_type,value_type> obj;
hash_map<key_type,value_type>::iterator iter = obj.begin();
在Windows下VC++的形式:
和map的使用方法一样,没有命名空间,直接#include <hash_map>就可以使用了,就像直接#include <map>一样。
相关文章推荐
- C++中的hash_map__Linux下g++和Windows下VC++下头文件,命名空间
- c++中的hash_map在g++和vc++下的使用
- Windows 和 Linux 下生成以当前时间命名的文件
- linux下C++ STL hash_map的使用以及使用char *型变量作为Key值的一大“坑”
- 用C++实现遍历文件夹下所有文件,windows ,linux 都能用
- C++ 头文件和命名空间
- c++ 操作.ini 文件(适用平台linux windows)
- C++程序调试输出并写入文件(Linux/Windows)
- C++实现Linux和Windows下遍历指定目录下的文件
- windows 与linux 下用C++读取sqlite实现文件复制(三)
- 在windows 和 linux下引入hash_set、hash_map头文件
- 如何去掉linux环境中C++代码中的^M,文件一般来自windows 下编辑的c++代码。
- 不可或缺 Windows Native (15) - C++: 命名空间
- Linux和Windows生成系统时间命名的文件
- C/C++遍历目录下的所有文件(Windows/Linux)
- windows命令行(或linux)下用gcc/g++编译多个c/cpp文件
- Windows host与VirtualBox中linux guest通过数据空间共享文件
- 在windows 和 linux下引入hash_set、hash_map头文件
- C++遍历目录,并把目录里超过7天的文件删除(跨平台windows&linux)
- 同一段C++在Linux和windows下编译后的可执行文件有什么不同?