#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. [luoguP1130] 红牌(DP)

    传送门 幼儿园DP. ——代码 #include <cstdio> #include <iostream> ; << ); int a[MAXN][MAXN], f ...

  2. 有一张表里面有上百万的数据,在做查询的时候,如何优化?从数据库端,java端和查询语句上回答

    原文:https://www.2cto.com/database/201612/580140.html 1)数据库设计方面: a. 对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 o ...

  3. 质因数分解 2012年NOIP全国联赛普及组

    时间限制: 1 s 空间限制: 128000 KB 题目等级 : 青铜 Bronze 题目描述 Description 已知正整数 n是两个不同的质数的乘积,试求出较大的那个质数 . 输入描述 Inp ...

  4. select节点clone全解析

    select节点clone全解析 2009-12-18 在开发ns-log项目中,统计分类有复制的功能.由于之前的统计分类中的数据是通过JS赋值进去的,之后用户可能又进行了修改,发现进行节点克隆时,出 ...

  5. nyoj_127_星际之门(一)_201403282033

    星际之门(一) 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 公元3000年,子虚帝国统领着N个星系,原先它们是靠近光束飞船来进行旅行的,近来,X博士发明了星际之门 ...

  6. Stockbroker Grapevine POJ 1125 Floyd

    Stockbroker Grapevine Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 37069   Accepted: ...

  7. [bzoj1115][POI2009]石子游戏Kam_博弈论_阶梯博弈

    石子游戏 Kam bzoj-1115 POI-2009 题目大意:给定n堆石子,两个人轮流取石子.每堆石子的个数都不少于前一堆石子.每次取后也必须维持这个性质.问谁有必胜策略. 注释:$1\le ca ...

  8. zoj——2588 Burning Bridges

    Burning Bridges Time Limit: 5 Seconds      Memory Limit: 32768 KB Ferry Kingdom is a nice little cou ...

  9. Codeforces 300E(数学)

    题意:给定k个数字,求最小的正整数n,使得“n的阶乘”是“这k个数字的阶乘的积”的倍数.1<=k<=1e6,数字ai满足1<=ai<=1e7 分析:如果我们能对着k个数字的阶乘 ...

  10. CN Internet

    来自为知笔记(Wiz)