#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
#include <iostream>
#include <hash_set>
#include <cstdlib>
#include <cstring>
#include <string>
using namespace std; //hash_set常规用法
void main()
{
////哈希表不需要考虑碰撞,查询的效率高,不能有重复的数据
//hash_set<int> myset{ 1,1,1,4,2134,12,34,56,34 };
//myset.insert(26);
//for (auto i : myset)
//{
// cout << i << endl;
//}
////正向迭代
//for (auto ib = myset.begin(), ie = myset.end(); ib != ie; ib++)
//{
// cout << *ib << endl;
//} ////反向迭代
//for (auto rb = myset.rbegin(), re = myset.rend(); rb != re; rb++)
//{
// cout << *rb << endl;
//} ////存储的数据个数
//cout << myset.size() << endl;
////哈希表大小
//cout << myset.bucket_count() << endl; //哈希表不需要考虑碰撞,查询的效率高,不能有重复的数据
hash_set<string> myset{ "microsoft","apple","oracle","tecent" };
myset.insert("huawei");
for (auto i : myset)
{
cout << i << endl;
}
//正向迭代
/*for (auto ib = myset.begin(), ie = myset.end(); ib != ie; ib++)
{
cout << *ib << endl;
}*/ //反向迭代
/*for (auto rb = myset.rbegin(), re = myset.rend(); rb != re; rb++)
{
cout << *rb << endl;
}*/ //存储的数据个数
/*cout << myset.size() << endl;*/
//哈希表大小
/*cout << myset.bucket_count() << endl;*/ auto it = myset.find("apple"); if (it != myset.end())
{
cout << "find" << endl;
cout << *it << endl;
}
else
{
cout << "not find" << endl;
}
cin.get();
}

最新文章

  1. [LeetCode] Increasing Triplet Subsequence 递增的三元子序列
  2. 16 On Large-Batch Training for Deep Learning: Generalization Gap and Sharp Minima 1609.04836v1
  3. bash fifo管道使用测试例子
  4. java生成excel文件
  5. Java微博搜索关键字采集
  6. 营业额统计(bzoj1588)
  7. git push throws error: RPC failed; result=22, HTTP code = 411的解决办法
  8. JDK版本不兼容问题之:一台机器安装多个版本的JDK
  9. Trie,HDU1875world puzzle
  10. Python中小中花括号的区别
  11. VBS 文件选择框,选择Excel文件
  12. node.js express mvc轻量级框架实践
  13. ●UVA 1608 Non-boring sequences
  14. 【BZOJ3110】【ZJOI2013】k大数查询
  15. 一、Ansible安装
  16. Spring学习四
  17. 20170711xlVBA自定义分类汇总一例
  18. .NET/C# 判断某个类是否是泛型类型或泛型接口的子类型
  19. swift3.0 保存图片到本地,申请权限
  20. python获取输入参数

热门文章

  1. NHibernate3剖析:Mapping篇之集合映射基础(3):List映射
  2. IIS身份验证的配置
  3. mybatis学习笔记(7)-输出映射
  4. Google Maps API 将开始收费
  5. zzulioj--1716--毒(模拟水题)
  6. Android 使用retrofit时,怎样获取响应的头信息
  7. hiho 1613 - 墨水滴 - bfs+优先队列 *
  8. windows连接投影仪后桌面画面和白板画面不一致
  9. swift语言点评十三-Lazy
  10. ActiveMQ学习笔记(22)----ActiveMQ的优化和使用建议