map,mulitmap,set,mulitset,unordered_map,unorderer_set
来源:互联网 发布:node.js w3cschool 编辑:程序博客网 时间:2024/05/21 11:28
关联容器:
map:key-value对
set: 关键字即值
(要求不重复的关键字)
multi:允许重复关键字
unordered: 不保持关键字按顺序存储 (哈希函数组织的)
如:unordered_multi_map:允许重复关键字,元素无序保存的集合
使用关键字类型的比较函数,如果你的元素类型是一个类的对象或者结构体对象,那么
你就需要定义针对你设计的关键字类型的比较函数
如:
multiset<Saleles_data,decltype(compareIsbn)*> bookstore(compareIsbn);
bool compareIsbn(const Sales_data *lhs,const Sales_data *rhs)
{
return lhs.isbn( )<rhs.isbn( );
}
decltype 来指出子定义操作的类型 ,加上*来指出我们要使用一个给定函数类型的指针
size_t hasher(const Sales_data &sd)
{
return hash<string>( ) ( sd.isbn( ) );
}
bool eqOp(const Sales_data &rhs,const Sales_data &lhs)
{
return lhs.isbn( ) == rhs.isbn();
}
using SD_multiset = unordered_multiset<Sales_data,decltype(hasher)*,decltype(eqOp)*>;
SD_multiset bookstore(42,hasher,eqOp);
unordered_set<Foo,decltype(FooHash)*>fooSet(10,FooHash); 这里需要Foo定义了==运算符
0 0
- map,mulitmap,set,mulitset,unordered_map,unorderer_set
- mulitset,mulitmap
- STL学习——set/map/multiset/mulitmap篇
- map,set,unordered_map,hash总结
- map,multimap,unordered_map,set,multiset,unordered_set
- set、unordered_set、unordered_multiset、map、unordered_map、unordered_multimap
- map、set和unordered_map、unordered_set对比
- STL容器之Map,MulitMap
- unordered_map & map
- <map>\<unordered_map>
- STL set multiset map multimap unordered_set unordered_map example
- unordered_map,unordered_set,map,set 插入查找耗时测试
- C++中map、set、hash_map、hash_set、unordered_map、unordered_set通俗辨析
- map/multimap/unordered_map/unordered_multimap; set/multiset/unordered_set/unordered_multiset
- 关联容器(map、set、multimap、multiset、pair、unordered_map)
- 【C++】unordered_map,unordered_set,map和set的用法和区别
- map, hash_map,unordered_map介绍
- map, hash_map,unordered_map
- 如何生成内部hide接口实例并通过反射作为参数进行传递
- Windows Eclipse Hadoop 开发
- Hibernate中的Entity类中的无参数构造函数
- 个人用户目录通过rysnc迁移
- Java Set转List,排序,去重
- map,mulitmap,set,mulitset,unordered_map,unorderer_set
- asp.net控件,服务器标记的格式不正确问题解决方法
- iOS开发~UITableView区头跟随移动
- Xcode真机调试出现 “Could not find Developer Disk Image”
- K好数
- cmd命令行下怎么切换目录
- View刷新
- iOS推送的众多坑
- try catch finally执行顺序和return值