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数组之上,这意味着它们很快. 考虑这些数据结构的最好方法是,较高维数据结构是其较低维数据结构的容器. ...
随机推荐
- windows操作系统记事本保存操作时间、字符映射表的打开、步骤记录器使用
记事本自动记录修改时间 你有用记事本记账或写日记的习惯吗?其实在记事本的文档开头输入".LOG"(无引号,字母为大写),之后记录内容并保存,这样以后打开就会看到之前每次修改的时间了 ...
- 解决:System.Data.SqlClient.SqlError: FILESTREAM 功能被禁用
还原 AdventureWorks Sample DataBase 时遇到 FILESTREAM feature is disabled 错误提示. FileStream是SQL Server 200 ...
- svn Couldn't open rep-cache database
出现这样的错误原因是因为 问题一 开始出现错误:The database disk image is malformed 解决方案:http://www.cnblogs.com/chen110xi/p ...
- Atitit。监听键盘上下左右方向键事件java js jquery c#.net
Atitit.监听键盘上下左右方向键事件java js jquery c#.net 1. Keyword1 2. 通用的实现流程1 3. Js的实现1 3.1. Bind control ,eve ...
- 李洪强漫谈iOS开发[C语言-002]-开发概述程序的本质与简单执行过程
李洪强iOS开发之应用程序的本质与简单执行过程 什么叫程序? 就是一段执行指令 程序的两个状态: 保存状态(保存到硬盘上) 运行状态(由CPU执行) 代码可以执行吗? CPU(中央处理器-> ...
- Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed
错误原因:常量.随机或者依赖时区的表达式不能作为分区函数. 解决方法:把ts列换成datetime类型,创建成功. CREATE TABLE T_log( id INT(11) NOT NULL AU ...
- 12:Web及MySQL服务异常监测案例
[root@db01 scripts]# cat db_check.sh #!/bin/bash db_num=$(mysql -h172. -P3306 -uroot -poldboy123 -e ...
- Spring Boot MongoDB JPA 简化开发
使用SpringBoot提供的@Repository接口,可以完成曾经需要大量代码编写和配置文件定制工作.这些以前让新手程序员头疼,让有经验的程序员引以为傲的配置,由于框架的不断完善,变得不那么重要, ...
- Spring MVC生成RSS源
下面的示例演示如何使用Spring Web MVC框架生成RSS源. 首先使用Eclipse IDE,并按照以下步骤使用Spring Web Framework开发基于动态表单的Web应用程序: 创建 ...
- Mysql事务-隔离级别
MYSQL事务-隔离级别 事务是什么? 事务简言之就是一组SQL执行要么全部成功,要么全部失败.MYSQL的事务在存储引擎层实现. 事务都有ACID特性: 原子性(Atomicity):一个事务必须被 ...