在windows 和 linux下引入hash_set、hash_map头文件
推荐使用方法:在源代码的前面写入一下代码:
// just for "#include <hash_*>" in linux
#if__GNUC__>2
#include<ext/hash_set>
#include<ext/hash_map>
usingnamespace__gnu_cxx;
#else
#include<hash_set>
#include<hash_map>
usingnamespacestdext;
#endif
其它解释和方法:
因为hash_map以前不属于标准库,而是后来引入的。
所以在windows下需要使用stlport,然后在setting中加入Additional library path。
在linux下使用gcc的时候,引入<hash_map>,使用的时候也说找不到hash_map,而这种后来引入标准库的有两种可能:
一种是它被放在了stdext名空间里,那么就要使用using namespace stdext引入该名空间并#include <hash_map>;
另一种可能就是它被放在标准库的ext目录底下,这时就仍旧需要使用属于std名空间,这时你的源文件应当#include <ext/hash_map>;
如果不知道是哪一种,就需要自己查一下,切换到c++库目录下:
cd /usr/include/c++/4.*.* |
然后使用grep命令:
grep -iR "hash_map" ./ |
查看hash_map在哪个头文件中。
找到后进去看一下就知道它到底被包含在哪个命名空间中了
相关推荐
源码之前了无秘密,你将看到vector的实现、list的实现、heap的实现、deque的实现、Red Black tree的实现、hash table的实现、set/map的实现;你将看到各种算法(排序、查找、排列组合、数据移动与复制技术)的实现;你...
hash_map
关于hash_map的用法与解释: #include <hash_map> #include #include using namespace std; //define the class class ClassA{ public: ClassA(int a):c_a(a){} int getvalue()const { return c_a;} void ...
一个用Hash算法实现的map,可以实际项目所使用。 希望能帮助大家学习。
linked_hash测试结果
很久以来,STL中都只提供<map>作为存放对应关系的容器,内部通常用红黑树实现,据说原因是二叉平衡树(如红黑树)的各种操作,插入、删除、查找等,都是稳定的时间复杂度,即O(log n);但是对于hash表来说,由于无法...
STL hash_map: 链式散列 版权所有 (c) 2014,龙 (Ryan) 南宫。 保留所有权利。 邮箱: 创建时间:2014 年 7 月 15 日 这是无序的哈希映射,它具有恒定的插入、删除、搜索时间,并支持向前/向后迭代。 hash_map 的...
源码之前了无秘密,你将看到vector的实现、list的实现、heap的实现、deque的实现、RB-tree的实现、hash-table的实现、set/map 的实现;你将看到各种算法(排序、搜寻、排列组合、数据移动与复制…)的实现;你甚至将...
5.9 hash_map 275 5.10 hash_multiset 279 5.11 hash_multimap 282 第6章 算法(algorithms) 285 6.1 算法概观 285 6.1.1 算法分析与复杂度表示 o( ) 286 6.1.2 stl算法总览 288 6.1.3 mutating algorithms ...
STL源码剖析,这本书所呈现的源码,使读者看到vector的实现、list的实现、heap的实现、deque的实现、Red Black tree的实现、hash table的实现、set/map的实现;看到各种算法(排序、查找、排列组合、数据移动与复制...
c++ std stl各容器的应用场合及性能 map hash_map unordered_map multimap list forward_list vector set hash_set multiset unsorted_set queue deque priority_queue
【内容简介】 C++ STL标准模板库在数据结构和算法的实践领域发挥着重要的作用。本书共分5篇26章,以“C++编程技术→C++ STL泛化技术基础→C++ STL容器技术→C++ STL算法技术→C++ STL...第16章 hash_map哈希映照容器
源码之前了无秘密,你将看到vector的实现、list的实现、heap的实现、deque的实现、RB-tree的实现、hash-table的实现、set/map 的实现;你将看到各种算法(排序、搜寻、排列组合、数据移动与复制…)的实现;你甚至将...
第16章 hash_map哈希映照容器 235 16.1 hash_map技术原理 235 16.2 hash_map应用基础 237 16.3 本章小结 242 第17章 string基本字符序列容器 243 17.1 string技术原理 243 17.2 string应用基础 258 ...
第16章 hash_map哈希映照容器 235 16.1 hash_map技术原理 235 16.2 hash_map应用基础 237 16.3 本章小结 242 第17章 string基本字符序列容器 243 17.1 string技术原理 243 17.2 string应用基础 258 ...
条款24: 当效率很关键时尽量用map::insert代替map::operator 条款25: 让自己熟悉非标准的hash容器 迭代器 条款26: 尽量使用iterator代替const_iterator,reverse_iterator和const_reverse_iterator 条款27: 使用...
其中m1就是⼀个关联数组,为了模拟普通哈希表 (这⾥的所有的都是⽤红⿊树实现的,如果你想⽤哈希表实现,请直接把map替换成hash_map,在空间⾜够的情况下) 另外,如果有C++11⽤,⼀定要⽤unordered_map,别⽤hash_...
第16章 hash_map哈希映照容器 235 16.1 hash_map技术原理 235 16.2 hash_map应用基础 237 16.3 本章小结 242 第17章 string基本字符序列容器 243 17.1 string技术原理 243 17.2 string应用基础 258 ...
这本书所呈现的源码,使读者看到vector的实现、list的实现、heap的实现、deque的实现、Red Black tree的实现、hash table的实现、set/map的实现;看到各种算法(排序、查找、排列组合、数据移动与复制技术)的实现;...
这本书所呈现的源码,使读者看到vector的实现、list的实现、heap的实现、deque的实现、Red Black tree的实现、hash table的实现、set/map的实现;看到各种算法(排序、查找、排列组合、数据移动与复制技术)的实现...