1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>Additional Features</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="../rationale.html" title="Rationale"> 9<link rel="prev" href="../rationale.html" title="Rationale"> 10<link rel="next" href="code.html" title="Code"> 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="../rationale.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../rationale.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="code.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h3 class="title"> 27<a name="boost_bimap.rationale.additional_features"></a><a class="link" href="additional_features.html" title="Additional Features">Additional 28 Features</a> 29</h3></div></div></div> 30<h5> 31<a name="boost_bimap.rationale.additional_features.h0"></a> 32 <span class="phrase"><a name="boost_bimap.rationale.additional_features.n_1__n_n__hashed_maps"></a></span><a class="link" href="additional_features.html#boost_bimap.rationale.additional_features.n_1__n_n__hashed_maps">N-1, 33 N-N, hashed maps</a> 34 </h5> 35<p> 36 This is a very interesting point of the design. The framework introduced 37 in <span class="emphasis"><em>std::set theory</em></span> permits the management of the different 38 constraints with a very simple and conceptual approach. It is easy both to 39 remember and to learn. The idea here is to allow the user to specify the 40 collection type of each key directly. In order to implement this feature, 41 we have to solve two problems: 42 </p> 43<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 44<li class="listitem"> 45 The index types of the <code class="computeroutput"><span class="identifier">multi_index_container</span></code> 46 core now depends on the collection type used for each key. 47 </li> 48<li class="listitem"> 49 The map views now change their semantics according to the collection 50 type chosen. 51 </li> 52</ul></div> 53<p> 54 Boost.Bimap relies heavily on Boost.MPL to implement all of the metaprogramming 55 necessary to make this framework work. By default, if the user does not specify 56 the kind of the set, a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span></code> type 57 is used. 58 </p> 59<p> 60 <span class="inlinemediaobject"><img src="../../images/bimap/bimap.structures.png" alt="bimap.structures"></span> 61 </p> 62<h5> 63<a name="boost_bimap.rationale.additional_features.h1"></a> 64 <span class="phrase"><a name="boost_bimap.rationale.additional_features.collection_type_of_relation_constraints"></a></span><a class="link" href="additional_features.html#boost_bimap.rationale.additional_features.collection_type_of_relation_constraints">Collection 65 type of relation constraints</a> 66 </h5> 67<p> 68 The constraints of the bimap set view are another very important feature. 69 In general, Boost.Bimap users will base the set view type on one of the two 70 collection types of their keys. It may be useful however to give this set 71 other constraints or simply to order it differently. By default, Boost.Bimap 72 bases the collection type of relations on the left collection type, but the 73 user may choose between: 74 </p> 75<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 76<li class="listitem"> 77 left_based 78 </li> 79<li class="listitem"> 80 right_based 81 </li> 82<li class="listitem"> 83 set_of_relation<> 84 </li> 85<li class="listitem"> 86 multiset_of_relation<> 87 </li> 88<li class="listitem"> 89 unordered_set_of_relation<> 90 </li> 91<li class="listitem"> 92 unordered_multiset_of_relation<> 93 </li> 94<li class="listitem"> 95 list_of 96 </li> 97<li class="listitem"> 98 vector_of 99 </li> 100</ul></div> 101<p> 102 In the first two cases, there are only two indices in the <code class="computeroutput"><span class="identifier">multi_index_core</span></code>, 103 and for this reason, these are the preferred options. The implementation 104 uses further metaprogramming to define a new index if necessary. 105 </p> 106<h5> 107<a name="boost_bimap.rationale.additional_features.h2"></a> 108 <span class="phrase"><a name="boost_bimap.rationale.additional_features.tagged"></a></span><a class="link" href="additional_features.html#boost_bimap.rationale.additional_features.tagged">Tagged</a> 109 </h5> 110<p> 111 The idea of using tags instead of the <code class="literal">member_at::side</code> 112 idiom is very appealing since code that uses it is more readable. The only 113 cost is compile time. <span class="emphasis"><em>boost/bimap/tagged</em></span> is the implementation 114 of a non-invasive tagged idiom. The <code class="literal">relation</code> class is 115 built in such a way that even when the user uses tags, the <code class="literal">member_at::side</code> 116 idiom continues to work. This is good since an user can start tagging even 117 before completing the coding of the algorithm, and the untagged code continues 118 to work. The development becomes a little more complicated when user-defined 119 tags are included, but there are many handy metafunctions defined in the 120 <code class="literal">tagged</code> idiom that help to keep things simple enough. 121 </p> 122<p> 123 <span class="inlinemediaobject"><img src="../../images/bimap/tagged.png" alt="tagged"></span> 124 </p> 125</div> 126<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 127<td align="left"></td> 128<td align="right"><div class="copyright-footer">Copyright © 2006-2012 Matias Capeletto<p> 129 Distributed under the Boost Software License, Version 1.0. (See accompanying 130 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>) 131 </p> 132</div></td> 133</tr></table> 134<hr> 135<div class="spirit-nav"> 136<a accesskey="p" href="../rationale.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../rationale.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="code.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a> 137</div> 138</body> 139</html> 140