17.查找效率最高的unorderd_set(替代hash_set)
2024-08-31 14:26:06
#include <string>
#include <iostream>
//查询性能最高(不允许重复数据)
#include <unordered_set>
using namespace std; void main()
{
unordered_set<string> myset{"move","jump","hello"}; //删除hash表第一个
//myset.erase(myset.begin()); //删除某一个
myset.erase("move"); myset.insert("hel1"); for (auto i : myset)
{
cout << i << endl;
}
for (auto ib = myset.begin(), ie = myset.end(); ib != ie; ib++)
{
cout << *ib << endl;
}
//哈希表长度
cout << myset.bucket_count() << endl; //输出hash表内存结构
for (int i = ; i < myset.bucket_count(); i++)
{
cout << "bucket" << i << ": ";
for (auto it = myset.begin(i); it != myset.end(i); it++)
{
cout << " " << *it;
}
cout << endl;
} //最大大小
cout << myset.max_size() << endl;
//当前大小
cout << myset.size() << endl;
cin.get();
}
最新文章
- 【232】◀▶ IDL显示地理图像
- SQL查询中in、exists、not in、not exists的用法与区别
- qt 的简介与使用
- iOS 开发 初级:应用内购买 In-App Purchase
- Effective C++ -----条款45:运用成员函数模板接受所有兼容类型
- 用Visual Studio调试Windows和驱动程序
- 修改php执行用户,并使其拥有root权限
- [原创]PostgreSQL Plus Advince Server在 HA环境中一对多的Stream Replication配置(二)
- MKDOCS在线文档编辑器
- eclipse设置系统字体
- 编写优秀jQuery插件的10个技巧
- sed高级命令
- PGA与SGA
- 节点操作,节点属性的操作及DOM event事件
- Haproxy 安装及配置
- DDMS调试工具
- 从CMDB动态获取服务器列表,按照Ansible的约定
- 064——VUE中vue-router之使用路由别名定制(alias)
- JSON定义及应用
- SEO优化:WordPress发布文章主动推送到百度,加快收录保护原创
热门文章
- [Angular] Read Custom HTTP Headers Sent by the Server in Angular
- Remove Duplicates from Sorted List II 解答(有个比較特殊的case leetcode OJ没有覆盖)
- SQL学习之使用order by 依照指定顺序排序或自己定义顺序排序
- caffe环境配置
- sql server执行动态拼接sql(带传参数)和去掉小数点后0的函数
- MyLayer MyScene
- Python之Linux下的virtualenv
- javaBean 练习—封装学生信息
- RocketMQ学习笔记(9)----RocketMQ的Producer 顺序消息
- ZBrush中Zproject与SubTool的综合应用