boost之数据结构和容器
1.静态数组array,boost对静态数组进行了封装,使用和普通数组一样的初始化式进行初始化。
#include <iostream>
#include <boost/array.hpp>
using namespace std;
using namespace boost; int main()
{
array<int,10> ar;
ar.back() = 10;
array<string,3> ar1 = {"tiger","dog","cat"};
return 0;
}
2.dynamic_bitset可以自由扩充二进制位的位数,可以自由进行位操作,还有一堆方便操作判断的函数。
#include <iostream>
#include <boost/dynamic_bitset.hpp>
using namespace std;
using namespace boost; int main()
{
dynamic_bitset<> db1;
dynamic_bitset<> db2(10);
cout << db2 <<endl;
db2.resize(6,true);
cout << db2 <<endl;
dynamic_bitset<> db3(string("100010"));
cout << db3<<endl;
cout << (db2 ^ db3) <<endl;
cout << (db2 & db3) <<endl;
if (db2.none())
{
cout << "have no 1"<<endl;
}
return 0;
}
3.unordered和hash_set,hash_map一样底层使用哈希表代替二叉树,实现关联容器。
4.bimap双向map
#include <iostream>
#include <string>
#include <boost/bimap.hpp>
using namespace std;
using namespace boost; int main()
{
bimap<int,string> bm;
bm.left.insert(make_pair(1,"111"));
bm.left.insert(make_pair(2,"222"));
bm.right.insert(make_pair("string",3));
bm.right.insert(make_pair("bimap",4));
for (bimap<int,string>::right_iterator it = bm.right.begin();it != bm.right.end();++it)
{
cout << it->second <<endl;
} return 0;
}
5.any可以被初始化或者赋值任意类型的数据
#include <iostream>
#include <string>
#include <boost/any.hpp>
using namespace std;
using namespace boost; int main()
{
any a(100);
a =string("char *");
//a = vector<vector<>int >(); return 0;
}
boost之数据结构和容器的更多相关文章
- boost::multi_index 多索引容器
#include "stdafx.h" #include <string> #include <boost/multi_index_container.hpp&g ...
- Boost C++: 数据结构---tuple
#include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple_io.hpp> #include <boost/ ...
- C++ STL常见数据结构(容器)分类
vector:(连续的空间存储,可以使用[]操作符)快速的访问随机的元素,快速的在末尾插入元素,但是在序列中间的插入,删除元素要慢,而且如果一开始分配的空间不够的话,可能重新分配更大空间,拷贝的性能开 ...
- 自制数据结构(容器)-java开发用的最多的ArrayList和HashMap
public class MyArrayList<E> { private int capacity = 10; private int size = 0; private E[] val ...
- 【Python】【容器 | 迭代对象 | 迭代器 | 生成器 | 生成器表达式 | 协程 | 期物 | 任务】
Python 的 asyncio 类似于 C++ 的 Boost.Asio. 所谓「异步 IO」,就是你发起一个 IO 操作,却不用等它结束,你可以继续做其他事情,当它结束时,你会得到通知. Asyn ...
- kubernetes容器编排系统介绍
版权声明:本文由turboxu原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/152 来源:腾云阁 https://www. ...
- boost 无锁队列
一哥们翻译的boost的无锁队列的官方文档 原文地址:http://blog.csdn.net/great3779/article/details/8765103 Boost_1_53_0终于迎来了久 ...
- 一文带你看透kubernetes 容器编排系统
本文由云+社区发表 作者:turboxu Kubernetes作为容器编排生态圈中重要一员,是Google大规模容器管理系统borg的开源版本实现,吸收借鉴了google过去十年间在生产环境上所学到的 ...
- Pandas三个数据结构
系列(Series) 数据帧(DataFrame) 面板(Panel) 这些数据结构构建在Numpy数组之上,这意味着它们很快. 考虑这些数据结构的最好方法是,较高维数据结构是其较低维数据结构的容器. ...
随机推荐
- Linux selinux关闭方法和防火墙关闭方法
在Linux下设置selinux有三种方法.一.在图形界面中: 桌面-->管理-->安全级别和防火墙,设置为disable.二.在命令模式下: 修改文件:/etc/selinu ...
- JMX简单样例
一:创建maven项目,在pom.xml里面增加例如以下依赖 <dependency> <groupId>com.sun.jdmk</groupId> <ar ...
- 王立平--Eclipse中配置svn
1.-------------------------------------------------------------------------------------------------- ...
- CentOS sendmail安装及邮件域名配置
http://www.centoscn.com/CentosServer/lighttpd/2013/0726/650.html sendmail是Linux下优秀的邮件系统.在不做任何设定的情况下, ...
- nginx利用lua实现nginx反向代理proxy_store缓存文件自删除
标题有点绕口.我尽量把关键词都贴进去.之前因为自己的nginx安装了ngx_lua模块,但是又需要引入 但是安装luafilesystem又需要先安装luarocks,比较繁琐.这里就想记录一下安装过 ...
- Swift 烧脑体操一
Swift 烧脑体操(一) - Optional 的嵌套 前言 Swift 其实比 Objective-C 复杂很多,相对于出生于上世纪 80 年代的 Objective-C 来说,Swift 融 ...
- 转载-好用的linux软件合集
音频 Airtime – Airtime 是一款用于调度和远程站点管理的开放广播软件 Ardour – 在 Linux 上录音,编辑,和混音 Audacious – 开源音频播放器,按你想要的方式 ...
- IOS MagicRecord 详解 (转载)
2014-10-22 14:37 6137人阅读 评论(6) 收藏 举报 IOSMagicRecordCoreData 目录(?)[+] 刚开始接触IOS不久,尝试着翻译一些博客,积累技术,与大家共享 ...
- 360 网络攻防 hackgame 解题报告(通关)
地址:http://challenge.onebox.so.com/ 1.referrer or host 2.js decode 3.urldecode, ASCII 4.JFIF * 2 5.go ...
- 非常好用的两个PHP函数 serialize()和unserialize()
使用serialize()函数和unserialize()函数,这两个函数的用法真是绝配,一个是进行序列化存储,另一个则是进行序列化恢复,方便极了 今天,在做一个关于PING服务的东西,由于不想把pi ...