STL hash_map
来源:互联网 发布:unity3d save project 编辑:程序博客网 时间:2024/09/21 08:19
定义哈希函数和比较函数
#include <hash_map> #include <string> #include <iostream> using namespace std; //define the class struct ClassA { ClassA(int a):c_a(a){} int getvalue()const { return c_a;} size_t c_a; }; //1 define the hash function struct hash_A { enum { // parameters for hash table bucket_size =2 , min_buckets =4 }; size_t operator()(const class ClassA & A)const { return A.getvalue()%min_buckets; } //2 define the equal function bool operator()(const class ClassA & a1, const class ClassA & a2)const { return a1.getvalue()<a2.getvalue(); } }; int main() { hash_map<ClassA,string, hash_A> hmap; ClassA a1(2); hmap[a1]="I love C++"; ClassA a2(56); hmap[a2]="Do you love it?"; cout<<hmap[a1]<<endl; cout<<hmap[a2]<<endl; return 0; }
0 0
- STL hash_map
- STL---hash_map
- STL hash_map
- stl-hash_map
- 详细解说STL hash_map
- 详细解说STL hash_map
- STL:map与hash_map
- STL hash_map使用
- STL hash_map使用
- STL中的hash_map
- 详细解说STL hash_map
- STL--hash_map用法(1)
- STL--hash_map用法(2)
- STL hash_map使用
- stl hash_map原理
- C++ STL中哈希表 hash_map
- STL hash_map使用
- stl hash_map详解
- ZigBee 设置信道、PANID、发射功率
- HorizontalScrollView水平方向滑动(嵌套GridView)
- error : sudo /etc/sudoer is world writable
- WebLogic11g-半小时让你的domain集群化
- is not in the sudoers file 解决(转)
- STL hash_map
- FreeSWITCH - mod_xml_rpc源码分析二channel.c
- libgdx 学习概述
- GSoC 2015 总结
- CentOS系统安装MySQL 5.6步骤简介
- MAKE FILE 多路径多文件编译
- 【Java CV与Android】在Android工程里配置JavaCV
- 上传构建版本
- 2015多校联合第五场 hdu5349 MZL's simple problem 优先队列