Boost Bimap示例
#include <string>
#include <iostream> #include <boost/bimap.hpp> template< class MapType >
void print_map(const MapType & map,
const std::string & separator,
std::ostream & os )
{
typedef typename MapType::const_iterator const_iterator; for( const_iterator i = map.begin(), iend = map.end(); i != iend; ++i )
{
os << i->first << separator << i->second << std::endl;
}
} int main()
{
// Soccer World cup typedef boost::bimap< std::string, int > results_bimap;
typedef results_bimap::value_type position; results_bimap results;
results.insert( position("Argentina" ,) );
results.insert( position("Spain" ,) );
results.insert( position("Germany" ,) );
results.insert( position("France" ,) ); std::cout << "The number of countries is " << results.size()
<< std::endl; std::cout << "The winner is " << results.right.at()
<< std::endl
<< std::endl; std::cout << "Countries names ordered by their final position:"
<< std::endl; // results.right works like a std::map< int, std::string > print_map( results.right, ") ", std::cout ); std::cout << std::endl
<< "Countries names ordered alphabetically along with"
"their final position:"
<< std::endl; // results.left works like a std::map< std::string, int > print_map( results.left, " ends in position ", std::cout ); return ;
}
Boost Bimap示例的更多相关文章
- boost bimap
The library Boost.Bimap is based on Boost.MultiIndex and provides a container that can be used immed ...
- boost容器bimap简单使用
C++标准提供了map和multi_map,把key映射到value; 但是这种映射是单向的,只能是key到value,不能反过来; boost.bimap扩展了标准库映射型容器,提供双向 ...
- boost开发指南
C++确实很复杂,神一样的0x不知道能否使C++变得纯粹和干爽? boost很复杂,感觉某些地方有过度设计和太过于就事论事的嫌疑,对实际开发工作的考虑太过于理想化.学习boost本身就是一个复杂度,有 ...
- BOOST Voronoi Visualizer
BOOST Voronoi Visualizer eryar@163.com Abstract. The Voronoi extension of the Boost.Polygon library ...
- Boost 1.61.0 Library Documentation
http://www.boost.org/doc/libs/1_61_0/ Boost 1.61.0 Library Documentation Accumulators Framework for ...
- boost 使用列子
#include <boost/lexical_cast.hpp>void test_lexical_cast(){ int number = 123; string str = &quo ...
- boost之数据结构和容器
1.静态数组array,boost对静态数组进行了封装,使用和普通数组一样的初始化式进行初始化. #include <iostream> #include <boost/array. ...
- 1.1. 如何使用XproerUI库
项目类型:MFC XproerUI结构: 3rd 第三方库目录 cximage dll 编译的DLL目录 pug ...
- 如何使用XproerUI库(WTL)-XproerUI界面库教程
版权所有 2009-2015 荆门泽优软件有限公司 保留所有权利 产品首页:http://www.ncmem.com/apps/xproerui/index.asp 开发文档(SkinStudio): ...
随机推荐
- Codeforces Round #260 (Div. 2) D
D. A Lot of Games time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- python——re模块(正则表达式)
re 模块的使用: 1.使用compile()函数编译一个parttern对象, 例如:parttern=re.compile(r'\d+') 2.通过pattern对象提供的一系列属相和方法,对文本 ...
- Luogu P1257 平面上的最接近点对 暴力
这道题数据不大 两点距离用勾股定理求 #include<iostream> #include<cmath> using namespace std; struct node{ ...
- vim下多行注释与解注释
1.多行注释 (1)按esc进入命令行模式 (2)按下Ctrl+v,进入区块模式,并使用上下键选择需要注释的多行 (3)按下“I”(大写)键,进入插入模式 (4)输入注释符(“//”或“#”等) (5 ...
- 解决CDH SparkStreaming任务启动之后executor不停增长的问题,num-executors配置不管用。
spark2-submit --class SparkKafka --master yarn --executor-memory 1G --num-executors 6 --driver-memor ...
- hdu3303
分析:一个最暴力的想法是把加入到集合S的数据一个个按顺序保存起来,然后每次查询的时候由后向前计算余数,如果遇到余数为0的,就直接把时间输出,否则就一直比较到最后找余数最小时间最晚的,这样查询的时间复杂 ...
- 10、Java并发性和多线程-线程安全与不可变性
以下内容转自http://ifeve.com/thread-safety-and-immutability/: 当多个线程同时访问同一个资源,并且其中的一个或者多个线程对这个资源进行了写操作,才会产生 ...
- OSX: node中安装zeromq
1. brew install pkg-config2. brew install zmq3. export PKG_CONFIG_PATH="/usr/local/lib/pkgconfi ...
- android_handler(一)
仅仅是一个简单的handler的样例,目的就是对handler有一个初步的接触. 在layout上加入一个button,点击按钮,然后打印出利用handler传送的数据.(都是执行在mainthrea ...
- python基础练习-猜年龄、编写登陆接口小程序
python基础练习: 一.猜年龄 , 可以让用户最多猜三次! age=40 count = 1 while count <=3 : user_guess=int(input("i ...