#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示例的更多相关文章

  1. boost bimap

    The library Boost.Bimap is based on Boost.MultiIndex and provides a container that can be used immed ...

  2. boost容器bimap简单使用

    C++标准提供了map和multi_map,把key映射到value;    但是这种映射是单向的,只能是key到value,不能反过来;    boost.bimap扩展了标准库映射型容器,提供双向 ...

  3. boost开发指南

    C++确实很复杂,神一样的0x不知道能否使C++变得纯粹和干爽? boost很复杂,感觉某些地方有过度设计和太过于就事论事的嫌疑,对实际开发工作的考虑太过于理想化.学习boost本身就是一个复杂度,有 ...

  4. BOOST Voronoi Visualizer

    BOOST Voronoi Visualizer eryar@163.com Abstract. The Voronoi extension of the Boost.Polygon library ...

  5. Boost 1.61.0 Library Documentation

    http://www.boost.org/doc/libs/1_61_0/ Boost 1.61.0 Library Documentation Accumulators Framework for ...

  6. boost 使用列子

    #include <boost/lexical_cast.hpp>void test_lexical_cast(){ int number = 123; string str = &quo ...

  7. boost之数据结构和容器

    1.静态数组array,boost对静态数组进行了封装,使用和普通数组一样的初始化式进行初始化. #include <iostream> #include <boost/array. ...

  8. 1.1. 如何使用XproerUI库

    项目类型:MFC   XproerUI结构: 3rd                    第三方库目录   cximage     dll                编译的DLL目录   pug ...

  9. 如何使用XproerUI库(WTL)-XproerUI界面库教程

    版权所有 2009-2015 荆门泽优软件有限公司 保留所有权利 产品首页:http://www.ncmem.com/apps/xproerui/index.asp 开发文档(SkinStudio): ...

随机推荐

  1. BZOJ3991 寻宝游戏 LCA 虚树 SET

    5.26 T1:寻宝游戏 Description 小B最近正在玩一个寻宝游戏,这个游戏的地图中有N个村庄和N-1条道路,并且任何两个村庄之间有且仅有一条路径可达.游戏开始时,玩家可以任意选择一个村庄, ...

  2. jconsole远程连接 jmx配置注意事项

    由于在测试程序时需要收集程序运行时的内存,CPU等消耗情况.选择了jconsole这个jdk自带工具来观察.为了不影响程序运行状态,用远程连接的方式来具体观察. 首先,程序是放在ubutun系统服务器 ...

  3. Docker创建PHP镜像

    Step: 1. 创建Dockerfile FROM php:7.0-apache RUN chmod -R 755 /var/www 2. 创建镜像 docker build -t docker_n ...

  4. MVC中从控制器到视图的数据传递方法汇总

    1.ViewData对象概述ViewData是一种字典集合数据,是"视图基类"和"控制器基类"的属性常见用法是在控制器中写入数据,在视图中读取数据ViewDat ...

  5. TI C66x DSP 系统events及其应用 - 5.11(中断控制寄存器)

    C66x DSP运行中断的简要流程: 1.使能了全局中断和子中断.假设硬件检測到中断发生,那么CPU就要跳转. 2.软件把CPU内部的A,B类寄存器的值等推入堆栈保存,把当前PC寄存器的值放入IRP寄 ...

  6. ssh2项目整合 struts2.1+hibernate3.3+spring3 基于hibernate注解和struts2注解

    项目文件夹结构例如以下: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQveW9uZ3poaWFu/font/5a6L5L2T/fontsize/400/fi ...

  7. 猫猫学iOS 之CoreLocation反地理编码小Demo输入经纬度得到城市

    猫猫分享,必须精品 原创文章,欢迎转载.转载请注明:翟乃玉的博客 地址:http://blog.csdn.net/u013357243 一:效果 输入经纬度,能够得到相应的地名 二:思路 跟地里编码差 ...

  8. OC-内存管理的一些要点

    创建一个BOOK对象,对其属性进行声明 定义. @property 属性声明 定义了对属性的赋值 -(void) dealloc 方法在对象销毁的时候进行调用. #import <Foundat ...

  9. Codeforces Round #316 (Div. 2) C. Replacement(线段树)

    C. Replacement time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  10. android 线程的开启和停止(借鉴java的技术)

    在onclick()点击事件中的 // 上传地理位置 case R.id.person_up_locat: System.out.println("====输出了.. .. ====&quo ...