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之数据结构和容器的更多相关文章

  1. boost::multi_index 多索引容器

    #include "stdafx.h" #include <string> #include <boost/multi_index_container.hpp&g ...

  2. Boost C++: 数据结构---tuple

    #include <boost/tuple/tuple.hpp> #include <boost/tuple/tuple_io.hpp> #include <boost/ ...

  3. C++ STL常见数据结构(容器)分类

    vector:(连续的空间存储,可以使用[]操作符)快速的访问随机的元素,快速的在末尾插入元素,但是在序列中间的插入,删除元素要慢,而且如果一开始分配的空间不够的话,可能重新分配更大空间,拷贝的性能开 ...

  4. 自制数据结构(容器)-java开发用的最多的ArrayList和HashMap

    public class MyArrayList<E> { private int capacity = 10; private int size = 0; private E[] val ...

  5. 【Python】【容器 | 迭代对象 | 迭代器 | 生成器 | 生成器表达式 | 协程 | 期物 | 任务】

    Python 的 asyncio 类似于 C++ 的 Boost.Asio. 所谓「异步 IO」,就是你发起一个 IO 操作,却不用等它结束,你可以继续做其他事情,当它结束时,你会得到通知. Asyn ...

  6. kubernetes容器编排系统介绍

    版权声明:本文由turboxu原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/152 来源:腾云阁 https://www. ...

  7. boost 无锁队列

    一哥们翻译的boost的无锁队列的官方文档 原文地址:http://blog.csdn.net/great3779/article/details/8765103 Boost_1_53_0终于迎来了久 ...

  8. 一文带你看透kubernetes 容器编排系统

    本文由云+社区发表 作者:turboxu Kubernetes作为容器编排生态圈中重要一员,是Google大规模容器管理系统borg的开源版本实现,吸收借鉴了google过去十年间在生产环境上所学到的 ...

  9. Pandas三个数据结构

    系列(Series) 数据帧(DataFrame) 面板(Panel) 这些数据结构构建在Numpy数组之上,这意味着它们很快. 考虑这些数据结构的最好方法是,较高维数据结构是其较低维数据结构的容器. ...

随机推荐

  1. unity, write/read txt file

    在Assets下新建文件夹StreamingAssets.然后下面代码可在其中生成test.txt文件,并读写: using UnityEngine;using System.Collections; ...

  2. atitit.解决struts2 SpringObjectFactory.getClassInstance NullPointerException  v2 q31

    atitit.解决struts2 SpringObjectFactory.getClassInstance NullPointerExceptionv2 q31 1. #--现象 java.lang. ...

  3. Spring 注解 @Scheduled(cron = "0 0/10 * * * ? ") 任务调度动态改变时间

    不需要重启应用就可以动态的改变Cron表达式的值 import java.util.Date; import java.util.concurrent.Executor; import java.ut ...

  4. 转载-好用的linux软件合集

    音频 Airtime – Airtime 是一款用于调度和远程站点管理的开放广播软件  Ardour – 在 Linux 上录音,编辑,和混音  Audacious – 开源音频播放器,按你想要的方式 ...

  5. mock实例方法

    1.Mockito.when(categoryService.queryTopCategory("1")).thenReturn(categories);//返回的是list列表, ...

  6. 小数数据精度问题Double与BigDecimal

    做项目的过程中涉及到小数问题的时候,一般我都用Double类型,但是经常出现*.999999998这种数据,然后自己再手动四舍五入,简直傻的要死. 明明就是一个1.51-1.38的问题,很简单怎么会得 ...

  7. Shiro学习(总结)

    声明:本文原文地址:http://www.iteye.com/blogs/subjects/shiro 感谢开涛提供的博文,让我学到了非常多.在这里由衷的感谢你,同一时候我强烈的推荐开涛的博文.他的博 ...

  8. spring 第一篇(1-3):鸟瞰spring蓝图

    如你所见,spring框架的核心是关注于如何使用DI.AOP和模板来让企业级java开发变得更简单.spring确实也是这样做的,所以很值得你去使用它.不过spring内容可能比你所能看到的要多很多. ...

  9. 不再为无限级树结构烦恼,且看此篇s

    很久都没有写点什么出来分享了,最近在做多级树的时候,发现来来回回写过很多遍,于是封装成用户控件,以方便日后重复使用. 首先上效果: 我们看到以上2种效果,都是支持任意级的,这里源码中使用的是递归,以便 ...

  10. Spring MVC的@ResponseBody回来JSON串

    1 406错误 <mvc:annotation-driven />不用动,请求的时候URL的文件扩展名应为json @ResponseBody会根据扩展名,或者Header,或者Param ...