hash_map的使用备忘
2011-04-15 15:31
190 查看
Windows上
定义一个类,重载两个操作符(此class 转自某csdn网友)
然后 stdext::hash_map<KEY, VALUE>
Mac上
定义两个类,各自重载一个操作符(突然觉得似乎可以定义一个,待会再试试)
然后 std::hash_map<KEY, VAL>
定义一个类,重载两个操作符(此class 转自某csdn网友)
class hash_comp { public: enum { bucket_size = 4, min_buckets = 8 }; bool operator () (const Point &p1,const Point &p2)const { if (p1.distanceTo(p2) < dZERO) { return true; } return false; } size_t operator()(const Point &pt)const { unsigned long nhash = sqrt(pt.x * pt.x + pt.y * pt.y) * 1000; return (size_t) nhash; } };
然后 stdext::hash_map<KEY, VALUE>
Mac上
定义两个类,各自重载一个操作符(突然觉得似乎可以定义一个,待会再试试)
class hash_fun { public: size_t operator() (const KEY& pt) const { ... return (size_t)nhash; } }; class hash_eq { public: bool operator() (const KEY& k1, const KEY& k2) const { if (...) { return true; } return false; } };
然后 std::hash_map<KEY, VAL>
相关文章推荐
- C++使用hash_map时警告
- c++ STL hash_map 使用
- STL中的hash_map使用
- STL中hash_map深度剖析—使用自定义类型
- 【节操】ext/hash_map使用指南
- linux下使用hash_map及STL总结
- STL hash_map使用
- hash_map 使用 string做 key
- Linux和MinGW(ZOJ)上hash_set和hash_map使用方案
- 在vs中使用hash_map的一个小总结
- linux hash_map的使用(g++)
- linux下C++ STL hash_map的使用以及使用char *型变量作为Key值的一大“坑”
- 在GCC和Visual Studio中使用hash_map
- 使用HashSet<String>将map集合去重
- linux下使用hash_map及STL总结
- 转载:gcc与vs中hash_map使用的差别
- c++中的hash_map在g++和vc++下的使用
- hash_map介绍与使用
- C++ 中标准库 map 和 hash_map 的使用方法
- hash_map/unordered_map原理和使用整理