#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. nyoj 95 众数问题(set)

    众数问题 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 所谓众数,就是对于给定的含有N个元素的多重集合,每个元素在S中出现次数最多的成为该元素的重数, 多重集合S重 ...

  2. asp.net mvc 4.0 新特性之移动特性

    asp.net mvc 4.0 新特性之移动特性 为不同的客户端提供不同的视图 手动重写 UserAgent,从而强制使用对应的视图 示例1.演示如何为不同的客户端提供不同的视图Global.asax ...

  3. 如何用js往html页面拼接一个div包括div的各种常用属性

    $("#div").append("<table><tr align='center'>" +"<td >&quo ...

  4. [国家集训队2010]小Z的袜子

    ★★★   输入文件:hose.in   输出文件:hose.out   简单对比 时间限制:1 s   内存限制:512 MB [题目描述] 作为一个生活散漫的人,小Z每天早上都要耗费很久从一堆五颜 ...

  5. Extended symmetrical multiprocessor architecture

    An architecture for an extended multiprocessor (XMP) computer system is provided. The XMP computer s ...

  6. JAVA NIO 之 Selector 组件

    NIO 重要功能就是实现多路复用.Selector是SelectableChannel对象的多路复用器.一些基础知识: 选择器(Selector):选择器类管理着一个被注册的通道集合的信息和它们的就绪 ...

  7. Eclipse导入Ant项目

    导入Ant项目有以下方式: 1.[File]->[Project]->[Java Project from Existing Ant Buildfile] 选择build.xml文件即可, ...

  8. 符号变换引擎(Symbol Transform Engine - STE)

    在写编译器的过程中.我意识到编译事实上是一种符号变换,比方C语言编译成机器码,事实上是C源代码文件里的符号变换成EXE的16进制符号,这和中文翻译成英语的语言翻译器没什么差别. 每一个程序猿都有自己喜 ...

  9. nodejs 运行

    运行 Node.js 程序的基本方法就是执行 node script.js,其中 script.js①是脚本的文件名. 除了直接运行脚本文件外,node --help 显示的使用方法中说明了另一种输出 ...

  10. Android实现微博分享及其注意事项

    在前面我写了两篇关于QQ和微信的分享(http://blog.csdn.net/dawanganban/article/details/42015249)(http://blog.csdn.net/d ...