Boost logo

Boost-Commit :

From: matias.capeletto_at_[hidden]
Date: 2008-02-04 16:18:32


Author: matias
Date: 2008-02-04 16:18:32 EST (Mon, 04 Feb 2008)
New Revision: 43104
URL: http://svn.boost.org/trac/boost/changeset/43104

Log:
merge html fix
Added:
   branches/release/libs/bimap/doc/html/boost_bimap/the_tutorial/additional_information.html
      - copied unchanged from r43103, /trunk/libs/bimap/doc/html/boost_bimap/the_tutorial/additional_information.html
Removed:
   branches/release/libs/bimap/doc/html/boost_bimap/the_tutorial/hooking_information.html

Deleted: branches/release/libs/bimap/doc/html/boost_bimap/the_tutorial/hooking_information.html
==============================================================================
--- branches/release/libs/bimap/doc/html/boost_bimap/the_tutorial/hooking_information.html 2008-02-04 16:18:32 EST (Mon, 04 Feb 2008)
+++ (empty file)
@@ -1,221 +0,0 @@
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
-<title>Hooking
- Information</title>
-<link rel="stylesheet" href="../../boostbook.css" type="text/css">
-<meta name="generator" content="DocBook XSL Stylesheets V1.70.1">
-<link rel="start" href="../../index.html" title="Chapter 1. Boost.Bimap">
-<link rel="up" href="../the_tutorial.html" title="The tutorial">
-<link rel="prev" href="unconstrained_sets.html" title="Unconstrained
- Sets">
-<link rel="next" href="complete_instantiation_scheme.html" title="Complete
- instantiation scheme">
-</head>
-<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
-<table cellpadding="2" width="100%">
-<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
-<td align="center">Home</td>
-<td align="center">Libraries</td>
-<td align="center">People</td>
-<td align="center">FAQ</td>
-<td align="center">More</td>
-</table>
-<hr>
-<div class="spirit-nav">
-<a accesskey="p" href="unconstrained_sets.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="complete_instantiation_scheme.html"><img src="../../images/next.png" alt="Next"></a>
-</div>
-<div class="section" lang="en">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_bimap.the_tutorial.hooking_information"></a><a href="hooking_information.html" title="Hooking
- Information">Hooking
- Information</a>
-</h3></div></div></div>
-<p>
- Bidirectional maps may have associated information about each relation. Suppose
- we want to represent a books and author bidirectional map.
- </p>
-<p>
- </p>
-<p>
-
-</p>
-<pre class="programlisting">
-<span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special">&lt;</span>
-
- <span class="identifier">multiset_of</span><span class="special">&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&gt;,</span> <span class="comment">// author
-</span> <span class="identifier">set_of</span><span class="special">&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&gt;</span> <span class="comment">// book name
-</span>
-<span class="special">&gt;</span> <span class="identifier">bm_type</span><span class="special">;</span>
-<span class="keyword">typedef</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">book</span><span class="special">;</span>
-
-<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span>
-
-<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">book</span><span class="special">(</span> <span class="string">"Bjarne Stroustrup"</span> <span class="special">,</span> <span class="string">"The C++ Programming Language"</span> <span class="special">)</span> <span class="special">);</span>
-<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">book</span><span class="special">(</span> <span class="string">"Scott Meyers"</span> <span class="special">,</span> <span class="string">"Effective C++"</span> <span class="special">)</span> <span class="special">);</span>
-<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span> <span class="identifier">book</span><span class="special">(</span> <span class="string">"Andrei Alexandrescu"</span> <span class="special">,</span> <span class="string">"Modern C++ Design"</span> <span class="special">)</span> <span class="special">);</span>
-
-<span class="comment">// Print the author of Modern C++
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">at</span><span class="special">(</span> <span class="string">"Modern C++ Design"</span> <span class="special">);</span>
-</pre>
-<p>
- </p>
-<p>
- </p>
-<p>
- </p>
-<div class="calloutlist"><table border="0" summary="Callout list"></table></div>
-<p>
- </p>
-<p>
- </p>
-<p>
- Suppose now that we want to store abstract of each book. We have two options:
- </p>
-<div class="orderedlist"><ol type="1">
-<li>
- Books name are unique identifiers, so we can create a separate <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">map</span><span class="special">&lt;</span> <span class="identifier">string</span><span class="special">,</span> <span class="identifier">string</span> <span class="special">&gt;</span></code>
- that relates books names with abstracts.
- </li>
-<li>
- We can use Boost.MultiIndex for the new beast.
- </li>
-</ol></div>
-<p>
- Option 1 is the wrong approach, if we go this path we lost what bimap has
- won us. We now have to maintain the logic of two interdependent containers,
- there is an extra string stored for each book name, and the performance will
- be worse. This is far away from being a good solution.
- </p>
-<p>
- Option 2 is correct. We start thinking books as entries in a table. So it
- makes sense to start using Boost.MultiIndex. We can then add the year of
- publication, the price, etc... and we can index this new items too. So Boost.MultiIndex
- is a sound solution for our problem.
- </p>
-<p>
- The thing is that there are cases where we want to maintain bimap semantics
- (use <code class="computeroutput"><span class="identifier">at</span><span class="special">()</span></code>
- to find an author given a book name and the other way around) and add information
- about the relations that we are sure we will not want to index later (like
- the abstracts). Option 1 is not possible, option 2 neither.
- </p>
-<p>
- Boost.Bimap provides support for this kind of situations by means of information
- hooking. You can pass an extra parameter to a bimap with the type <code class="computeroutput"><span class="identifier">info_hook</span><span class="special">&lt;</span>
- <span class="identifier">InfoType</span> <span class="special">&gt;</span></code>
- and an <code class="computeroutput"><span class="identifier">info</span></code> member of type
- <code class="computeroutput"><span class="identifier">InfoType</span></code> will appear in the
- relation and bimap pairs.
- </p>
-<p>
- Relations and bimap pairs constructors can take an extra argument. If only
- two arguments are used, the information will be initialized with their default
- constructor.
- </p>
-<p>
- </p>
-<p>
-
-</p>
-<pre class="programlisting">
-<span class="keyword">typedef</span> <span class="identifier">bimap</span><span class="special">&lt;</span>
-
- <span class="identifier">multiset_of</span><span class="special">&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&gt;,</span> <span class="comment">// author
-</span> <span class="identifier">set_of</span><span class="special">&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&gt;,</span> <span class="comment">// book name
-</span>
- <span class="identifier">with_info</span><span class="special">&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&gt;</span> <span class="comment">// abstract
-</span>
-<span class="special">&gt;</span> <span class="identifier">bm_type</span><span class="special">;</span>
-<span class="keyword">typedef</span> <span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">book</span><span class="special">;</span>
-
-<span class="identifier">bm_type</span> <span class="identifier">bm</span><span class="special">;</span>
-
-<span class="identifier">bm</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span>
-
- <span class="identifier">book</span><span class="special">(</span> <span class="string">"Bjarne Stroustrup"</span> <span class="special">,</span> <span class="string">"The C++ Programming Language"</span><span class="special">,</span>
-
- <span class="string">"For C++ old-timers, the first edition of this book is"</span>
- <span class="string">"the one that started it all&#8212;the font of our knowledge."</span> <span class="special">)</span>
-<span class="special">);</span>
-
-
-<span class="comment">// Print the abstract of the bible
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">at</span><span class="special">(</span><span class="string">"The C++ Programming Language"</span><span class="special">);</span>
-
-<span class="comment">// Print the abstract of this book
-</span><span class="identifier">bm_type</span><span class="special">::</span><span class="identifier">left_iterator</span> <span class="identifier">i</span> <span class="special">=</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">left</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="string">"Bjarne Stroustrup"</span><span class="special">);</span>
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">i</span><span class="special">-&gt;</span><span class="identifier">info</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-<p>
- </p>
-<p>
- </p>
-<div class="calloutlist"><table border="0" summary="Callout list"></table></div>
-<p>
- </p>
-<p>
- </p>
-<p>
- Contrary to the two key types, the information will be mutable using iterators.
- </p>
-<p>
- </p>
-<p>
-
-</p>
-<pre class="programlisting">
-<span class="identifier">i</span><span class="special">-&gt;</span><span class="identifier">info</span> <span class="special">+=</span> <span class="string">"More details about this book"</span><span class="special">;</span>
-</pre>
-<p>
- </p>
-<p>
- </p>
-<p>
- </p>
-<div class="calloutlist"><table border="0" summary="Callout list"></table></div>
-<p>
- </p>
-<p>
- </p>
-<p>
- A new function is included in <span class="emphasis"><em>unique</em></span> map views: <code class="computeroutput"><span class="identifier">info_at</span><span class="special">(</span><span class="identifier">key</span><span class="special">)</span></code>, that
- mimics the standard <code class="computeroutput"><span class="identifier">at</span><span class="special">(</span><span class="identifier">key</span><span class="special">)</span></code> function
- but returned the associated information instead of the data.
- </p>
-<p>
- </p>
-<p>
-
-</p>
-<pre class="programlisting">
-<span class="comment">// Print the new abstract
-</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special">&lt;&lt;</span> <span class="identifier">bm</span><span class="special">.</span><span class="identifier">right</span><span class="special">.</span><span class="identifier">info_at</span><span class="special">(</span><span class="string">"The C++ Programming Language"</span><span class="special">);</span>
-</pre>
-<p>
- </p>
-<p>
- </p>
-<p>
- </p>
-<div class="calloutlist"><table border="0" summary="Callout list"></table></div>
-<p>
- </p>
-<p>
- </p>
-<p>
- Go to source code
- </p>
-</div>
-<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"></td>
-<td align="right"><small>Copyright © 2006 -2007 Matias Capeletto</small></td>
-</tr></table>
-<hr>
-<div class="spirit-nav">
-<a accesskey="p" href="unconstrained_sets.html"><img src="../../images/prev.png" alt="Prev"></a><a accesskey="u" href="../the_tutorial.html"><img src="../../images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="complete_instantiation_scheme.html"><img src="../../images/next.png" alt="Next"></a>
-</div>
-</body>
-</html>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk