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): ...
随机推荐
- cmd界面中断一个程序快捷键 ctrl+c
cmd界面中断一个程序快捷键 ctrl+c
- 由MTK平台 mtkfb 设备注册疑问引发的知识延伸--ARM Device Tree
问题: 在kernel-3.10\drivers\misc\mediatek\videox\mt6735\mtkfb.c里面int __init mtkfb_init(void) 有看到 platfo ...
- 消息传递(cogs 1001)
问题描述WZland开办了一个俱乐部(这里面可以干任何的事情),这引来了许多的人来加入.俱乐部的人数越来越多,关系也越来越复杂……俱乐部的人来自各个地方,为了增加友谊,俱乐部举行了一次晚会.晚会上又进 ...
- my first emacs custom key binding
(defun comment-this-level () (interactive) (move-beginning-of-line 1) (set-mark-command nil) (fo ...
- 使用AtomicInteger原子类代替i++线程安全操作
Java中自增自减操作不具原子性,在多线程环境下是线程不安全的,可以使用使用AtomicInteger原子类代替i++,i--操作完成多线程线程安全操作. 下面是等于i++多线程的自增操作代码: pu ...
- 9、Java并发性和多线程-线程安全与共享资源
以下内容转自http://ifeve.com/thread-safety/: 允许被多个线程同时执行的代码称作线程安全的代码.线程安全的代码不包含竞态条件.当多个线程同时更新共享资源时会引发竞态条件. ...
- 【Android】自己定义圆形ImageView(圆形头像 可指定大小)
近期在仿手Q的UI,这里面常常要用到的就是圆形头像,看到 在android中画圆形图片的几种办法 这篇文章,了解了制作这样的头像的原理.只是里面提供的方法另一个不足的地方就是不能依据实际需求改变图片的 ...
- HDU 1255 覆盖的面积(线段树+扫描线)
题目地址:HDU 1255 这题跟面积并的方法非常像,仅仅只是须要再加一个变量. 刚開始我以为直接用那个变量即可,仅仅只是推断是否大于0改成推断是否大于1.可是后来发现了个问题,由于这个没有下放,没延 ...
- 机器学习A
订阅地址 : http://blog.csdn.net/lizhe_dashuju/rss/list
- LeetCode OJ 322. Coin Change DP求解
题目链接:https://leetcode.com/problems/coin-change/ 322. Coin Change My Submissions Question Total Accep ...