Boost组件multi_index_container实例(续4)

本博客http://blog.csdn.net/livelylittlefish 贴 出作 者(三二一@小鱼)相关研究、学习内容所做的笔记,欢迎广大朋友指正!

 

1. 引子

 

实例 ( 3) 的基础上,将 print _container free _container find _container 模板化。

 

2. 修改 print _container free _container find _container 函数

 

//a template to print a container

template <typename Tag , typename MultiIndexContainer >

void print_container(const MultiIndexContainer& container)

{

    //obtain a reference to the index tagged by Tag

    const typename boost::multi_index::index<MultiIndexContainer , Tag >::type& indexSet = get<Tag >(container);

 

    typedef typename MultiIndexContainer ::value_type value_type;

 

    //dump the elements of the index to cout

    std::copy(indexSet.begin(), indexSet.end(), std::ostream_iterator(cout));

}

 

3. 代码及运行结果

 

multiindexcontainer4.cpp

运行结果如下:

(1, 1, 1) - (10, 100)

(1, 1, 2) - (20, 200)

(1, 1, 3) - (30, 300)

(1, 2, 1) - (40, 400)

(1, 2, 2) - (50, 500)

(1, 2, 3) - (60, 600)

(1, 3, 1) - (70, 700)

(1, 3, 2) - (80, 800)

(1, 3, 3) - (90, 900)

(2, 1, 1) - (110, 1000)

(2, 1, 2) - (220, 2000)

(2, 1, 3) - (330, 3000)

(2, 2, 1) - (440, 4000)

(2, 2, 2) - (550, 5000)

(2, 2, 3) - (660, 6000)

(2, 3, 1) - (770, 7000)

(2, 3, 2) - (880, 8000)

(2, 3, 3) - (990, 9000)

 

(1, 1, 1) - (10, 100), found

(1, 1, 2) - (20, 200), found

(1, 1, 3) - (30, 300), found

(1, 2, 1) - (40, 400), found

(1, 2, 2) - (50, 500), found

(1, 2, 3) - (60, 600), found

(1, 3, 1) - (70, 700), found

(1, 3, 2) - (80, 800), found

(1, 3, 3) - (90, 900), found

(2, 1, 1) - (110, 1000), found

(2, 1, 2) - (220, 2000), found

(2, 1, 3) - (330, 3000), found

(2, 2, 1) - (440, 4000), found

(2, 2, 2) - (550, 5000), found

(2, 2, 3) - (660, 6000), found

(2, 3, 1) - (770, 7000), found

(2, 3, 2) - (880, 8000), found

(2, 3, 3) - (990, 9000), found

 

(1, 1, 1) - (10, 100), destructed

(1, 1, 2) - (20, 200), destructed

(1, 1, 3) - (30, 300), destructed

(1, 2, 1) - (40, 400), destructed

(1, 2, 2) - (50, 500), destructed

(1, 2, 3) - (60, 600), destructed

(1, 3, 1) - (70, 700), destructed

(1, 3, 2) - (80, 800), destructed

(1, 3, 3) - (90, 900), destructed

(2, 1, 1) - (110, 1000), destructed

(2, 1, 2) - (220, 2000), destructed

(2, 1, 3) - (330, 3000), destructed

(2, 2, 1) - (440, 4000), destructed

(2, 2, 2) - (550, 5000), destructed

(2, 2, 3) - (660, 6000), destructed

(2, 3, 1) - (770, 7000), destructed

(2, 3, 2) - (880, 8000), destructed

(2, 3, 3) - (990, 9000), destructed


Technorati 标签: Boost , multi_index , multi_index_container

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值