• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Bimap and Boost</title>
5<link rel="stylesheet" href="../boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../index.html" title="Chapter 1. Boost.Bimap">
8<link rel="up" href="../index.html" title="Chapter 1. Boost.Bimap">
9<link rel="prev" href="the_tutorial/complete_instantiation_scheme.html" title="Complete instantiation scheme">
10<link rel="next" href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html" title="Boost Libraries that work well with Boost.Bimap">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="the_tutorial/complete_instantiation_scheme.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h2 class="title" style="clear: both">
27<a name="boost_bimap.bimap_and_boost"></a><a class="link" href="bimap_and_boost.html" title="Bimap and Boost">Bimap and Boost</a>
28</h2></div></div></div>
29<div class="toc"><dl class="toc">
30<dt><span class="section"><a href="bimap_and_boost.html#boost_bimap.bimap_and_boost.bimap_and_multiindex">Bimap
31      and MultiIndex</a></span></dt>
32<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html">Boost
33      Libraries that work well with Boost.Bimap</a></span></dt>
34<dd><dl>
35<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.introduction">Introduction</a></span></dt>
36<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_serialization">Boost.Serialization</a></span></dt>
37<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_assign">Boost.Assign</a></span></dt>
38<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_hash">Boost.Hash</a></span></dt>
39<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_lambda">Boost.Lambda</a></span></dt>
40<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_range">Boost.Range</a></span></dt>
41<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_foreach">Boost.Foreach</a></span></dt>
42<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_typeof">Boost.Typeof</a></span></dt>
43<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_xpressive">Boost.Xpressive</a></span></dt>
44<dt><span class="section"><a href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_property_map">Boost.Property_map</a></span></dt>
45</dl></dd>
46<dt><span class="section"><a href="bimap_and_boost/dependencies.html">Dependencies</a></span></dt>
47</dl></div>
48<div class="section">
49<div class="titlepage"><div><div><h3 class="title">
50<a name="boost_bimap.bimap_and_boost.bimap_and_multiindex"></a><a class="link" href="bimap_and_boost.html#boost_bimap.bimap_and_boost.bimap_and_multiindex" title="Bimap and MultiIndex">Bimap
51      and MultiIndex</a>
52</h3></div></div></div>
53<p>
54        <span class="emphasis"><em>MISC</em></span> - <span class="bold"><strong>M</strong></span>ulti-<span class="bold"><strong>I</strong></span>ndex <span class="bold"><strong>S</strong></span>pecialized
55        <span class="bold"><strong>C</strong></span>ontainers
56      </p>
57<div class="blockquote"><blockquote class="blockquote"><p>
58          <span class="emphasis"><em> Let's be generic, construct frameworks, describe the world in
59          an unified way... </em></span>
60        </p></blockquote></div>
61<div class="blockquote"><blockquote class="blockquote"><p>
62          <span class="emphasis"><em> No!, it is better to be specialized, design easy-to-use components,
63          offer plug-and-play objects... </em></span>
64        </p></blockquote></div>
65<div class="blockquote"><blockquote class="blockquote"><p>
66          <span class="bold"><strong> Why not take advantage of the best of both worlds?
67          </strong></span>
68        </p></blockquote></div>
69<p>
70        <span class="inlinemediaobject"><img src="../images/bimap/miBimapFramework.png" alt="miBimapFramework"></span>
71      </p>
72<p>
73        With Boost.Bimap, you can build associative containers in which both types
74        can be used as key. There is a library in Boost that already allows the creation
75        of this kind of container: Boost.MultiIndex. It offers great flexibility
76        and lets you construct almost any container that you could dream of. The
77        framework is very clean. You might want to read this library's tutorial to
78        learn about the power that has been achieved.
79      </p>
80<p>
81        But generality comes at a price: the interface that results might not be
82        the best for every specialization. People may end up wrapping a B.MI container
83        in its own class every time they want to use it as a bidirectional map. Boost.Bimap
84        takes advantage of the narrower scope to produce a better interface for bidirectional
85        maps <a href="#ftn.boost_bimap.bimap_and_boost.bimap_and_multiindex.f0" class="footnote" name="boost_bimap.bimap_and_boost.bimap_and_multiindex.f0"><sup class="footnote">[2]</sup></a>. There is no learning curve if you know how to use standard containers.
86        Great effort was put into mapping the naming scheme of the STL to Boost.Bimap.
87        The library is designed to match the common STL containers.
88      </p>
89<p>
90        Boost.MultiIndex is, in fact, the core of the bimap container.
91      </p>
92<p>
93        However, Boost.Bimap do not aim to tackle every problem with two indexed
94        types. There exist some problems that are better modelled with Boost.MultiIndex.
95      </p>
96<div class="blurb">
97<div class="titlepage"><div><div><p class="title"><b></b></p></div></div></div>
98<p>
99        <span class="bold"><strong>Problem I - An employee register</strong></span>
100      </p>
101<p>
102        <span class="emphasis"><em>Store an ID and a name for an employee, with fast search on each
103        member.</em></span>
104      </p>
105<p>
106        This type of problem is better modelled as a database table, and <span class="bold"><strong>Boost.MultiIndex</strong></span> is the preferred choice. It is possible
107        that other data will need to be indexed later.
108      </p>
109</div>
110<div class="blurb">
111<div class="titlepage"><div><div><p class="title"><b></b></p></div></div></div>
112<p>
113        <span class="bold"><strong>Problem II - A partners container</strong></span>
114      </p>
115<p>
116        <span class="emphasis"><em>Store the names of couples and be able to get the name of a person's
117        partner.</em></span>
118      </p>
119<p>
120        This problem is better modelled as a collection of relations, and <span class="bold"><strong>Boost.Bimap</strong></span> fits nicely here.
121      </p>
122</div>
123<p>
124        You can also read <a class="link" href="the_tutorial/additional_information.html" title="Additional information">Additional
125        Information</a> for more information about the relation of this two libraries.
126      </p>
127</div>
128<div class="footnotes">
129<br><hr style="width:100; text-align:left;margin-left: 0">
130<div id="ftn.boost_bimap.bimap_and_boost.bimap_and_multiindex.f0" class="footnote"><p><a href="#boost_bimap.bimap_and_boost.bimap_and_multiindex.f0" class="para"><sup class="para">[2] </sup></a>
131          In the same fashion, Boost.MRU will allow the creation of <span class="emphasis"><em>most
132          recent updated</em></span> aware containers, hiding the complexity of Boost.MultiIndex.
133        </p></div>
134</div>
135</div>
136<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
137<td align="left"></td>
138<td align="right"><div class="copyright-footer">Copyright © 2006-2012 Matias Capeletto<p>
139        Distributed under the Boost Software License, Version 1.0. (See accompanying
140        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
141      </p>
142</div></td>
143</tr></table>
144<hr>
145<div class="spirit-nav">
146<a accesskey="p" href="the_tutorial/complete_instantiation_scheme.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
147</div>
148</body>
149</html>
150