diff options
author | Anas Nashif <anas.nashif@intel.com> | 2012-10-30 12:57:26 -0700 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2012-10-30 12:57:26 -0700 |
commit | 1a78a62555be32868418fe52f8e330c9d0f95d5a (patch) | |
tree | d3765a80e7d3b9640ec2e930743630cd6b9fce2b /doc/html/intrusive | |
download | boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.gz boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.bz2 boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.zip |
Imported Upstream version 1.49.0upstream/1.49.0
Diffstat (limited to 'doc/html/intrusive')
36 files changed, 12491 insertions, 0 deletions
diff --git a/doc/html/intrusive/acknowledgements.html b/doc/html/intrusive/acknowledgements.html new file mode 100755 index 0000000000..048a60d887 --- /dev/null +++ b/doc/html/intrusive/acknowledgements.html @@ -0,0 +1,102 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Acknowledgements</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="references.html" title="References"> +<link rel="next" href="index.html" title="Indexes"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="references.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="index.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.acknowledgements"></a><a class="link" href="acknowledgements.html" title="Acknowledgements">Acknowledgements</a> +</h2></div></div></div> +<p> + <span class="bold"><strong>Olaf Krzikalla</strong></span> would like to thank: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Markus Schaaf</strong></span> for pointing out the possibility + and the advantages of the derivation approach. + </li> +<li class="listitem"> + <span class="bold"><strong>Udo Steinbach</strong></span> for encouragements to present + this work for boost, a lot of fixes and helpful discussions. + </li> +<li class="listitem"> + <span class="bold"><strong>Jaap Suter</strong></span> for the initial hint, which + eventually lead to the member value_traits. + </li> +</ul></div> +<p> + <span class="bold"><strong>Ion Gaztanaga</strong></span> would like to thank: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Olaf Krzikalla</strong></span> for the permission to continue + his great work. + </li> +<li class="listitem"> + <span class="bold"><strong>Joaquin M. Lopez Munoz</strong></span> for his thorough + review, help, and ideas. + </li> +<li class="listitem"> + <span class="bold"><strong>Cory Nelson</strong></span>, <span class="bold"><strong>Daniel + James</strong></span>, <span class="bold"><strong>Dave Harris</strong></span>, <span class="bold"><strong>Guillaume Melquiond</strong></span>, <span class="bold"><strong>Henri + Bavestrello</strong></span>, <span class="bold"><strong>Hervé Bronnimann</strong></span>, + <span class="bold"><strong>Kai Bruning</strong></span>, <span class="bold"><strong>Kevin + Sopp</strong></span>, <span class="bold"><strong>Paul Rose</strong></span>, <span class="bold"><strong>Pavel Vozelinek</strong></span>, <span class="bold"><strong>Howard Hinnant</strong></span>, + <span class="bold"><strong>Olaf Krzikalla</strong></span>, <span class="bold"><strong>Samuel + Debionne</strong></span>, <span class="bold"><strong>Stjepan Rajko</strong></span>, <span class="bold"><strong>Thorsten Ottosen</strong></span>, <span class="bold"><strong>Tobias Schwinger</strong></span>, + <span class="bold"><strong>Tom Brinkman</strong></span> and <span class="bold"><strong>Steven + Watanabe</strong></span> for their comments and reviews in the Boost.Intrusive + formal review. + </li> +<li class="listitem"> + Thanks to <span class="bold"><strong>Julienne Walker</strong></span> and <span class="bold"><strong>The EC Team</strong></span> (<a href="http://eternallyconfuzzled.com" target="_top">http://eternallyconfuzzled.com</a>) + for their great algorithms. + </li> +<li class="listitem"> + Thanks to <span class="bold"><strong>Daniel K. O.</strong></span> for his AVL tree + rebalancing code. + </li> +<li class="listitem"> + Thanks to <span class="bold"><strong>Ralf Mattethat</strong></span> for his splay + tree article and code. + </li> +<li class="listitem"> + Special thanks to <span class="bold"><strong>Steven Watanabe</strong></span> and + <span class="bold"><strong>Tobias Schwinger</strong></span> for their invaluable + suggestions and improvements. + </li> +</ul></div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="references.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="index.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/advanced_lookups_insertions.html b/doc/html/intrusive/advanced_lookups_insertions.html new file mode 100755 index 0000000000..892af34530 --- /dev/null +++ b/doc/html/intrusive/advanced_lookups_insertions.html @@ -0,0 +1,442 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Advanced lookup and insertion functions for associative containers</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="treap_set_multiset.html" title="Intrusive treap based associative containers: treap_set, treap_multiset and treap"> +<link rel="next" href="erasing_and_disposing.html" title="Erasing and disposing values from Boost.Intrusive containers"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="treap_set_multiset.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="erasing_and_disposing.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.advanced_lookups_insertions"></a><a class="link" href="advanced_lookups_insertions.html" title="Advanced lookup and insertion functions for associative containers">Advanced lookup + and insertion functions for associative containers</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="advanced_lookups_insertions.html#intrusive.advanced_lookups_insertions.advanced_lookups">Advanced + lookups</a></span></dt> +<dt><span class="section"><a href="advanced_lookups_insertions.html#intrusive.advanced_lookups_insertions.advanced_insertions">Advanced + insertions</a></span></dt> +<dt><span class="section"><a href="advanced_lookups_insertions.html#intrusive.advanced_lookups_insertions.positional_insertions">Positional + insertions</a></span></dt> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.advanced_lookups_insertions.advanced_lookups"></a><a class="link" href="advanced_lookups_insertions.html#intrusive.advanced_lookups_insertions.advanced_lookups" title="Advanced lookups">Advanced + lookups</a> +</h3></div></div></div> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> associative containers offer + the same interface as STL associative containers. However, STL and TR1 ordered + and unordered simple associative containers (<code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span></code>, + <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">multiset</span></code>, <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">tr1</span><span class="special">::</span><span class="identifier">unordered_set</span></code> and <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">tr1</span><span class="special">::</span><span class="identifier">unordered_multiset</span></code>) have some inefficiencies + caused by the interface: the user can only operate with <code class="computeroutput"><span class="identifier">value_type</span></code> + objects. When using these containers we must use <code class="computeroutput"><span class="identifier">iterator</span> + <span class="identifier">find</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> + <span class="special">&</span><span class="identifier">value</span><span class="special">)</span></code> to find a value. The same happens in other + functions like <code class="computeroutput"><span class="identifier">equal_range</span></code>, + <code class="computeroutput"><span class="identifier">lower_bound</span></code>, <code class="computeroutput"><span class="identifier">upper_bound</span></code>, etc. + </p> +<p> + However, sometimes the object to be searched is quite expensive to construct: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">set</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">unordered_set</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cstring</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="comment">// Hash function for strings</span> +<span class="keyword">struct</span> <span class="identifier">StrHasher</span> +<span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span><span class="identifier">str</span><span class="special">)</span> <span class="keyword">const</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">seed</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> + <span class="keyword">for</span><span class="special">(;</span> <span class="special">*</span><span class="identifier">str</span><span class="special">;</span> <span class="special">++</span><span class="identifier">str</span><span class="special">)</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">hash_combine</span><span class="special">(</span><span class="identifier">seed</span><span class="special">,</span> <span class="special">*</span><span class="identifier">str</span><span class="special">);</span> + <span class="keyword">return</span> <span class="identifier">seed</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">};</span> + +<span class="keyword">class</span> <span class="identifier">Expensive</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">set_base_hook</span><span class="special"><>,</span> <span class="keyword">public</span> <span class="identifier">unordered_set_base_hook</span><span class="special"><></span> +<span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">key_</span><span class="special">;</span> + <span class="comment">// Other members...</span> + + <span class="keyword">public</span><span class="special">:</span> + <span class="identifier">Expensive</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span><span class="identifier">key</span><span class="special">)</span> + <span class="special">:</span> <span class="identifier">key_</span><span class="special">(</span><span class="identifier">key</span><span class="special">)</span> + <span class="special">{}</span> <span class="comment">//other expensive initializations...</span> + + <span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="special">&</span> <span class="identifier">get_key</span><span class="special">()</span> <span class="keyword">const</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">key_</span><span class="special">;</span> <span class="special">}</span> + + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span> <span class="special"><</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">Expensive</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Expensive</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">key_</span> <span class="special"><</span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">key_</span><span class="special">;</span> <span class="special">}</span> + + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span> <span class="special">==</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">Expensive</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Expensive</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">key_</span> <span class="special">==</span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">key_</span><span class="special">;</span> <span class="special">}</span> + + <span class="keyword">friend</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">hash_value</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">Expensive</span> <span class="special">&</span><span class="identifier">object</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">StrHasher</span><span class="special">()(</span><span class="identifier">object</span><span class="special">.</span><span class="identifier">get_key</span><span class="special">().</span><span class="identifier">c_str</span><span class="special">());</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="comment">// A set and unordered_set that store Expensive objects</span> +<span class="keyword">typedef</span> <span class="identifier">set</span><span class="special"><</span><span class="identifier">Expensive</span><span class="special">></span> <span class="identifier">Set</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">unordered_set</span><span class="special"><</span><span class="identifier">Expensive</span><span class="special">></span> <span class="identifier">UnorderedSet</span><span class="special">;</span> + +<span class="comment">// Search functions</span> +<span class="identifier">Expensive</span> <span class="special">*</span><span class="identifier">get_from_set</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">key</span><span class="special">,</span> <span class="identifier">Set</span> <span class="special">&</span><span class="identifier">set_object</span><span class="special">)</span> +<span class="special">{</span> + <span class="identifier">Set</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">set_object</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="identifier">Expensive</span><span class="special">(</span><span class="identifier">key</span><span class="special">));</span> + <span class="keyword">if</span><span class="special">(</span> <span class="identifier">it</span> <span class="special">==</span> <span class="identifier">set_object</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> + <span class="keyword">return</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">;</span> +<span class="special">}</span> + +<span class="identifier">Expensive</span> <span class="special">*</span><span class="identifier">get_from_uset</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">key</span><span class="special">,</span> <span class="identifier">UnorderedSet</span> <span class="special">&</span><span class="identifier">uset_object</span><span class="special">)</span> +<span class="special">{</span> + <span class="identifier">UnorderedSet</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">uset_object</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="identifier">Expensive</span> <span class="special">(</span><span class="identifier">key</span><span class="special">));</span> + <span class="keyword">if</span><span class="special">(</span> <span class="identifier">it</span> <span class="special">==</span> <span class="identifier">uset_object</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> + <span class="keyword">return</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + <code class="computeroutput"><span class="identifier">Expensive</span></code> is an expensive + object to construct. If "key" c-string is quite long <code class="computeroutput"><span class="identifier">Expensive</span></code> has to construct a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code> + using heap memory. Like <code class="computeroutput"><span class="identifier">Expensive</span></code>, + many times the only member taking part in ordering issues is just a small + part of the class. For example, with <code class="computeroutput"><span class="identifier">Expensive</span></code>, + only the internal <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code> is needed to compare the object. + </p> +<p> + In both containers, if we call <code class="computeroutput"><span class="identifier">get_from_set</span><span class="special">/</span><span class="identifier">get_from_unordered_set</span></code> + in a loop, we might get a performance penalty, because we are forced to create + a whole <code class="computeroutput"><span class="identifier">Expensive</span></code> object + to be able to find an equivalent one. + </p> +<p> + Sometimes this interface limitation is severe, because we <span class="bold"><strong>might + not have enough information to construct the object</strong></span> but we might + <span class="bold"><strong>have enough information to find the object</strong></span>. + In this case, a name is enough to search <code class="computeroutput"><span class="identifier">Expensive</span></code> + in the container but constructing an <code class="computeroutput"><span class="identifier">Expensive</span></code> + might require more information that the user might not have. + </p> +<p> + To solve this, <code class="computeroutput"><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a></code>/<code class="computeroutput"><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a></code> offer alternative functions, + which take any type comparable with the value and a functor that should be + compatible with the ordering function of the associative container. <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set.html" title="Class template unordered_set">unordered_set</a></code>/<code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_multiset.html" title="Class template unordered_multiset">unordered_multiset</a></code> + offers functions that take any key type and compatible hash and equality + functions. Now, let's see the optimized search function: + </p> +<p> +</p> +<pre class="programlisting"><span class="comment">// These compare Expensive and a c-string</span> +<span class="keyword">struct</span> <span class="identifier">StrExpComp</span> +<span class="special">{</span> + <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span><span class="identifier">str</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Expensive</span> <span class="special">&</span><span class="identifier">c</span><span class="special">)</span> <span class="keyword">const</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">strcmp</span><span class="special">(</span><span class="identifier">str</span><span class="special">,</span> <span class="identifier">c</span><span class="special">.</span><span class="identifier">get_key</span><span class="special">().</span><span class="identifier">c_str</span><span class="special">())</span> <span class="special"><</span> <span class="number">0</span><span class="special">;</span> <span class="special">}</span> + + <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="identifier">Expensive</span> <span class="special">&</span><span class="identifier">c</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span><span class="identifier">str</span><span class="special">)</span> <span class="keyword">const</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">strcmp</span><span class="special">(</span><span class="identifier">c</span><span class="special">.</span><span class="identifier">get_key</span><span class="special">().</span><span class="identifier">c_str</span><span class="special">(),</span> <span class="identifier">str</span><span class="special">)</span> <span class="special"><</span> <span class="number">0</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="keyword">struct</span> <span class="identifier">StrExpEqual</span> +<span class="special">{</span> + <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span><span class="identifier">str</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Expensive</span> <span class="special">&</span><span class="identifier">c</span><span class="special">)</span> <span class="keyword">const</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">strcmp</span><span class="special">(</span><span class="identifier">str</span><span class="special">,</span> <span class="identifier">c</span><span class="special">.</span><span class="identifier">get_key</span><span class="special">().</span><span class="identifier">c_str</span><span class="special">())</span> <span class="special">==</span> <span class="number">0</span><span class="special">;</span> <span class="special">}</span> + + <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="identifier">Expensive</span> <span class="special">&</span><span class="identifier">c</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span><span class="identifier">str</span><span class="special">)</span> <span class="keyword">const</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">strcmp</span><span class="special">(</span><span class="identifier">c</span><span class="special">.</span><span class="identifier">get_key</span><span class="special">().</span><span class="identifier">c_str</span><span class="special">(),</span> <span class="identifier">str</span><span class="special">)</span> <span class="special">==</span> <span class="number">0</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="comment">// Optimized search functions</span> +<span class="identifier">Expensive</span> <span class="special">*</span><span class="identifier">get_from_set_optimized</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">key</span><span class="special">,</span> <span class="identifier">Set</span> <span class="special">&</span><span class="identifier">set_object</span><span class="special">)</span> +<span class="special">{</span> + <span class="identifier">Set</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">set_object</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="identifier">key</span><span class="special">,</span> <span class="identifier">StrExpComp</span><span class="special">());</span> + <span class="keyword">if</span><span class="special">(</span> <span class="identifier">it</span> <span class="special">==</span> <span class="identifier">set_object</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> + <span class="keyword">return</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">;</span> +<span class="special">}</span> + +<span class="identifier">Expensive</span> <span class="special">*</span><span class="identifier">get_from_uset_optimized</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">key</span><span class="special">,</span> <span class="identifier">UnorderedSet</span> <span class="special">&</span><span class="identifier">uset_object</span><span class="special">)</span> +<span class="special">{</span> + <span class="identifier">UnorderedSet</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">uset_object</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="identifier">key</span><span class="special">,</span> <span class="identifier">StrHasher</span><span class="special">(),</span> <span class="identifier">StrExpEqual</span><span class="special">());</span> + <span class="keyword">if</span><span class="special">(</span> <span class="identifier">it</span> <span class="special">==</span> <span class="identifier">uset_object</span><span class="special">.</span><span class="identifier">end</span><span class="special">()</span> <span class="special">)</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> + <span class="keyword">return</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + This new arbitrary key overload is also available for other functions taking + values as arguments: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + equal_range + </li> +<li class="listitem"> + lower_bound + </li> +<li class="listitem"> + upper_bound + </li> +<li class="listitem"> + count + </li> +<li class="listitem"> + find + </li> +<li class="listitem"> + erase + </li> +</ul></div> +<p> + Check <code class="computeroutput"><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a></code>, <code class="computeroutput"><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a></code>, <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set.html" title="Class template unordered_set">unordered_set</a></code>, + <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_multiset.html" title="Class template unordered_multiset">unordered_multiset</a></code> + references to know more about those functions. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.advanced_lookups_insertions.advanced_insertions"></a><a class="link" href="advanced_lookups_insertions.html#intrusive.advanced_lookups_insertions.advanced_insertions" title="Advanced insertions">Advanced + insertions</a> +</h3></div></div></div> +<p> + A similar issue happens with insertions in simple ordered and unordered associative + containers with unique keys (<code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span></code> and + <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">tr1</span><span class="special">::</span><span class="identifier">unordered_set</span></code>). + In these containers, if a value is already present, the value to be inserted + is discarded. With expensive values, if the value is already present, we + can suffer efficiency problems. + </p> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a></code> and <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set.html" title="Class template unordered_set">unordered_set</a></code> + have insertion functions to check efficiently, without constructing the value, + if a value is present or not and if it's not present, a function to insert + it immediately without any further lookup. For example, using the same <code class="computeroutput"><span class="identifier">Expensive</span></code> class, this function can be inefficient: + </p> +<p> +</p> +<pre class="programlisting"><span class="comment">// Insertion functions</span> +<span class="keyword">bool</span> <span class="identifier">insert_to_set</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">key</span><span class="special">,</span> <span class="identifier">Set</span> <span class="special">&</span><span class="identifier">set_object</span><span class="special">)</span> +<span class="special">{</span> + <span class="identifier">Expensive</span> <span class="special">*</span><span class="identifier">pobject</span> <span class="special">=</span> <span class="keyword">new</span> <span class="identifier">Expensive</span><span class="special">(</span><span class="identifier">key</span><span class="special">);</span> + <span class="keyword">bool</span> <span class="identifier">success</span> <span class="special">=</span> <span class="identifier">set_object</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(*</span><span class="identifier">pobject</span><span class="special">).</span><span class="identifier">second</span><span class="special">;</span> + <span class="keyword">if</span><span class="special">(!</span><span class="identifier">success</span><span class="special">)</span> <span class="keyword">delete</span> <span class="identifier">pobject</span><span class="special">;</span> + <span class="keyword">return</span> <span class="identifier">success</span><span class="special">;</span> +<span class="special">}</span> + +<span class="keyword">bool</span> <span class="identifier">insert_to_uset</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">key</span><span class="special">,</span> <span class="identifier">UnorderedSet</span> <span class="special">&</span><span class="identifier">uset_object</span><span class="special">)</span> +<span class="special">{</span> + <span class="identifier">Expensive</span> <span class="special">*</span><span class="identifier">pobject</span> <span class="special">=</span> <span class="keyword">new</span> <span class="identifier">Expensive</span><span class="special">(</span><span class="identifier">key</span><span class="special">);</span> + <span class="keyword">bool</span> <span class="identifier">success</span> <span class="special">=</span> <span class="identifier">uset_object</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(*</span><span class="identifier">pobject</span><span class="special">).</span><span class="identifier">second</span><span class="special">;</span> + <span class="keyword">if</span><span class="special">(!</span><span class="identifier">success</span><span class="special">)</span> <span class="keyword">delete</span> <span class="identifier">pobject</span><span class="special">;</span> + <span class="keyword">return</span> <span class="identifier">success</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + If the object is already present, we are constructing an <code class="computeroutput"><span class="identifier">Expensive</span></code> + that will be discarded, and this is a waste of resources. Instead of that, + let's use <code class="computeroutput"><span class="identifier">insert_check</span></code> and + <code class="computeroutput"><span class="identifier">insert_commit</span></code> functions: + </p> +<p> +</p> +<pre class="programlisting"><span class="comment">// Optimized insertion functions</span> +<span class="keyword">bool</span> <span class="identifier">insert_to_set_optimized</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">key</span><span class="special">,</span> <span class="identifier">Set</span> <span class="special">&</span><span class="identifier">set_object</span><span class="special">)</span> +<span class="special">{</span> + <span class="identifier">Set</span><span class="special">::</span><span class="identifier">insert_commit_data</span> <span class="identifier">insert_data</span><span class="special">;</span> + <span class="keyword">bool</span> <span class="identifier">success</span> <span class="special">=</span> <span class="identifier">set_object</span><span class="special">.</span><span class="identifier">insert_check</span><span class="special">(</span><span class="identifier">key</span><span class="special">,</span> <span class="identifier">StrExpComp</span><span class="special">(),</span> <span class="identifier">insert_data</span><span class="special">).</span><span class="identifier">second</span><span class="special">;</span> + <span class="keyword">if</span><span class="special">(</span><span class="identifier">success</span><span class="special">)</span> <span class="identifier">set_object</span><span class="special">.</span><span class="identifier">insert_commit</span><span class="special">(*</span><span class="keyword">new</span> <span class="identifier">Expensive</span><span class="special">(</span><span class="identifier">key</span><span class="special">),</span> <span class="identifier">insert_data</span><span class="special">);</span> + <span class="keyword">return</span> <span class="identifier">success</span><span class="special">;</span> +<span class="special">}</span> + +<span class="keyword">bool</span> <span class="identifier">insert_to_uset_optimized</span><span class="special">(</span><span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">key</span><span class="special">,</span> <span class="identifier">UnorderedSet</span> <span class="special">&</span><span class="identifier">uset_object</span><span class="special">)</span> +<span class="special">{</span> + <span class="identifier">UnorderedSet</span><span class="special">::</span><span class="identifier">insert_commit_data</span> <span class="identifier">insert_data</span><span class="special">;</span> + <span class="keyword">bool</span> <span class="identifier">success</span> <span class="special">=</span> <span class="identifier">uset_object</span><span class="special">.</span><span class="identifier">insert_check</span> + <span class="special">(</span><span class="identifier">key</span><span class="special">,</span> <span class="identifier">StrHasher</span><span class="special">(),</span> <span class="identifier">StrExpEqual</span><span class="special">(),</span> <span class="identifier">insert_data</span><span class="special">).</span><span class="identifier">second</span><span class="special">;</span> + <span class="keyword">if</span><span class="special">(</span><span class="identifier">success</span><span class="special">)</span> <span class="identifier">uset_object</span><span class="special">.</span><span class="identifier">insert_commit</span><span class="special">(*</span><span class="keyword">new</span> <span class="identifier">Expensive</span><span class="special">(</span><span class="identifier">key</span><span class="special">),</span> <span class="identifier">insert_data</span><span class="special">);</span> + <span class="keyword">return</span> <span class="identifier">success</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + <code class="computeroutput"><span class="identifier">insert_check</span></code> is similar to + a normal <code class="computeroutput"><span class="identifier">insert</span></code> but: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">insert_check</span></code> can be used + with arbitrary keys + </li> +<li class="listitem"> + if the insertion is possible (there is no equivalent value) <code class="computeroutput"><span class="identifier">insert_check</span></code> collects all the needed + information in an <code class="computeroutput"><span class="identifier">insert_commit_data</span></code> + structure, so that <code class="computeroutput"><span class="identifier">insert_commit</span></code>: + <div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + <span class="bold"><strong>does not execute</strong></span> further comparisons + </li> +<li class="listitem"> + can be executed with <span class="bold"><strong>constant-time complexity</strong></span> + </li> +<li class="listitem"> + has <span class="bold"><strong>no-throw guarantee</strong></span>. + </li> +</ul></div> + </li> +</ul></div> +<p> + These functions must be used with care, since no other insertion or erasure + must be executed between an <code class="computeroutput"><span class="identifier">insert_check</span></code> + and an <code class="computeroutput"><span class="identifier">insert_commit</span></code> pair. + Otherwise, the behaviour is undefined. <code class="computeroutput"><span class="identifier">insert_check</span></code> + and <code class="computeroutput"><span class="identifier">insert_commit</span></code> will come + in handy for developers programming efficient non-intrusive associative containers. + See <code class="computeroutput"><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a></code> and <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set.html" title="Class template unordered_set">unordered_set</a></code> reference + for more information about <code class="computeroutput"><span class="identifier">insert_check</span></code> + and <code class="computeroutput"><span class="identifier">insert_commit</span></code>. + </p> +<p> + With multiple ordered and unordered associative containers (<code class="computeroutput"><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a></code> + and <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_multiset.html" title="Class template unordered_multiset">unordered_multiset</a></code>) + there is no need for these advanced insertion functions, since insertions + are always successful. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.advanced_lookups_insertions.positional_insertions"></a><a class="link" href="advanced_lookups_insertions.html#intrusive.advanced_lookups_insertions.positional_insertions" title="Positional insertions">Positional + insertions</a> +</h3></div></div></div> +<p> + Some ordered associative containers offer low-level functions to bypass ordering + checks and insert nodes directly in desired tree positions. These functions + are provided for performance reasons when values to be inserted in the container + are known to fulfill order (sets and multisets) and uniqueness (sets) invariants. + A typical usage of these functions is when intrusive associative containers + are used to build non-intrusive containers and the programmer wants to speed + up assignments from other associative containers: if the ordering and uniqueness + properties are the same, there is no need to waste time checking the position + of each source value, because values are already ordered: back insertions + will be much more efficient. + </p> +<p> + <span class="bold"><strong>Note:</strong></span> These functions <span class="bold"><strong>don't + check preconditions</strong></span> so they must used with care. These are functions + are low-level operations <span class="bold"><strong>will break container invariants + if ordering and uniqueness preconditions are not assured by the caller.</strong></span> + </p> +<p> + Let's see an example: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">set</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cassert</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="comment">//A simple class with a set hook</span> +<span class="keyword">class</span> <span class="identifier">MyClass</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">set_base_hook</span><span class="special"><></span> +<span class="special">{</span> + <span class="keyword">public</span><span class="special">:</span> + <span class="keyword">int</span> <span class="identifier">int_</span><span class="special">;</span> + + <span class="identifier">MyClass</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">int_</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> <span class="special">{}</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special"><</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">int_</span> <span class="special"><</span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">></span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">int_</span> <span class="special">></span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="comment">//Create some ORDERED elements</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">values</span><span class="special">;</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">100</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">values</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">MyClass</span><span class="special">(</span><span class="identifier">i</span><span class="special">));</span> + + <span class="special">{</span> <span class="comment">//Data is naturally ordered in the vector with the same criteria</span> + <span class="comment">//as multiset's comparison predicate, so we can just push back</span> + <span class="comment">//all elements, which is more efficient than normal insertion</span> + <span class="identifier">multiset</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">mset</span><span class="special">;</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">100</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">mset</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">values</span><span class="special">[</span><span class="identifier">i</span><span class="special">]);</span> + + <span class="comment">//Now check orderd invariant</span> + <span class="identifier">multiset</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">const_iterator</span> <span class="identifier">next</span><span class="special">(</span><span class="identifier">mset</span><span class="special">.</span><span class="identifier">cbegin</span><span class="special">()),</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">next</span><span class="special">++);</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">99</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">,</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">next</span><span class="special">)</span> <span class="identifier">assert</span><span class="special">(*</span><span class="identifier">it</span> <span class="special"><</span> <span class="special">*</span><span class="identifier">next</span><span class="special">);</span> + <span class="special">}</span> + <span class="special">{</span> <span class="comment">//Now the correct order for the set is the reverse order</span> + <span class="comment">//so let's push front all elements</span> + <span class="identifier">multiset</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">compare</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">greater</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="special">></span> <span class="special">></span> <span class="identifier">mset</span><span class="special">;</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">100</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">mset</span><span class="special">.</span><span class="identifier">push_front</span><span class="special">(</span><span class="identifier">values</span><span class="special">[</span><span class="identifier">i</span><span class="special">]);</span> + + <span class="comment">//Now check orderd invariant</span> + <span class="identifier">multiset</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">compare</span><span class="special"><</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">greater</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="special">></span> <span class="special">>::</span> + <span class="identifier">const_iterator</span> <span class="identifier">next</span><span class="special">(</span><span class="identifier">mset</span><span class="special">.</span><span class="identifier">cbegin</span><span class="special">()),</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">next</span><span class="special">++);</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">99</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">,</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">next</span><span class="special">)</span> <span class="identifier">assert</span><span class="special">(*</span><span class="identifier">it</span> <span class="special">></span> <span class="special">*</span><span class="identifier">next</span><span class="special">);</span> + <span class="special">}</span> + <span class="special">{</span> <span class="comment">//Now push the first and the last and insert the rest</span> + <span class="comment">//before the last position using "insert_before"</span> + <span class="identifier">multiset</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">mset</span><span class="special">;</span> + <span class="identifier">mset</span><span class="special">.</span><span class="identifier">insert_before</span><span class="special">(</span><span class="identifier">mset</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">values</span><span class="special">[</span><span class="number">0</span><span class="special">]);</span> + <span class="identifier">multiset</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">const_iterator</span> <span class="identifier">pos</span> <span class="special">=</span> + <span class="identifier">mset</span><span class="special">.</span><span class="identifier">insert_before</span><span class="special">(</span><span class="identifier">mset</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">values</span><span class="special">[</span><span class="number">99</span><span class="special">]);</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">99</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">mset</span><span class="special">.</span><span class="identifier">insert_before</span><span class="special">(</span><span class="identifier">pos</span><span class="special">,</span> <span class="identifier">values</span><span class="special">[</span><span class="identifier">i</span><span class="special">]);</span> + + <span class="comment">//Now check orderd invariant</span> + <span class="identifier">multiset</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">const_iterator</span> <span class="identifier">next</span><span class="special">(</span><span class="identifier">mset</span><span class="special">.</span><span class="identifier">cbegin</span><span class="special">()),</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">next</span><span class="special">++);</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">99</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">,</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">next</span><span class="special">)</span> <span class="identifier">assert</span><span class="special">(*</span><span class="identifier">it</span> <span class="special"><</span> <span class="special">*</span><span class="identifier">next</span><span class="special">);</span> + <span class="special">}</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +</div> +<p> + For more information about advanced lookup and insertion functions see associative + containers' documentation (e.g. <code class="computeroutput"><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a></code>, + <code class="computeroutput"><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a></code>, <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set.html" title="Class template unordered_set">unordered_set</a></code> and <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_multiset.html" title="Class template unordered_multiset">unordered_multiset</a></code> references). + </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"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="treap_set_multiset.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="erasing_and_disposing.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/any_hooks.html b/doc/html/intrusive/any_hooks.html new file mode 100755 index 0000000000..f7797036a7 --- /dev/null +++ b/doc/html/intrusive/any_hooks.html @@ -0,0 +1,145 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Any Hooks: A single hook for any Intrusive container</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="obtaining_iterators_from_values.html" title="Obtaining iterators from values"> +<link rel="next" href="concepts.html" title="Concepts explained"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="obtaining_iterators_from_values.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="concepts.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.any_hooks"></a><a class="link" href="any_hooks.html" title="Any Hooks: A single hook for any Intrusive container">Any Hooks: A single hook for any Intrusive + container</a> +</h2></div></div></div> +<p> + Sometimes, a class programmer wants to place a class in several intrusive containers + but no at the same time. In this case, the programmer might decide to insert + two hooks in the same class. + </p> +<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">MyClass</span> + <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">list_base_hook</span><span class="special"><>,</span> <span class="keyword">public</span> <span class="identifier">slist_base_hook</span><span class="special"><></span> <span class="comment">//...</span> +<span class="special">{};</span> +</pre> +<p> + However, there is a more size-efficient alternative in <span class="bold"><strong>Boost.Intrusive</strong></span>: + "any" hooks (<code class="computeroutput"><a class="link" href="../boost/intrusive/any_base_hook.html" title="Class template any_base_hook">any_base_hook</a></code> + and <code class="computeroutput"><a class="link" href="../boost/intrusive/any_member_hook.html" title="Class template any_member_hook">any_member_hook</a></code>). + These hooks can be used to store a type in several containers offered by <span class="bold"><strong>Boost.Intrusive</strong></span> minimizing the size of the class. + </p> +<p> + These hooks support these options: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">tag</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Tag</span><span class="special">></span></code></strong></span> + (for base hooks only): This argument serves as a tag, so you can derive + from more than one slist hook. Default: <code class="computeroutput"><span class="identifier">tag</span><span class="special"><</span><span class="identifier">default_tag</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">link_mode_type</span> + <span class="identifier">LinkMode</span><span class="special">></span></code></strong></span>: + The linking policy. <code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">auto_unlink</span><span class="special">></span></code> is <span class="bold"><strong>not</strong></span> + supported and <code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">safe_mode</span><span class="special">></span></code> might offer weaker error detection + in any hooks than in other hooks. Default: <code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">safe_link</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">void_pointer</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">VoidPointer</span><span class="special">></span></code></strong></span>: + The pointer type to be used internally in the hook and propagated to the + container. Default: <code class="computeroutput"><span class="identifier">void_pointer</span><span class="special"><</span><span class="keyword">void</span><span class="special">*></span></code>. + </li> +</ul></div> +<p> + <code class="computeroutput"><span class="identifier">auto_unlink</span></code> can't be supported + because the hook does not know in which type of container might be currently + inserted. Additionally, these hooks don't support <code class="computeroutput"><span class="identifier">unlink</span><span class="special">()</span></code> and <code class="computeroutput"><span class="identifier">swap_nodes</span><span class="special">()</span></code> operations for the same reason. + </p> +<p> + Here is an example that creates a class with two any hooks, and uses one to + insert the class in a <code class="computeroutput">slist</code> and the other + one in a <code class="computeroutput">list</code>. + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">any_hook</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">slist</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="keyword">class</span> <span class="identifier">MyClass</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">any_base_hook</span><span class="special"><></span> <span class="comment">//Base hook</span> +<span class="special">{</span> + <span class="keyword">int</span> <span class="identifier">int_</span><span class="special">;</span> + + <span class="keyword">public</span><span class="special">:</span> + <span class="identifier">any_member_hook</span><span class="special"><></span> <span class="identifier">member_hook_</span><span class="special">;</span> <span class="comment">//Member hook</span> + + <span class="identifier">MyClass</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">int_</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> + <span class="special">{}</span> +<span class="special">};</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="comment">//Define a base hook option that converts any_base_hook to a slist hook</span> + <span class="keyword">typedef</span> <span class="identifier">any_to_slist_hook</span> <span class="special"><</span> <span class="identifier">base_hook</span><span class="special"><</span> <span class="identifier">any_base_hook</span><span class="special"><></span> <span class="special">></span> <span class="special">></span> <span class="identifier">BaseSlistOption</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">slist</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">BaseSlistOption</span><span class="special">></span> <span class="identifier">BaseSList</span><span class="special">;</span> + + <span class="comment">//Define a member hook option that converts any_member_hook to a list hook</span> + <span class="keyword">typedef</span> <span class="identifier">any_to_list_hook</span><span class="special"><</span> <span class="identifier">member_hook</span> + <span class="special"><</span> <span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">any_member_hook</span><span class="special"><>,</span> <span class="special">&</span><span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">member_hook_</span><span class="special">></span> <span class="special">></span> <span class="identifier">MemberListOption</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">MemberListOption</span><span class="special">></span> <span class="identifier">MemberList</span><span class="special">;</span> + + <span class="comment">//Create several MyClass objects, each one with a different value</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">values</span><span class="special">;</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">100</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">){</span> <span class="identifier">values</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">MyClass</span><span class="special">(</span><span class="identifier">i</span><span class="special">));</span> <span class="special">}</span> + + <span class="identifier">BaseSList</span> <span class="identifier">base_slist</span><span class="special">;</span> <span class="identifier">MemberList</span> <span class="identifier">member_list</span><span class="special">;</span> + + <span class="comment">//Now insert them in reverse order in the slist and in order in the list</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">iterator</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">)</span> + <span class="identifier">base_slist</span><span class="special">.</span><span class="identifier">push_front</span><span class="special">(*</span><span class="identifier">it</span><span class="special">),</span> <span class="identifier">member_list</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + + <span class="comment">//Now test lists</span> + <span class="identifier">BaseSList</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">bit</span><span class="special">(</span><span class="identifier">base_slist</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">bitend</span><span class="special">(</span><span class="identifier">base_slist</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + <span class="identifier">MemberList</span><span class="special">::</span><span class="identifier">reverse_iterator</span> <span class="identifier">mrit</span><span class="special">(</span><span class="identifier">member_list</span><span class="special">.</span><span class="identifier">rbegin</span><span class="special">()),</span> <span class="identifier">mritend</span><span class="special">(</span><span class="identifier">member_list</span><span class="special">.</span><span class="identifier">rend</span><span class="special">());</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">reverse_iterator</span> <span class="identifier">rit</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">rbegin</span><span class="special">()),</span> <span class="identifier">ritend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">rend</span><span class="special">());</span> + + <span class="comment">//Test the objects inserted in the base hook list</span> + <span class="keyword">for</span><span class="special">(;</span> <span class="identifier">rit</span> <span class="special">!=</span> <span class="identifier">ritend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">rit</span><span class="special">,</span> <span class="special">++</span><span class="identifier">bit</span><span class="special">,</span> <span class="special">++</span><span class="identifier">mrit</span><span class="special">)</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">bit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">rit</span> <span class="special">||</span> <span class="special">&*</span><span class="identifier">mrit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">rit</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </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"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="obtaining_iterators_from_values.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="concepts.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/auto_unlink_hooks.html b/doc/html/intrusive/auto_unlink_hooks.html new file mode 100755 index 0000000000..13bd04f1fc --- /dev/null +++ b/doc/html/intrusive/auto_unlink_hooks.html @@ -0,0 +1,247 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Auto-unlink hooks</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="safe_hook.html" title="Safe hooks"> +<link rel="next" href="slist.html" title="Intrusive singly linked list: slist"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="safe_hook.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="slist.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.auto_unlink_hooks"></a><a class="link" href="auto_unlink_hooks.html" title="Auto-unlink hooks">Auto-unlink hooks</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="auto_unlink_hooks.html#intrusive.auto_unlink_hooks.auto_unlink_hooks_what">What's + an auto-unlink hook?</a></span></dt> +<dt><span class="section"><a href="auto_unlink_hooks.html#intrusive.auto_unlink_hooks.auto_unlink_hooks_example">Auto-unlink + hook example</a></span></dt> +<dt><span class="section"><a href="auto_unlink_hooks.html#intrusive.auto_unlink_hooks.auto_unlink_and_constant_time">Auto-unlink + hooks and containers with constant-time <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code></a></span></dt> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.auto_unlink_hooks.auto_unlink_hooks_what"></a><a class="link" href="auto_unlink_hooks.html#intrusive.auto_unlink_hooks.auto_unlink_hooks_what" title="What's an auto-unlink hook?">What's + an auto-unlink hook?</a> +</h3></div></div></div> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> offers additional hooks + with unique features: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + When the destructor of the hook is called, the hook checks if the node + is inserted in a container. If so, the hook removes the node from the + container. + </li> +<li class="listitem"> + The hook has a member function called <code class="computeroutput"><span class="identifier">unlink</span><span class="special">()</span></code> that can be used to unlink the node + from the container at any time, without having any reference to the container, + if the user wants to do so. + </li> +</ul></div> +<p> + These hooks have exactly the same size overhead as their analog non auto-unlinking + hooks, but they have a restriction: they can only be used with <a class="link" href="presenting_containers.html" title="Presenting Boost.Intrusive containers">non-constant + time containers</a>. There is a reason for this: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + Auto-unlink hooks don't store any reference to the container where they + are inserted. + </li> +<li class="listitem"> + Only containers with non constant-time <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code> allow removing an object from the container + without referring to the container. + </li> +</ul></div> +<p> + This auto-unlink feature is useful in certain applications but it must be + used <span class="bold"><strong>very carefully</strong></span>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + If several threads are using the same container the destructor of the + auto-unlink hook will be called without any thread synchronization so + removing the object is thread-unsafe. + </li> +<li class="listitem"> + Container contents change silently without modifying the container directly. + This can lead to surprising effects. + </li> +</ul></div> +<p> + These auto-unlink hooks have also safe-mode properties: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + Hooks' constructors put the hook in a well-known default state. + </li> +<li class="listitem"> + Every time an object is inserted in the intrusive container, the container + checks if the hook is in the well-known default state. If not, an assertion + is raised. + </li> +<li class="listitem"> + Every time an object is erased from an intrusive container, the container + puts the erased object in the well-known default state. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.auto_unlink_hooks.auto_unlink_hooks_example"></a><a class="link" href="auto_unlink_hooks.html#intrusive.auto_unlink_hooks.auto_unlink_hooks_example" title="Auto-unlink hook example">Auto-unlink + hook example</a> +</h3></div></div></div> +<p> + Let's see an example of an auto-unlink hook: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cassert</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">list_base_hook</span><span class="special"><</span><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">auto_unlink</span><span class="special">></span> <span class="special">></span> <span class="identifier">auto_unlink_hook</span><span class="special">;</span> + +<span class="keyword">class</span> <span class="identifier">MyClass</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">auto_unlink_hook</span> + <span class="comment">//This hook removes the node in the destructor</span> +<span class="special">{</span> + <span class="keyword">int</span> <span class="identifier">int_</span><span class="special">;</span> + + <span class="keyword">public</span><span class="special">:</span> + <span class="identifier">MyClass</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">int_</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> <span class="special">{}</span> + <span class="keyword">void</span> <span class="identifier">unlink</span><span class="special">()</span> <span class="special">{</span> <span class="identifier">auto_unlink_hook</span><span class="special">::</span><span class="identifier">unlink</span><span class="special">();</span> <span class="special">}</span> + <span class="keyword">bool</span> <span class="identifier">is_linked</span><span class="special">()</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">auto_unlink_hook</span><span class="special">::</span><span class="identifier">is_linked</span><span class="special">();</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="comment">//Define a list that will store values using the base hook</span> +<span class="comment">//The list can't have constant-time size!</span> +<span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span> <span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">false</span><span class="special">></span> <span class="special">></span> <span class="identifier">List</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="comment">//Create the list</span> + <span class="identifier">List</span> <span class="identifier">l</span><span class="special">;</span> + <span class="special">{</span> + <span class="comment">//Create myclass and check it's linked</span> + <span class="identifier">MyClass</span> <span class="identifier">myclass</span><span class="special">;</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">myclass</span><span class="special">.</span><span class="identifier">is_linked</span><span class="special">()</span> <span class="special">==</span> <span class="keyword">false</span><span class="special">);</span> + + <span class="comment">//Insert the object</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">myclass</span><span class="special">);</span> + + <span class="comment">//Check that we have inserted the object</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">empty</span><span class="special">()</span> <span class="special">==</span> <span class="keyword">false</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(&</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">front</span><span class="special">()</span> <span class="special">==</span> <span class="special">&</span><span class="identifier">myclass</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">myclass</span><span class="special">.</span><span class="identifier">is_linked</span><span class="special">()</span> <span class="special">==</span> <span class="keyword">true</span><span class="special">);</span> + + <span class="comment">//Now myclass' destructor will unlink it</span> + <span class="comment">//automatically</span> + <span class="special">}</span> + + <span class="comment">//Check auto-unlink has been executed</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">empty</span><span class="special">()</span> <span class="special">==</span> <span class="keyword">true</span><span class="special">);</span> + + <span class="special">{</span> + <span class="comment">//Now test the unlink() function</span> + + <span class="comment">//Create myclass and check it's linked</span> + <span class="identifier">MyClass</span> <span class="identifier">myclass</span><span class="special">;</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">myclass</span><span class="special">.</span><span class="identifier">is_linked</span><span class="special">()</span> <span class="special">==</span> <span class="keyword">false</span><span class="special">);</span> + + <span class="comment">//Insert the object</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">myclass</span><span class="special">);</span> + + <span class="comment">//Check that we have inserted the object</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">empty</span><span class="special">()</span> <span class="special">==</span> <span class="keyword">false</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(&</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">front</span><span class="special">()</span> <span class="special">==</span> <span class="special">&</span><span class="identifier">myclass</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">myclass</span><span class="special">.</span><span class="identifier">is_linked</span><span class="special">()</span> <span class="special">==</span> <span class="keyword">true</span><span class="special">);</span> + + <span class="comment">//Now unlink the node</span> + <span class="identifier">myclass</span><span class="special">.</span><span class="identifier">unlink</span><span class="special">();</span> + + <span class="comment">//Check auto-unlink has been executed</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">empty</span><span class="special">()</span> <span class="special">==</span> <span class="keyword">true</span><span class="special">);</span> + <span class="special">}</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.auto_unlink_hooks.auto_unlink_and_constant_time"></a><a class="link" href="auto_unlink_hooks.html#intrusive.auto_unlink_hooks.auto_unlink_and_constant_time" title="Auto-unlink hooks and containers with constant-time size()">Auto-unlink + hooks and containers with constant-time <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code></a> +</h3></div></div></div> +<p> + As explained, <span class="bold"><strong>Boost.Intrusive</strong></span> auto-unlink + hooks are incompatible with containers that have constant-time <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code>, + so if you try to define such container with an auto-unlink hook's value_traits, + you will get a static assertion: + </p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="keyword">struct</span> <span class="identifier">MyTag</span><span class="special">;</span> + +<span class="keyword">class</span> <span class="identifier">MyClass</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">list_base_hook</span><span class="special"><</span> <span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">auto_unlink</span><span class="special">></span> <span class="special">></span> +<span class="special">{/**/};</span> + +<span class="identifier">list</span> <span class="special"><</span><span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">true</span><span class="special">></span> <span class="special">></span> <span class="identifier">bad_list</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="identifier">bad_list</span> <span class="identifier">list</span><span class="special">;</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + leads to an error similar to: + </p> +<pre class="programlisting">error : use of undefined type 'boost::STATIC_ASSERTION_FAILURE<false>' +</pre> +<p> + Pointing to code like this: + </p> +<pre class="programlisting"><span class="comment">//Constant-time size is incompatible with auto-unlink hooks!</span> +<span class="identifier">BOOST_STATIC_ASSERT</span><span class="special">(!(</span><span class="identifier">constant_time_size</span> <span class="special">&&</span> <span class="special">((</span><span class="keyword">int</span><span class="special">)</span><span class="identifier">value_traits</span><span class="special">::</span><span class="identifier">link_mode</span> <span class="special">==</span> <span class="special">(</span><span class="keyword">int</span><span class="special">)</span><span class="identifier">auto_unlink</span><span class="special">)));</span> +</pre> +<p> + This way, there is no way to compile a program if you try to use auto-unlink + hooks in constant-time size containers. + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="safe_hook.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="slist.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/avl_set_multiset.html b/doc/html/intrusive/avl_set_multiset.html new file mode 100755 index 0000000000..92392735de --- /dev/null +++ b/doc/html/intrusive/avl_set_multiset.html @@ -0,0 +1,272 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Intrusive avl tree based associative containers: avl_set, avl_multiset and avltree</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="splay_set_multiset.html" title="Intrusive splay tree based associative containers: splay_set, splay_multiset and , splay_tree"> +<link rel="next" href="sg_set_multiset.html" title="Intrusive scapegoat tree based associative containers: sg_set, sg_multiset and sgtree"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="splay_set_multiset.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="sg_set_multiset.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.avl_set_multiset"></a><a class="link" href="avl_set_multiset.html" title="Intrusive avl tree based associative containers: avl_set, avl_multiset and avltree">Intrusive avl tree based associative + containers: avl_set, avl_multiset and avltree</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="avl_set_multiset.html#intrusive.avl_set_multiset.avl_set_multiset_hooks">avl_set, + avl_multiset and avltree hooks</a></span></dt> +<dt><span class="section"><a href="avl_set_multiset.html#intrusive.avl_set_multiset.set_multiset_containers">avl_set, + avl_multiset and avltree containers</a></span></dt> +<dt><span class="section"><a href="avl_set_multiset.html#intrusive.avl_set_multiset.avl_set_multiset_example">Example</a></span></dt> +</dl></div> +<p> + Similar to red-black trees, AVL trees are balanced binary trees. AVL trees + are often compared with red-black trees because they support the same set of + operations and because both take O(log n) time for basic operations. AVL trees + are more rigidly balanced than Red-Black trees, leading to slower insertion + and removal but faster retrieval, so AVL trees perform better than red-black + trees for lookup-intensive applications. + </p> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> offers 3 containers based + on avl trees: <code class="computeroutput"><a class="link" href="../boost/intrusive/avl_set.html" title="Class template avl_set">avl_set</a></code>, + <code class="computeroutput"><a class="link" href="../boost/intrusive/avl_multiset.html" title="Class template avl_multiset">avl_multiset</a></code> and + <code class="computeroutput"><a class="link" href="../boost/intrusive/avltree.html" title="Class template avltree">avltree</a></code>. The first two + are similar to <code class="computeroutput"><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a></code> or <code class="computeroutput"><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a></code> and the latter is a generalization + that offers functions both to insert unique and multiple keys. + </p> +<p> + The memory overhead of these containers with Boost.Intrusive hooks is usually + 3 pointers and 2 bits (due to alignment, this usually means 3 pointers plus + an integer). This size can be reduced to 3 pointers if pointers have 4 byte + alignment (which is usually true in 32 bit systems). + </p> +<p> + An empty, non constant-time size <code class="computeroutput"><a class="link" href="../boost/intrusive/avl_set.html" title="Class template avl_set">avl_set</a></code>, + <code class="computeroutput"><a class="link" href="../boost/intrusive/avl_multiset.html" title="Class template avl_multiset">avl_multiset</a></code> or + <code class="computeroutput"><a class="link" href="../boost/intrusive/avltree.html" title="Class template avltree">avltree</a></code> also has a size + of 3 pointers and an integer (3 pointers when optimized for size). + </p> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.avl_set_multiset.avl_set_multiset_hooks"></a><a class="link" href="avl_set_multiset.html#intrusive.avl_set_multiset.avl_set_multiset_hooks" title="avl_set, avl_multiset and avltree hooks">avl_set, + avl_multiset and avltree hooks</a> +</h3></div></div></div> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/avl_set.html" title="Class template avl_set">avl_set</a></code>, <code class="computeroutput"><a class="link" href="../boost/intrusive/avl_multiset.html" title="Class template avl_multiset">avl_multiset</a></code> and <code class="computeroutput"><a class="link" href="../boost/intrusive/avltree.html" title="Class template avltree">avltree</a></code> share the same hooks. + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">avl_set_base_hook</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <code class="computeroutput"><a class="link" href="../boost/intrusive/avl_set_base_hook.html" title="Class template avl_set_base_hook">avl_set_base_hook</a></code>: + the user class derives publicly from this class to make it compatible + with avl tree based containers. + </li></ul></div> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">avl_set_member_hook</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <code class="computeroutput"><a class="link" href="../boost/intrusive/set_member_hook.html" title="Class template set_member_hook">set_member_hook</a></code>: + the user class contains a public member of this class to make it compatible + with avl tree based containers. + </li></ul></div> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/avl_set_base_hook.html" title="Class template avl_set_base_hook">avl_set_base_hook</a></code> + and <code class="computeroutput"><a class="link" href="../boost/intrusive/avl_set_member_hook.html" title="Class template avl_set_member_hook">avl_set_member_hook</a></code> + receive the same options explained in the section <a class="link" href="usage.html" title="How to use Boost.Intrusive">How + to use Boost.Intrusive</a> plus an option to optimize the size of the + node: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">tag</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Tag</span><span class="special">></span></code></strong></span> + (for base hooks only): This argument serves as a tag, so you can derive + from more than one base hook. Default: <code class="computeroutput"><span class="identifier">tag</span><span class="special"><</span><span class="identifier">default_tag</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">link_mode_type</span> + <span class="identifier">LinkMode</span><span class="special">></span></code></strong></span>: + The linking policy. Default: <code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">safe_link</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">void_pointer</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">VoidPointer</span><span class="special">></span></code></strong></span>: + The pointer type to be used internally in the hook and propagated to + the container. Default: <code class="computeroutput"><span class="identifier">void_pointer</span><span class="special"><</span><span class="keyword">void</span><span class="special">*></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">optimize_size</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enable</span><span class="special">></span></code></strong></span>: + The hook will be optimized for size instead of speed. The hook will embed + the balance bits of the AVL tree node in the parent pointer if pointer + alignment is multiple of 4. In some platforms, optimizing the size might + reduce speed performance a bit since masking operations will be needed + to access parent pointer and balance factor attributes, in other platforms + this option improves performance due to improved memory locality. Default: + <code class="computeroutput"><span class="identifier">optimize_size</span><span class="special"><</span><span class="keyword">false</span><span class="special">></span></code>. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.avl_set_multiset.set_multiset_containers"></a><a class="link" href="avl_set_multiset.html#intrusive.avl_set_multiset.set_multiset_containers" title="avl_set, avl_multiset and avltree containers">avl_set, + avl_multiset and avltree containers</a> +</h3></div></div></div> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">avl_set</span><span class="special">;</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">avl_multiset</span><span class="special">;</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">avltree</span><span class="special">;</span> +</pre> +<p> + These containers receive the same options explained in the section <a class="link" href="usage.html" title="How to use Boost.Intrusive">How to use Boost.Intrusive</a>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">base_hook</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Hook</span><span class="special">></span></code></strong></span> + / <span class="bold"><strong><code class="computeroutput"><span class="identifier">member_hook</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Hook</span><span class="special">,</span> <span class="identifier">Hook</span> <span class="identifier">T</span><span class="special">::*</span> <span class="identifier">PtrToMember</span><span class="special">></span></code></strong></span> + / <span class="bold"><strong><code class="computeroutput"><span class="identifier">value_traits</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">ValueTraits</span><span class="special">></span></code></strong></span>: + To specify the hook type or value traits used to configure the container. + (To learn about value traits go to the section <a class="link" href="value_traits.html" title="Containers with custom ValueTraits">Containers + with custom ValueTraits</a>.) + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + To activate the constant-time <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code> operation. Default: <code class="computeroutput"><span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">true</span><span class="special">></span></code> + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">size_type</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + To specify the type that will be used to store the size of the container. + Default: <code class="computeroutput"><span class="identifier">size_type</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">></span></code> + </li> +</ul></div> +<p> + And they also can receive an additional option: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">compare</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Compare</span><span class="special">></span></code></strong></span>: + Comparison function for the objects to be inserted in containers. The + comparison functor must induce a strict weak ordering. Default: <code class="computeroutput"><span class="identifier">compare</span><span class="special"><</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="special">></span></code> + </li></ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.avl_set_multiset.avl_set_multiset_example"></a><a class="link" href="avl_set_multiset.html#intrusive.avl_set_multiset.avl_set_multiset_example" title="Example">Example</a> +</h3></div></div></div> +<p> + Now let's see a small example using both hooks and <code class="computeroutput"><a class="link" href="../boost/intrusive/avl_set.html" title="Class template avl_set">avl_set</a></code>/ + <code class="computeroutput"><a class="link" href="../boost/intrusive/avl_multiset.html" title="Class template avl_multiset">avl_multiset</a></code> + containers: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">avl_set</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cassert</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + + <span class="comment">//This is a base hook optimized for size</span> +<span class="keyword">class</span> <span class="identifier">MyClass</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">avl_set_base_hook</span><span class="special"><</span><span class="identifier">optimize_size</span><span class="special"><</span><span class="keyword">true</span><span class="special">></span> <span class="special">></span> +<span class="special">{</span> + <span class="keyword">int</span> <span class="identifier">int_</span><span class="special">;</span> + + <span class="keyword">public</span><span class="special">:</span> + <span class="comment">//This is a member hook</span> + <span class="identifier">avl_set_member_hook</span><span class="special"><></span> <span class="identifier">member_hook_</span><span class="special">;</span> + + <span class="identifier">MyClass</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">)</span> + <span class="special">:</span> <span class="identifier">int_</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> + <span class="special">{}</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special"><</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">int_</span> <span class="special"><</span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">></span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">int_</span> <span class="special">></span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">==</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">int_</span> <span class="special">==</span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="comment">//Define an avl_set using the base hook that will store values in reverse order</span> +<span class="keyword">typedef</span> <span class="identifier">avl_set</span><span class="special"><</span> <span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">compare</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">greater</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="special">></span> <span class="special">></span> <span class="identifier">BaseSet</span><span class="special">;</span> + +<span class="comment">//Define an multiset using the member hook</span> +<span class="keyword">typedef</span> <span class="identifier">member_hook</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">avl_set_member_hook</span><span class="special"><>,</span> <span class="special">&</span><span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">member_hook_</span><span class="special">></span> <span class="identifier">MemberOption</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">avl_multiset</span><span class="special"><</span> <span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">MemberOption</span><span class="special">></span> <span class="identifier">MemberMultiset</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">iterator</span> <span class="identifier">VectIt</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">reverse_iterator</span> <span class="identifier">VectRit</span><span class="special">;</span> + + <span class="comment">//Create several MyClass objects, each one with a different value</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">values</span><span class="special">;</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">100</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">values</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">MyClass</span><span class="special">(</span><span class="identifier">i</span><span class="special">));</span> + + <span class="identifier">BaseSet</span> <span class="identifier">baseset</span><span class="special">;</span> + <span class="identifier">MemberMultiset</span> <span class="identifier">membermultiset</span><span class="special">;</span> + + <span class="comment">//Check that size optimization is activated in the base hook </span> + <span class="identifier">assert</span><span class="special">(</span><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">avl_set_base_hook</span><span class="special"><</span><span class="identifier">optimize_size</span><span class="special"><</span><span class="keyword">true</span><span class="special">></span> <span class="special">>)</span> <span class="special">==</span> <span class="number">3</span><span class="special">*</span><span class="keyword">sizeof</span><span class="special">(</span><span class="keyword">void</span><span class="special">*));</span> + <span class="comment">//Check that size optimization is deactivated in the member hook </span> + <span class="identifier">assert</span><span class="special">(</span><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">avl_set_member_hook</span><span class="special"><>)</span> <span class="special">></span> <span class="number">3</span><span class="special">*</span><span class="keyword">sizeof</span><span class="special">(</span><span class="keyword">void</span><span class="special">*));</span> + + <span class="comment">//Now insert them in the sets</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">){</span> + <span class="identifier">baseset</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + <span class="identifier">membermultiset</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + <span class="special">}</span> + + <span class="comment">//Now test avl_sets</span> + <span class="special">{</span> + <span class="identifier">BaseSet</span><span class="special">::</span><span class="identifier">reverse_iterator</span> <span class="identifier">rbit</span><span class="special">(</span><span class="identifier">baseset</span><span class="special">.</span><span class="identifier">rbegin</span><span class="special">()),</span> <span class="identifier">rbitend</span><span class="special">(</span><span class="identifier">baseset</span><span class="special">.</span><span class="identifier">rend</span><span class="special">());</span> + <span class="identifier">MemberMultiset</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">mit</span><span class="special">(</span><span class="identifier">membermultiset</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">mitend</span><span class="special">(</span><span class="identifier">membermultiset</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + <span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + + <span class="comment">//Test the objects inserted in the base hook avl_set</span> + <span class="keyword">for</span><span class="special">(;</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">rbit</span><span class="special">)</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">rbit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + + <span class="comment">//Test the objects inserted in the member hook avl_set</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">it</span> <span class="special">=</span> <span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">();</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">mit</span><span class="special">)</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">mit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + <span class="special">}</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="splay_set_multiset.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="sg_set_multiset.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/clone_from.html b/doc/html/intrusive/clone_from.html new file mode 100755 index 0000000000..11d3fce0d7 --- /dev/null +++ b/doc/html/intrusive/clone_from.html @@ -0,0 +1,174 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Cloning Boost.Intrusive containers</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="erasing_and_disposing.html" title="Erasing and disposing values from Boost.Intrusive containers"> +<link rel="next" href="function_hooks.html" title="Using function hooks"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="erasing_and_disposing.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="function_hooks.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.clone_from"></a><a class="link" href="clone_from.html" title="Cloning Boost.Intrusive containers">Cloning Boost.Intrusive containers</a> +</h2></div></div></div> +<p> + As previously mentioned, <span class="bold"><strong>Boost.Intrusive</strong></span> containers + are <span class="bold"><strong>non-copyable and non-assignable</strong></span>, because + intrusive containers don't allocate memory at all. To implement a copy-constructor + or assignment operator, the user must clone one by one all the elements of + the container and insert them in another intrusive container. However, cloning + by hand is usually more inefficient than a member cloning function and a specialized + cloning function can offer more guarantees than the manual cloning (better + exception safety guarantees, for example). + </p> +<p> + To ease the implementation of copy constructors and assignment operators of + classes containing <span class="bold"><strong>Boost.Intrusive</strong></span> containers, + all <span class="bold"><strong>Boost.Intrusive</strong></span> containers offer a special + cloning function called <code class="computeroutput"><span class="identifier">clone_from</span></code>. + </p> +<p> + Apart from the container to be cloned, <code class="computeroutput"><span class="identifier">clone_from</span></code> + takes two function objects as arguments. For example, consider the <code class="computeroutput"><span class="identifier">clone_from</span></code> member function of <code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a></code>: + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Cloner</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Disposer</span><span class="special">></span> +<span class="keyword">void</span> <span class="identifier">clone_from</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">list</span> <span class="special">&</span><span class="identifier">src</span><span class="special">,</span> <span class="identifier">Cloner</span> <span class="identifier">cloner</span><span class="special">,</span> <span class="identifier">Disposer</span> <span class="identifier">disposer</span><span class="special">);</span> +</pre> +<p> + This function will make <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> + a clone of <code class="computeroutput"><span class="identifier">src</span></code>. Let's explain + the arguments: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + The first parameter is the list to be cloned. + </li> +<li class="listitem"> + The second parameter is a function object that will clone <code class="computeroutput"><span class="identifier">value_type</span></code> objects and return a pointer + to the clone. It must implement the following function: <code class="computeroutput"><span class="identifier">pointer</span> + <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="identifier">value_type</span> + <span class="special">&)</span></code>. + </li> +<li class="listitem"> + The second parameter is a function object that will dispose <code class="computeroutput"><span class="identifier">value_type</span></code> objects. It's used first to + empty the container before cloning and to dispose the elements if an exception + is thrown. + </li> +</ul></div> +<p> + The cloning function works as follows: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + First it clears and disposes all the elements from *this using the disposer + function object. + </li> +<li class="listitem"> + After that it starts cloning all the elements of the source container using + the cloner function object. + </li> +<li class="listitem"> + If any operation in the cloning function (for example, the cloner function + object) throws, all the constructed elements are disposed using the disposer + function object. + </li> +</ul></div> +<p> + Here is an example of <code class="computeroutput"><span class="identifier">clone_from</span></code>: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="comment">//A class that can be inserted in an intrusive list</span> +<span class="keyword">class</span> <span class="identifier">my_class</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">list_base_hook</span><span class="special"><></span> +<span class="special">{</span> + <span class="keyword">public</span><span class="special">:</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">==(</span><span class="keyword">const</span> <span class="identifier">my_class</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">my_class</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">int_</span> <span class="special">==</span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> + + <span class="keyword">int</span> <span class="identifier">int_</span><span class="special">;</span> + + <span class="comment">//...</span> +<span class="special">};</span> + +<span class="comment">//Definition of the intrusive list</span> +<span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span><span class="identifier">my_class</span><span class="special">></span> <span class="identifier">my_class_list</span><span class="special">;</span> + +<span class="comment">//Cloner object function</span> +<span class="keyword">struct</span> <span class="identifier">new_cloner</span> +<span class="special">{</span> + <span class="identifier">my_class</span> <span class="special">*</span><span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="identifier">my_class</span> <span class="special">&</span><span class="identifier">clone_this</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="keyword">new</span> <span class="identifier">my_class</span><span class="special">(</span><span class="identifier">clone_this</span><span class="special">);</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="comment">//The disposer object function</span> +<span class="keyword">struct</span> <span class="identifier">delete_disposer</span> +<span class="special">{</span> + <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">my_class</span> <span class="special">*</span><span class="identifier">delete_this</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">delete</span> <span class="identifier">delete_this</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">MaxElem</span> <span class="special">=</span> <span class="number">100</span><span class="special">;</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">my_class</span><span class="special">></span> <span class="identifier">nodes</span><span class="special">(</span><span class="identifier">MaxElem</span><span class="special">);</span> + + <span class="comment">//Fill all the nodes and insert them in the list</span> + <span class="identifier">my_class_list</span> <span class="identifier">list</span><span class="special">;</span> + + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="identifier">MaxElem</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">nodes</span><span class="special">[</span><span class="identifier">i</span><span class="special">].</span><span class="identifier">int_</span> <span class="special">=</span> <span class="identifier">i</span><span class="special">;</span> + + <span class="identifier">list</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">nodes</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">nodes</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + + <span class="comment">//Now clone "list" using "new" and "delete" object functions</span> + <span class="identifier">my_class_list</span> <span class="identifier">cloned_list</span><span class="special">;</span> + <span class="identifier">cloned_list</span><span class="special">.</span><span class="identifier">clone_from</span><span class="special">(</span><span class="identifier">list</span><span class="special">,</span> <span class="identifier">new_cloner</span><span class="special">(),</span> <span class="identifier">delete_disposer</span><span class="special">());</span> + + <span class="comment">//Test that both are equal</span> + <span class="keyword">if</span><span class="special">(</span><span class="identifier">cloned_list</span> <span class="special">!=</span> <span class="identifier">list</span><span class="special">)</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Both lists are different"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + <span class="keyword">else</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"Both lists are equal"</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> + + <span class="comment">//Don't forget to free the memory from the second list</span> + <span class="identifier">cloned_list</span><span class="special">.</span><span class="identifier">clear_and_dispose</span><span class="special">(</span><span class="identifier">delete_disposer</span><span class="special">());</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </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"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="erasing_and_disposing.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="function_hooks.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/concepts.html b/doc/html/intrusive/concepts.html new file mode 100755 index 0000000000..83bcb907b9 --- /dev/null +++ b/doc/html/intrusive/concepts.html @@ -0,0 +1,239 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Concepts explained</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="any_hooks.html" title="Any Hooks: A single hook for any Intrusive container"> +<link rel="next" href="node_algorithms.html" title="Node algorithms with custom NodeTraits"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="any_hooks.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="node_algorithms.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.concepts"></a><a class="link" href="concepts.html" title="Concepts explained">Concepts explained</a> +</h2></div></div></div> +<p> + This section will expand the explanation of previously presented basic concepts + before explaining the customization options of <span class="bold"><strong>Boost.Intrusive</strong></span>. + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong>Node Algorithms</strong></span>: A set of static functions + that implement basic operations on a group of nodes: initialize a node, + link_mode_type a node to a group of nodes, unlink a node from another group + of nodes, etc. For example, a circular singly linked list is a group of + nodes, where each node has a pointer to the next node. <span class="bold"><strong>Node + Algorithms</strong></span> just require a <span class="bold"><strong>NodeTraits</strong></span> + template parameter and they can work with any <span class="bold"><strong>NodeTraits</strong></span> + class that fulfills the needed interface. As an example, here is a class + that implements operations7' to manage a group of nodes forming a circular + singly linked list: + </li></ul></div> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">NodeTraits</span><span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">my_slist_algorithms</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">NodeTraits</span><span class="special">::</span><span class="identifier">node_ptr</span> <span class="identifier">node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">NodeTraits</span><span class="special">::</span><span class="identifier">const_node_ptr</span> <span class="identifier">const_node_ptr</span><span class="special">;</span> + + <span class="comment">//Get the previous node of "this_node"</span> + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">get_prev_node</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">this_node</span><span class="special">)</span> + <span class="special">{</span> + <span class="identifier">node_ptr</span> <span class="identifier">p</span> <span class="special">=</span> <span class="identifier">this_node</span><span class="special">;</span> + <span class="keyword">while</span> <span class="special">(</span><span class="identifier">this_node</span> <span class="special">!=</span> <span class="identifier">NodeTraits</span><span class="special">::</span><span class="identifier">get_next</span><span class="special">(</span><span class="identifier">p</span><span class="special">))</span> + <span class="identifier">p</span> <span class="special">=</span> <span class="identifier">NodeTraits</span><span class="special">::</span><span class="identifier">get_next</span><span class="special">(</span><span class="identifier">p</span><span class="special">);</span> + <span class="keyword">return</span> <span class="identifier">p</span><span class="special">;</span> + <span class="special">}</span> + + <span class="comment">// number of elements in the group of nodes containing "this_node"</span> + <span class="keyword">static</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">count</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">this_node</span><span class="special">)</span> + <span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">result</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> + <span class="identifier">const_node_ptr</span> <span class="identifier">p</span> <span class="special">=</span> <span class="identifier">this_node</span><span class="special">;</span> + <span class="keyword">do</span><span class="special">{</span> + <span class="identifier">p</span> <span class="special">=</span> <span class="identifier">NodeTraits</span><span class="special">::</span><span class="identifier">get_next</span><span class="special">(</span><span class="identifier">p</span><span class="special">);</span> + <span class="special">++</span><span class="identifier">result</span><span class="special">;</span> + <span class="special">}</span> <span class="keyword">while</span> <span class="special">(</span><span class="identifier">p</span> <span class="special">!=</span> <span class="identifier">this_node</span><span class="special">);</span> + <span class="keyword">return</span> <span class="identifier">result</span><span class="special">;</span> + <span class="special">}</span> + + <span class="comment">// More operations</span> + <span class="comment">// ...</span> +<span class="special">};</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong>Node Traits</strong></span>: A class that encapsulates + the basic information and operations on a node within a group of nodes: + the type of the node, a function to obtain the pointer to the next node, + etc. <span class="bold"><strong>Node Traits</strong></span> specify the configuration + information <span class="bold"><strong>Node Algorithms</strong></span> need. Each + type of <span class="bold"><strong>Node Algorithm</strong></span> expects an interface + that compatible <span class="bold"><strong>Node Traits</strong></span> classes must + implement. As an example, this is the definition of a <span class="bold"><strong>Node + Traits</strong></span> class that is compatible with the previously presented + <code class="computeroutput"><span class="identifier">my_slist_algorithms</span></code>: + </li></ul></div> +<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">my_slist_node_traits</span> +<span class="special">{</span> + <span class="comment">//The type of the node</span> + <span class="keyword">struct</span> <span class="identifier">node</span> + <span class="special">{</span> + <span class="identifier">node</span> <span class="special">*</span><span class="identifier">next_</span><span class="special">;</span> + <span class="special">};</span> + + <span class="keyword">typedef</span> <span class="identifier">node</span> <span class="special">*</span> <span class="identifier">node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">node</span> <span class="special">*</span> <span class="identifier">const_node_ptr</span><span class="special">;</span> + + <span class="comment">//A function to obtain a pointer to the next node</span> + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">get_next</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">next_</span><span class="special">;</span> <span class="special">}</span> + + <span class="comment">//A function to set the pointer to the next node</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_next</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> <span class="identifier">next</span><span class="special">)</span> + <span class="special">{</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">next_</span> <span class="special">=</span> <span class="identifier">next</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong>Hook</strong></span>: A class that the user must add as + a base class or as a member to his own class to make that class insertable + in an intrusive container. Usually the hook contains a node object that + will be used to form the group of nodes: For example, the following class + is a <span class="bold"><strong>Hook</strong></span> that the user can add as a base + class, to make the user class compatible with a singly linked list container: + </li></ul></div> +<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">my_slist_base_hook</span> + <span class="comment">//This hook contains a node, that will be used</span> + <span class="comment">//to link the user object in the group of nodes</span> + <span class="special">:</span> <span class="keyword">private</span> <span class="identifier">my_slist_node_traits</span><span class="special">::</span><span class="identifier">node</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">my_slist_node_traits</span><span class="special">::</span><span class="identifier">node_ptr</span> <span class="identifier">node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">my_slist_node_traits</span><span class="special">::</span><span class="identifier">const_node_ptr</span> <span class="identifier">const_node_ptr</span><span class="special">;</span> + + <span class="comment">//Converts the generic node to the hook</span> + <span class="keyword">static</span> <span class="identifier">my_slist_base_hook</span> <span class="special">*</span><span class="identifier">to_hook_ptr</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">p</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">my_slist_base_hook</span><span class="special">*>(</span><span class="identifier">p</span><span class="special">);</span> <span class="special">}</span> + + <span class="comment">//Returns the generic node stored by this hook</span> + <span class="identifier">node_ptr</span> <span class="identifier">to_node_ptr</span><span class="special">()</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">node</span> <span class="special">*</span><span class="keyword">const</span><span class="special">>(</span><span class="keyword">this</span><span class="special">);</span> <span class="special">}</span> + + <span class="comment">// More operations</span> + <span class="comment">// ...</span> +<span class="special">};</span> + +<span class="comment">//To make MyClass compatible with an intrusive singly linked list</span> +<span class="comment">//derive our class from the hook.</span> +<span class="keyword">class</span> <span class="identifier">MyClass</span> + <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">my_slist_base_hook</span> +<span class="special">{</span> + <span class="keyword">void</span> <span class="identifier">set</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">value</span><span class="special">);</span> + <span class="keyword">int</span> <span class="identifier">get</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + + <span class="keyword">private</span><span class="special">:</span> + <span class="keyword">int</span> <span class="identifier">value_</span><span class="special">;</span> +<span class="special">};</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong>Intrusive Container</strong></span>: A container that + offers a STL-like interface to store user objects. An intrusive container + can be templatized to store different value types that use different hooks. + An intrusive container is also more elaborate than a group of nodes: it + can store the number of elements to achieve constant-time size information, + it can offer debugging facilities, etc. For example, an <code class="computeroutput"><a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a></code> + container (intrusive singly linked list) should be able to hold <code class="computeroutput"><span class="identifier">MyClass</span></code> objects that might have decided + to store the hook as a base class or as a member. Internally, the container + will use <span class="bold"><strong>Node Algorithms</strong></span> to implement + its operations, and an intrusive container is configured using a template + parameter called <span class="bold"><strong>ValueTraits</strong></span>. <span class="bold"><strong>ValueTraits</strong></span> will contain the information to convert + user classes in nodes compatible with <span class="bold"><strong>Node Algorithms</strong></span>. + For example, this a possible <code class="computeroutput"><a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a></code> + implementation: + </li></ul></div> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">ValueTraits</span><span class="special">,</span> <span class="special">...></span> +<span class="keyword">class</span> <span class="identifier">slist</span> +<span class="special">{</span> + <span class="keyword">public</span><span class="special">:</span> + <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">ValueTraits</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">value_type</span><span class="special">;</span> + + <span class="comment">//More typedefs and functions</span> + <span class="comment">// ...</span> + + <span class="comment">//Insert the value as the first element of the list</span> + <span class="keyword">void</span> <span class="identifier">push_front</span> <span class="special">(</span><span class="identifier">reference</span> <span class="identifier">value</span><span class="special">)</span> + <span class="special">{</span> + <span class="identifier">node_ptr</span> <span class="identifier">to_insert</span><span class="special">(</span><span class="identifier">ValueTraits</span><span class="special">::</span><span class="identifier">to_node_ptr</span><span class="special">(</span><span class="identifier">value</span><span class="special">));</span> + <span class="identifier">circular_list_algorithms</span><span class="special">::</span><span class="identifier">link_after</span><span class="special">(</span><span class="identifier">to_insert</span><span class="special">,</span> <span class="identifier">get_root_node</span><span class="special">());</span> + <span class="special">}</span> + + <span class="comment">// More operations</span> + <span class="comment">// ...</span> +<span class="special">};</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Semi-Intrusive Container</strong></span>: A semi-intrusive + container is similar to an intrusive container, but apart from the values + to be inserted in the container, it needs additional memory (for example, + auxiliary arrays or indexes). + </li> +<li class="listitem"> + <span class="bold"><strong>Value Traits</strong></span>: As we can see, to make our + classes intrusive-friendly we add a simple hook as a member or base class. + The hook contains a generic node that will be inserted in a group of nodes. + <span class="bold"><strong>Node Algorithms</strong></span> just work with nodes and + don't know anything about user classes. On the other hand, an intrusive + container needs to know how to obtain a node from a user class, and also + the inverse operation. So we can define <span class="bold"><strong>ValueTraits</strong></span> + as the glue between user classes and nodes required by <span class="bold"><strong>Node + Algorithms</strong></span>. Let's see a possible implementation of a value traits + class that glues MyClass and the node stored in the hook: + </li> +</ul></div> +<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">my_slist_derivation_value_traits</span> +<span class="special">{</span> + <span class="keyword">public</span><span class="special">:</span> + <span class="keyword">typedef</span> <span class="identifier">slist_node_traits</span> <span class="identifier">node_traits</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">MyClass</span> <span class="identifier">value_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">node_traits</span><span class="special">::</span><span class="identifier">node_ptr</span> <span class="identifier">node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">value_type</span><span class="special">*</span> <span class="identifier">pointer</span><span class="special">;</span> + <span class="comment">//...</span> + + <span class="comment">//Converts user's value to a generic node</span> + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">to_node_ptr</span><span class="special">(</span><span class="identifier">reference</span> <span class="identifier">value</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">slist_base_hook</span> <span class="special">&>(</span><span class="identifier">value</span><span class="special">).</span><span class="identifier">to_node_ptr</span><span class="special">();</span> <span class="special">}</span> + + <span class="comment">//Converts a generic node into user's value</span> + <span class="keyword">static</span> <span class="identifier">value_type</span> <span class="special">*</span><span class="identifier">to_value_ptr</span><span class="special">(</span><span class="identifier">node_traits</span><span class="special">::</span><span class="identifier">node</span> <span class="special">*</span><span class="identifier">n</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">value_type</span><span class="special">*>(</span><span class="identifier">slist_base_hook</span><span class="special">::</span><span class="identifier">to_hook_ptr</span><span class="special">(</span><span class="identifier">n</span><span class="special">));</span> <span class="special">}</span> + + <span class="comment">// More operations</span> + <span class="comment">// ...</span> +<span class="special">};</span> +</pre> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="any_hooks.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="node_algorithms.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/concepts_summary.html b/doc/html/intrusive/concepts_summary.html new file mode 100755 index 0000000000..eed6287c32 --- /dev/null +++ b/doc/html/intrusive/concepts_summary.html @@ -0,0 +1,84 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Concept summary</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="usage_when.html" title="When to use?"> +<link rel="next" href="presenting_containers.html" title="Presenting Boost.Intrusive containers"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="usage_when.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="presenting_containers.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.concepts_summary"></a><a class="link" href="concepts_summary.html" title="Concept summary">Concept summary</a> +</h2></div></div></div> +<p> + Here is a small summary of the basic concepts that will be used in the following + chapters: + </p> +<div class="variablelist"> +<p class="title"><b>Brief Concepts Summary</b></p> +<dl> +<dt><span class="term">Node Algorithms</span></dt> +<dd><p> + A class containing typedefs and static functions that define basic operations + that can be applied to a group of nodes. It's independent from the node + definition and configured using a NodeTraits template parameter that + describes the node. + </p></dd> +<dt><span class="term">Node Traits</span></dt> +<dd><p> + A class that stores basic information and operations to insert a node + into a group of nodes. + </p></dd> +<dt><span class="term">Hook</span></dt> +<dd><p> + A class that a user must add as a base class or as a member to make the + user class compatible with intrusive containers. + </p></dd> +<dt><span class="term">Intrusive Container</span></dt> +<dd><p> + A class that stores user classes that have the needed hooks. It takes + a ValueTraits template parameter as configuration information. + </p></dd> +<dt><span class="term">Semi-Intrusive Container</span></dt> +<dd><p> + Similar to an intrusive container but a semi-intrusive container needs + additional memory (e.g. an auxiliary array) to work. + </p></dd> +<dt><span class="term">Value Traits</span></dt> +<dd><p> + A class containing typedefs and operations to obtain the node to be used + by Node Algorithms from the user class and the inverse. + </p></dd> +</dl> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="usage_when.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="presenting_containers.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/design_notes.html b/doc/html/intrusive/design_notes.html new file mode 100755 index 0000000000..d5aa295c68 --- /dev/null +++ b/doc/html/intrusive/design_notes.html @@ -0,0 +1,134 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Design Notes</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="obtaining_same_type_reducing_space.html" title="Obtaining the same types and reducing symbol length"> +<link rel="next" href="performance.html" title="Performance"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="obtaining_same_type_reducing_space.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="performance.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.design_notes"></a><a class="link" href="design_notes.html" title="Design Notes">Design Notes</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="design_notes.html#intrusive.design_notes.performance_sensitive">Boost.Intrusive + in performance sensitive environments</a></span></dt> +<dt><span class="section"><a href="design_notes.html#intrusive.design_notes.space_constrained">Boost.Intrusive + in space constrained environments</a></span></dt> +<dt><span class="section"><a href="design_notes.html#intrusive.design_notes.basic_building_block">Boost.Intrusive + as a basic building block</a></span></dt> +<dt><span class="section"><a href="design_notes.html#intrusive.design_notes.extending_intrusive">Extending + Boost.Intrusive</a></span></dt> +</dl></div> +<p> + When designing <span class="bold"><strong>Boost.Intrusive</strong></span> the following + guidelines have been taken into account: + </p> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.design_notes.performance_sensitive"></a><a class="link" href="design_notes.html#intrusive.design_notes.performance_sensitive" title="Boost.Intrusive in performance sensitive environments">Boost.Intrusive + in performance sensitive environments</a> +</h3></div></div></div> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> should be a valuable tool + in performance sensitive environments, and following this guideline, <span class="bold"><strong>Boost.Intrusive</strong></span> has been designed to offer well known + complexity guarantees. Apart from that, some options, like optional constant-time, + have been designed to offer faster complexity guarantees in some functions, + like <code class="computeroutput"><span class="identifier">slist</span><span class="special">::</span><span class="identifier">splice</span></code>. + </p> +<p> + The advanced lookup and insertion functions for associative containers, taking + an arbitrary key type and predicates, were designed to avoid unnecessary + object constructions. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.design_notes.space_constrained"></a><a class="link" href="design_notes.html#intrusive.design_notes.space_constrained" title="Boost.Intrusive in space constrained environments">Boost.Intrusive + in space constrained environments</a> +</h3></div></div></div> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> should be useful in space + constrained environments, and following this guideline <span class="bold"><strong>Boost.Intrusive</strong></span> + separates node algorithms and intrusive containers to avoid instantiating + node algorithms for each user type. For example, a single class of red-black + algorithms will be instantiated to implement all set and multiset containers + using raw pointers. This way, <span class="bold"><strong>Boost.Intrusive</strong></span> + seeks to avoid any code size overhead associated with templates. + </p> +<p> + Apart from that, <span class="bold"><strong>Boost.Intrusive</strong></span> implements + some size improvements: for example, red-black trees embed the color bit + in the parent pointer lower bit, if nodes are two-byte aligned. The option + to forgo constant-time size operations can reduce container size, and this + extra size optimization is noticeable when the container is empty or contains + few values. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.design_notes.basic_building_block"></a><a class="link" href="design_notes.html#intrusive.design_notes.basic_building_block" title="Boost.Intrusive as a basic building block">Boost.Intrusive + as a basic building block</a> +</h3></div></div></div> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> can be a basic building + block to build more complex containers and this potential has motivated many + design decisions. For example, the ability to have more than one hook per + user type opens the opportunity to implement multi-index containers on top + of <span class="bold"><strong>Boost.Intrusive</strong></span>. + </p> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> containers implement advanced + functions taking function objects as arguments (<code class="computeroutput"><span class="identifier">clone_from</span></code>, + <code class="computeroutput"><span class="identifier">erase_and_dispose</span></code>, <code class="computeroutput"><span class="identifier">insert_check</span></code>, etc.). These functions come + in handy when implementing non-intrusive containers (for example, STL-like + containers) on top of intrusive containers. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.design_notes.extending_intrusive"></a><a class="link" href="design_notes.html#intrusive.design_notes.extending_intrusive" title="Extending Boost.Intrusive">Extending + Boost.Intrusive</a> +</h3></div></div></div> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> offers a wide range of containers + but also allows the construction of custom containers reusing <span class="bold"><strong>Boost.Intrusive</strong></span> + elements. The programmer might want to use node algorithms directly or build + special hooks that take advantage of an application environment. + </p> +<p> + For example, the programmer can customize parts of <span class="bold"><strong>Boost.Intrusive</strong></span> + to manage old data structures whose definition can't be changed. + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="obtaining_same_type_reducing_space.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="performance.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/erasing_and_disposing.html b/doc/html/intrusive/erasing_and_disposing.html new file mode 100755 index 0000000000..310d206d2e --- /dev/null +++ b/doc/html/intrusive/erasing_and_disposing.html @@ -0,0 +1,145 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Erasing and disposing values from Boost.Intrusive containers</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="advanced_lookups_insertions.html" title="Advanced lookup and insertion functions for associative containers"> +<link rel="next" href="clone_from.html" title="Cloning Boost.Intrusive containers"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="advanced_lookups_insertions.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="clone_from.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.erasing_and_disposing"></a><a class="link" href="erasing_and_disposing.html" title="Erasing and disposing values from Boost.Intrusive containers">Erasing and disposing + values from Boost.Intrusive containers</a> +</h2></div></div></div> +<p> + One of the most tedious tasks when using intrusive containers is the management + of the erased elements. When using STL containers, the container itself unlinks + and destroys the contained elements, but with intrusive containers, the user + must explicitly destroy the object after erasing an element from the container. + This makes STL-like functions erasing multiple objects unhelpful: the user + can't destroy every erased element. For example, let's take the function <code class="computeroutput"><span class="identifier">remove_if</span></code> from <code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a></code>: + </p> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Pred</span><span class="special">></span> +<span class="keyword">void</span> <span class="identifier">remove_if</span><span class="special">(</span><span class="identifier">Pred</span> <span class="identifier">pred</span><span class="special">);</span> +</pre> +<p> + How can the user destroy the elements (say, using <code class="computeroutput"><span class="keyword">operator</span> + <span class="keyword">delete</span></code>) that will be erased according + to the predicate? <span class="bold"><strong>Boost.Intrusive</strong></span> containers + offer additional functions that take a function object that will be called + after the element has been erased from the container. For example, <code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a></code> offers: + </p> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Pred</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Disposer</span><span class="special">></span> +<span class="keyword">void</span> <span class="identifier">remove_and_dispose_if</span><span class="special">(</span><span class="identifier">Pred</span> <span class="identifier">pred</span><span class="special">,</span> <span class="identifier">Disposer</span> <span class="identifier">disposer</span><span class="special">)</span> +</pre> +<p> + With this function the user can efficiently remove and destroy elements if + the disposer function destroys an object: <code class="computeroutput"><span class="identifier">remove_and_dispose_if</span></code> + will call the "disposer" function object for every removed element. + <code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a></code> offers more functions + taking a disposer function object as argument, like <code class="computeroutput"><span class="identifier">erase_and_dispose</span></code>, + <code class="computeroutput"><span class="identifier">clear_and_dispose</span></code>, <code class="computeroutput"><span class="identifier">remove_and_dispose</span></code>, etc. + </p> +<p> + Note that the disposing function does not need to just destroy the object. + It can implement any other operation like inserting the remove object in another + container. Let's see a small example: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="comment">//A class that can be inserted in an intrusive list</span> +<span class="keyword">class</span> <span class="identifier">my_class</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">list_base_hook</span><span class="special"><></span> +<span class="special">{</span> + <span class="keyword">public</span><span class="special">:</span> + <span class="identifier">my_class</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">)</span> + <span class="special">:</span> <span class="identifier">int_</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> + <span class="special">{}</span> + + <span class="keyword">int</span> <span class="identifier">int_</span><span class="special">;</span> + <span class="comment">//...</span> +<span class="special">};</span> + +<span class="comment">//Definition of the intrusive list</span> +<span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span><span class="identifier">my_class</span><span class="special">></span> <span class="identifier">my_class_list</span><span class="special">;</span> + +<span class="comment">//The predicate function</span> +<span class="keyword">struct</span> <span class="identifier">is_even</span> +<span class="special">{</span> + <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="identifier">my_class</span> <span class="special">&</span><span class="identifier">c</span><span class="special">)</span> <span class="keyword">const</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="number">0</span> <span class="special">==</span> <span class="special">(</span><span class="identifier">c</span><span class="special">.</span><span class="identifier">int_</span> <span class="special">%</span> <span class="number">2</span><span class="special">);</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="comment">//The disposer object function</span> +<span class="keyword">struct</span> <span class="identifier">delete_disposer</span> +<span class="special">{</span> + <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">my_class</span> <span class="special">*</span><span class="identifier">delete_this</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">delete</span> <span class="identifier">delete_this</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">MaxElem</span> <span class="special">=</span> <span class="number">100</span><span class="special">;</span> + + <span class="comment">//Fill all the nodes and insert them in the list</span> + <span class="identifier">my_class_list</span> <span class="identifier">list</span><span class="special">;</span> + + <span class="keyword">try</span><span class="special">{</span> + <span class="comment">//Insert new objects in the container</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="identifier">MaxElem</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">list</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(*</span><span class="keyword">new</span> <span class="identifier">my_class</span><span class="special">(</span><span class="identifier">i</span><span class="special">));</span> + + <span class="comment">//Now use remove_and_dispose_if to erase and delete the objects</span> + <span class="identifier">list</span><span class="special">.</span><span class="identifier">remove_and_dispose_if</span><span class="special">(</span><span class="identifier">is_even</span><span class="special">(),</span> <span class="identifier">delete_disposer</span><span class="special">());</span> + <span class="special">}</span> + <span class="keyword">catch</span><span class="special">(...){</span> + <span class="comment">//If something throws, make sure that all the memory is freed</span> + <span class="identifier">list</span><span class="special">.</span><span class="identifier">clear_and_dispose</span><span class="special">(</span><span class="identifier">delete_disposer</span><span class="special">());</span> + <span class="keyword">throw</span><span class="special">;</span> + <span class="special">}</span> + + <span class="comment">//Dispose remaining elements</span> + <span class="identifier">list</span><span class="special">.</span><span class="identifier">erase_and_dispose</span><span class="special">(</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">list</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">delete_disposer</span><span class="special">());</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + All <span class="bold"><strong>Boost.Intrusive</strong></span> containers offer these + "erase + dispose" additional members for all functions that erase + an element from the container. + </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"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="advanced_lookups_insertions.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="clone_from.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/function_hooks.html b/doc/html/intrusive/function_hooks.html new file mode 100755 index 0000000000..4e9e8b88b2 --- /dev/null +++ b/doc/html/intrusive/function_hooks.html @@ -0,0 +1,146 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Using function hooks</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="clone_from.html" title="Cloning Boost.Intrusive containers"> +<link rel="next" href="recursive.html" title="Recursive Boost.Intrusive containers"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="clone_from.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="recursive.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.function_hooks"></a><a class="link" href="function_hooks.html" title="Using function hooks">Using function hooks</a> +</h2></div></div></div> +<p> + A programmer might find that base or member hooks are not flexible enough in + some situations. In some applications it would be optimal to put a hook deep + inside a member of a class or just outside the class. <span class="bold"><strong>Boost.Intrusive</strong></span> + has an easy option to allow such cases: <code class="computeroutput"><a class="link" href="../boost/intrusive/function_hook.html" title="Struct template function_hook">function_hook</a></code>. + </p> +<p> + This option is similar to <code class="computeroutput"><a class="link" href="../boost/intrusive/member_hook.html" title="Struct template member_hook">member_hook</a></code> + or <code class="computeroutput"><a class="link" href="../boost/intrusive/base_hook.html" title="Struct template base_hook">base_hook</a></code>, but + the programmer can specify a function object that tells the container how to + obtain a hook from a value and vice versa. The programmer just needs to define + the following function object: + </p> +<pre class="programlisting"><span class="comment">//This functor converts between value_type and a hook_type</span> +<span class="keyword">struct</span> <span class="identifier">Functor</span> +<span class="special">{</span> + <span class="comment">//Required types</span> + <span class="keyword">typedef</span> <span class="comment">/*impl-defined*/</span> <span class="identifier">hook_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="comment">/*impl-defined*/</span> <span class="identifier">hook_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="comment">/*impl-defined*/</span> <span class="identifier">const_hook_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="comment">/*impl-defined*/</span> <span class="identifier">value_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="comment">/*impl-defined*/</span> <span class="identifier">pointer</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="comment">/*impl-defined*/</span> <span class="identifier">const_pointer</span><span class="special">;</span> + <span class="comment">//Required static functions</span> + <span class="keyword">static</span> <span class="identifier">hook_ptr</span> <span class="identifier">to_hook_ptr</span> <span class="special">(</span><span class="identifier">value_type</span> <span class="special">&</span><span class="identifier">value</span><span class="special">);</span> + <span class="keyword">static</span> <span class="identifier">const_hook_ptr</span> <span class="identifier">to_hook_ptr</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span><span class="identifier">value</span><span class="special">);</span> + <span class="keyword">static</span> <span class="identifier">pointer</span> <span class="identifier">to_value_ptr</span><span class="special">(</span><span class="identifier">hook_ptr</span> <span class="identifier">n</span><span class="special">);</span> + <span class="keyword">static</span> <span class="identifier">const_pointer</span> <span class="identifier">to_value_ptr</span><span class="special">(</span><span class="identifier">const_hook_ptr</span> <span class="identifier">n</span><span class="special">);</span> +<span class="special">};</span> +</pre> +<p> + Converting from values to hooks is generally easy, since most hooks are in + practice members or base classes of class data members. The inverse operation + is a bit more complicated, but <span class="bold"><strong>Boost.Intrusive</strong></span> + offers a bit of help with the function <code class="computeroutput"><a class="link" href="../boost/intrusive/get_parent_from_member_id1190255.html" title="Function template get_parent_from_member">get_parent_from_member</a></code>, + which allows easy conversions from the address of a data member to the address + of the parent holding that member. Let's see a little example of <code class="computeroutput"><a class="link" href="../boost/intrusive/function_hook.html" title="Struct template function_hook">function_hook</a></code>: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">parent_from_member</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="keyword">struct</span> <span class="identifier">MyClass</span> +<span class="special">{</span> + <span class="keyword">int</span> <span class="identifier">dummy</span><span class="special">;</span> + <span class="comment">//This internal type has a member hook</span> + <span class="keyword">struct</span> <span class="identifier">InnerNode</span> + <span class="special">{</span> + <span class="keyword">int</span> <span class="identifier">dummy</span><span class="special">;</span> + <span class="identifier">list_member_hook</span><span class="special"><></span> <span class="identifier">hook</span><span class="special">;</span> + <span class="special">}</span> <span class="identifier">inner</span><span class="special">;</span> +<span class="special">};</span> + +<span class="comment">//This functor converts between MyClass and InnerNode's member hook</span> +<span class="keyword">struct</span> <span class="identifier">Functor</span> +<span class="special">{</span> + <span class="comment">//Required types</span> + <span class="keyword">typedef</span> <span class="identifier">list_member_hook</span><span class="special"><></span> <span class="identifier">hook_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">hook_type</span><span class="special">*</span> <span class="identifier">hook_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">hook_type</span><span class="special">*</span> <span class="identifier">const_hook_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">MyClass</span> <span class="identifier">value_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">value_type</span><span class="special">*</span> <span class="identifier">pointer</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">value_type</span><span class="special">*</span> <span class="identifier">const_pointer</span><span class="special">;</span> + + <span class="comment">//Required static functions</span> + <span class="keyword">static</span> <span class="identifier">hook_ptr</span> <span class="identifier">to_hook_ptr</span> <span class="special">(</span><span class="identifier">value_type</span> <span class="special">&</span><span class="identifier">value</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="special">&</span><span class="identifier">value</span><span class="special">.</span><span class="identifier">inner</span><span class="special">.</span><span class="identifier">hook</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">const_hook_ptr</span> <span class="identifier">to_hook_ptr</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span><span class="identifier">value</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="special">&</span><span class="identifier">value</span><span class="special">.</span><span class="identifier">inner</span><span class="special">.</span><span class="identifier">hook</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">pointer</span> <span class="identifier">to_value_ptr</span><span class="special">(</span><span class="identifier">hook_ptr</span> <span class="identifier">n</span><span class="special">)</span> + <span class="special">{</span> + <span class="keyword">return</span> <span class="identifier">get_parent_from_member</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> + <span class="special">(</span><span class="identifier">get_parent_from_member</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">InnerNode</span><span class="special">>(</span><span class="identifier">n</span><span class="special">,</span> <span class="special">&</span><span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">InnerNode</span><span class="special">::</span><span class="identifier">hook</span><span class="special">)</span> + <span class="special">,&</span><span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">inner</span> + <span class="special">);</span> + <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">const_pointer</span> <span class="identifier">to_value_ptr</span><span class="special">(</span><span class="identifier">const_hook_ptr</span> <span class="identifier">n</span><span class="special">)</span> + <span class="special">{</span> + <span class="keyword">return</span> <span class="identifier">get_parent_from_member</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> + <span class="special">(</span><span class="identifier">get_parent_from_member</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">InnerNode</span><span class="special">>(</span><span class="identifier">n</span><span class="special">,</span> <span class="special">&</span><span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">InnerNode</span><span class="special">::</span><span class="identifier">hook</span><span class="special">)</span> + <span class="special">,&</span><span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">inner</span> + <span class="special">);</span> + <span class="special">}</span> +<span class="special">};</span> + +<span class="comment">//Define a list that will use the hook accessed through the function object</span> +<span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span> <span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">function_hook</span><span class="special"><</span> <span class="identifier">Functor</span><span class="special">></span> <span class="special">></span> <span class="identifier">List</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="identifier">MyClass</span> <span class="identifier">n</span><span class="special">;</span> + <span class="identifier">List</span> <span class="identifier">l</span><span class="special">;</span> + <span class="comment">//Insert the node in both lists</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">n</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span> <span class="special">==</span> <span class="number">1</span><span class="special">);</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </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"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="clone_from.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="recursive.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/index.html b/doc/html/intrusive/index.html new file mode 100755 index 0000000000..f6ec77d98b --- /dev/null +++ b/doc/html/intrusive/index.html @@ -0,0 +1,1055 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Indexes</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="acknowledgements.html" title="Acknowledgements"> +<link rel="next" href="reference.html" title="Reference"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="acknowledgements.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="reference.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.index"></a><a class="link" href="index.html" title="Indexes">Indexes</a> +</h2></div></div></div> +<p> + </p> +<div class="index"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="id1982036"></a>Class Index</h3></div></div></div> +<div class="index"> +<div class="indexdiv"> +<h3>Symbols</h3> +<dl> +<dt>64-bit compilation, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dd><dl> +<dt>gcc, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.compiler.gcc">GNU C++</a> +</dt> +<dt>Microsoft Visual Studio, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#v2.reference.tools.compiler.msvc.64">64-bit support</a> +</dt> +<dt>Sun Studio, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.compiler.sun">Sun Studio</a> +</dt> +</dl></dd> +</dl> +</div> +<div class="indexdiv"> +<h3>A</h3> +<dl> +<dt>additional parser, <a class="indexterm" href="../../../../../../../../../../program_options/howto.html#id2501876">Non-conventional Syntax</a> +</dt> +<dt>always building a metatarget, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.rules">Builtin rules</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>B</h3> +<dl> +<dt>boostbook</dt> +<dd><dl> +<dt>module, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>rule, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +</dl></dd> +</dl> +</div> +<div class="indexdiv"> +<h3>C</h3> +<dl> +<dt>catalog, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>common signature, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.targets">Declaring Targets</a> +</dt> +<dt>cross compilation, <a class="indexterm" href="../../../../../../../../../../bbv2/tasks.html#bbv2.tasks.crosscompile">Cross-compilation</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>D</h3> +<dl> +<dt>define, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>dependency, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>dll-path, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>docbook, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>doxygen, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +<dd><dl><dt>rule, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt></dl></dd> +<dt>doxygen:param, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +<dt>doxygen:xml-imagedir, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>E</h3> +<dl> +<dt>embed-manifest, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>exe, <a class="indexterm" href="../../../../../../../../../../bbv2/tasks.html#bbv2.tasks.programs">Programs</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>F</h3> +<dl> +<dt>fat binaries, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.compiler.darwin">Apple Darwin gcc</a> +</dt> +<dt>features</dt> +<dd><dl><dt>builtin, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt></dl></dd> +<dt>fo, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>fop, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.fop">fop</a> +</dt> +<dt>format, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>G</h3> +<dl> +<dt>generators, <a class="indexterm" href="../../../../../../../../../../bbv2/extender.html#bbv2.extender.overview.generators">Generators</a> +</dt> +<dt>glob-tree, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.rules">Builtin rules</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>H</h3> +<dl> +<dt>hardcode-dll-paths, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>html, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>htmlhelp, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>I</h3> +<dl> +<dt>include, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>install-source-root, <a class="indexterm" href="../../../../../../../../../../bbv2/tasks.html#bbv2.tasks.installing">Installing</a> +</dt> +<dt>instruction-set, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>L</h3> +<dl> +<dt>library, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>link, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>M</h3> +<dl> +<dt>main target (see metataget)</dt> +<dd><dl><dt>declaration + syntax, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.targets">Declaring Targets</a> +</dt></dl></dd> +<dt>man, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>manifest file</dt> +<dd><dl><dt>embedding, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt></dl></dd> +<dt>metatarget</dt> +<dd><dl><dt>definition, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.concepts">Concepts</a> +</dt></dl></dd> +</dl> +</div> +<div class="indexdiv"> +<h3>O</h3> +<dl><dt>onehtml, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt></dl> +</div> +<div class="indexdiv"> +<h3>P</h3> +<dl> +<dt>pdf, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>prefix, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +<dt>preprocessed, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.rules">Builtin rules</a> +</dt> +<dt>preserve-test-targets, <a class="indexterm" href="../../../../../../../../../../bbv2/tasks.html#bbv2.builtins.testing">Testing</a> +</dt> +<dt>property</dt> +<dd><dl> +<dt>definition, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.concepts">Concepts</a> +</dt> +<dt>propagation, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.concepts">Concepts</a> +</dt> +</dl></dd> +<dt>ps, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>Q</h3> +<dl><dt>quickbook, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.quickbook">quickbook</a> +</dt></dl> +</div> +<div class="indexdiv"> +<h3>R</h3> +<dl> +<dt>reftitle, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +<dt>requirements, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.targets.requirements">Requirements</a> +</dt> +<dt>response files, <a class="indexterm" href="../../../../../../../../../../program_options/howto.html#id2501928">Response Files</a> +</dt> +<dt>rule + , <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.jam_language">Boost.Jam Language</a> +</dt> +<dt>runtime linking, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>S</h3> +<dl> +<dt>source, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>STLport, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.libraries.stlport">STLport library</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>T</h3> +<dl> +<dt>tests, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>threading, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>U</h3> +<dl><dt>use, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt></dl> +</div> +<div class="indexdiv"> +<h3>V</h3> +<dl><dt>variant, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt></dl> +</div> +<div class="indexdiv"> +<h3>X</h3> +<dl> +<dt>xhtml, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>xsl:param, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>xsl:path, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>xslt, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>xslt-dir, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>xsltproc, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +</dl> +</div> +</div> +</div> +<p> + </p> +<p> + </p> +<div class="index"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="id1982045"></a>Typedef Index</h3></div></div></div> +<div class="index"> +<div class="indexdiv"> +<h3>Symbols</h3> +<dl> +<dt>64-bit compilation, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dd><dl> +<dt>gcc, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.compiler.gcc">GNU C++</a> +</dt> +<dt>Microsoft Visual Studio, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#v2.reference.tools.compiler.msvc.64">64-bit support</a> +</dt> +<dt>Sun Studio, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.compiler.sun">Sun Studio</a> +</dt> +</dl></dd> +</dl> +</div> +<div class="indexdiv"> +<h3>A</h3> +<dl> +<dt>additional parser, <a class="indexterm" href="../../../../../../../../../../program_options/howto.html#id2501876">Non-conventional Syntax</a> +</dt> +<dt>always building a metatarget, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.rules">Builtin rules</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>B</h3> +<dl> +<dt>boostbook</dt> +<dd><dl> +<dt>module, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>rule, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +</dl></dd> +</dl> +</div> +<div class="indexdiv"> +<h3>C</h3> +<dl> +<dt>catalog, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>common signature, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.targets">Declaring Targets</a> +</dt> +<dt>cross compilation, <a class="indexterm" href="../../../../../../../../../../bbv2/tasks.html#bbv2.tasks.crosscompile">Cross-compilation</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>D</h3> +<dl> +<dt>define, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>dependency, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>dll-path, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>docbook, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>doxygen, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +<dd><dl><dt>rule, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt></dl></dd> +<dt>doxygen:param, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +<dt>doxygen:xml-imagedir, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>E</h3> +<dl> +<dt>embed-manifest, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>exe, <a class="indexterm" href="../../../../../../../../../../bbv2/tasks.html#bbv2.tasks.programs">Programs</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>F</h3> +<dl> +<dt>fat binaries, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.compiler.darwin">Apple Darwin gcc</a> +</dt> +<dt>features</dt> +<dd><dl><dt>builtin, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt></dl></dd> +<dt>fo, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>fop, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.fop">fop</a> +</dt> +<dt>format, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>G</h3> +<dl> +<dt>generators, <a class="indexterm" href="../../../../../../../../../../bbv2/extender.html#bbv2.extender.overview.generators">Generators</a> +</dt> +<dt>glob-tree, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.rules">Builtin rules</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>H</h3> +<dl> +<dt>hardcode-dll-paths, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>html, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>htmlhelp, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>I</h3> +<dl> +<dt>include, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>install-source-root, <a class="indexterm" href="../../../../../../../../../../bbv2/tasks.html#bbv2.tasks.installing">Installing</a> +</dt> +<dt>instruction-set, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>L</h3> +<dl> +<dt>library, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>link, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>M</h3> +<dl> +<dt>main target (see metataget)</dt> +<dd><dl><dt>declaration + syntax, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.targets">Declaring Targets</a> +</dt></dl></dd> +<dt>man, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>manifest file</dt> +<dd><dl><dt>embedding, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt></dl></dd> +<dt>metatarget</dt> +<dd><dl><dt>definition, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.concepts">Concepts</a> +</dt></dl></dd> +</dl> +</div> +<div class="indexdiv"> +<h3>O</h3> +<dl><dt>onehtml, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt></dl> +</div> +<div class="indexdiv"> +<h3>P</h3> +<dl> +<dt>pdf, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>prefix, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +<dt>preprocessed, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.rules">Builtin rules</a> +</dt> +<dt>preserve-test-targets, <a class="indexterm" href="../../../../../../../../../../bbv2/tasks.html#bbv2.builtins.testing">Testing</a> +</dt> +<dt>property</dt> +<dd><dl> +<dt>definition, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.concepts">Concepts</a> +</dt> +<dt>propagation, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.concepts">Concepts</a> +</dt> +</dl></dd> +<dt>ps, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>Q</h3> +<dl><dt>quickbook, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.quickbook">quickbook</a> +</dt></dl> +</div> +<div class="indexdiv"> +<h3>R</h3> +<dl> +<dt>reftitle, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +<dt>requirements, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.targets.requirements">Requirements</a> +</dt> +<dt>response files, <a class="indexterm" href="../../../../../../../../../../program_options/howto.html#id2501928">Response Files</a> +</dt> +<dt>rule + , <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.jam_language">Boost.Jam Language</a> +</dt> +<dt>runtime linking, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>S</h3> +<dl> +<dt>source, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>STLport, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.libraries.stlport">STLport library</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>T</h3> +<dl> +<dt>tests, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>threading, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>U</h3> +<dl><dt>use, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt></dl> +</div> +<div class="indexdiv"> +<h3>V</h3> +<dl><dt>variant, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt></dl> +</div> +<div class="indexdiv"> +<h3>X</h3> +<dl> +<dt>xhtml, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>xsl:param, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>xsl:path, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>xslt, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>xslt-dir, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>xsltproc, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +</dl> +</div> +</div> +</div> +<p> + </p> +<p> + </p> +<div class="index"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="id1982055"></a>Function Index</h3></div></div></div> +<div class="index"> +<div class="indexdiv"> +<h3>Symbols</h3> +<dl> +<dt>64-bit compilation, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dd><dl> +<dt>gcc, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.compiler.gcc">GNU C++</a> +</dt> +<dt>Microsoft Visual Studio, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#v2.reference.tools.compiler.msvc.64">64-bit support</a> +</dt> +<dt>Sun Studio, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.compiler.sun">Sun Studio</a> +</dt> +</dl></dd> +</dl> +</div> +<div class="indexdiv"> +<h3>A</h3> +<dl> +<dt>additional parser, <a class="indexterm" href="../../../../../../../../../../program_options/howto.html#id2501876">Non-conventional Syntax</a> +</dt> +<dt>always building a metatarget, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.rules">Builtin rules</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>B</h3> +<dl> +<dt>boostbook</dt> +<dd><dl> +<dt>module, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>rule, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +</dl></dd> +</dl> +</div> +<div class="indexdiv"> +<h3>C</h3> +<dl> +<dt>catalog, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>common signature, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.targets">Declaring Targets</a> +</dt> +<dt>cross compilation, <a class="indexterm" href="../../../../../../../../../../bbv2/tasks.html#bbv2.tasks.crosscompile">Cross-compilation</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>D</h3> +<dl> +<dt>define, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>dependency, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>dll-path, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>docbook, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>doxygen, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +<dd><dl><dt>rule, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt></dl></dd> +<dt>doxygen:param, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +<dt>doxygen:xml-imagedir, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>E</h3> +<dl> +<dt>embed-manifest, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>exe, <a class="indexterm" href="../../../../../../../../../../bbv2/tasks.html#bbv2.tasks.programs">Programs</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>F</h3> +<dl> +<dt>fat binaries, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.compiler.darwin">Apple Darwin gcc</a> +</dt> +<dt>features</dt> +<dd><dl><dt>builtin, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt></dl></dd> +<dt>fo, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>fop, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.fop">fop</a> +</dt> +<dt>format, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>G</h3> +<dl> +<dt>generators, <a class="indexterm" href="../../../../../../../../../../bbv2/extender.html#bbv2.extender.overview.generators">Generators</a> +</dt> +<dt>glob-tree, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.rules">Builtin rules</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>H</h3> +<dl> +<dt>hardcode-dll-paths, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>html, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>htmlhelp, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>I</h3> +<dl> +<dt>include, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>install-source-root, <a class="indexterm" href="../../../../../../../../../../bbv2/tasks.html#bbv2.tasks.installing">Installing</a> +</dt> +<dt>instruction-set, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>L</h3> +<dl> +<dt>library, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>link, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>M</h3> +<dl> +<dt>main target (see metataget)</dt> +<dd><dl><dt>declaration + syntax, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.targets">Declaring Targets</a> +</dt></dl></dd> +<dt>man, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>manifest file</dt> +<dd><dl><dt>embedding, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt></dl></dd> +<dt>metatarget</dt> +<dd><dl><dt>definition, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.concepts">Concepts</a> +</dt></dl></dd> +</dl> +</div> +<div class="indexdiv"> +<h3>O</h3> +<dl><dt>onehtml, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt></dl> +</div> +<div class="indexdiv"> +<h3>P</h3> +<dl> +<dt>pdf, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>prefix, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +<dt>preprocessed, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.rules">Builtin rules</a> +</dt> +<dt>preserve-test-targets, <a class="indexterm" href="../../../../../../../../../../bbv2/tasks.html#bbv2.builtins.testing">Testing</a> +</dt> +<dt>property</dt> +<dd><dl> +<dt>definition, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.concepts">Concepts</a> +</dt> +<dt>propagation, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.concepts">Concepts</a> +</dt> +</dl></dd> +<dt>ps, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>Q</h3> +<dl><dt>quickbook, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.quickbook">quickbook</a> +</dt></dl> +</div> +<div class="indexdiv"> +<h3>R</h3> +<dl> +<dt>reftitle, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +<dt>requirements, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.targets.requirements">Requirements</a> +</dt> +<dt>response files, <a class="indexterm" href="../../../../../../../../../../program_options/howto.html#id2501928">Response Files</a> +</dt> +<dt>rule + , <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.jam_language">Boost.Jam Language</a> +</dt> +<dt>runtime linking, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>S</h3> +<dl> +<dt>source, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>STLport, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.libraries.stlport">STLport library</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>T</h3> +<dl> +<dt>tests, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>threading, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>U</h3> +<dl><dt>use, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt></dl> +</div> +<div class="indexdiv"> +<h3>V</h3> +<dl><dt>variant, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt></dl> +</div> +<div class="indexdiv"> +<h3>X</h3> +<dl> +<dt>xhtml, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>xsl:param, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>xsl:path, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>xslt, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>xslt-dir, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>xsltproc, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +</dl> +</div> +</div> +</div> +<p> + </p> +<p> + </p> +<div class="index"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="id1982065"></a>Macro Index</h3></div></div></div> +<div class="index"> +<div class="indexdiv"> +<h3>Symbols</h3> +<dl> +<dt>64-bit compilation, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dd><dl> +<dt>gcc, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.compiler.gcc">GNU C++</a> +</dt> +<dt>Microsoft Visual Studio, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#v2.reference.tools.compiler.msvc.64">64-bit support</a> +</dt> +<dt>Sun Studio, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.compiler.sun">Sun Studio</a> +</dt> +</dl></dd> +</dl> +</div> +<div class="indexdiv"> +<h3>A</h3> +<dl> +<dt>additional parser, <a class="indexterm" href="../../../../../../../../../../program_options/howto.html#id2501876">Non-conventional Syntax</a> +</dt> +<dt>always building a metatarget, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.rules">Builtin rules</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>B</h3> +<dl> +<dt>boostbook</dt> +<dd><dl> +<dt>module, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>rule, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +</dl></dd> +</dl> +</div> +<div class="indexdiv"> +<h3>C</h3> +<dl> +<dt>catalog, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>common signature, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.targets">Declaring Targets</a> +</dt> +<dt>cross compilation, <a class="indexterm" href="../../../../../../../../../../bbv2/tasks.html#bbv2.tasks.crosscompile">Cross-compilation</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>D</h3> +<dl> +<dt>define, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>dependency, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>dll-path, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>docbook, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>doxygen, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +<dd><dl><dt>rule, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt></dl></dd> +<dt>doxygen:param, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +<dt>doxygen:xml-imagedir, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>E</h3> +<dl> +<dt>embed-manifest, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>exe, <a class="indexterm" href="../../../../../../../../../../bbv2/tasks.html#bbv2.tasks.programs">Programs</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>F</h3> +<dl> +<dt>fat binaries, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.compiler.darwin">Apple Darwin gcc</a> +</dt> +<dt>features</dt> +<dd><dl><dt>builtin, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt></dl></dd> +<dt>fo, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>fop, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.fop">fop</a> +</dt> +<dt>format, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>G</h3> +<dl> +<dt>generators, <a class="indexterm" href="../../../../../../../../../../bbv2/extender.html#bbv2.extender.overview.generators">Generators</a> +</dt> +<dt>glob-tree, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.rules">Builtin rules</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>H</h3> +<dl> +<dt>hardcode-dll-paths, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>html, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>htmlhelp, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>I</h3> +<dl> +<dt>include, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>install-source-root, <a class="indexterm" href="../../../../../../../../../../bbv2/tasks.html#bbv2.tasks.installing">Installing</a> +</dt> +<dt>instruction-set, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>L</h3> +<dl> +<dt>library, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>link, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>M</h3> +<dl> +<dt>main target (see metataget)</dt> +<dd><dl><dt>declaration + syntax, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.targets">Declaring Targets</a> +</dt></dl></dd> +<dt>man, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>manifest file</dt> +<dd><dl><dt>embedding, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt></dl></dd> +<dt>metatarget</dt> +<dd><dl><dt>definition, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.concepts">Concepts</a> +</dt></dl></dd> +</dl> +</div> +<div class="indexdiv"> +<h3>O</h3> +<dl><dt>onehtml, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt></dl> +</div> +<div class="indexdiv"> +<h3>P</h3> +<dl> +<dt>pdf, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>prefix, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +<dt>preprocessed, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.rules">Builtin rules</a> +</dt> +<dt>preserve-test-targets, <a class="indexterm" href="../../../../../../../../../../bbv2/tasks.html#bbv2.builtins.testing">Testing</a> +</dt> +<dt>property</dt> +<dd><dl> +<dt>definition, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.concepts">Concepts</a> +</dt> +<dt>propagation, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.concepts">Concepts</a> +</dt> +</dl></dd> +<dt>ps, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>Q</h3> +<dl><dt>quickbook, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.quickbook">quickbook</a> +</dt></dl> +</div> +<div class="indexdiv"> +<h3>R</h3> +<dl> +<dt>reftitle, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.doxygen">doxygen</a> +</dt> +<dt>requirements, <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.targets.requirements">Requirements</a> +</dt> +<dt>response files, <a class="indexterm" href="../../../../../../../../../../program_options/howto.html#id2501928">Response Files</a> +</dt> +<dt>rule + , <a class="indexterm" href="../../../../../../../../../../bbv2/overview.html#bbv2.overview.jam_language">Boost.Jam Language</a> +</dt> +<dt>runtime linking, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>S</h3> +<dl> +<dt>source, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +<dt>STLport, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.libraries.stlport">STLport library</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>T</h3> +<dl> +<dt>tests, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>threading, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt> +</dl> +</div> +<div class="indexdiv"> +<h3>U</h3> +<dl><dt>use, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt></dl> +</div> +<div class="indexdiv"> +<h3>V</h3> +<dl><dt>variant, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.overview.builtins.features">Builtin features</a> +</dt></dl> +</div> +<div class="indexdiv"> +<h3>X</h3> +<dl> +<dt>xhtml, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.boostbook">boostbook</a> +</dt> +<dt>xsl:param, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>xsl:path, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>xslt, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>xslt-dir, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +<dt>xsltproc, <a class="indexterm" href="../../../../../../../../../../bbv2/reference.html#bbv2.reference.tools.doc.xsltproc">xsltproc</a> +</dt> +</dl> +</div> +</div> +</div> +<p> + </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"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="acknowledgements.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="reference.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/intrusive_vs_nontrusive.html b/doc/html/intrusive/intrusive_vs_nontrusive.html new file mode 100755 index 0000000000..e7234569eb --- /dev/null +++ b/doc/html/intrusive/intrusive_vs_nontrusive.html @@ -0,0 +1,515 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Intrusive and non-intrusive containers</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="next" href="usage.html" title="How to use Boost.Intrusive"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../intrusive.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="usage.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.intrusive_vs_nontrusive"></a><a class="link" href="intrusive_vs_nontrusive.html" title="Intrusive and non-intrusive containers">Intrusive and non-intrusive + containers</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="intrusive_vs_nontrusive.html#intrusive.intrusive_vs_nontrusive.differences_intrusive_vs_nontrusive">Differences + between intrusive and non-intrusive containers</a></span></dt> +<dt><span class="section"><a href="intrusive_vs_nontrusive.html#intrusive.intrusive_vs_nontrusive.properties_of_intrusive">Properties + of Boost.Intrusive containers</a></span></dt> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.intrusive_vs_nontrusive.differences_intrusive_vs_nontrusive"></a><a class="link" href="intrusive_vs_nontrusive.html#intrusive.intrusive_vs_nontrusive.differences_intrusive_vs_nontrusive" title="Differences between intrusive and non-intrusive containers">Differences + between intrusive and non-intrusive containers</a> +</h3></div></div></div> +<p> + The main difference between intrusive containers and non-intrusive containers + is that in C++ non-intrusive containers store <span class="bold"><strong>copies</strong></span> + of values passed by the user. Containers use the <code class="computeroutput"><span class="identifier">Allocator</span></code> + template parameter to allocate the stored values: + </p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">list</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">assert</span><span class="special">.</span><span class="identifier">h</span><span class="special">></span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">myclass_list</span><span class="special">;</span> + + <span class="identifier">MyClass</span> <span class="identifier">myclass</span><span class="special">(...);</span> + <span class="identifier">myclass_list</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">myclass</span><span class="special">);</span> + + <span class="comment">//The stored object is different from the original object</span> + <span class="identifier">assert</span><span class="special">(&</span><span class="identifier">myclass</span> <span class="special">!=</span> <span class="special">&</span><span class="identifier">myclass_list</span><span class="special">.</span><span class="identifier">front</span><span class="special">());</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + To store the newly allocated copy of <code class="computeroutput"><span class="identifier">myclass</span></code>, + the container needs additional data: <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span></code> + usually allocates nodes that contain pointers to the next and previous node + and the value itself. Something similar to: + </p> +<pre class="programlisting"><span class="comment">//A possible implementation of a std::list<MyClass> node</span> +<span class="keyword">class</span> <span class="identifier">list_node</span> +<span class="special">{</span> + <span class="identifier">list_node</span> <span class="special">*</span><span class="identifier">next</span><span class="special">;</span> + <span class="identifier">list_node</span> <span class="special">*</span><span class="identifier">previous</span><span class="special">;</span> + <span class="identifier">MyClass</span> <span class="identifier">value</span><span class="special">;</span> +<span class="special">};</span> +</pre> +<p> + On the other hand, an intrusive container does not store copies of passed + objects, but it stores the objects themselves. The additional data needed + to insert the object in the container must be provided by the object itself. + For example, to insert <code class="computeroutput"><span class="identifier">MyClass</span></code> + in an intrusive container that implements a linked list, <code class="computeroutput"><span class="identifier">MyClass</span></code> + must contain the needed <span class="emphasis"><em>next</em></span> and <span class="emphasis"><em>previous</em></span> + pointers: + </p> +<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">MyClass</span> +<span class="special">{</span> + <span class="identifier">MyClass</span> <span class="special">*</span><span class="identifier">next</span><span class="special">;</span> + <span class="identifier">MyClass</span> <span class="special">*</span><span class="identifier">previous</span><span class="special">;</span> + <span class="comment">//Other members...</span> +<span class="special">};</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="identifier">acme_intrusive_list</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">list</span><span class="special">;</span> + + <span class="identifier">MyClass</span> <span class="identifier">myclass</span><span class="special">;</span> + <span class="identifier">list</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">myclass</span><span class="special">);</span> + + <span class="comment">//"myclass" object is stored in the list</span> + <span class="identifier">assert</span><span class="special">(&</span><span class="identifier">myclass</span> <span class="special">==</span> <span class="special">&</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">front</span><span class="special">());</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + As we can see, knowing which additional data the class should contain is + not an easy task. <span class="bold"><strong>Boost.Intrusive</strong></span> offers + several intrusive containers and an easy way to make user classes compatible + with those containers. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.intrusive_vs_nontrusive.properties_of_intrusive"></a><a class="link" href="intrusive_vs_nontrusive.html#intrusive.intrusive_vs_nontrusive.properties_of_intrusive" title="Properties of Boost.Intrusive containers">Properties + of Boost.Intrusive containers</a> +</h3></div></div></div> +<p> + Semantically, a <span class="bold"><strong>Boost.Intrusive</strong></span> container + is similar to a STL container holding pointers to objects. That is, if you + have an intrusive list holding objects of type <code class="computeroutput"><span class="identifier">T</span></code>, + then <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span><span class="identifier">T</span><span class="special">*></span></code> + would allow you to do quite the same operations (maintaining and navigating + a set of objects of type T and types derived from it). + </p> +<p> + A non-intrusive container has some limitations: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + An object can only belong to one container: If you want to share an object + between two containers, you either have to store multiple copies of those + objects or you need to use containers of pointers: <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span><span class="identifier">Object</span><span class="special">*></span></code>. + </li> +<li class="listitem"> + The use of dynamic allocation to create copies of passed values can be + a performance and size bottleneck in some applications. Normally, dynamic + allocation imposes a size overhead for each allocation to store bookkeeping + information and a synchronization to protected concurrent allocation + from different threads. + </li> +<li class="listitem"> + Only copies of objects are stored in non-intrusive containers. Hence + copy or move constructors and copy or move assignment operators are required. + Non-copyable and non-movable objects can't be stored in non-intrusive + containers. + </li> +<li class="listitem"> + It's not possible to store a derived object in a STL-container while + retaining its original type. + </li> +</ul></div> +<p> + Intrusive containers have some important advantages: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + Operating with intrusive containers doesn't invoke any memory management + at all. The time and size overhead associated with dynamic memory can + be minimized. + </li> +<li class="listitem"> + Iterating an Intrusive container needs less memory accesses than the + semantically equivalent container of pointers: iteration is faster. + </li> +<li class="listitem"> + Intrusive containers offer better exception guarantees than non-intrusive + containers. In some situations intrusive containers offer a no-throw + guarantee that can't be achieved with non-intrusive containers. + </li> +<li class="listitem"> + The computation of an iterator to an element from a pointer or reference + to that element is a constant time operation (computing the position + of <code class="computeroutput"><span class="identifier">T</span><span class="special">*</span></code> + in a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span><span class="identifier">T</span><span class="special">*></span></code> + has linear complexity). + </li> +<li class="listitem"> + Intrusive containers offer predictability when inserting and erasing + objects since no memory management is done with intrusive containers. + Memory management usually is not a predictable operation so complexity + guarantees from non-intrusive containers are looser than the guarantees + offered by intrusive containers. + </li> +</ul></div> +<p> + Intrusive containers have also downsides: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + Each type stored in an intrusive container needs additional memory holding + the maintenance information needed by the container. Hence, whenever + a certain type will be stored in an intrusive container <span class="bold"><strong>you + have to change the definition of that type</strong></span> appropriately. + Although this task is easy with <span class="bold"><strong>Boost.Intrusive</strong></span>, + touching the definition of a type is sometimes a crucial issue. + </li> +<li class="listitem"> + In intrusive containers you don't store a copy of an object, <span class="bold"><strong>but rather the original object is linked with other objects + in the container</strong></span>. Objects don't need copy-constructors or + assignment operators to be stored in intrusive containers. But you have + to take care of possible side effects, whenever you change the contents + of an object (this is especially important for associative containers). + </li> +<li class="listitem"> + The user <span class="bold"><strong>has to manage the lifetime of inserted + objects</strong></span> independently from the containers. + </li> +<li class="listitem"> + Again you have to be <span class="bold"><strong>careful</strong></span>: in contrast + to STL containers <span class="bold"><strong>it's easy to render an iterator + invalid</strong></span> without touching the intrusive container directly, + because the object can be disposed before is erased from the container. + </li> +<li class="listitem"> + <span class="bold"><strong>Boost.Intrusive</strong></span> containers are <span class="bold"><strong>non-copyable and non-assignable</strong></span>. Since intrusive + containers don't have allocation capabilities, these operations make + no sense. However, swapping can be used to implement move capabilities. + To ease the implementation of copy constructors and assignment operators + of classes storing <span class="bold"><strong>Boost.Intrusive</strong></span> containers, + <span class="bold"><strong>Boost.Intrusive</strong></span> offers special cloning + functions. See <a class="link" href="clone_from.html" title="Cloning Boost.Intrusive containers">Cloning Boost.Intrusive + containers</a> section for more information. + </li> +<li class="listitem"> + Analyzing the thread safety of a program that uses containers is harder + with intrusive containers, because the container might be modified indirectly + without an explicit call to a container member. + </li> +</ul></div> +<div class="table"> +<a name="intrusive.intrusive_vs_nontrusive.properties_of_intrusive.t0"></a><p class="title"><b>Table 13.1. Summary of intrusive containers advantages and disadvantages</b></p> +<div class="table-contents"><table class="table" summary="Summary of intrusive containers advantages and disadvantages"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Issue + </p> + </th> +<th> + <p> + Intrusive + </p> + </th> +<th> + <p> + Non-intrusive + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + Memory management + </p> + </td> +<td> + <p> + External + </p> + </td> +<td> + <p> + Internal through allocator + </p> + </td> +</tr> +<tr> +<td> + <p> + Insertion/Erasure time + </p> + </td> +<td> + <p> + Faster + </p> + </td> +<td> + <p> + Slower + </p> + </td> +</tr> +<tr> +<td> + <p> + Memory locality + </p> + </td> +<td> + <p> + Better + </p> + </td> +<td> + <p> + Worse + </p> + </td> +</tr> +<tr> +<td> + <p> + Can hold non-copyable and non-movable objects by value + </p> + </td> +<td> + <p> + Yes + </p> + </td> +<td> + <p> + No + </p> + </td> +</tr> +<tr> +<td> + <p> + Exception guarantees + </p> + </td> +<td> + <p> + Better + </p> + </td> +<td> + <p> + Worse + </p> + </td> +</tr> +<tr> +<td> + <p> + Computation of iterator from value + </p> + </td> +<td> + <p> + Constant + </p> + </td> +<td> + <p> + Non-constant + </p> + </td> +</tr> +<tr> +<td> + <p> + Insertion/erasure predictability + </p> + </td> +<td> + <p> + High + </p> + </td> +<td> + <p> + Low + </p> + </td> +</tr> +<tr> +<td> + <p> + Memory use + </p> + </td> +<td> + <p> + Minimal + </p> + </td> +<td> + <p> + More than minimal + </p> + </td> +</tr> +<tr> +<td> + <p> + Insert objects by value retaining polymorphic behavior + </p> + </td> +<td> + <p> + Yes + </p> + </td> +<td> + <p> + No (slicing) + </p> + </td> +</tr> +<tr> +<td> + <p> + User must modify the definition of the values to insert + </p> + </td> +<td> + <p> + Yes + </p> + </td> +<td> + <p> + No + </p> + </td> +</tr> +<tr> +<td> + <p> + Containers are copyable + </p> + </td> +<td> + <p> + No + </p> + </td> +<td> + <p> + Yes + </p> + </td> +</tr> +<tr> +<td> + <p> + Inserted object's lifetime managed by + </p> + </td> +<td> + <p> + User (more complex) + </p> + </td> +<td> + <p> + Container (less complex) + </p> + </td> +</tr> +<tr> +<td> + <p> + Container invariants can be broken without using the container + </p> + </td> +<td> + <p> + Easier + </p> + </td> +<td> + <p> + Harder (only with containers of pointers) + </p> + </td> +</tr> +<tr> +<td> + <p> + Thread-safety analysis + </p> + </td> +<td> + <p> + Harder + </p> + </td> +<td> + <p> + Easier + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><p> + For a performance comparison between Intrusive and Non-intrusive containers + see <a class="link" href="performance.html" title="Performance">Performance</a> section. + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="../intrusive.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="usage.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/list.html b/doc/html/intrusive/list.html new file mode 100755 index 0000000000..a1a5ae84d3 --- /dev/null +++ b/doc/html/intrusive/list.html @@ -0,0 +1,213 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Intrusive doubly linked list: list</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="slist.html" title="Intrusive singly linked list: slist"> +<link rel="next" href="set_multiset.html" title="Intrusive associative containers: set, multiset, rbtree"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="slist.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="set_multiset.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.list"></a><a class="link" href="list.html" title="Intrusive doubly linked list: list">Intrusive doubly linked list: list</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="list.html#intrusive.list.list_hooks">list hooks</a></span></dt> +<dt><span class="section"><a href="list.html#intrusive.list.list_container">list container</a></span></dt> +<dt><span class="section"><a href="list.html#intrusive.list.list_example">Example</a></span></dt> +</dl></div> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a></code> is a doubly linked + list. The memory overhead it imposes is 2 pointers per node. An empty, non + constant-time size <code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a></code> + also has the size of 2 pointers. <code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a></code> + has many more constant-time operations than <code class="computeroutput"><a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a></code> + and provides a bidirectional iterator. It is recommended to use <code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a></code> instead of <code class="computeroutput"><a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a></code> + if the size overhead is acceptable: + </p> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.list.list_hooks"></a><a class="link" href="list.html#intrusive.list.list_hooks" title="list hooks">list hooks</a> +</h3></div></div></div> +<p> + Like the rest of <span class="bold"><strong>Boost.Intrusive</strong></span> containers, + <code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a></code> has two hook types: + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">list_base_hook</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <code class="computeroutput"><a class="link" href="../boost/intrusive/list_base_hook.html" title="Class template list_base_hook">list_base_hook</a></code>: + the user class derives publicly from <code class="computeroutput"><a class="link" href="../boost/intrusive/list_base_hook.html" title="Class template list_base_hook">list_base_hook</a></code> + to make it <code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a></code>-compatible. + </li></ul></div> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">list_member_hook</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <code class="computeroutput"><a class="link" href="../boost/intrusive/list_member_hook.html" title="Class template list_member_hook">list_member_hook</a></code>: + the user class contains a public <code class="computeroutput"><a class="link" href="../boost/intrusive/list_member_hook.html" title="Class template list_member_hook">list_member_hook</a></code> + to make it <code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a></code>-compatible. + </li></ul></div> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/list_base_hook.html" title="Class template list_base_hook">list_base_hook</a></code> + and <code class="computeroutput"><a class="link" href="../boost/intrusive/list_member_hook.html" title="Class template list_member_hook">list_member_hook</a></code> + receive the same options explained in the section <a class="link" href="usage.html" title="How to use Boost.Intrusive">How + to use Boost.Intrusive</a>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">tag</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Tag</span><span class="special">></span></code></strong></span> + (for base hooks only): This argument serves as a tag, so you can derive + from more than one list hook. Default: <code class="computeroutput"><span class="identifier">tag</span><span class="special"><</span><span class="identifier">default_tag</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">link_mode_type</span> + <span class="identifier">LinkMode</span><span class="special">></span></code></strong></span>: + The linking policy. Default: <code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">safe_link</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">void_pointer</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">VoidPointer</span><span class="special">></span></code></strong></span>: + The pointer type to be used internally in the hook and propagated to + the container. Default: <code class="computeroutput"><span class="identifier">void_pointer</span><span class="special"><</span><span class="keyword">void</span><span class="special">*></span></code>. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.list.list_container"></a><a class="link" href="list.html#intrusive.list.list_container" title="list container">list container</a> +</h3></div></div></div> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">list</span><span class="special">;</span> +</pre> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a></code> receives the same + options explained in the section <a class="link" href="usage.html" title="How to use Boost.Intrusive">How to use + Boost.Intrusive</a>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">base_hook</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Hook</span><span class="special">></span></code></strong></span> + / <span class="bold"><strong><code class="computeroutput"><span class="identifier">member_hook</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Hook</span><span class="special">,</span> <span class="identifier">Hook</span> <span class="identifier">T</span><span class="special">::*</span> <span class="identifier">PtrToMember</span><span class="special">></span></code></strong></span> + / <span class="bold"><strong><code class="computeroutput"><span class="identifier">value_traits</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">ValueTraits</span><span class="special">></span></code></strong></span>: + To specify the hook type or value traits used to configure the container. + (To learn about value traits go to the section <a class="link" href="value_traits.html" title="Containers with custom ValueTraits">Containers + with custom ValueTraits</a>.) + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + To activate the constant-time <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code> operation. Default: <code class="computeroutput"><span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">true</span><span class="special">></span></code> + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">size_type</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + To specify the type that will be used to store the size of the container. + Default: <code class="computeroutput"><span class="identifier">size_type</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">></span></code> + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.list.list_example"></a><a class="link" href="list.html#intrusive.list.list_example" title="Example">Example</a> +</h3></div></div></div> +<p> + Now let's see a small example using both hooks: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="keyword">class</span> <span class="identifier">MyClass</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">list_base_hook</span><span class="special"><></span> <span class="comment">//This is a derivation hook</span> +<span class="special">{</span> + <span class="keyword">int</span> <span class="identifier">int_</span><span class="special">;</span> + + <span class="keyword">public</span><span class="special">:</span> + <span class="comment">//This is a member hook</span> + <span class="identifier">list_member_hook</span><span class="special"><></span> <span class="identifier">member_hook_</span><span class="special">;</span> + + <span class="identifier">MyClass</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">)</span> + <span class="special">:</span> <span class="identifier">int_</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> + <span class="special">{}</span> +<span class="special">};</span> + +<span class="comment">//Define a list that will store MyClass using the public base hook</span> +<span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">BaseList</span><span class="special">;</span> + +<span class="comment">//Define a list that will store MyClass using the public member hook</span> +<span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span> <span class="identifier">MyClass</span> + <span class="special">,</span> <span class="identifier">member_hook</span><span class="special"><</span> <span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">list_member_hook</span><span class="special"><>,</span> <span class="special">&</span><span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">member_hook_</span><span class="special">></span> + <span class="special">></span> <span class="identifier">MemberList</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">iterator</span> <span class="identifier">VectIt</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">reverse_iterator</span> <span class="identifier">VectRit</span><span class="special">;</span> + + <span class="comment">//Create several MyClass objects, each one with a different value</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">values</span><span class="special">;</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">100</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">values</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">MyClass</span><span class="special">(</span><span class="identifier">i</span><span class="special">));</span> + + <span class="identifier">BaseList</span> <span class="identifier">baselist</span><span class="special">;</span> + <span class="identifier">MemberList</span> <span class="identifier">memberlist</span><span class="special">;</span> + + <span class="comment">//Now insert them in the reverse order in the base hook list</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">)</span> + <span class="identifier">baselist</span><span class="special">.</span><span class="identifier">push_front</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + + <span class="comment">//Now insert them in the same order as in vector in the member hook list</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">)</span> + <span class="identifier">memberlist</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + + <span class="comment">//Now test lists</span> + <span class="special">{</span> + <span class="identifier">BaseList</span><span class="special">::</span><span class="identifier">reverse_iterator</span> <span class="identifier">rbit</span><span class="special">(</span><span class="identifier">baselist</span><span class="special">.</span><span class="identifier">rbegin</span><span class="special">()),</span> <span class="identifier">rbitend</span><span class="special">(</span><span class="identifier">baselist</span><span class="special">.</span><span class="identifier">rend</span><span class="special">());</span> + <span class="identifier">MemberList</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">mit</span><span class="special">(</span><span class="identifier">memberlist</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">mitend</span><span class="special">(</span><span class="identifier">memberlist</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + <span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + + <span class="comment">//Test the objects inserted in the base hook list</span> + <span class="keyword">for</span><span class="special">(;</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">rbit</span><span class="special">)</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">rbit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + + <span class="comment">//Test the objects inserted in the member hook list</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">it</span> <span class="special">=</span> <span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">();</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">mit</span><span class="special">)</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">mit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + <span class="special">}</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="slist.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="set_multiset.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/node_algorithms.html b/doc/html/intrusive/node_algorithms.html new file mode 100755 index 0000000000..a7f0d82683 --- /dev/null +++ b/doc/html/intrusive/node_algorithms.html @@ -0,0 +1,987 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Node algorithms with custom NodeTraits</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="concepts.html" title="Concepts explained"> +<link rel="next" href="value_traits.html" title="Containers with custom ValueTraits"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="concepts.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="value_traits.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.node_algorithms"></a><a class="link" href="node_algorithms.html" title="Node algorithms with custom NodeTraits">Node algorithms with custom + NodeTraits</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="node_algorithms.html#intrusive.node_algorithms.circular_slist_algorithms">Intrusive + singly linked list algorithms</a></span></dt> +<dt><span class="section"><a href="node_algorithms.html#intrusive.node_algorithms.circular_list_algorithms">Intrusive + doubly linked list algorithms</a></span></dt> +<dt><span class="section"><a href="node_algorithms.html#intrusive.node_algorithms.rbtree_algorithms">Intrusive + red-black tree algorithms</a></span></dt> +<dt><span class="section"><a href="node_algorithms.html#intrusive.node_algorithms.splaytree_algorithms">Intrusive + splay tree algorithms</a></span></dt> +<dt><span class="section"><a href="node_algorithms.html#intrusive.node_algorithms.avltree_algorithms">Intrusive + avl tree algorithms</a></span></dt> +<dt><span class="section"><a href="node_algorithms.html#intrusive.node_algorithms.treap_algorithms">Intrusive + treap algorithms</a></span></dt> +</dl></div> +<p> + As explained in the <a class="link" href="concepts.html" title="Concepts explained">Concepts</a> section, + <span class="bold"><strong>Boost.Intrusive</strong></span> containers are implemented + using node algorithms that work on generic nodes. + </p> +<p> + Sometimes, the use of intrusive containers is expensive for some environments + and the programmer might want to avoid all the template instantiations related + to <span class="bold"><strong>Boost.Intrusive</strong></span> containers. However, the + user can still benefit from <span class="bold"><strong>Boost.Intrusive</strong></span> + using the node algorithms, because some of those algorithms, like red-black + tree algorithms, are not trivial to write. + </p> +<p> + All node algorithm classes are templatized by a <code class="computeroutput"><span class="identifier">NodeTraits</span></code> + class. This class encapsulates the needed internal type declarations and operations + to make a node compatible with node algorithms. Each type of node algorithms + has its own requirements: + </p> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.node_algorithms.circular_slist_algorithms"></a><a class="link" href="node_algorithms.html#intrusive.node_algorithms.circular_slist_algorithms" title="Intrusive singly linked list algorithms">Intrusive + singly linked list algorithms</a> +</h3></div></div></div> +<p> + These algorithms are static members of the <code class="computeroutput"><a class="link" href="../boost/intrusive/circular_slist_algorithms.html" title="Class template circular_slist_algorithms">circular_slist_algorithms</a></code> + class: + </p> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">NodeTraits</span><span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">circular_slist_algorithms</span><span class="special">;</span> +</pre> +<p> + An empty list is formed by a node whose pointer to the next node points to + itself. <code class="computeroutput"><a class="link" href="../boost/intrusive/circular_slist_algorithms.html" title="Class template circular_slist_algorithms">circular_slist_algorithms</a></code> + is configured with a NodeTraits class, which encapsulates the information + about the node to be manipulated. NodeTraits must support the following interface: + </p> +<p> + <span class="bold"><strong>Typedefs</strong></span>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">node</span></code>: The type of the + node that forms the circular list + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">node_ptr</span></code>: The type of + a pointer to a node (usually node*) + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">const_node_ptr</span></code>: The type + of a pointer to a const node (usually const node*) + </li> +</ul></div> +<p> + <span class="bold"><strong>Static functions</strong></span>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">node_ptr</span> + <span class="identifier">get_next</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">);</span></code>: Returns a pointer to the next node + stored in "n". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="keyword">void</span> + <span class="identifier">set_next</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> + <span class="identifier">next</span><span class="special">);</span></code>: + Sets the pointer to the next node stored in "n" to "next". + </li> +</ul></div> +<p> + Once we have a node traits configuration we can use <span class="bold"><strong>Boost.Intrusive</strong></span> + algorithms with our nodes: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">circular_slist_algorithms</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cassert</span><span class="special">></span> + +<span class="keyword">struct</span> <span class="identifier">my_node</span> +<span class="special">{</span> + <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">next_</span><span class="special">;</span> + <span class="comment">//other members...</span> +<span class="special">};</span> + +<span class="comment">//Define our own slist_node_traits</span> +<span class="keyword">struct</span> <span class="identifier">my_slist_node_traits</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">my_node</span> <span class="identifier">node</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">my_node</span> <span class="special">*</span> <span class="identifier">node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">my_node</span> <span class="special">*</span> <span class="identifier">const_node_ptr</span><span class="special">;</span> + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">get_next</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">next_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_next</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> <span class="identifier">next</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">next_</span> <span class="special">=</span> <span class="identifier">next</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">::</span><span class="identifier">circular_slist_algorithms</span><span class="special"><</span><span class="identifier">my_slist_node_traits</span><span class="special">></span> <span class="identifier">algo</span><span class="special">;</span> + <span class="identifier">my_node</span> <span class="identifier">one</span><span class="special">,</span> <span class="identifier">two</span><span class="special">,</span> <span class="identifier">three</span><span class="special">;</span> + + <span class="comment">//Create an empty singly linked list container:</span> + <span class="comment">//"one" will be the first node of the container</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">init_header</span><span class="special">(&</span><span class="identifier">one</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">algo</span><span class="special">::</span><span class="identifier">count</span><span class="special">(&</span><span class="identifier">one</span><span class="special">)</span> <span class="special">==</span> <span class="number">1</span><span class="special">);</span> + + <span class="comment">//Now add a new node</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">link_after</span><span class="special">(&</span><span class="identifier">one</span><span class="special">,</span> <span class="special">&</span><span class="identifier">two</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">algo</span><span class="special">::</span><span class="identifier">count</span><span class="special">(&</span><span class="identifier">one</span><span class="special">)</span> <span class="special">==</span> <span class="number">2</span><span class="special">);</span> + + <span class="comment">//Now add a new node after "one"</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">link_after</span><span class="special">(&</span><span class="identifier">one</span><span class="special">,</span> <span class="special">&</span><span class="identifier">three</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">algo</span><span class="special">::</span><span class="identifier">count</span><span class="special">(&</span><span class="identifier">one</span><span class="special">)</span> <span class="special">==</span> <span class="number">3</span><span class="special">);</span> + + <span class="comment">//Now unlink the node after one</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">unlink_after</span><span class="special">(&</span><span class="identifier">one</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">algo</span><span class="special">::</span><span class="identifier">count</span><span class="special">(&</span><span class="identifier">one</span><span class="special">)</span> <span class="special">==</span> <span class="number">2</span><span class="special">);</span> + + <span class="comment">//Now unlink two</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">unlink</span><span class="special">(&</span><span class="identifier">two</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">algo</span><span class="special">::</span><span class="identifier">count</span><span class="special">(&</span><span class="identifier">one</span><span class="special">)</span> <span class="special">==</span> <span class="number">1</span><span class="special">);</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + For a complete list of functions see <code class="computeroutput"><a class="link" href="../boost/intrusive/circular_slist_algorithms.html" title="Class template circular_slist_algorithms">circular_slist_algorithms + reference</a></code>. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.node_algorithms.circular_list_algorithms"></a><a class="link" href="node_algorithms.html#intrusive.node_algorithms.circular_list_algorithms" title="Intrusive doubly linked list algorithms">Intrusive + doubly linked list algorithms</a> +</h3></div></div></div> +<p> + These algorithms are static members of the <code class="computeroutput"><a class="link" href="../boost/intrusive/circular_list_algorithms.html" title="Class template circular_list_algorithms">circular_list_algorithms</a></code> + class: + </p> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">NodeTraits</span><span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">circular_list_algorithms</span><span class="special">;</span> +</pre> +<p> + An empty list is formed by a node whose pointer to the next node points to + itself. <code class="computeroutput"><a class="link" href="../boost/intrusive/circular_list_algorithms.html" title="Class template circular_list_algorithms">circular_list_algorithms</a></code> + is configured with a NodeTraits class, which encapsulates the information + about the node to be manipulated. NodeTraits must support the following interface: + </p> +<p> + <span class="bold"><strong>Typedefs</strong></span>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">node</span></code>: The type of the + node that forms the circular list + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">node_ptr</span></code>: The type of + a pointer to a node (usually node*) + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">const_node_ptr</span></code>: The type + of a pointer to a const node (usually const node*) + </li> +</ul></div> +<p> + <span class="bold"><strong>Static functions</strong></span>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">node_ptr</span> + <span class="identifier">get_next</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">);</span></code>: Returns a pointer to the next node + stored in "n". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="keyword">void</span> + <span class="identifier">set_next</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> + <span class="identifier">next</span><span class="special">);</span></code>: + Sets the pointer to the next node stored in "n" to "next". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">node_ptr</span> + <span class="identifier">get_previous</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">);</span></code>: Returns a pointer to the previous + node stored in "n". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="keyword">void</span> + <span class="identifier">set_previous</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> + <span class="identifier">prev</span><span class="special">);</span></code>: + Sets the pointer to the previous node stored in "n" to "prev". + </li> +</ul></div> +<p> + Once we have a node traits configuration we can use <span class="bold"><strong>Boost.Intrusive</strong></span> + algorithms with our nodes: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">circular_list_algorithms</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cassert</span><span class="special">></span> + +<span class="keyword">struct</span> <span class="identifier">my_node</span> +<span class="special">{</span> + <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">next_</span><span class="special">,</span> <span class="special">*</span><span class="identifier">prev_</span><span class="special">;</span> + <span class="comment">//other members...</span> +<span class="special">};</span> + +<span class="comment">//Define our own list_node_traits</span> +<span class="keyword">struct</span> <span class="identifier">my_list_node_traits</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">my_node</span> <span class="identifier">node</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">my_node</span> <span class="special">*</span> <span class="identifier">node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">my_node</span> <span class="special">*</span> <span class="identifier">const_node_ptr</span><span class="special">;</span> + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">get_next</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">next_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_next</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> <span class="identifier">next</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">next_</span> <span class="special">=</span> <span class="identifier">next</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">node</span> <span class="special">*</span><span class="identifier">get_previous</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">prev_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_previous</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> <span class="identifier">prev</span><span class="special">){</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">prev_</span> <span class="special">=</span> <span class="identifier">prev</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">::</span><span class="identifier">circular_list_algorithms</span><span class="special"><</span><span class="identifier">my_list_node_traits</span><span class="special">></span> <span class="identifier">algo</span><span class="special">;</span> + <span class="identifier">my_node</span> <span class="identifier">one</span><span class="special">,</span> <span class="identifier">two</span><span class="special">,</span> <span class="identifier">three</span><span class="special">;</span> + + <span class="comment">//Create an empty doubly linked list container:</span> + <span class="comment">//"one" will be the first node of the container</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">init_header</span><span class="special">(&</span><span class="identifier">one</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">algo</span><span class="special">::</span><span class="identifier">count</span><span class="special">(&</span><span class="identifier">one</span><span class="special">)</span> <span class="special">==</span> <span class="number">1</span><span class="special">);</span> + + <span class="comment">//Now add a new node before "one"</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">link_before</span><span class="special">(&</span><span class="identifier">one</span><span class="special">,</span> <span class="special">&</span><span class="identifier">two</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">algo</span><span class="special">::</span><span class="identifier">count</span><span class="special">(&</span><span class="identifier">one</span><span class="special">)</span> <span class="special">==</span> <span class="number">2</span><span class="special">);</span> + + <span class="comment">//Now add a new node after "two"</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">link_after</span><span class="special">(&</span><span class="identifier">two</span><span class="special">,</span> <span class="special">&</span><span class="identifier">three</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">algo</span><span class="special">::</span><span class="identifier">count</span><span class="special">(&</span><span class="identifier">one</span><span class="special">)</span> <span class="special">==</span> <span class="number">3</span><span class="special">);</span> + + <span class="comment">//Now unlink the node after one</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">unlink</span><span class="special">(&</span><span class="identifier">three</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">algo</span><span class="special">::</span><span class="identifier">count</span><span class="special">(&</span><span class="identifier">one</span><span class="special">)</span> <span class="special">==</span> <span class="number">2</span><span class="special">);</span> + + <span class="comment">//Now unlink two</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">unlink</span><span class="special">(&</span><span class="identifier">two</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">algo</span><span class="special">::</span><span class="identifier">count</span><span class="special">(&</span><span class="identifier">one</span><span class="special">)</span> <span class="special">==</span> <span class="number">1</span><span class="special">);</span> + + <span class="comment">//Now unlink one</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">unlink</span><span class="special">(&</span><span class="identifier">one</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">algo</span><span class="special">::</span><span class="identifier">count</span><span class="special">(&</span><span class="identifier">one</span><span class="special">)</span> <span class="special">==</span> <span class="number">1</span><span class="special">);</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + For a complete list of functions see <code class="computeroutput"><a class="link" href="../boost/intrusive/circular_list_algorithms.html" title="Class template circular_list_algorithms">circular_list_algorithms + reference</a></code>. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.node_algorithms.rbtree_algorithms"></a><a class="link" href="node_algorithms.html#intrusive.node_algorithms.rbtree_algorithms" title="Intrusive red-black tree algorithms">Intrusive + red-black tree algorithms</a> +</h3></div></div></div> +<p> + These algorithms are static members of the <code class="computeroutput"><a class="link" href="../boost/intrusive/rbtree_algorithms.html" title="Class template rbtree_algorithms">rbtree_algorithms</a></code> + class: + </p> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">NodeTraits</span><span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">rbtree_algorithms</span><span class="special">;</span> +</pre> +<p> + An empty tree is formed by a node whose pointer to the parent node is null, + the left and right node pointers point to itself, and whose color is red. + <code class="computeroutput"><a class="link" href="../boost/intrusive/rbtree_algorithms.html" title="Class template rbtree_algorithms">rbtree_algorithms</a></code> + is configured with a NodeTraits class, which encapsulates the information + about the node to be manipulated. NodeTraits must support the following interface: + </p> +<p> + <span class="bold"><strong>Typedefs</strong></span>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">node</span></code>: The type of the + node that forms the circular rbtree + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">node_ptr</span></code>: The type of + a pointer to a node (usually node*) + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">const_node_ptr</span></code>: The type + of a pointer to a const node (usually const node*) + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">color</span></code>: The type that + can store the color of a node + </li> +</ul></div> +<p> + <span class="bold"><strong>Static functions</strong></span>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">node_ptr</span> + <span class="identifier">get_parent</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">);</span></code>: Returns a pointer to the parent node + stored in "n". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="keyword">void</span> + <span class="identifier">set_parent</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> + <span class="identifier">p</span><span class="special">);</span></code>: + Sets the pointer to the parent node stored in "n" to "p". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">node_ptr</span> + <span class="identifier">get_left</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">);</span></code>: Returns a pointer to the left node + stored in "n". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="keyword">void</span> + <span class="identifier">set_left</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> + <span class="identifier">l</span><span class="special">);</span></code>: + Sets the pointer to the left node stored in "n" to "l". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">node_ptr</span> + <span class="identifier">get_right</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">);</span></code>: Returns a pointer to the right node + stored in "n". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="keyword">void</span> + <span class="identifier">set_right</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> + <span class="identifier">r</span><span class="special">);</span></code>: + Sets the pointer to the right node stored in "n" to "r". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">color</span> + <span class="identifier">get_color</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">);</span></code>: Returns the color stored in "n". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="keyword">void</span> + <span class="identifier">set_color</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">color</span> <span class="identifier">c</span><span class="special">);</span></code>: + Sets the color stored in "n" to "c". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">color</span> + <span class="identifier">black</span><span class="special">();</span></code>: + Returns a value representing the black color. + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">color</span> + <span class="identifier">red</span><span class="special">();</span></code>: + Returns a value representing the red color. + </li> +</ul></div> +<p> + Once we have a node traits configuration we can use <span class="bold"><strong>Boost.Intrusive</strong></span> + algorithms with our nodes: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">rbtree_algorithms</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cassert</span><span class="special">></span> + +<span class="keyword">struct</span> <span class="identifier">my_node</span> +<span class="special">{</span> + <span class="identifier">my_node</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> + <span class="special">:</span> <span class="identifier">int_</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> + <span class="special">{}</span> + <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">parent_</span><span class="special">,</span> <span class="special">*</span><span class="identifier">left_</span><span class="special">,</span> <span class="special">*</span><span class="identifier">right_</span><span class="special">;</span> + <span class="keyword">int</span> <span class="identifier">color_</span><span class="special">;</span> + <span class="comment">//other members</span> + <span class="keyword">int</span> <span class="identifier">int_</span><span class="special">;</span> +<span class="special">};</span> + +<span class="comment">//Define our own rbtree_node_traits</span> +<span class="keyword">struct</span> <span class="identifier">my_rbtree_node_traits</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">my_node</span> <span class="identifier">node</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">my_node</span> <span class="special">*</span> <span class="identifier">node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">my_node</span> <span class="special">*</span> <span class="identifier">const_node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">int</span> <span class="identifier">color</span><span class="special">;</span> + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">get_parent</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">parent_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_parent</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> <span class="identifier">parent</span><span class="special">){</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">parent_</span> <span class="special">=</span> <span class="identifier">parent</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">get_left</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">left_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_left</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> <span class="identifier">left</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">left_</span> <span class="special">=</span> <span class="identifier">left</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">get_right</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">right_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_right</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> <span class="identifier">right</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">right_</span> <span class="special">=</span> <span class="identifier">right</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">color</span> <span class="identifier">get_color</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">color_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_color</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">color</span> <span class="identifier">c</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">color_</span> <span class="special">=</span> <span class="identifier">c</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">color</span> <span class="identifier">black</span><span class="special">()</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">color</span><span class="special">(</span><span class="number">0</span><span class="special">);</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">color</span> <span class="identifier">red</span><span class="special">()</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">color</span><span class="special">(</span><span class="number">1</span><span class="special">);</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="keyword">struct</span> <span class="identifier">node_ptr_compare</span> +<span class="special">{</span> + <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">-></span><span class="identifier">int_</span> <span class="special"><</span> <span class="identifier">b</span><span class="special">-></span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">::</span><span class="identifier">rbtree_algorithms</span><span class="special"><</span><span class="identifier">my_rbtree_node_traits</span><span class="special">></span> <span class="identifier">algo</span><span class="special">;</span> + <span class="identifier">my_node</span> <span class="identifier">header</span><span class="special">,</span> <span class="identifier">two</span><span class="special">(</span><span class="number">2</span><span class="special">),</span> <span class="identifier">three</span><span class="special">(</span><span class="number">3</span><span class="special">);</span> + + <span class="comment">//Create an empty rbtree container:</span> + <span class="comment">//"header" will be the header node of the tree</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">init_header</span><span class="special">(&</span><span class="identifier">header</span><span class="special">);</span> + + <span class="comment">//Now insert node "two" in the tree using the sorting functor</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">insert_equal_upper_bound</span><span class="special">(&</span><span class="identifier">header</span><span class="special">,</span> <span class="special">&</span><span class="identifier">two</span><span class="special">,</span> <span class="identifier">node_ptr_compare</span><span class="special">());</span> + + <span class="comment">//Now insert node "three" in the tree using the sorting functor</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">insert_equal_lower_bound</span><span class="special">(&</span><span class="identifier">header</span><span class="special">,</span> <span class="special">&</span><span class="identifier">three</span><span class="special">,</span> <span class="identifier">node_ptr_compare</span><span class="special">());</span> + + <span class="comment">//Now take the first node (the left node of the header)</span> + <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">n</span> <span class="special">=</span> <span class="identifier">header</span><span class="special">.</span><span class="identifier">left_</span><span class="special">;</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">n</span> <span class="special">==</span> <span class="special">&</span><span class="identifier">two</span><span class="special">);</span> + + <span class="comment">//Now go to the next node</span> + <span class="identifier">n</span> <span class="special">=</span> <span class="identifier">algo</span><span class="special">::</span><span class="identifier">next_node</span><span class="special">(</span><span class="identifier">n</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">n</span> <span class="special">==</span> <span class="special">&</span><span class="identifier">three</span><span class="special">);</span> + + <span class="comment">//Erase a node just using a pointer to it</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">unlink</span><span class="special">(&</span><span class="identifier">two</span><span class="special">);</span> + + <span class="comment">//Erase a node using also the header (faster)</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">erase</span><span class="special">(&</span><span class="identifier">header</span><span class="special">,</span> <span class="special">&</span><span class="identifier">three</span><span class="special">);</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + For a complete list of functions see <code class="computeroutput"><a class="link" href="../boost/intrusive/rbtree_algorithms.html" title="Class template rbtree_algorithms">rbtree_algorithms + reference</a></code>. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.node_algorithms.splaytree_algorithms"></a><a class="link" href="node_algorithms.html#intrusive.node_algorithms.splaytree_algorithms" title="Intrusive splay tree algorithms">Intrusive + splay tree algorithms</a> +</h3></div></div></div> +<p> + These algorithms are static members of the <code class="computeroutput"><a class="link" href="../boost/intrusive/splaytree_algorithms.html" title="Class template splaytree_algorithms">splaytree_algorithms</a></code> + class: + </p> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">NodeTraits</span><span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">splaytree_algorithms</span><span class="special">;</span> +</pre> +<p> + An empty tree is formed by a node whose pointer to the parent node is null, + and whose left and right nodes pointers point to itself. <code class="computeroutput"><a class="link" href="../boost/intrusive/splaytree_algorithms.html" title="Class template splaytree_algorithms">splaytree_algorithms</a></code> + is configured with a NodeTraits class, which encapsulates the information + about the node to be manipulated. NodeTraits must support the following interface: + </p> +<p> + <span class="bold"><strong>Typedefs</strong></span>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">node</span></code>: The type of the + node that forms the circular splaytree + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">node_ptr</span></code>: The type of + a pointer to a node (usually node*) + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">const_node_ptr</span></code>: The type + of a pointer to a const node (usually const node*) + </li> +</ul></div> +<p> + <span class="bold"><strong>Static functions</strong></span>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">node_ptr</span> + <span class="identifier">get_parent</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">);</span></code>: Returns a pointer to the parent node + stored in "n". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="keyword">void</span> + <span class="identifier">set_parent</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> + <span class="identifier">p</span><span class="special">);</span></code>: + Sets the pointer to the parent node stored in "n" to "p". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">node_ptr</span> + <span class="identifier">get_left</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">);</span></code>: Returns a pointer to the left node + stored in "n". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="keyword">void</span> + <span class="identifier">set_left</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> + <span class="identifier">l</span><span class="special">);</span></code>: + Sets the pointer to the left node stored in "n" to "l". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">node_ptr</span> + <span class="identifier">get_right</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">);</span></code>: Returns a pointer to the right node + stored in "n". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="keyword">void</span> + <span class="identifier">set_right</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> + <span class="identifier">r</span><span class="special">);</span></code>: + Sets the pointer to the right node stored in "n" to "r". + </li> +</ul></div> +<p> + Once we have a node traits configuration we can use <span class="bold"><strong>Boost.Intrusive</strong></span> + algorithms with our nodes: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">splaytree_algorithms</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cassert</span><span class="special">></span> + +<span class="keyword">struct</span> <span class="identifier">my_node</span> +<span class="special">{</span> + <span class="identifier">my_node</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> + <span class="special">:</span> <span class="identifier">int_</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> + <span class="special">{}</span> + <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">parent_</span><span class="special">,</span> <span class="special">*</span><span class="identifier">left_</span><span class="special">,</span> <span class="special">*</span><span class="identifier">right_</span><span class="special">;</span> + <span class="comment">//other members</span> + <span class="keyword">int</span> <span class="identifier">int_</span><span class="special">;</span> +<span class="special">};</span> + +<span class="comment">//Define our own splaytree_node_traits</span> +<span class="keyword">struct</span> <span class="identifier">my_splaytree_node_traits</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">my_node</span> <span class="identifier">node</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">my_node</span> <span class="special">*</span> <span class="identifier">node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">my_node</span> <span class="special">*</span> <span class="identifier">const_node_ptr</span><span class="special">;</span> + + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">get_parent</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">parent_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_parent</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> <span class="identifier">parent</span><span class="special">){</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">parent_</span> <span class="special">=</span> <span class="identifier">parent</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">get_left</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">left_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_left</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> <span class="identifier">left</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">left_</span> <span class="special">=</span> <span class="identifier">left</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">get_right</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">right_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_right</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> <span class="identifier">right</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">right_</span> <span class="special">=</span> <span class="identifier">right</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="keyword">struct</span> <span class="identifier">node_ptr_compare</span> +<span class="special">{</span> + <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">-></span><span class="identifier">int_</span> <span class="special"><</span> <span class="identifier">b</span><span class="special">-></span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">::</span><span class="identifier">splaytree_algorithms</span><span class="special"><</span><span class="identifier">my_splaytree_node_traits</span><span class="special">></span> <span class="identifier">algo</span><span class="special">;</span> + <span class="identifier">my_node</span> <span class="identifier">header</span><span class="special">,</span> <span class="identifier">two</span><span class="special">(</span><span class="number">2</span><span class="special">),</span> <span class="identifier">three</span><span class="special">(</span><span class="number">3</span><span class="special">);</span> + + <span class="comment">//Create an empty splaytree container:</span> + <span class="comment">//"header" will be the header node of the tree</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">init_header</span><span class="special">(&</span><span class="identifier">header</span><span class="special">);</span> + + <span class="comment">//Now insert node "two" in the tree using the sorting functor</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">insert_equal_upper_bound</span><span class="special">(&</span><span class="identifier">header</span><span class="special">,</span> <span class="special">&</span><span class="identifier">two</span><span class="special">,</span> <span class="identifier">node_ptr_compare</span><span class="special">());</span> + + <span class="comment">//Now insert node "three" in the tree using the sorting functor</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">insert_equal_lower_bound</span><span class="special">(&</span><span class="identifier">header</span><span class="special">,</span> <span class="special">&</span><span class="identifier">three</span><span class="special">,</span> <span class="identifier">node_ptr_compare</span><span class="special">());</span> + + <span class="comment">//Now take the first node (the left node of the header)</span> + <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">n</span> <span class="special">=</span> <span class="identifier">header</span><span class="special">.</span><span class="identifier">left_</span><span class="special">;</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">n</span> <span class="special">==</span> <span class="special">&</span><span class="identifier">two</span><span class="special">);</span> + + <span class="comment">//Now go to the next node</span> + <span class="identifier">n</span> <span class="special">=</span> <span class="identifier">algo</span><span class="special">::</span><span class="identifier">next_node</span><span class="special">(</span><span class="identifier">n</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">n</span> <span class="special">==</span> <span class="special">&</span><span class="identifier">three</span><span class="special">);</span> + + <span class="comment">//Erase a node just using a pointer to it</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">unlink</span><span class="special">(&</span><span class="identifier">two</span><span class="special">);</span> + + <span class="comment">//Erase a node using also the header (faster)</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">erase</span><span class="special">(&</span><span class="identifier">header</span><span class="special">,</span> <span class="special">&</span><span class="identifier">three</span><span class="special">);</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + For a complete list of functions see <code class="computeroutput"><a class="link" href="../boost/intrusive/splaytree_algorithms.html" title="Class template splaytree_algorithms">splaytree_algorithms + reference</a></code>. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.node_algorithms.avltree_algorithms"></a><a class="link" href="node_algorithms.html#intrusive.node_algorithms.avltree_algorithms" title="Intrusive avl tree algorithms">Intrusive + avl tree algorithms</a> +</h3></div></div></div> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/avltree_algorithms.html" title="Class template avltree_algorithms">avltree_algorithms</a></code> + have the same interface as <code class="computeroutput"><a class="link" href="../boost/intrusive/rbtree_algorithms.html" title="Class template rbtree_algorithms">rbtree_algorithms</a></code>. + </p> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">NodeTraits</span><span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">avltree_algorithms</span><span class="special">;</span> +</pre> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/avltree_algorithms.html" title="Class template avltree_algorithms">avltree_algorithms</a></code> + is configured with a NodeTraits class, which encapsulates the information + about the node to be manipulated. NodeTraits must support the following interface: + </p> +<p> + <span class="bold"><strong>Typedefs</strong></span>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">node</span></code>: The type of the + node that forms the circular avltree + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">node_ptr</span></code>: The type of + a pointer to a node (usually node*) + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">const_node_ptr</span></code>: The type + of a pointer to a const node (usually const node*) + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">balance</span></code>: A type that + can represent 3 balance types (usually an integer) + </li> +</ul></div> +<p> + <span class="bold"><strong>Static functions</strong></span>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">node_ptr</span> + <span class="identifier">get_parent</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">);</span></code>: Returns a pointer to the parent node + stored in "n". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="keyword">void</span> + <span class="identifier">set_parent</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> + <span class="identifier">p</span><span class="special">);</span></code>: + Sets the pointer to the parent node stored in "n" to "p". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">node_ptr</span> + <span class="identifier">get_left</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">);</span></code>: Returns a pointer to the left node + stored in "n". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="keyword">void</span> + <span class="identifier">set_left</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> + <span class="identifier">l</span><span class="special">);</span></code>: + Sets the pointer to the left node stored in "n" to "l". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">node_ptr</span> + <span class="identifier">get_right</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">);</span></code>: Returns a pointer to the right node + stored in "n". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="keyword">void</span> + <span class="identifier">set_right</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> + <span class="identifier">r</span><span class="special">);</span></code>: + Sets the pointer to the right node stored in "n" to "r". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">balance</span> + <span class="identifier">get_balance</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">);</span></code>: Returns the balance factor stored + in "n". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="keyword">void</span> + <span class="identifier">set_balance</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">balance</span> + <span class="identifier">b</span><span class="special">);</span></code>: + Sets the balance factor stored in "n" to "b". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">balance</span> + <span class="identifier">negative</span><span class="special">();</span></code>: + Returns a value representing a negative balance factor. + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">balance</span> + <span class="identifier">zero</span><span class="special">();</span></code>: + Returns a value representing a zero balance factor. + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">balance</span> + <span class="identifier">positive</span><span class="special">();</span></code>: + Returns a value representing a positive balance factor. + </li> +</ul></div> +<p> + Once we have a node traits configuration we can use <span class="bold"><strong>Boost.Intrusive</strong></span> + algorithms with our nodes: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">avltree_algorithms</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cassert</span><span class="special">></span> + +<span class="keyword">struct</span> <span class="identifier">my_node</span> +<span class="special">{</span> + <span class="identifier">my_node</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> + <span class="special">:</span> <span class="identifier">int_</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> + <span class="special">{}</span> + <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">parent_</span><span class="special">,</span> <span class="special">*</span><span class="identifier">left_</span><span class="special">,</span> <span class="special">*</span><span class="identifier">right_</span><span class="special">;</span> + <span class="keyword">int</span> <span class="identifier">balance_</span><span class="special">;</span> + <span class="comment">//other members</span> + <span class="keyword">int</span> <span class="identifier">int_</span><span class="special">;</span> +<span class="special">};</span> + +<span class="comment">//Define our own avltree_node_traits</span> +<span class="keyword">struct</span> <span class="identifier">my_avltree_node_traits</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">my_node</span> <span class="identifier">node</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">my_node</span> <span class="special">*</span> <span class="identifier">node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">my_node</span> <span class="special">*</span> <span class="identifier">const_node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">int</span> <span class="identifier">balance</span><span class="special">;</span> + + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">get_parent</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">parent_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_parent</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> <span class="identifier">parent</span><span class="special">){</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">parent_</span> <span class="special">=</span> <span class="identifier">parent</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">get_left</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">left_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_left</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> <span class="identifier">left</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">left_</span> <span class="special">=</span> <span class="identifier">left</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">get_right</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">right_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_right</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> <span class="identifier">right</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">right_</span> <span class="special">=</span> <span class="identifier">right</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">balance</span> <span class="identifier">get_balance</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">balance_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_balance</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">balance</span> <span class="identifier">b</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">balance_</span> <span class="special">=</span> <span class="identifier">b</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">balance</span> <span class="identifier">negative</span><span class="special">()</span> <span class="special">{</span> <span class="keyword">return</span> <span class="special">-</span><span class="number">1</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">balance</span> <span class="identifier">zero</span><span class="special">()</span> <span class="special">{</span> <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">balance</span> <span class="identifier">positive</span><span class="special">()</span> <span class="special">{</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="keyword">struct</span> <span class="identifier">node_ptr_compare</span> +<span class="special">{</span> + <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">-></span><span class="identifier">int_</span> <span class="special"><</span> <span class="identifier">b</span><span class="special">-></span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">::</span><span class="identifier">avltree_algorithms</span><span class="special"><</span><span class="identifier">my_avltree_node_traits</span><span class="special">></span> <span class="identifier">algo</span><span class="special">;</span> + <span class="identifier">my_node</span> <span class="identifier">header</span><span class="special">,</span> <span class="identifier">two</span><span class="special">(</span><span class="number">2</span><span class="special">),</span> <span class="identifier">three</span><span class="special">(</span><span class="number">3</span><span class="special">);</span> + + <span class="comment">//Create an empty avltree container:</span> + <span class="comment">//"header" will be the header node of the tree</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">init_header</span><span class="special">(&</span><span class="identifier">header</span><span class="special">);</span> + + <span class="comment">//Now insert node "two" in the tree using the sorting functor</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">insert_equal_upper_bound</span><span class="special">(&</span><span class="identifier">header</span><span class="special">,</span> <span class="special">&</span><span class="identifier">two</span><span class="special">,</span> <span class="identifier">node_ptr_compare</span><span class="special">());</span> + + <span class="comment">//Now insert node "three" in the tree using the sorting functor</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">insert_equal_lower_bound</span><span class="special">(&</span><span class="identifier">header</span><span class="special">,</span> <span class="special">&</span><span class="identifier">three</span><span class="special">,</span> <span class="identifier">node_ptr_compare</span><span class="special">());</span> + + <span class="comment">//Now take the first node (the left node of the header)</span> + <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">n</span> <span class="special">=</span> <span class="identifier">header</span><span class="special">.</span><span class="identifier">left_</span><span class="special">;</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">n</span> <span class="special">==</span> <span class="special">&</span><span class="identifier">two</span><span class="special">);</span> + + <span class="comment">//Now go to the next node</span> + <span class="identifier">n</span> <span class="special">=</span> <span class="identifier">algo</span><span class="special">::</span><span class="identifier">next_node</span><span class="special">(</span><span class="identifier">n</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">n</span> <span class="special">==</span> <span class="special">&</span><span class="identifier">three</span><span class="special">);</span> + + <span class="comment">//Erase a node just using a pointer to it</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">unlink</span><span class="special">(&</span><span class="identifier">two</span><span class="special">);</span> + + <span class="comment">//Erase a node using also the header (faster)</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">erase</span><span class="special">(&</span><span class="identifier">header</span><span class="special">,</span> <span class="special">&</span><span class="identifier">three</span><span class="special">);</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + For a complete list of functions see <code class="computeroutput"><a class="link" href="../boost/intrusive/avltree_algorithms.html" title="Class template avltree_algorithms">avltree_algorithms + reference</a></code>. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.node_algorithms.treap_algorithms"></a><a class="link" href="node_algorithms.html#intrusive.node_algorithms.treap_algorithms" title="Intrusive treap algorithms">Intrusive + treap algorithms</a> +</h3></div></div></div> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/treap_algorithms.html" title="Class template treap_algorithms">treap_algorithms</a></code> + have the same interface as <code class="computeroutput"><a class="link" href="../boost/intrusive/rbtree_algorithms.html" title="Class template rbtree_algorithms">rbtree_algorithms</a></code>. + </p> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">NodeTraits</span><span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">treap_algorithms</span><span class="special">;</span> +</pre> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/treap_algorithms.html" title="Class template treap_algorithms">treap_algorithms</a></code> + is configured with a NodeTraits class, which encapsulates the information + about the node to be manipulated. NodeTraits must support the following interface: + </p> +<p> + <span class="bold"><strong>Typedefs</strong></span>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">node</span></code>: The type of the + node that forms the circular treap + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">node_ptr</span></code>: The type of + a pointer to a node (usually node*) + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">const_node_ptr</span></code>: The type + of a pointer to a const node (usually const node*) + </li> +</ul></div> +<p> + <span class="bold"><strong>Static functions</strong></span>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">node_ptr</span> + <span class="identifier">get_parent</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">);</span></code>: Returns a pointer to the parent node + stored in "n". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="keyword">void</span> + <span class="identifier">set_parent</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> + <span class="identifier">p</span><span class="special">);</span></code>: + Sets the pointer to the parent node stored in "n" to "p". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">node_ptr</span> + <span class="identifier">get_left</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">);</span></code>: Returns a pointer to the left node + stored in "n". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="keyword">void</span> + <span class="identifier">set_left</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> + <span class="identifier">l</span><span class="special">);</span></code>: + Sets the pointer to the left node stored in "n" to "l". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="identifier">node_ptr</span> + <span class="identifier">get_right</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">);</span></code>: Returns a pointer to the right node + stored in "n". + </li> +<li class="listitem"> + <code class="computeroutput"><span class="keyword">static</span> <span class="keyword">void</span> + <span class="identifier">set_right</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> + <span class="identifier">r</span><span class="special">);</span></code>: + Sets the pointer to the right node stored in "n" to "r". + </li> +</ul></div> +<p> + Once we have a node traits configuration we can use <span class="bold"><strong>Boost.Intrusive</strong></span> + algorithms with our nodes: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">treap_algorithms</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cassert</span><span class="special">></span> + +<span class="keyword">struct</span> <span class="identifier">my_node</span> +<span class="special">{</span> + <span class="identifier">my_node</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">priority</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> + <span class="special">:</span> <span class="identifier">prio_</span><span class="special">(</span><span class="identifier">priority</span><span class="special">),</span> <span class="identifier">int_</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> + <span class="special">{}</span> + <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">parent_</span><span class="special">,</span> <span class="special">*</span><span class="identifier">left_</span><span class="special">,</span> <span class="special">*</span><span class="identifier">right_</span><span class="special">;</span> + <span class="keyword">int</span> <span class="identifier">prio_</span><span class="special">;</span> + <span class="comment">//other members</span> + <span class="keyword">int</span> <span class="identifier">int_</span><span class="special">;</span> +<span class="special">};</span> + +<span class="comment">//Define our own treap_node_traits</span> +<span class="keyword">struct</span> <span class="identifier">my_treap_node_traits</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">my_node</span> <span class="identifier">node</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">my_node</span> <span class="special">*</span> <span class="identifier">node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">my_node</span> <span class="special">*</span> <span class="identifier">const_node_ptr</span><span class="special">;</span> + + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">get_parent</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">parent_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_parent</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> <span class="identifier">parent</span><span class="special">){</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">parent_</span> <span class="special">=</span> <span class="identifier">parent</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">get_left</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">left_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_left</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> <span class="identifier">left</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">left_</span> <span class="special">=</span> <span class="identifier">left</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">get_right</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">right_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_right</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">,</span> <span class="identifier">node_ptr</span> <span class="identifier">right</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">right_</span> <span class="special">=</span> <span class="identifier">right</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="keyword">struct</span> <span class="identifier">node_ptr_compare</span> +<span class="special">{</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">b</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">-></span><span class="identifier">int_</span> <span class="special"><</span> <span class="identifier">b</span><span class="special">-></span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> <span class="special">};</span> + +<span class="keyword">struct</span> <span class="identifier">node_ptr_priority</span> +<span class="special">{</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">b</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">-></span><span class="identifier">prio_</span> <span class="special"><</span> <span class="identifier">b</span><span class="special">-></span><span class="identifier">prio_</span><span class="special">;}</span> <span class="special">};</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">::</span><span class="identifier">treap_algorithms</span><span class="special"><</span><span class="identifier">my_treap_node_traits</span><span class="special">></span> <span class="identifier">algo</span><span class="special">;</span> + <span class="identifier">my_node</span> <span class="identifier">header</span><span class="special">,</span> <span class="identifier">two</span><span class="special">(</span><span class="number">2</span><span class="special">,</span> <span class="number">5</span><span class="special">),</span> <span class="identifier">three</span><span class="special">(</span><span class="number">3</span><span class="special">,</span> <span class="number">1</span><span class="special">);</span> + + <span class="comment">//Create an empty treap container:</span> + <span class="comment">//"header" will be the header node of the tree</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">init_header</span><span class="special">(&</span><span class="identifier">header</span><span class="special">);</span> + + <span class="comment">//Now insert node "two" in the tree using the sorting functor</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">insert_equal_upper_bound</span><span class="special">(&</span><span class="identifier">header</span><span class="special">,</span> <span class="special">&</span><span class="identifier">two</span><span class="special">,</span> <span class="identifier">node_ptr_compare</span><span class="special">(),</span> <span class="identifier">node_ptr_priority</span><span class="special">());</span> + + <span class="comment">//Now insert node "three" in the tree using the sorting functor</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">insert_equal_lower_bound</span><span class="special">(&</span><span class="identifier">header</span><span class="special">,</span> <span class="special">&</span><span class="identifier">three</span><span class="special">,</span> <span class="identifier">node_ptr_compare</span><span class="special">(),</span> <span class="identifier">node_ptr_priority</span><span class="special">());</span> + + <span class="comment">//Now take the first node (the left node of the header)</span> + <span class="identifier">my_node</span> <span class="special">*</span><span class="identifier">n</span> <span class="special">=</span> <span class="identifier">header</span><span class="special">.</span><span class="identifier">left_</span><span class="special">;</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">n</span> <span class="special">==</span> <span class="special">&</span><span class="identifier">two</span><span class="special">);</span> + + <span class="comment">//Now go to the next node</span> + <span class="identifier">n</span> <span class="special">=</span> <span class="identifier">algo</span><span class="special">::</span><span class="identifier">next_node</span><span class="special">(</span><span class="identifier">n</span><span class="special">);</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">n</span> <span class="special">==</span> <span class="special">&</span><span class="identifier">three</span><span class="special">);</span> + + <span class="comment">//Erase a node just using a pointer to it</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">unlink</span><span class="special">(&</span><span class="identifier">two</span><span class="special">,</span> <span class="identifier">node_ptr_priority</span><span class="special">());</span> + + <span class="comment">//Erase a node using also the header (faster)</span> + <span class="identifier">algo</span><span class="special">::</span><span class="identifier">erase</span><span class="special">(&</span><span class="identifier">header</span><span class="special">,</span> <span class="special">&</span><span class="identifier">three</span><span class="special">,</span> <span class="identifier">node_ptr_priority</span><span class="special">());</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + For a complete list of functions see <code class="computeroutput"><a class="link" href="../boost/intrusive/treap_algorithms.html" title="Class template treap_algorithms">treap_algorithms + reference</a></code>. + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="concepts.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="value_traits.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/obtaining_iterators_from_values.html b/doc/html/intrusive/obtaining_iterators_from_values.html new file mode 100755 index 0000000000..0eb51602e1 --- /dev/null +++ b/doc/html/intrusive/obtaining_iterators_from_values.html @@ -0,0 +1,172 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Obtaining iterators from values</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="using_smart_pointers.html" title="Using smart pointers with Boost.Intrusive containers"> +<link rel="next" href="any_hooks.html" title="Any Hooks: A single hook for any Intrusive container"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="using_smart_pointers.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="any_hooks.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.obtaining_iterators_from_values"></a><a class="link" href="obtaining_iterators_from_values.html" title="Obtaining iterators from values">Obtaining iterators + from values</a> +</h2></div></div></div> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> offers another useful feature + that's not present in STL containers: it's possible to obtain an iterator to + a value from the value itself. This feature is implemented in <span class="bold"><strong>Boost.Intrusive</strong></span> + containers by a function called <code class="computeroutput"><span class="identifier">iterator_to</span></code>: + </p> +<pre class="programlisting"><span class="identifier">iterator</span> <span class="identifier">iterator_to</span><span class="special">(</span><span class="identifier">reference</span> <span class="identifier">value</span><span class="special">);</span> +<span class="identifier">const_iterator</span> <span class="identifier">iterator_to</span><span class="special">(</span><span class="identifier">const_reference</span> <span class="identifier">value</span><span class="special">);</span> +</pre> +<p> + For <span class="bold"><strong>Boost.Intrusive</strong></span> containers that have local + iterators, like unordered associative containers, we can also obtain local + iterators: + </p> +<pre class="programlisting"><span class="identifier">local_iterator</span> <span class="identifier">local_iterator_to</span><span class="special">(</span><span class="identifier">reference</span> <span class="identifier">value</span><span class="special">);</span> +<span class="identifier">const_local_iterator</span> <span class="identifier">local_iterator_to</span><span class="special">(</span><span class="identifier">const_reference</span> <span class="identifier">value</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> +</pre> +<p> + For most <span class="bold"><strong>Boost.Intrusive</strong></span> containers (<code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a></code>, <code class="computeroutput"><a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a></code>, + <code class="computeroutput"><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a></code>, <code class="computeroutput"><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a></code>) + we have an alternative static <code class="computeroutput"><span class="identifier">s_iterator_to</span></code> + function. + </p> +<p> + For unordered associative containers (<code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set.html" title="Class template unordered_set">unordered_set</a></code>, + <code class="computeroutput"><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a></code>), <code class="computeroutput"><span class="identifier">iterator_to</span></code> has no static alternative function. + On the other hand, <code class="computeroutput"><span class="identifier">local_iterator_to</span></code> + functions have their <code class="computeroutput"><span class="identifier">s_local_iterator_to</span></code> + static alternatives. + </p> +<p> + Alternative static functions are available under certain circumstances explained + in the <a class="link" href="value_traits.html#intrusive.value_traits.stateful_value_traits" title="Stateful value traits">Stateful + value traits</a> section; if the programmer uses hooks provided by <span class="bold"><strong>Boost.Intrusive</strong></span>, those functions will be available. + </p> +<p> + Let's see a small function that shows the use of <code class="computeroutput"><span class="identifier">iterator_to</span></code> + and <code class="computeroutput"><span class="identifier">local_iterator_to</span></code>: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">unordered_set</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">functional</span><span class="special">/</span><span class="identifier">hash</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="keyword">class</span> <span class="identifier">intrusive_data</span> +<span class="special">{</span> + <span class="keyword">int</span> <span class="identifier">data_id_</span><span class="special">;</span> + <span class="keyword">public</span><span class="special">:</span> + + <span class="keyword">void</span> <span class="identifier">set</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">id</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">data_id_</span> <span class="special">=</span> <span class="identifier">id</span><span class="special">;</span> <span class="special">}</span> + + <span class="comment">//This class can be inserted in an intrusive list</span> + <span class="identifier">list_member_hook</span><span class="special"><></span> <span class="identifier">list_hook_</span><span class="special">;</span> + + <span class="comment">//This class can be inserted in an intrusive unordered_set</span> + <span class="identifier">unordered_set_member_hook</span><span class="special"><></span> <span class="identifier">unordered_set_hook_</span><span class="special">;</span> + + <span class="comment">//Comparison operators</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">==(</span><span class="keyword">const</span> <span class="identifier">intrusive_data</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">intrusive_data</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">data_id_</span> <span class="special">==</span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">data_id_</span><span class="special">;</span> <span class="special">}</span> + + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">!=(</span><span class="keyword">const</span> <span class="identifier">intrusive_data</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">intrusive_data</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">data_id_</span> <span class="special">!=</span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">data_id_</span><span class="special">;</span> <span class="special">}</span> + + <span class="comment">//The hash function</span> + <span class="keyword">friend</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">hash_value</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">intrusive_data</span> <span class="special">&</span><span class="identifier">i</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">hash</span><span class="special"><</span><span class="keyword">int</span><span class="special">>()(</span><span class="identifier">i</span><span class="special">.</span><span class="identifier">data_id_</span><span class="special">);</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="comment">//Definition of the intrusive list that will hold intrusive_data</span> +<span class="keyword">typedef</span> <span class="identifier">member_hook</span><span class="special"><</span><span class="identifier">intrusive_data</span><span class="special">,</span> <span class="identifier">list_member_hook</span><span class="special"><></span> + <span class="special">,</span> <span class="special">&</span><span class="identifier">intrusive_data</span><span class="special">::</span><span class="identifier">list_hook_</span><span class="special">></span> <span class="identifier">MemberListOption</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span><span class="identifier">intrusive_data</span><span class="special">,</span> <span class="identifier">MemberListOption</span><span class="special">></span> <span class="identifier">list_t</span><span class="special">;</span> + +<span class="comment">//Definition of the intrusive unordered_set that will hold intrusive_data</span> +<span class="keyword">typedef</span> <span class="identifier">member_hook</span> + <span class="special"><</span> <span class="identifier">intrusive_data</span><span class="special">,</span> <span class="identifier">unordered_set_member_hook</span><span class="special"><></span> + <span class="special">,</span> <span class="special">&</span><span class="identifier">intrusive_data</span><span class="special">::</span><span class="identifier">unordered_set_hook_</span><span class="special">></span> <span class="identifier">MemberUsetOption</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">::</span><span class="identifier">unordered_set</span> + <span class="special"><</span> <span class="identifier">intrusive_data</span><span class="special">,</span> <span class="identifier">MemberUsetOption</span><span class="special">></span> <span class="identifier">unordered_set_t</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="comment">//Create MaxElem objects</span> + <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">MaxElem</span> <span class="special">=</span> <span class="number">100</span><span class="special">;</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">intrusive_data</span><span class="special">></span> <span class="identifier">nodes</span><span class="special">(</span><span class="identifier">MaxElem</span><span class="special">);</span> + + <span class="comment">//Declare the intrusive containers</span> + <span class="identifier">list_t</span> <span class="identifier">list</span><span class="special">;</span> + <span class="identifier">unordered_set_t</span><span class="special">::</span><span class="identifier">bucket_type</span> <span class="identifier">buckets</span><span class="special">[</span><span class="identifier">MaxElem</span><span class="special">];</span> + <span class="identifier">unordered_set_t</span> <span class="identifier">unordered_set</span> + <span class="special">(</span><span class="identifier">unordered_set_t</span><span class="special">::</span><span class="identifier">bucket_traits</span><span class="special">(</span><span class="identifier">buckets</span><span class="special">,</span> <span class="identifier">MaxElem</span><span class="special">));</span> + + <span class="comment">//Initialize all the nodes</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="identifier">MaxElem</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">nodes</span><span class="special">[</span><span class="identifier">i</span><span class="special">].</span><span class="identifier">set</span><span class="special">(</span><span class="identifier">i</span><span class="special">);</span> + + <span class="comment">//Now insert them in both intrusive containers</span> + <span class="identifier">list</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">nodes</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">nodes</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + <span class="identifier">unordered_set</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">nodes</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">nodes</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + + <span class="comment">//Now check the iterator_to function</span> + <span class="identifier">list_t</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">list_it</span><span class="special">(</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">begin</span><span class="special">());</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="identifier">MaxElem</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">,</span> <span class="special">++</span><span class="identifier">list_it</span><span class="special">)</span> + <span class="keyword">if</span><span class="special">(</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">iterator_to</span><span class="special">(</span><span class="identifier">nodes</span><span class="special">[</span><span class="identifier">i</span><span class="special">])</span> <span class="special">!=</span> <span class="identifier">list_it</span> <span class="special">||</span> + <span class="identifier">list_t</span><span class="special">::</span><span class="identifier">s_iterator_to</span><span class="special">(</span><span class="identifier">nodes</span><span class="special">[</span><span class="identifier">i</span><span class="special">])</span> <span class="special">!=</span> <span class="identifier">list_it</span><span class="special">)</span> + <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + + <span class="comment">//Now check unordered_set::s_iterator_to (which is a member function)</span> + <span class="comment">//and unordered_set::s_local_iterator_to (which is an static member function)</span> + <span class="identifier">unordered_set_t</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">unordered_set_it</span><span class="special">(</span><span class="identifier">unordered_set</span><span class="special">.</span><span class="identifier">begin</span><span class="special">());</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="identifier">MaxElem</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">){</span> + <span class="identifier">unordered_set_it</span> <span class="special">=</span> <span class="identifier">unordered_set</span><span class="special">.</span><span class="identifier">find</span><span class="special">(</span><span class="identifier">nodes</span><span class="special">[</span><span class="identifier">i</span><span class="special">]);</span> + <span class="keyword">if</span><span class="special">(</span><span class="identifier">unordered_set</span><span class="special">.</span><span class="identifier">iterator_to</span><span class="special">(</span><span class="identifier">nodes</span><span class="special">[</span><span class="identifier">i</span><span class="special">])</span> <span class="special">!=</span> <span class="identifier">unordered_set_it</span><span class="special">)</span> + <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + <span class="keyword">if</span><span class="special">(*</span><span class="identifier">unordered_set</span><span class="special">.</span><span class="identifier">local_iterator_to</span><span class="special">(</span><span class="identifier">nodes</span><span class="special">[</span><span class="identifier">i</span><span class="special">])</span> <span class="special">!=</span> <span class="special">*</span><span class="identifier">unordered_set_it</span> <span class="special">||</span> + <span class="special">*</span><span class="identifier">unordered_set_t</span><span class="special">::</span><span class="identifier">s_local_iterator_to</span><span class="special">(</span><span class="identifier">nodes</span><span class="special">[</span><span class="identifier">i</span><span class="special">])</span> <span class="special">!=</span> <span class="special">*</span><span class="identifier">unordered_set_it</span> <span class="special">)</span> + <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + <span class="special">}</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </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"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="using_smart_pointers.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="any_hooks.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/obtaining_same_type_reducing_space.html b/doc/html/intrusive/obtaining_same_type_reducing_space.html new file mode 100755 index 0000000000..10e8de738a --- /dev/null +++ b/doc/html/intrusive/obtaining_same_type_reducing_space.html @@ -0,0 +1,100 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Obtaining the same types and reducing symbol length</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="thread_safety.html" title="Thread safety guarantees"> +<link rel="next" href="design_notes.html" title="Design Notes"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="thread_safety.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="design_notes.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.obtaining_same_type_reducing_space"></a><a class="link" href="obtaining_same_type_reducing_space.html" title="Obtaining the same types and reducing symbol length">Obtaining + the same types and reducing symbol length</a> +</h2></div></div></div> +<p> + The flexible option specification mechanism used by <span class="bold"><strong>Boost.Intrusive</strong></span> + for hooks and containers has a couple of downsides: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + If a user specifies the same options in different order or specifies some + options and leaves the rest as defaults, the type of the created container/hook + will be different. Sometimes this is annoying, because two programmers + specifying the same options might end up with incompatible types. For example, + the following two lists, although using the same options, do not have the + same type: + </li></ul></div> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="comment">//Explicitly specify constant-time size and size type</span> +<span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">true</span><span class="special">>,</span> <span class="identifier">size_type</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">></span> <span class="identifier">List1</span><span class="special">;</span> + +<span class="comment">//Implicitly specify constant-time size and size type</span> +<span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="identifier">List2</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + Option specifiers lead to long template symbols for classes and functions. + Option specifiers themselves are verbose and without variadic templates, + several default template parameters are assigned for non-specified options. + Object and debugging information files can grow and compilation times may + suffer if long names are produced. + </li></ul></div> +<p> + To solve these issues <span class="bold"><strong>Boost.Intrusive</strong></span> offers + some helper metafunctions that reduce symbol lengths and create the same type + if the same options (either explicitly or implicitly) are used. These also + improve compilation times. All containers and hooks have their respective + <code class="computeroutput"><span class="identifier">make_xxx</span></code> versions. The previously + shown example can be rewritten like this to obtain the same list type: + </p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + + <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + + <span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + + <span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + + <span class="comment">//Explicitly specify constant-time size and size type</span> + <span class="keyword">typedef</span> <span class="identifier">make_list</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">true</span><span class="special">>,</span> <span class="identifier">size_type</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">List1</span><span class="special">;</span> + + <span class="comment">//Implicitly specify constant-time size and size type</span> + <span class="keyword">typedef</span> <span class="identifier">make_list</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">List2</span><span class="special">;</span> +</pre> +<p> + Produced symbol lengths and compilation times will usually be shorter and object/debug + files smaller. If you are concerned with file sizes and compilation times, + this option is your best choice. + </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"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="thread_safety.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="design_notes.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/performance.html b/doc/html/intrusive/performance.html new file mode 100755 index 0000000000..62ab490d24 --- /dev/null +++ b/doc/html/intrusive/performance.html @@ -0,0 +1,2041 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Performance</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="design_notes.html" title="Design Notes"> +<link rel="next" href="release_notes.html" title="Release Notes"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="design_notes.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="release_notes.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.performance"></a><a class="link" href="performance.html" title="Performance">Performance</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="performance.html#intrusive.performance.performance_results_push_back">Back + insertion and destruction</a></span></dt> +<dt><span class="section"><a href="performance.html#intrusive.performance.performance_results_reversing">Reversing</a></span></dt> +<dt><span class="section"><a href="performance.html#intrusive.performance.performance_results_sorting">Sorting</a></span></dt> +<dt><span class="section"><a href="performance.html#intrusive.performance.performance_results_write_access">Write + access</a></span></dt> +<dt><span class="section"><a href="performance.html#intrusive.performance.performance_results_conclusions">Conclusions</a></span></dt> +</dl></div> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> containers offer speed improvements + compared to non-intrusive containers primarily because: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + They minimize memory allocation/deallocation calls. + </li> +<li class="listitem"> + They obtain better memory locality. + </li> +</ul></div> +<p> + This section will show performance tests comparing some operations on <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">::</span><span class="identifier">list</span></code> and + <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span></code>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + Insertions using <code class="computeroutput"><span class="identifier">push_back</span></code> + and container destruction will show the overhead associated with memory + allocation/deallocation. + </li> +<li class="listitem"> + The <code class="computeroutput"><span class="identifier">reverse</span></code> member function + will show the advantages of the compact memory representation that can + be achieved with intrusive containers. + </li> +<li class="listitem"> + The <code class="computeroutput"><span class="identifier">sort</span></code> and <code class="computeroutput"><span class="identifier">write</span> <span class="identifier">access</span></code> + tests will show the advantage of intrusive containers minimizing memory + accesses compared to containers of pointers. + </li> +</ul></div> +<p> + Given an object of type <code class="computeroutput"><span class="identifier">T</span></code>, + <code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">boost::intrusive::list<T></a></code> + can replace <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code> to + avoid memory allocation overhead, or it can replace <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span><span class="identifier">T</span><span class="special">*></span></code> when + the user wants containers with polymorphic values or wants to share values + between several containers. Because of this versatility, the performance tests + will be executed for 6 different list types: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + 3 intrusive lists holding a class named <code class="computeroutput"><span class="identifier">itest_class</span></code>, + each one with a different linking policy (<code class="computeroutput"><span class="identifier">normal_link</span></code>, + <code class="computeroutput"><span class="identifier">safe_link</span></code>, <code class="computeroutput"><span class="identifier">auto_unlink</span></code>). The <code class="computeroutput"><span class="identifier">itest_class</span></code> + objects will be tightly packed in a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">itest_class</span><span class="special">></span></code> object. + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span><span class="identifier">test_class</span><span class="special">></span></code>, + where <code class="computeroutput"><span class="identifier">test_class</span></code> is exactly + the same as <code class="computeroutput"><span class="identifier">itest_class</span></code>, + but without the intrusive hook. + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span><span class="identifier">test_class</span><span class="special">*></span></code>. + The list will contain pointers to <code class="computeroutput"><span class="identifier">test_class</span></code> + objects tightly packed in a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">test_class</span><span class="special">></span></code> object. We'll call this configuration + <span class="emphasis"><em>compact pointer list</em></span> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span><span class="identifier">test_class</span><span class="special">*></span></code>. + The list will contain pointers to <code class="computeroutput"><span class="identifier">test_class</span></code> + objects owned by a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span><span class="identifier">test_class</span><span class="special">></span></code> object. We'll call this configuration + <span class="emphasis"><em>disperse pointer list</em></span>. + </li> +</ul></div> +<p> + Both <code class="computeroutput"><span class="identifier">test_class</span></code> and <code class="computeroutput"><span class="identifier">itest_class</span></code> are templatized classes that + can be configured with a boolean to increase the size of the object. This way, + the tests can be executed with small and big objects. Here is the first part + of the testing code, which shows the definitions of <code class="computeroutput"><span class="identifier">test_class</span></code> + and <code class="computeroutput"><span class="identifier">itest_class</span></code> classes, and + some other utilities: + </p> +<p> +</p> +<pre class="programlisting"><span class="comment">//Iteration and element count defines</span> +<span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">NumIter</span> <span class="special">=</span> <span class="number">100</span><span class="special">;</span> +<span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">NumElements</span> <span class="special">=</span> <span class="number">50000</span><span class="special">;</span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="keyword">template</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">BigSize</span><span class="special">></span> <span class="keyword">struct</span> <span class="identifier">filler</span> <span class="special">{</span> <span class="keyword">int</span> <span class="identifier">dummy</span><span class="special">[</span><span class="number">10</span><span class="special">];</span> <span class="special">};</span> +<span class="keyword">template</span> <span class="special"><></span> <span class="keyword">struct</span> <span class="identifier">filler</span><span class="special"><</span><span class="keyword">false</span><span class="special">></span> <span class="special">{};</span> + +<span class="keyword">template</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">BigSize</span><span class="special">></span> <span class="comment">//The object for non-intrusive containers</span> +<span class="keyword">struct</span> <span class="identifier">test_class</span> <span class="special">:</span> <span class="keyword">private</span> <span class="identifier">filler</span><span class="special"><</span><span class="identifier">BigSize</span><span class="special">></span> +<span class="special">{</span> + <span class="keyword">int</span> <span class="identifier">i_</span><span class="special">;</span> + <span class="identifier">test_class</span><span class="special">()</span> <span class="special">{}</span> + <span class="identifier">test_class</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">i_</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> <span class="special">{}</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span> <span class="special"><(</span><span class="keyword">const</span> <span class="identifier">test_class</span> <span class="special">&</span><span class="identifier">l</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">test_class</span> <span class="special">&</span><span class="identifier">r</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">l</span><span class="special">.</span><span class="identifier">i_</span> <span class="special"><</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">i_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span> <span class="special">>(</span><span class="keyword">const</span> <span class="identifier">test_class</span> <span class="special">&</span><span class="identifier">l</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">test_class</span> <span class="special">&</span><span class="identifier">r</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">l</span><span class="special">.</span><span class="identifier">i_</span> <span class="special">></span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">i_</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">bool</span> <span class="identifier">BigSize</span><span class="special">,</span> <span class="identifier">link_mode_type</span> <span class="identifier">LinkMode</span><span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">itest_class</span> <span class="comment">//The object for intrusive containers</span> + <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">list_base_hook</span><span class="special"><</span><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">LinkMode</span><span class="special">></span> <span class="special">>,</span> <span class="keyword">public</span> <span class="identifier">test_class</span><span class="special"><</span><span class="identifier">BigSize</span><span class="special">></span> +<span class="special">{</span> + <span class="identifier">itest_class</span><span class="special">()</span> <span class="special">{}</span> + <span class="identifier">itest_class</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">test_class</span><span class="special"><</span><span class="identifier">BigSize</span><span class="special">>(</span><span class="identifier">i</span><span class="special">)</span> <span class="special">{}</span> +<span class="special">};</span> + +<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">FuncObj</span><span class="special">></span> <span class="comment">//Adapts functors taking values to functors taking pointers</span> +<span class="keyword">struct</span> <span class="identifier">func_ptr_adaptor</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">FuncObj</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">FuncObj</span><span class="special">::</span><span class="identifier">first_argument_type</span><span class="special">*</span> <span class="identifier">first_argument_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">FuncObj</span><span class="special">::</span><span class="identifier">second_argument_type</span><span class="special">*</span> <span class="identifier">second_argument_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">FuncObj</span><span class="special">::</span><span class="identifier">result_type</span> <span class="identifier">result_type</span><span class="special">;</span> + <span class="identifier">result_type</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">first_argument_type</span> <span class="identifier">a</span><span class="special">,</span> <span class="identifier">second_argument_type</span> <span class="identifier">b</span><span class="special">)</span> <span class="keyword">const</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">FuncObj</span><span class="special">::</span><span class="keyword">operator</span><span class="special">()(*</span><span class="identifier">a</span><span class="special">,</span> <span class="special">*</span><span class="identifier">b</span><span class="special">);</span> <span class="special">}</span> +<span class="special">};</span> +</pre> +<p> + </p> +<p> + As we can see, <code class="computeroutput"><span class="identifier">test_class</span></code> is + a very simple class holding an <code class="computeroutput"><span class="keyword">int</span></code>. + <code class="computeroutput"><span class="identifier">itest_class</span></code> is just a class + that has a base hook (<code class="computeroutput"><a class="link" href="../boost/intrusive/list_base_hook.html" title="Class template list_base_hook">list_base_hook</a></code>) + and also derives from <code class="computeroutput"><span class="identifier">test_class</span></code>. + </p> +<p> + <code class="computeroutput"><span class="identifier">func_ptr_adaptor</span></code> is just a + functor adaptor to convert function objects taking <code class="computeroutput"><span class="identifier">test_list</span></code> + objects to function objects taking pointers to them. + </p> +<p> + You can find the full test code code in the <a href="../../../libs/intrusive/perf/perf_list.cpp" target="_top">perf_list.cpp</a> + source file. + </p> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.performance.performance_results_push_back"></a><a class="link" href="performance.html#intrusive.performance.performance_results_push_back" title="Back insertion and destruction">Back + insertion and destruction</a> +</h3></div></div></div> +<p> + The first test will measure the benefits we can obtain with intrusive containers + avoiding memory allocations and deallocations. All the objects to be inserted + in intrusive containers are allocated in a single allocation call, whereas + <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span></code> will need to allocate memory for each + object and deallocate it for every erasure (or container destruction). + </p> +<p> + Let's compare the code to be executed for each container type for different + insertion tests: + </p> +<p> +</p> +<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">ilist</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">></span> <span class="identifier">objects</span><span class="special">(</span><span class="identifier">NumElements</span><span class="special">);</span> +<span class="identifier">ilist</span> <span class="identifier">l</span><span class="special">;</span> +<span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="identifier">NumElements</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">objects</span><span class="special">[</span><span class="identifier">i</span><span class="special">]);</span> +<span class="comment">//Elements are unlinked in ilist's destructor</span> +<span class="comment">//Elements are destroyed in vector's destructor</span> +</pre> +<p> + </p> +<p> + For intrusive containers, all the values are created in a vector and after + that inserted in the intrusive list. + </p> +<p> +</p> +<pre class="programlisting"><span class="identifier">stdlist</span> <span class="identifier">l</span><span class="special">;</span> +<span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="identifier">NumElements</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="keyword">typename</span> <span class="identifier">stdlist</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="identifier">i</span><span class="special">));</span> +<span class="comment">//Elements unlinked and destroyed in stdlist's destructor</span> +</pre> +<p> + </p> +<p> + For a standard list, elements are pushed back using push_back(). + </p> +<p> +</p> +<pre class="programlisting"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">stdlist</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">></span> <span class="identifier">objects</span><span class="special">(</span><span class="identifier">NumElements</span><span class="special">);</span> +<span class="identifier">stdptrlist</span> <span class="identifier">l</span><span class="special">;</span> +<span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="identifier">NumElements</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(&</span><span class="identifier">objects</span><span class="special">[</span><span class="identifier">i</span><span class="special">]);</span> +<span class="comment">//Pointers to elements unlinked and destroyed in stdptrlist's destructor</span> +<span class="comment">//Elements destroyed in vector's destructor</span> +</pre> +<p> + </p> +<p> + For a standard compact pointer list, elements are created in a vector and + pushed back in the pointer list using push_back(). + </p> +<p> +</p> +<pre class="programlisting"><span class="identifier">stdlist</span> <span class="identifier">objects</span><span class="special">;</span> <span class="identifier">stdptrlist</span> <span class="identifier">l</span><span class="special">;</span> +<span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="identifier">NumElements</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">){</span> + <span class="identifier">objects</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="keyword">typename</span> <span class="identifier">stdlist</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="identifier">i</span><span class="special">));</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(&</span><span class="identifier">objects</span><span class="special">.</span><span class="identifier">back</span><span class="special">());</span> +<span class="special">}</span> +<span class="comment">//Pointers to elements unlinked and destroyed in stdptrlist's destructor</span> +<span class="comment">//Elements unlinked and destroyed in stdlist's destructor</span> +</pre> +<p> + </p> +<p> + For a <span class="emphasis"><em>disperse pointer list</em></span>, elements are created in + a list and pushed back in the pointer list using push_back(). + </p> +<p> + These are the times in microseconds for each case, and the normalized time: + </p> +<div class="table"> +<a name="intrusive.performance.performance_results_push_back.t0"></a><p class="title"><b>Table 13.2. Back insertion + destruction times for Visual C++ 7.1 / Windows XP</b></p> +<div class="table-contents"><table class="table" summary="Back insertion + destruction times for Visual C++ 7.1 / Windows XP"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Container + </p> + </th> +<th> + <p> + Time in us/iteration (small object / big object) + </p> + </th> +<th> + <p> + Normalized time (small object / big object) + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">normal_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 5000 / 22500 + </p> + </td> +<td> + <p> + 1 / 1 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">safe_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 7812 / 32187 + </p> + </td> +<td> + <p> + 1.56 / 1.43 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">auto_unlink</span></code> intrusive + list + </p> + </td> +<td> + <p> + 10156 / 41562 + </p> + </td> +<td> + <p> + 2.03 / 1.84 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard list + </p> + </td> +<td> + <p> + 26875 / 97500 + </p> + </td> +<td> + <p> + 5.37 / 4.33 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard compact pointer list + </p> + </td> +<td> + <p> + 76406 / 86718 + </p> + </td> +<td> + <p> + 15.28 / 3.85 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard disperse pointer list + </p> + </td> +<td> + <p> + 146562 / 175625 + </p> + </td> +<td> + <p> + 29.31 / 7.80 + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="intrusive.performance.performance_results_push_back.t1"></a><p class="title"><b>Table 13.3. Back insertion + destruction times for GCC 4.1.1 / MinGW over Windows + XP</b></p> +<div class="table-contents"><table class="table" summary="Back insertion + destruction times for GCC 4.1.1 / MinGW over Windows + XP"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Container + </p> + </th> +<th> + <p> + Time in us/iteration (small object / big object) + </p> + </th> +<th> + <p> + Normalized time (small object / big object) + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">normal_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 4375 / 22187 + </p> + </td> +<td> + <p> + 1 / 1 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">safe_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 7812 / 32812 + </p> + </td> +<td> + <p> + 1.78 / 1.47 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">auto_unlink</span></code> intrusive + list + </p> + </td> +<td> + <p> + 10468 / 42031 + </p> + </td> +<td> + <p> + 2.39 / 1.89 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard list + </p> + </td> +<td> + <p> + 81250 / 98125 + </p> + </td> +<td> + <p> + 18.57 / 4.42 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard compact pointer list + </p> + </td> +<td> + <p> + 83750 / 94218 + </p> + </td> +<td> + <p> + 19.14 / 4.24 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard disperse pointer list + </p> + </td> +<td> + <p> + 155625 / 175625 + </p> + </td> +<td> + <p> + 35.57 / 7.91 + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="intrusive.performance.performance_results_push_back.t2"></a><p class="title"><b>Table 13.4. Back insertion + destruction times for GCC 4.1.2 / Linux Kernel 2.6.18 + (OpenSuse 10.2)</b></p> +<div class="table-contents"><table class="table" summary="Back insertion + destruction times for GCC 4.1.2 / Linux Kernel 2.6.18 + (OpenSuse 10.2)"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Container + </p> + </th> +<th> + <p> + Time in us/iteration (small object / big object) + </p> + </th> +<th> + <p> + Normalized time (small object / big object) + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">normal_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 4792 / 20495 + </p> + </td> +<td> + <p> + 1 / 1 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">safe_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 7709 / 30803 + </p> + </td> +<td> + <p> + 1.60 / 1.5 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">auto_unlink</span></code> intrusive + list + </p> + </td> +<td> + <p> + 10180 / 41183 + </p> + </td> +<td> + <p> + 2.12 / 2.0 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard list + </p> + </td> +<td> + <p> + 17031 / 32586 + </p> + </td> +<td> + <p> + 3.55 / 1.58 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard compact pointer list + </p> + </td> +<td> + <p> + 27221 / 34823 + </p> + </td> +<td> + <p> + 5.68 / 1.69 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard disperse pointer list + </p> + </td> +<td> + <p> + 102272 / 60056 + </p> + </td> +<td> + <p> + 21.34 / 2.93 + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><p> + The results are logical: intrusive lists just need one allocation. The destruction + time of the <code class="computeroutput"><span class="identifier">normal_link</span></code> intrusive + container is trivial (complexity: <code class="computeroutput"><span class="identifier">O</span><span class="special">(</span><span class="number">1</span><span class="special">)</span></code>), + whereas <code class="computeroutput"><span class="identifier">safe_link</span></code> and <code class="computeroutput"><span class="identifier">auto_unlink</span></code> intrusive containers need to + put the hooks of erased values in the default state (complexity: <code class="computeroutput"><span class="identifier">O</span><span class="special">(</span><span class="identifier">NumElements</span><span class="special">)</span></code>). That's why <code class="computeroutput"><span class="identifier">normal_link</span></code> + intrusive list shines in this test. + </p> +<p> + Non-intrusive containers need to make many more allocations and that's why + they lag behind. The <code class="computeroutput"><span class="identifier">disperse</span> <span class="identifier">pointer</span> <span class="identifier">list</span></code> + needs to make <code class="computeroutput"><span class="identifier">NumElements</span><span class="special">*</span><span class="number">2</span></code> allocations, + so the result is not surprising. + </p> +<p> + The Linux test shows that standard containers perform very well against intrusive + containers with big objects. Nearly the same GCC version in MinGW performs + worse, so maybe a good memory allocator is the reason for these excellent + results. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.performance.performance_results_reversing"></a><a class="link" href="performance.html#intrusive.performance.performance_results_reversing" title="Reversing">Reversing</a> +</h3></div></div></div> +<p> + The next test measures the time needed to complete calls to the member function + <code class="computeroutput"><span class="identifier">reverse</span><span class="special">()</span></code>. + Values (<code class="computeroutput"><span class="identifier">test_class</span></code> and <code class="computeroutput"><span class="identifier">itest_class</span></code>) and lists are created as explained + in the previous section. + </p> +<p> + Note that for pointer lists, <code class="computeroutput"><span class="identifier">reverse</span></code> + <span class="bold"><strong>does not need to access <code class="computeroutput"><span class="identifier">test_class</span></code> + values stored in another list or vector</strong></span>, since this function just + needs to adjust internal pointers, so in theory all tested lists need to + perform the same operations. + </p> +<p> + These are the results: + </p> +<div class="table"> +<a name="intrusive.performance.performance_results_reversing.t0"></a><p class="title"><b>Table 13.5. Reverse times for Visual C++ 7.1 / Windows XP</b></p> +<div class="table-contents"><table class="table" summary="Reverse times for Visual C++ 7.1 / Windows XP"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Container + </p> + </th> +<th> + <p> + Time in us/iteration (small object / big object) + </p> + </th> +<th> + <p> + Normalized time (small object / big object) + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">normal_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 2656 / 10625 + </p> + </td> +<td> + <p> + 1 / 1.83 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">safe_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 2812 / 10937 + </p> + </td> +<td> + <p> + 1.05 / 1.89 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">auto_unlink</span></code> intrusive + list + </p> + </td> +<td> + <p> + 2710 / 10781 + </p> + </td> +<td> + <p> + 1.02 / 1.86 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard list + </p> + </td> +<td> + <p> + 5781 / 14531 + </p> + </td> +<td> + <p> + 2.17 / 2.51 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard compact pointer list + </p> + </td> +<td> + <p> + 5781 / 5781 + </p> + </td> +<td> + <p> + 2.17 / 1 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard disperse pointer list + </p> + </td> +<td> + <p> + 10781 / 15781 + </p> + </td> +<td> + <p> + 4.05 / 2.72 + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="intrusive.performance.performance_results_reversing.t1"></a><p class="title"><b>Table 13.6. Reverse times for GCC 4.1.1 / MinGW over Windows XP</b></p> +<div class="table-contents"><table class="table" summary="Reverse times for GCC 4.1.1 / MinGW over Windows XP"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Container + </p> + </th> +<th> + <p> + Time in us/iteration (small object / big object) + </p> + </th> +<th> + <p> + Normalized time (small object / big object) + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">normal_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 2656 / 10781 + </p> + </td> +<td> + <p> + 1 / 2.22 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">safe_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 2656 / 10781 + </p> + </td> +<td> + <p> + 1 / 2.22 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">auto_unlink</span></code> intrusive + list + </p> + </td> +<td> + <p> + 2812 / 10781 + </p> + </td> +<td> + <p> + 1.02 / 2.22 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard list + </p> + </td> +<td> + <p> + 4843 / 12500 + </p> + </td> +<td> + <p> + 1.82 / 2.58 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard compact pointer list + </p> + </td> +<td> + <p> + 4843 / 4843 + </p> + </td> +<td> + <p> + 1.82 / 1 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard disperse pointer list + </p> + </td> +<td> + <p> + 9218 / 12968 + </p> + </td> +<td> + <p> + 3.47 / 2.67 + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="intrusive.performance.performance_results_reversing.t2"></a><p class="title"><b>Table 13.7. Reverse times for GCC 4.1.2 / Linux Kernel 2.6.18 (OpenSuse 10.2)</b></p> +<div class="table-contents"><table class="table" summary="Reverse times for GCC 4.1.2 / Linux Kernel 2.6.18 (OpenSuse 10.2)"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Container + </p> + </th> +<th> + <p> + Time in us/iteration (small object / big object) + </p> + </th> +<th> + <p> + Normalized time (small object / big object) + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">normal_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 2742 / 10847 + </p> + </td> +<td> + <p> + 1 / 3.41 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">safe_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 2742 / 10847 + </p> + </td> +<td> + <p> + 1 / 3.41 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">auto_unlink</span></code> intrusive + list + </p> + </td> +<td> + <p> + 2742 / 11027 + </p> + </td> +<td> + <p> + 1 / 3.47 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard list + </p> + </td> +<td> + <p> + 3184 / 10942 + </p> + </td> +<td> + <p> + 1.16 / 3.44 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard compact pointer list + </p> + </td> +<td> + <p> + 3207 / 3176 + </p> + </td> +<td> + <p> + 1.16 / 1 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard disperse pointer list + </p> + </td> +<td> + <p> + 5814 / 13381 + </p> + </td> +<td> + <p> + 2.12 / 4.21 + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><p> + For small objects the results show that the compact storage of values in + intrusive containers improve locality and reversing is faster than with standard + containers, whose values might be dispersed in memory because each value + is independently allocated. Note that the dispersed pointer list (a list + of pointers to values allocated in another list) suffers more because nodes + of the pointer list might be more dispersed, since allocations from both + lists are interleaved in the code: + </p> +<pre class="programlisting"><span class="comment">//Object list (holding `test_class`)</span> +<span class="identifier">stdlist</span> <span class="identifier">objects</span><span class="special">;</span> + +<span class="comment">//Pointer list (holding `test_class` pointers)</span> +<span class="identifier">stdptrlist</span> <span class="identifier">l</span><span class="special">;</span> + +<span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="identifier">NumElements</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">){</span> + <span class="comment">//Allocation from the object list</span> + <span class="identifier">objects</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">stdlist</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">(</span><span class="identifier">i</span><span class="special">));</span> + <span class="comment">//Allocation from the pointer list</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(&</span><span class="identifier">objects</span><span class="special">.</span><span class="identifier">back</span><span class="special">());</span> +<span class="special">}</span> +</pre> +<p> + For big objects the compact pointer list wins because the reversal test doesn't + need access to values stored in another container. Since all the allocations + for nodes of this pointer list are likely to be close (since there is no + other allocation in the process until the pointer list is created) locality + is better than with intrusive containers. The dispersed pointer list, as + with small values, has poor locality. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.performance.performance_results_sorting"></a><a class="link" href="performance.html#intrusive.performance.performance_results_sorting" title="Sorting">Sorting</a> +</h3></div></div></div> +<p> + The next test measures the time needed to complete calls to the member function + <code class="computeroutput"><span class="identifier">sort</span><span class="special">(</span><span class="identifier">Pred</span> <span class="identifier">pred</span><span class="special">)</span></code>. Values (<code class="computeroutput"><span class="identifier">test_class</span></code> + and <code class="computeroutput"><span class="identifier">itest_class</span></code>) and lists + are created as explained in the first section. The values will be sorted + in ascending and descending order each iteration. For example, if <span class="emphasis"><em>l</em></span> + is a list: + </p> +<pre class="programlisting"><span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="identifier">NumIter</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">){</span> + <span class="keyword">if</span><span class="special">(!(</span><span class="identifier">i</span> <span class="special">%</span> <span class="number">2</span><span class="special">))</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">sort</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">greater</span><span class="special"><</span><span class="identifier">stdlist</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">>());</span> + <span class="keyword">else</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">sort</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="identifier">stdlist</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">>());</span> +<span class="special">}</span> +</pre> +<p> + For a pointer list, the function object will be adapted using <code class="computeroutput"><span class="identifier">func_ptr_adaptor</span></code>: + </p> +<pre class="programlisting"><span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="identifier">NumIter</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">){</span> + <span class="keyword">if</span><span class="special">(!(</span><span class="identifier">i</span> <span class="special">%</span> <span class="number">2</span><span class="special">))</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">sort</span><span class="special">(</span><span class="identifier">func_ptr_adaptor</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">greater</span><span class="special"><</span><span class="identifier">stdlist</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">></span> <span class="special">>());</span> + <span class="keyword">else</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">sort</span><span class="special">(</span><span class="identifier">func_ptr_adaptor</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="identifier">stdlist</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">></span> <span class="special">>());</span> +<span class="special">}</span> +</pre> +<p> + Note that for pointer lists, <code class="computeroutput"><span class="identifier">sort</span></code> + will take a function object that <span class="bold"><strong>will access <code class="computeroutput"><span class="identifier">test_class</span></code> values stored in another list + or vector</strong></span>, so pointer lists will suffer an extra indirection: + they will need to access the <code class="computeroutput"><span class="identifier">test_class</span></code> + values stored in another container to compare two elements. + </p> +<p> + These are the results: + </p> +<div class="table"> +<a name="intrusive.performance.performance_results_sorting.t0"></a><p class="title"><b>Table 13.8. Sort times for Visual C++ 7.1 / Windows XP</b></p> +<div class="table-contents"><table class="table" summary="Sort times for Visual C++ 7.1 / Windows XP"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Container + </p> + </th> +<th> + <p> + Time in us/iteration (small object / big object) + </p> + </th> +<th> + <p> + Normalized time (small object / big object) + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">normal_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 16093 / 38906 + </p> + </td> +<td> + <p> + 1 / 1 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">safe_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 16093 / 39062 + </p> + </td> +<td> + <p> + 1 / 1 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">auto_unlink</span></code> intrusive + list + </p> + </td> +<td> + <p> + 16093 / 38906 + </p> + </td> +<td> + <p> + 1 / 1 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard list + </p> + </td> +<td> + <p> + 32343 / 56406 + </p> + </td> +<td> + <p> + 2.0 / 1.44 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard compact pointer list + </p> + </td> +<td> + <p> + 33593 / 46093 + </p> + </td> +<td> + <p> + 2.08 / 1.18 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard disperse pointer list + </p> + </td> +<td> + <p> + 46875 / 68593 + </p> + </td> +<td> + <p> + 2.91 / 1.76 + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="intrusive.performance.performance_results_sorting.t1"></a><p class="title"><b>Table 13.9. Sort times for GCC 4.1.1 / MinGW over Windows XP</b></p> +<div class="table-contents"><table class="table" summary="Sort times for GCC 4.1.1 / MinGW over Windows XP"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Container + </p> + </th> +<th> + <p> + Time in us/iteration (small object / big object) + </p> + </th> +<th> + <p> + Normalized time (small object / big object) + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">normal_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 15000 / 39218 + </p> + </td> +<td> + <p> + 1 / 1 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">safe_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 15156 / 39531 + </p> + </td> +<td> + <p> + 1.01 / 1.01 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">auto_unlink</span></code> intrusive + list + </p> + </td> +<td> + <p> + 15156 / 39531 + </p> + </td> +<td> + <p> + 1.01 / 1.01 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard list + </p> + </td> +<td> + <p> + 34218 / 56875 + </p> + </td> +<td> + <p> + 2.28 / 1.45 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard compact pointer list + </p> + </td> +<td> + <p> + 35468 / 49218 + </p> + </td> +<td> + <p> + 2.36 / 1.25 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard disperse pointer list + </p> + </td> +<td> + <p> + 47656 / 70156 + </p> + </td> +<td> + <p> + 3.17 / 1.78 + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="intrusive.performance.performance_results_sorting.t2"></a><p class="title"><b>Table 13.10. Sort times for GCC 4.1.2 / Linux Kernel 2.6.18 (OpenSuse 10.2)</b></p> +<div class="table-contents"><table class="table" summary="Sort times for GCC 4.1.2 / Linux Kernel 2.6.18 (OpenSuse 10.2)"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Container + </p> + </th> +<th> + <p> + Time in us/iteration (small object / big object) + </p> + </th> +<th> + <p> + Normalized time (small object / big object) + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">normal_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 18003 / 40795 + </p> + </td> +<td> + <p> + 1 / 1 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">safe_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 18003 / 41017 + </p> + </td> +<td> + <p> + 1 / 1 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">auto_unlink</span></code> intrusive + list + </p> + </td> +<td> + <p> + 18230 / 40941 + </p> + </td> +<td> + <p> + 1.01 / 1 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard list + </p> + </td> +<td> + <p> + 26273 / 49643 + </p> + </td> +<td> + <p> + 1.45 / 1.21 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard compact pointer list + </p> + </td> +<td> + <p> + 28540 / 43172 + </p> + </td> +<td> + <p> + 1.58 / 1.05 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard disperse pointer list + </p> + </td> +<td> + <p> + 35077 / 57638 + </p> + </td> +<td> + <p> + 1.94 / 1.41 + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><p> + The results show that intrusive containers are faster than standard containers. + We can see that the pointer list holding pointers to values stored in a vector + is quite fast, so the extra indirection that is needed to access the value + is minimized because all the values are tightly stored, improving caching. + The disperse list, on the other hand, is slower because the indirection to + access values stored in the object list is more expensive than accessing + values stored in a vector. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.performance.performance_results_write_access"></a><a class="link" href="performance.html#intrusive.performance.performance_results_write_access" title="Write access">Write + access</a> +</h3></div></div></div> +<p> + The next test measures the time needed to iterate through all the elements + of a list, and increment the value of the internal <code class="computeroutput"><span class="identifier">i_</span></code> + member: + </p> +<pre class="programlisting"><span class="identifier">stdlist</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">end</span><span class="special">(</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> +<span class="keyword">for</span><span class="special">(;</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">end</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">)</span> + <span class="special">++(</span><span class="identifier">it</span><span class="special">-></span><span class="identifier">i_</span><span class="special">);</span> +</pre> +<p> + Values (<code class="computeroutput"><span class="identifier">test_class</span></code> and <code class="computeroutput"><span class="identifier">itest_class</span></code>) and lists are created as explained + in the first section. Note that for pointer lists, the iteration will suffer + an extra indirection: they will need to access the <code class="computeroutput"><span class="identifier">test_class</span></code> + values stored in another container: + </p> +<pre class="programlisting"><span class="identifier">stdptrlist</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">end</span><span class="special">(</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> +<span class="keyword">for</span><span class="special">(;</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">end</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">)</span> + <span class="special">++((*</span><span class="identifier">it</span><span class="special">)-></span><span class="identifier">i_</span><span class="special">);</span> +</pre> +<p> + These are the results: + </p> +<div class="table"> +<a name="intrusive.performance.performance_results_write_access.t0"></a><p class="title"><b>Table 13.11. Write access times for Visual C++ 7.1 / Windows XP</b></p> +<div class="table-contents"><table class="table" summary="Write access times for Visual C++ 7.1 / Windows XP"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Container + </p> + </th> +<th> + <p> + Time in us/iteration (small object / big object) + </p> + </th> +<th> + <p> + Normalized time (small object / big object) + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">normal_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 2031 / 8125 + </p> + </td> +<td> + <p> + 1 / 1 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">safe_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 2031 / 8281 + </p> + </td> +<td> + <p> + 1 / 1.01 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">auto_unlink</span></code> intrusive + list + </p> + </td> +<td> + <p> + 2031 / 8281 + </p> + </td> +<td> + <p> + 1 / 1.01 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard list + </p> + </td> +<td> + <p> + 4218 / 10000 + </p> + </td> +<td> + <p> + 2.07 / 1.23 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard compact pointer list + </p> + </td> +<td> + <p> + 4062 / 8437 + </p> + </td> +<td> + <p> + 2.0 / 1.03 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard disperse pointer list + </p> + </td> +<td> + <p> + 8593 / 13125 + </p> + </td> +<td> + <p> + 4.23 / 1.61 + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="intrusive.performance.performance_results_write_access.t1"></a><p class="title"><b>Table 13.12. Write access times for GCC 4.1.1 / MinGW over Windows XP</b></p> +<div class="table-contents"><table class="table" summary="Write access times for GCC 4.1.1 / MinGW over Windows XP"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Container + </p> + </th> +<th> + <p> + Time in us/iteration (small object / big object) + </p> + </th> +<th> + <p> + Normalized time (small object / big object) + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">normal_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 2343 / 8281 + </p> + </td> +<td> + <p> + 1 / 1 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">safe_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 2500 / 8281 + </p> + </td> +<td> + <p> + 1.06 / 1 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">auto_unlink</span></code> intrusive + list + </p> + </td> +<td> + <p> + 2500 / 8281 + </p> + </td> +<td> + <p> + 1.06 / 1 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard list + </p> + </td> +<td> + <p> + 4218 / 10781 + </p> + </td> +<td> + <p> + 1.8 / 1.3 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard compact pointer list + </p> + </td> +<td> + <p> + 3906 / 8281 + </p> + </td> +<td> + <p> + 1.66 / 1 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard disperse pointer list + </p> + </td> +<td> + <p> + 8281 / 13750 + </p> + </td> +<td> + <p> + 3.53 / 1.66 + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><div class="table"> +<a name="intrusive.performance.performance_results_write_access.t2"></a><p class="title"><b>Table 13.13. Write access times for GCC 4.1.2 / Linux Kernel 2.6.18 (OpenSuse 10.2)</b></p> +<div class="table-contents"><table class="table" summary="Write access times for GCC 4.1.2 / Linux Kernel 2.6.18 (OpenSuse 10.2)"> +<colgroup> +<col> +<col> +<col> +</colgroup> +<thead><tr> +<th> + <p> + Container + </p> + </th> +<th> + <p> + Time in us/iteration (small object / big object) + </p> + </th> +<th> + <p> + Normalized time (small object / big object) + </p> + </th> +</tr></thead> +<tbody> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">normal_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 2286 / 8468 + </p> + </td> +<td> + <p> + 1 / 1.1 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">safe_link</span></code> intrusive + list + </p> + </td> +<td> + <p> + 2381 / 8412 + </p> + </td> +<td> + <p> + 1.04 / 1.09 + </p> + </td> +</tr> +<tr> +<td> + <p> + <code class="computeroutput"><span class="identifier">auto_unlink</span></code> intrusive + list + </p> + </td> +<td> + <p> + 2301 / 8437 + </p> + </td> +<td> + <p> + 1.01 / 1.1 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard list + </p> + </td> +<td> + <p> + 3044 / 9061 + </p> + </td> +<td> + <p> + 1.33 / 1.18 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard compact pointer list + </p> + </td> +<td> + <p> + 2755 / 7660 + </p> + </td> +<td> + <p> + 1.20 / 1 + </p> + </td> +</tr> +<tr> +<td> + <p> + Standard disperse pointer list + </p> + </td> +<td> + <p> + 6118 / 12453 + </p> + </td> +<td> + <p> + 2.67 / 1.62 + </p> + </td> +</tr> +</tbody> +</table></div> +</div> +<br class="table-break"><p> + As with the read access test, the results show that intrusive containers + outperform all other containers if the values are tightly packed in a vector. + The disperse list is again the slowest. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.performance.performance_results_conclusions"></a><a class="link" href="performance.html#intrusive.performance.performance_results_conclusions" title="Conclusions">Conclusions</a> +</h3></div></div></div> +<p> + Intrusive containers can offer performance benefits that cannot be achieved + with equivalent non-intrusive containers. Memory locality improvements are + noticeable when the objects to be inserted are small. Minimizing memory allocation/deallocation + calls is also an important factor and intrusive containers make this simple + if the user allocates all the objects to be inserted in intrusive containers + in containers like <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span></code> or <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">deque</span></code>. + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="design_notes.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="release_notes.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/presenting_containers.html b/doc/html/intrusive/presenting_containers.html new file mode 100755 index 0000000000..9106c2c022 --- /dev/null +++ b/doc/html/intrusive/presenting_containers.html @@ -0,0 +1,165 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Presenting Boost.Intrusive containers</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="concepts_summary.html" title="Concept summary"> +<link rel="next" href="safe_hook.html" title="Safe hooks"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="concepts_summary.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="safe_hook.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.presenting_containers"></a><a class="link" href="presenting_containers.html" title="Presenting Boost.Intrusive containers">Presenting Boost.Intrusive + containers</a> +</h2></div></div></div> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> offers a wide range of intrusive + containers: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>slist</strong></span>: An intrusive singly linked list. + The size overhead is very small for user classes (usually the size of one + pointer) but many operations have linear time complexity, so the user must + be careful if he wants to avoid performance problems. + </li> +<li class="listitem"> + <span class="bold"><strong>list</strong></span>: A <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span></code> + like intrusive linked list. The size overhead is quite small for user classes + (usually the size of two pointers). Many operations have constant time + complexity. + </li> +<li class="listitem"> + <span class="bold"><strong>set/multiset/rbtree</strong></span>: <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span><span class="special">/</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">multiset</span></code> + like intrusive associative containers based on red-black trees. The size + overhead is moderate for user classes (usually the size of three pointers). + Many operations have logarithmic time complexity. + </li> +<li class="listitem"> + <span class="bold"><strong>avl_set/avl_multiset/avltree</strong></span>: A <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span><span class="special">/</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">multiset</span></code> like intrusive associative containers + based on AVL trees. The size overhead is moderate for user classes (usually + the size of three pointers). Many operations have logarithmic time complexity. + </li> +<li class="listitem"> + <span class="bold"><strong>splay_set/splay_multiset/splaytree</strong></span>: <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span><span class="special">/</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">multiset</span></code> like intrusive associative containers + based on splay trees. Splay trees have no constant operations, but they + have some interesting caching properties. The size overhead is moderate + for user classes (usually the size of three pointers). Many operations + have logarithmic time complexity. + </li> +<li class="listitem"> + <span class="bold"><strong>sg_set/sg_multiset/sgtree</strong></span>: A <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span><span class="special">/</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">multiset</span></code> like intrusive associative containers + based on scapegoat trees. Scapegoat can be configured with the desired + balance factor to achieve the desired rebalancing frequency/search time + compromise. The size overhead is moderate for user classes (usually the + size of three pointers). Many operations have logarithmic time complexity. + </li> +</ul></div> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> also offers semi-intrusive + containers: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong>unordered_set/unordered_multiset</strong></span>: <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">tr1</span><span class="special">::</span><span class="identifier">unordered_set</span><span class="special">/</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">tr1</span><span class="special">::</span><span class="identifier">unordered_multiset</span></code> like intrusive unordered + associative containers. The size overhead is moderate for user classes + (an average of two pointers per element). Many operations have amortized + constant time complexity. + </li></ul></div> +<p> + Most of these intrusive containers can be configured with constant or linear + time size: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Linear time size</strong></span>: The intrusive container + doesn't hold a size member that is updated with every insertion/erasure. + This implies that the <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code> function doesn't have constant time complexity. + On the other hand, the container is smaller, and some operations, like + <code class="computeroutput"><span class="identifier">splice</span><span class="special">()</span></code> + taking a range of iterators in linked lists, have constant time complexity + instead of linear complexity. + </li> +<li class="listitem"> + <span class="bold"><strong>Constant time size</strong></span>: The intrusive container + holds a size member that is updated with every insertion/erasure. This + implies that the <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code> + function has constant time complexity. On the other hand, increases the + size of the container, and some operations, like <code class="computeroutput"><span class="identifier">splice</span><span class="special">()</span></code> taking a range of iterators, have linear + time complexity in linked lists. + </li> +</ul></div> +<p> + To make user classes compatible with these intrusive containers <span class="bold"><strong>Boost.Intrusive</strong></span> + offers two types of hooks for each container type: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Base hook</strong></span>: The hook is stored as a public + base class of the user class. + </li> +<li class="listitem"> + <span class="bold"><strong>Member hook</strong></span>: The hook is stored as a public + member of the user class. + </li> +</ul></div> +<p> + Apart from that, <span class="bold"><strong>Boost.Intrusive</strong></span> offers additional + features: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Safe mode hooks</strong></span>: Hook constructor initializes + the internal data to a well-known safe state and intrusive containers check + that state before inserting a value in the container. When erasing an element + from the container, the container puts the hook in the safe state again. + This allows a safer use mode and it can be used to detect programming errors. + It implies a slight performance overhead in some operations and can convert + some constant time operations to linear time operations. + </li> +<li class="listitem"> + <span class="bold"><strong>Auto-unlink hooks</strong></span>: The hook destructor + removes the object from the container automatically and the user can safely + unlink the object from the container without referring to the container. + </li> +<li class="listitem"> + <span class="bold"><strong>Non-raw pointers</strong></span>: If the user wants to + use smart pointers instead of raw pointers, <span class="bold"><strong>Boost.Intrusive</strong></span> + hooks can be configured to use any type of pointer. This configuration + information is also transmitted to the containers, so all the internal + pointers used by intrusive containers configured with these hooks will + be smart pointers. As an example, <span class="bold"><strong>Boost.Interprocess</strong></span> + defines a smart pointer compatible with shared memory, called <code class="computeroutput"><span class="identifier">offset_ptr</span></code>. <span class="bold"><strong>Boost.Intrusive</strong></span> + can be configured to use this smart pointer to allow shared memory intrusive + containers. + </li> +</ul></div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="concepts_summary.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="safe_hook.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/recursive.html b/doc/html/intrusive/recursive.html new file mode 100755 index 0000000000..2e9ced6e2b --- /dev/null +++ b/doc/html/intrusive/recursive.html @@ -0,0 +1,208 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Recursive Boost.Intrusive containers</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="function_hooks.html" title="Using function hooks"> +<link rel="next" href="using_smart_pointers.html" title="Using smart pointers with Boost.Intrusive containers"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="function_hooks.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="using_smart_pointers.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.recursive"></a><a class="link" href="recursive.html" title="Recursive Boost.Intrusive containers">Recursive Boost.Intrusive containers</a> +</h2></div></div></div> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> containers can be used to + define recursive structures very easily, allowing complex data structures with + very low overhead. Let's see an example: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cassert</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">list_base_hook</span><span class="special"><></span> <span class="identifier">BaseHook</span><span class="special">;</span> + +<span class="comment">//A recursive class</span> +<span class="keyword">class</span> <span class="identifier">Recursive</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">BaseHook</span> +<span class="special">{</span> + <span class="keyword">private</span><span class="special">:</span> + <span class="identifier">Recursive</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">Recursive</span><span class="special">&);</span> + <span class="identifier">Recursive</span> <span class="special">&</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">Recursive</span><span class="special">&);</span> + + <span class="keyword">public</span><span class="special">:</span> + <span class="identifier">Recursive</span><span class="special">()</span> <span class="special">:</span> <span class="identifier">BaseHook</span><span class="special">(),</span> <span class="identifier">children</span><span class="special">(){}</span> + <span class="identifier">list</span><span class="special"><</span> <span class="identifier">Recursive</span><span class="special">,</span> <span class="identifier">base_hook</span><span class="special"><</span><span class="identifier">BaseHook</span><span class="special">></span> <span class="special">></span> <span class="identifier">children</span><span class="special">;</span> +<span class="special">};</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="identifier">Recursive</span> <span class="identifier">f</span><span class="special">,</span> <span class="identifier">f2</span><span class="special">;</span> + <span class="comment">//A recursive list of Recursive</span> + <span class="identifier">list</span><span class="special"><</span> <span class="identifier">Recursive</span><span class="special">,</span> <span class="identifier">base_hook</span><span class="special"><</span><span class="identifier">BaseHook</span><span class="special">></span> <span class="special">></span> <span class="identifier">l</span><span class="special">;</span> + + <span class="comment">//Insert a node in parent list</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">f</span><span class="special">);</span> + + <span class="comment">//Insert a node in child list</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()-></span><span class="identifier">children</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()-></span><span class="identifier">children</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">f2</span><span class="special">);</span> + + <span class="comment">//Objects properly inserted</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span> <span class="special">==</span> <span class="identifier">l</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()-></span><span class="identifier">children</span><span class="special">.</span><span class="identifier">size</span><span class="special">());</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span> <span class="special">==</span> <span class="number">1</span><span class="special">);</span> + + <span class="comment">//Clear both lists</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()-></span><span class="identifier">children</span><span class="special">.</span><span class="identifier">clear</span><span class="special">();</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">clear</span><span class="special">();</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + Recursive data structures using <span class="bold"><strong>Boost.Intrusive</strong></span> + containers must avoid using hook deduction to avoid early type instantiation: + </p> +<pre class="programlisting"><span class="comment">//This leads to compilation error (Recursive is instantiated by </span> +<span class="comment">//'list' to deduce hook properties (pointer type, tag, safe-mode...)</span> +<span class="keyword">class</span> <span class="identifier">Recursive</span> +<span class="special">{</span> <span class="comment">//...</span> + + <span class="identifier">list</span><span class="special"><</span> <span class="identifier">Recursive</span> <span class="special">></span> <span class="identifier">l</span><span class="special">;</span> + <span class="comment">//...</span> +<span class="special">};</span> + +<span class="comment">//Ok, programmer must specify the hook type to avoid early Recursive instantiation</span> +<span class="keyword">class</span> <span class="identifier">Recursive</span> +<span class="special">{</span> <span class="comment">//...</span> + <span class="identifier">list</span><span class="special"><</span> <span class="identifier">Recursive</span><span class="special">,</span> <span class="identifier">base_hook</span><span class="special"><</span><span class="identifier">BaseHook</span><span class="special">></span> <span class="special">></span> <span class="identifier">l</span><span class="special">;</span> + <span class="comment">//...</span> +<span class="special">};</span> +</pre> +<p> + Member hooks are not suitable for recursive structures: + </p> +<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">Recursive</span> +<span class="special">{</span> + <span class="keyword">private</span><span class="special">:</span> + <span class="identifier">Recursive</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">Recursive</span><span class="special">&);</span> + <span class="identifier">Recursive</span> <span class="special">&</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">Recursive</span><span class="special">&);</span> + + <span class="keyword">public</span><span class="special">:</span> + <span class="identifier">list_member_hook</span><span class="special"><></span> <span class="identifier">memhook</span><span class="special">;</span> + <span class="identifier">list</span><span class="special"><</span> <span class="identifier">Recursive</span><span class="special">,</span> <span class="identifier">member_hook</span><span class="special"><</span><span class="identifier">Recursive</span><span class="special">,</span> <span class="identifier">list_member_hook</span><span class="special"><>,</span> <span class="special">&</span><span class="identifier">Recursive</span><span class="special">::</span><span class="identifier">memhook</span><span class="special">></span> <span class="special">></span> <span class="identifier">children</span><span class="special">;</span> +<span class="special">};</span> +</pre> +<p> + Specifying <code class="computeroutput"><span class="special">&</span><span class="identifier">Recursive</span><span class="special">::</span><span class="identifier">memhook</span></code> + (that is, the offset between memhook and Recursive) provokes an early instantiation + of <code class="computeroutput"><span class="identifier">Recursive</span></code>. To define recursive + structures using member hooks, a programmer should use <code class="computeroutput">function_hook</code>: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">parent_from_member</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="keyword">class</span> <span class="identifier">Recursive</span><span class="special">;</span> + +<span class="comment">//Declaration of the functor that converts betwen the Recursive</span> +<span class="comment">//class and the hook</span> +<span class="keyword">struct</span> <span class="identifier">Functor</span> +<span class="special">{</span> + <span class="comment">//Required types</span> + <span class="keyword">typedef</span> <span class="identifier">list_member_hook</span><span class="special"><></span> <span class="identifier">hook_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">hook_type</span><span class="special">*</span> <span class="identifier">hook_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">hook_type</span><span class="special">*</span> <span class="identifier">const_hook_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">Recursive</span> <span class="identifier">value_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">value_type</span><span class="special">*</span> <span class="identifier">pointer</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">value_type</span><span class="special">*</span> <span class="identifier">const_pointer</span><span class="special">;</span> + + <span class="comment">//Required static functions</span> + <span class="keyword">static</span> <span class="identifier">hook_ptr</span> <span class="identifier">to_hook_ptr</span> <span class="special">(</span><span class="identifier">value_type</span> <span class="special">&</span><span class="identifier">value</span><span class="special">);</span> + <span class="keyword">static</span> <span class="identifier">const_hook_ptr</span> <span class="identifier">to_hook_ptr</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span><span class="identifier">value</span><span class="special">);</span> + <span class="keyword">static</span> <span class="identifier">pointer</span> <span class="identifier">to_value_ptr</span><span class="special">(</span><span class="identifier">hook_ptr</span> <span class="identifier">n</span><span class="special">);</span> + <span class="keyword">static</span> <span class="identifier">const_pointer</span> <span class="identifier">to_value_ptr</span><span class="special">(</span><span class="identifier">const_hook_ptr</span> <span class="identifier">n</span><span class="special">);</span> +<span class="special">};</span> + +<span class="comment">//Define the recursive class</span> +<span class="keyword">class</span> <span class="identifier">Recursive</span> +<span class="special">{</span> + <span class="keyword">private</span><span class="special">:</span> + <span class="identifier">Recursive</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">Recursive</span><span class="special">&);</span> + <span class="identifier">Recursive</span> <span class="special">&</span> <span class="keyword">operator</span><span class="special">=(</span><span class="keyword">const</span> <span class="identifier">Recursive</span><span class="special">&);</span> + + <span class="keyword">public</span><span class="special">:</span> + <span class="identifier">Recursive</span><span class="special">()</span> <span class="special">:</span> <span class="identifier">hook</span><span class="special">(),</span> <span class="identifier">children</span><span class="special">()</span> <span class="special">{}</span> + <span class="identifier">list_member_hook</span><span class="special"><></span> <span class="identifier">hook</span><span class="special">;</span> + <span class="identifier">list</span><span class="special"><</span> <span class="identifier">Recursive</span><span class="special">,</span> <span class="identifier">function_hook</span><span class="special"><</span> <span class="identifier">Functor</span><span class="special">></span> <span class="special">></span> <span class="identifier">children</span><span class="special">;</span> +<span class="special">};</span> + +<span class="comment">//Definition of Functor functions</span> +<span class="keyword">inline</span> <span class="identifier">Functor</span><span class="special">::</span><span class="identifier">hook_ptr</span> <span class="identifier">Functor</span><span class="special">::</span><span class="identifier">to_hook_ptr</span> <span class="special">(</span><span class="identifier">Functor</span><span class="special">::</span><span class="identifier">value_type</span> <span class="special">&</span><span class="identifier">value</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="special">&</span><span class="identifier">value</span><span class="special">.</span><span class="identifier">hook</span><span class="special">;</span> <span class="special">}</span> +<span class="keyword">inline</span> <span class="identifier">Functor</span><span class="special">::</span><span class="identifier">const_hook_ptr</span> <span class="identifier">Functor</span><span class="special">::</span><span class="identifier">to_hook_ptr</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">Functor</span><span class="special">::</span><span class="identifier">value_type</span> <span class="special">&</span><span class="identifier">value</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="special">&</span><span class="identifier">value</span><span class="special">.</span><span class="identifier">hook</span><span class="special">;</span> <span class="special">}</span> +<span class="keyword">inline</span> <span class="identifier">Functor</span><span class="special">::</span><span class="identifier">pointer</span> <span class="identifier">Functor</span><span class="special">::</span><span class="identifier">to_value_ptr</span><span class="special">(</span><span class="identifier">Functor</span><span class="special">::</span><span class="identifier">hook_ptr</span> <span class="identifier">n</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">get_parent_from_member</span><span class="special"><</span><span class="identifier">Recursive</span><span class="special">>(</span><span class="identifier">n</span><span class="special">,</span> <span class="special">&</span><span class="identifier">Recursive</span><span class="special">::</span><span class="identifier">hook</span><span class="special">);</span> <span class="special">}</span> +<span class="keyword">inline</span> <span class="identifier">Functor</span><span class="special">::</span><span class="identifier">const_pointer</span> <span class="identifier">Functor</span><span class="special">::</span><span class="identifier">to_value_ptr</span><span class="special">(</span><span class="identifier">Functor</span><span class="special">::</span><span class="identifier">const_hook_ptr</span> <span class="identifier">n</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">get_parent_from_member</span><span class="special"><</span><span class="identifier">Recursive</span><span class="special">>(</span><span class="identifier">n</span><span class="special">,</span> <span class="special">&</span><span class="identifier">Recursive</span><span class="special">::</span><span class="identifier">hook</span><span class="special">);</span> <span class="special">}</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="identifier">Recursive</span> <span class="identifier">f</span><span class="special">,</span> <span class="identifier">f2</span><span class="special">;</span> + <span class="comment">//A recursive list of Recursive</span> + <span class="identifier">list</span><span class="special"><</span> <span class="identifier">Recursive</span><span class="special">,</span> <span class="identifier">function_hook</span><span class="special"><</span> <span class="identifier">Functor</span><span class="special">></span> <span class="special">></span> <span class="identifier">l</span><span class="special">;</span> + + <span class="comment">//Insert a node in parent list</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">f</span><span class="special">);</span> + + <span class="comment">//Insert a node in child list</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()-></span><span class="identifier">children</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()-></span><span class="identifier">children</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">f2</span><span class="special">);</span> + + <span class="comment">//Objects properly inserted</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span> <span class="special">==</span> <span class="identifier">l</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()-></span><span class="identifier">children</span><span class="special">.</span><span class="identifier">size</span><span class="special">());</span> + <span class="identifier">assert</span><span class="special">(</span><span class="identifier">l</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span> <span class="special">==</span> <span class="number">1</span><span class="special">);</span> + + <span class="comment">//Clear both lists</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()-></span><span class="identifier">children</span><span class="special">.</span><span class="identifier">clear</span><span class="special">();</span> + <span class="identifier">l</span><span class="special">.</span><span class="identifier">clear</span><span class="special">();</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </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"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="function_hooks.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="using_smart_pointers.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/reference.html b/doc/html/intrusive/reference.html new file mode 100755 index 0000000000..bf76f6aa32 --- /dev/null +++ b/doc/html/intrusive/reference.html @@ -0,0 +1,868 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Reference</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="index.html" title="Indexes"> +<link rel="next" href="../boost/intrusive/make_any_base_hook.html" title="Struct template make_any_base_hook"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="index.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="../boost/intrusive/make_any_base_hook.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.reference"></a>Reference</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.any_hook_hpp">Header <boost/intrusive/any_hook.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.avl_set_hpp">Header <boost/intrusive/avl_set.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.avl_set_hook_hpp">Header <boost/intrusive/avl_set_hook.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.avltree_hpp">Header <boost/intrusive/avltree.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.avltree_algorithms_hpp">Header <boost/intrusive/avltree_algorithms.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.bs_set_hook_hpp">Header <boost/intrusive/bs_set_hook.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.circular_list_algorithms_hpp">Header <boost/intrusive/circular_list_algorithms.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.circular_slist_algorithms_hpp">Header <boost/intrusive/circular_slist_algorithms.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.derivation_value_traits_hpp">Header <boost/intrusive/derivation_value_traits.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.hashtable_hpp">Header <boost/intrusive/hashtable.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.linear_slist_algorithms_hpp">Header <boost/intrusive/linear_slist_algorithms.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.link_mode_hpp">Header <boost/intrusive/link_mode.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.list_hpp">Header <boost/intrusive/list.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.list_hook_hpp">Header <boost/intrusive/list_hook.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.member_value_traits_hpp">Header <boost/intrusive/member_value_traits.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.options_hpp">Header <boost/intrusive/options.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.parent_from_member_hpp">Header <boost/intrusive/parent_from_member.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.pointer_plus_bits_hpp">Header <boost/intrusive/pointer_plus_bits.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.pointer_traits_hpp">Header <boost/intrusive/pointer_traits.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.priority_compare_hpp">Header <boost/intrusive/priority_compare.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.rbtree_hpp">Header <boost/intrusive/rbtree.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.rbtree_algorithms_hpp">Header <boost/intrusive/rbtree_algorithms.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.set_hpp">Header <boost/intrusive/set.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.set_hook_hpp">Header <boost/intrusive/set_hook.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.sg_set_hpp">Header <boost/intrusive/sg_set.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.sgtree_hpp">Header <boost/intrusive/sgtree.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.sgtree_algorithms_hpp">Header <boost/intrusive/sgtree_algorithms.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.slist_hpp">Header <boost/intrusive/slist.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.slist_hook_hpp">Header <boost/intrusive/slist_hook.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.splay_set_hpp">Header <boost/intrusive/splay_set.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.splay_set_hook_hpp">Header <boost/intrusive/splay_set_hook.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.splaytree_hpp">Header <boost/intrusive/splaytree.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.splaytree_algorithms_hpp">Header <boost/intrusive/splaytree_algorithms.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.treap_hpp">Header <boost/intrusive/treap.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.treap_algorithms_hpp">Header <boost/intrusive/treap_algorithms.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.treap_set_hpp">Header <boost/intrusive/treap_set.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.trivial_value_traits_hpp">Header <boost/intrusive/trivial_value_traits.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.unordered_set_hpp">Header <boost/intrusive/unordered_set.hpp></a></span></dt> +<dt><span class="section"><a href="reference.html#header.boost.intrusive.unordered_set_hook_hpp">Header <boost/intrusive/unordered_set_hook.hpp></a></span></dt> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.any_hook_hpp"></a>Header <<a href="../../../boost/intrusive/any_hook.hpp" target="_top">boost/intrusive/any_hook.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_any_base_hook.html" title="Struct template make_any_base_hook">make_any_base_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/any_base_hook.html" title="Class template any_base_hook">any_base_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_any_member_hook.html" title="Struct template make_any_member_hook">make_any_member_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/any_member_hook.html" title="Class template any_member_hook">any_member_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> BaseHook<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/any_to_slist_hook.html" title="Struct template any_to_slist_hook">any_to_slist_hook</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> BaseHook<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/any_to_list_hook.html" title="Struct template any_to_list_hook">any_to_list_hook</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> BaseHook<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/any_to_set_hook.html" title="Struct template any_to_set_hook">any_to_set_hook</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> BaseHook<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/any_to_avl_set_hook.html" title="Struct template any_to_avl_set_hook">any_to_avl_set_hook</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> BaseHook<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/any_to_bs_set_hook.html" title="Struct template any_to_bs_set_hook">any_to_bs_set_hook</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> BaseHook<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/any_to_unordered_set_hook.html" title="Struct template any_to_unordered_set_hook">any_to_unordered_set_hook</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.avl_set_hpp"></a>Header <<a href="../../../boost/intrusive/avl_set.hpp" target="_top">boost/intrusive/avl_set.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/avl_set.html" title="Class template avl_set">avl_set</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_avl_set.html" title="Struct template make_avl_set">make_avl_set</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/avl_multiset.html" title="Class template avl_multiset">avl_multiset</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_avl_multiset.html" title="Struct template make_avl_multiset">make_avl_multiset</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator!=_id757856"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/avl_set.html" title="Class template avl_set">avl_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/avl_set.html" title="Class template avl_set">avl_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id757895"></a><span class="keyword">operator</span><span class="special">></span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/avl_set.html" title="Class template avl_set">avl_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/avl_set.html" title="Class template avl_set">avl_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id757933"></a><span class="keyword">operator</span><span class="special"><=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/avl_set.html" title="Class template avl_set">avl_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/avl_set.html" title="Class template avl_set">avl_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id757972"></a><span class="keyword">operator</span><span class="special">>=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/avl_set.html" title="Class template avl_set">avl_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/avl_set.html" title="Class template avl_set">avl_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">void</span> <a name="boost.intrusive.swap_id758011"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="../boost/intrusive/avl_set.html" title="Class template avl_set">avl_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> <a class="link" href="../boost/intrusive/avl_set.html" title="Class template avl_set">avl_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator!=_id758047"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/avl_multiset.html" title="Class template avl_multiset">avl_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/avl_multiset.html" title="Class template avl_multiset">avl_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id758086"></a><span class="keyword">operator</span><span class="special">></span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/avl_multiset.html" title="Class template avl_multiset">avl_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/avl_multiset.html" title="Class template avl_multiset">avl_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id758125"></a><span class="keyword">operator</span><span class="special"><=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/avl_multiset.html" title="Class template avl_multiset">avl_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/avl_multiset.html" title="Class template avl_multiset">avl_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id758163"></a><span class="keyword">operator</span><span class="special">>=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/avl_multiset.html" title="Class template avl_multiset">avl_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/avl_multiset.html" title="Class template avl_multiset">avl_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">void</span> <a name="boost.intrusive.swap_id755927"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="../boost/intrusive/avl_multiset.html" title="Class template avl_multiset">avl_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <a class="link" href="../boost/intrusive/avl_multiset.html" title="Class template avl_multiset">avl_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.avl_set_hook_hpp"></a>Header <<a href="../../../boost/intrusive/avl_set_hook.hpp" target="_top">boost/intrusive/avl_set_hook.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_avl_set_base_hook.html" title="Struct template make_avl_set_base_hook">make_avl_set_base_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/avl_set_base_hook.html" title="Class template avl_set_base_hook">avl_set_base_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_avl_set_member_hook.html" title="Struct template make_avl_set_member_hook">make_avl_set_member_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/avl_set_member_hook.html" title="Class template avl_set_member_hook">avl_set_member_hook</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.avltree_hpp"></a>Header <<a href="../../../boost/intrusive/avltree.hpp" target="_top">boost/intrusive/avltree.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/avltree.html" title="Class template avltree">avltree</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_avltree.html" title="Struct template make_avltree">make_avltree</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1174392"></a><span class="keyword">operator</span><span class="special"><</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/avltree.html" title="Class template avltree">avltree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/avltree.html" title="Class template avltree">avltree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator==_id1174431"></a><span class="keyword">operator</span><span class="special">==</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/avltree.html" title="Class template avltree">avltree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/avltree.html" title="Class template avltree">avltree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator!=_id1174469"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/avltree.html" title="Class template avltree">avltree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/avltree.html" title="Class template avltree">avltree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1174508"></a><span class="keyword">operator</span><span class="special">></span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/avltree.html" title="Class template avltree">avltree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/avltree.html" title="Class template avltree">avltree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1174547"></a><span class="keyword">operator</span><span class="special"><=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/avltree.html" title="Class template avltree">avltree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/avltree.html" title="Class template avltree">avltree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1174585"></a><span class="keyword">operator</span><span class="special">>=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/avltree.html" title="Class template avltree">avltree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/avltree.html" title="Class template avltree">avltree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">void</span> <a name="boost.intrusive.swap_id1174624"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="../boost/intrusive/avltree.html" title="Class template avltree">avltree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> <a class="link" href="../boost/intrusive/avltree.html" title="Class template avltree">avltree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.avltree_algorithms_hpp"></a>Header <<a href="../../../boost/intrusive/avltree_algorithms.hpp" target="_top">boost/intrusive/avltree_algorithms.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> NodeTraits<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/avltree_algorithms.html" title="Class template avltree_algorithms">avltree_algorithms</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.bs_set_hook_hpp"></a>Header <<a href="../../../boost/intrusive/bs_set_hook.hpp" target="_top">boost/intrusive/bs_set_hook.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_bs_set_base_hook.html" title="Struct template make_bs_set_base_hook">make_bs_set_base_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/bs_set_base_hook.html" title="Class template bs_set_base_hook">bs_set_base_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_bs_set_member_hook.html" title="Struct template make_bs_set_member_hook">make_bs_set_member_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/bs_set_member_hook.html" title="Class template bs_set_member_hook">bs_set_member_hook</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.circular_list_algorithms_hpp"></a>Header <<a href="../../../boost/intrusive/circular_list_algorithms.hpp" target="_top">boost/intrusive/circular_list_algorithms.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> NodeTraits<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/circular_list_algorithms.html" title="Class template circular_list_algorithms">circular_list_algorithms</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.circular_slist_algorithms_hpp"></a>Header <<a href="../../../boost/intrusive/circular_slist_algorithms.hpp" target="_top">boost/intrusive/circular_slist_algorithms.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> NodeTraits<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/circular_slist_algorithms.html" title="Class template circular_slist_algorithms">circular_slist_algorithms</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.derivation_value_traits_hpp"></a>Header <<a href="../../../boost/intrusive/derivation_value_traits.hpp" target="_top">boost/intrusive/derivation_value_traits.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">typename</span> NodeTraits<span class="special">,</span> + <span class="identifier">link_mode_type</span> LinkMode <span class="special">=</span> <span class="identifier">safe_link</span><span class="special">></span> + <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/derivation_value_traits.html" title="Struct template derivation_value_traits">derivation_value_traits</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.hashtable_hpp"></a>Header <<a href="../../../boost/intrusive/hashtable.hpp" target="_top">boost/intrusive/hashtable.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/hashtable.html" title="Class template hashtable">hashtable</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_hashtable.html" title="Struct template make_hashtable">make_hashtable</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.linear_slist_algorithms_hpp"></a>Header <<a href="../../../boost/intrusive/linear_slist_algorithms.hpp" target="_top">boost/intrusive/linear_slist_algorithms.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> NodeTraits<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/linear_slist_algorithms.html" title="Class template linear_slist_algorithms">linear_slist_algorithms</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.link_mode_hpp"></a>Header <<a href="../../../boost/intrusive/link_mode.hpp" target="_top">boost/intrusive/link_mode.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">enum</span> <a class="link" href="../boost/intrusive/link_mode_type.html" title="Type link_mode_type">link_mode_type</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.list_hpp"></a>Header <<a href="../../../boost/intrusive/list.hpp" target="_top">boost/intrusive/list.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_list.html" title="Struct template make_list">make_list</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1188545"></a><span class="keyword">operator</span><span class="special"><</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator==_id1188584"></a><span class="keyword">operator</span><span class="special">==</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator!=_id1188622"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1188661"></a><span class="keyword">operator</span><span class="special">></span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1188700"></a><span class="keyword">operator</span><span class="special"><=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1188738"></a><span class="keyword">operator</span><span class="special">>=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">void</span> <a name="boost.intrusive.swap_id1188777"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> <a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.list_hook_hpp"></a>Header <<a href="../../../boost/intrusive/list_hook.hpp" target="_top">boost/intrusive/list_hook.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_list_base_hook.html" title="Struct template make_list_base_hook">make_list_base_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/list_base_hook.html" title="Class template list_base_hook">list_base_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_list_member_hook.html" title="Struct template make_list_member_hook">make_list_member_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/list_member_hook.html" title="Class template list_member_hook">list_member_hook</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.member_value_traits_hpp"></a>Header <<a href="../../../boost/intrusive/member_value_traits.hpp" target="_top">boost/intrusive/member_value_traits.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">typename</span> NodeTraits<span class="special">,</span> + <span class="keyword">typename</span> <span class="identifier">NodeTraits</span><span class="special">::</span><span class="identifier">node</span> <span class="identifier">T</span><span class="special">::</span><span class="special">*</span> PtrToMember<span class="special">,</span> + <span class="identifier">link_mode_type</span> LinkMode <span class="special">=</span> <span class="identifier">safe_link</span><span class="special">></span> + <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/member_value_traits.html" title="Struct template member_value_traits">member_value_traits</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.options_hpp"></a>Header <<a href="../../../boost/intrusive/options.hpp" target="_top">boost/intrusive/options.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">bool</span> Enabled<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/constant_time_size.html" title="Struct template constant_time_size">constant_time_size</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> SizeType<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/size_type.html" title="Struct template size_type">size_type</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Compare<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/compare.html" title="Struct template compare">compare</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">bool</span> Enabled<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/floating_point.html" title="Struct template floating_point">floating_point</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Equal<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/equal.html" title="Struct template equal">equal</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Priority<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/priority.html" title="Struct template priority">priority</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Hash<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/hash.html" title="Struct template hash">hash</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> ValueTraits<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/value_traits.html" title="Struct template value_traits">value_traits</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Parent<span class="special">,</span> <span class="keyword">typename</span> MemberHook<span class="special">,</span> + <span class="identifier">MemberHook</span> <span class="identifier">Parent</span><span class="special">::</span><span class="special">*</span> PtrToMember<span class="special">></span> + <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/member_hook.html" title="Struct template member_hook">member_hook</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Functor<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/function_hook.html" title="Struct template function_hook">function_hook</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> BaseHook<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/base_hook.html" title="Struct template base_hook">base_hook</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> VoidPointer<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/void_pointer.html" title="Struct template void_pointer">void_pointer</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Tag<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/tag.html" title="Struct template tag">tag</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="identifier">link_mode_type</span> LinkType<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/link_mode.html" title="Struct template link_mode">link_mode</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">bool</span> Enabled<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/optimize_size.html" title="Struct template optimize_size">optimize_size</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">bool</span> Enabled<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/linear.html" title="Struct template linear">linear</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">bool</span> Enabled<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/cache_last.html" title="Struct template cache_last">cache_last</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> BucketTraits<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/bucket_traits.html" title="Struct template bucket_traits">bucket_traits</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">bool</span> Enabled<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/store_hash.html" title="Struct template store_hash">store_hash</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">bool</span> Enabled<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/optimize_multikey.html" title="Struct template optimize_multikey">optimize_multikey</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">bool</span> Enabled<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/power_2_buckets.html" title="Struct template power_2_buckets">power_2_buckets</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">bool</span> Enabled<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/cache_begin.html" title="Struct template cache_begin">cache_begin</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">bool</span> Enabled<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/compare_hash.html" title="Struct template compare_hash">compare_hash</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">bool</span> Enabled<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/incremental.html" title="Struct template incremental">incremental</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.parent_from_member_hpp"></a>Header <<a href="../../../boost/intrusive/parent_from_member.hpp" target="_top">boost/intrusive/parent_from_member.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Parent<span class="special">,</span> <span class="keyword">typename</span> Member<span class="special">></span> + <span class="identifier">Parent</span> <span class="special">*</span> <a class="link" href="../boost/intrusive/get_parent_from_member_id1190255.html" title="Function template get_parent_from_member"><span class="identifier">get_parent_from_member</span></a><span class="special">(</span><span class="identifier">Member</span> <span class="special">*</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Member</span> <span class="identifier">Parent</span><span class="special">::</span><span class="special">*</span><span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Parent<span class="special">,</span> <span class="keyword">typename</span> Member<span class="special">></span> + <span class="keyword">const</span> <span class="identifier">Parent</span> <span class="special">*</span> + <a class="link" href="../boost/intrusive/get_parent_from_member_id1190291.html" title="Function template get_parent_from_member"><span class="identifier">get_parent_from_member</span></a><span class="special">(</span><span class="keyword">const</span> <span class="identifier">Member</span> <span class="special">*</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">Member</span> <span class="identifier">Parent</span><span class="special">::</span><span class="special">*</span><span class="special">)</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.pointer_plus_bits_hpp"></a>Header <<a href="../../../boost/intrusive/pointer_plus_bits.hpp" target="_top">boost/intrusive/pointer_plus_bits.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> VoidPointer<span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> Alignment<span class="special">></span> + <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/max_pointer_plus_bits.html" title="Struct template max_pointer_plus_bits">max_pointer_plus_bits</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> Alignment<span class="special">></span> + <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/max_pointer_plus_bits_v_id1190369.html" title="Struct template max_pointer_plus_bits<void *, Alignment>">max_pointer_plus_bits</a><span class="special"><</span><span class="keyword">void</span> <span class="special">*</span><span class="special">,</span> <span class="identifier">Alignment</span><span class="special">></span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> NumBits<span class="special">></span> + <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/pointer_plus_bits_T___N_id1190402.html" title="Struct template pointer_plus_bits<T *, NumBits>">pointer_plus_bits</a><span class="special"><</span><span class="identifier">T</span> <span class="special">*</span><span class="special">,</span> <span class="identifier">NumBits</span><span class="special">></span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.pointer_traits_hpp"></a>Header <<a href="../../../boost/intrusive/pointer_traits.hpp" target="_top">boost/intrusive/pointer_traits.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> Ptr<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/pointer_traits.html" title="Struct template pointer_traits">pointer_traits</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/pointer_traits_T_id1190754.html" title="Struct template pointer_traits<T *>">pointer_traits</a><span class="special"><</span><span class="identifier">T</span> <span class="special">*</span><span class="special">></span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.priority_compare_hpp"></a>Header <<a href="../../../boost/intrusive/priority_compare.hpp" target="_top">boost/intrusive/priority_compare.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/priority_compare.html" title="Struct template priority_compare">priority_compare</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.rbtree_hpp"></a>Header <<a href="../../../boost/intrusive/rbtree.hpp" target="_top">boost/intrusive/rbtree.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/rbtree.html" title="Class template rbtree">rbtree</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_rbtree.html" title="Struct template make_rbtree">make_rbtree</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1194939"></a><span class="keyword">operator</span><span class="special"><</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/rbtree.html" title="Class template rbtree">rbtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/rbtree.html" title="Class template rbtree">rbtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator==_id1194977"></a><span class="keyword">operator</span><span class="special">==</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/rbtree.html" title="Class template rbtree">rbtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/rbtree.html" title="Class template rbtree">rbtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator!=_id1195016"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/rbtree.html" title="Class template rbtree">rbtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/rbtree.html" title="Class template rbtree">rbtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1195055"></a><span class="keyword">operator</span><span class="special">></span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/rbtree.html" title="Class template rbtree">rbtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/rbtree.html" title="Class template rbtree">rbtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1195093"></a><span class="keyword">operator</span><span class="special"><=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/rbtree.html" title="Class template rbtree">rbtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/rbtree.html" title="Class template rbtree">rbtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1195132"></a><span class="keyword">operator</span><span class="special">>=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/rbtree.html" title="Class template rbtree">rbtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/rbtree.html" title="Class template rbtree">rbtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">void</span> <a name="boost.intrusive.swap_id1195171"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="../boost/intrusive/rbtree.html" title="Class template rbtree">rbtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> <a class="link" href="../boost/intrusive/rbtree.html" title="Class template rbtree">rbtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.rbtree_algorithms_hpp"></a>Header <<a href="../../../boost/intrusive/rbtree_algorithms.hpp" target="_top">boost/intrusive/rbtree_algorithms.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> NodeTraits<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/rbtree_algorithms.html" title="Class template rbtree_algorithms">rbtree_algorithms</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.set_hpp"></a>Header <<a href="../../../boost/intrusive/set.hpp" target="_top">boost/intrusive/set.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_set.html" title="Struct template make_set">make_set</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_multiset.html" title="Struct template make_multiset">make_multiset</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator!=_id1204943"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1204982"></a><span class="keyword">operator</span><span class="special">></span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1205020"></a><span class="keyword">operator</span><span class="special"><=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1205059"></a><span class="keyword">operator</span><span class="special">>=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">void</span> <a name="boost.intrusive.swap_id1205098"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> <a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator!=_id1205134"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1205172"></a><span class="keyword">operator</span><span class="special">></span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1205211"></a><span class="keyword">operator</span><span class="special"><=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1205250"></a><span class="keyword">operator</span><span class="special">>=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">void</span> <a name="boost.intrusive.swap_id1205288"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> <a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.set_hook_hpp"></a>Header <<a href="../../../boost/intrusive/set_hook.hpp" target="_top">boost/intrusive/set_hook.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_set_base_hook.html" title="Struct template make_set_base_hook">make_set_base_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/set_base_hook.html" title="Class template set_base_hook">set_base_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_set_member_hook.html" title="Struct template make_set_member_hook">make_set_member_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/set_member_hook.html" title="Class template set_member_hook">set_member_hook</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.sg_set_hpp"></a>Header <<a href="../../../boost/intrusive/sg_set.hpp" target="_top">boost/intrusive/sg_set.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/sg_set.html" title="Class template sg_set">sg_set</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_sg_set.html" title="Struct template make_sg_set">make_sg_set</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/sg_multiset.html" title="Class template sg_multiset">sg_multiset</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_sg_multiset.html" title="Struct template make_sg_multiset">make_sg_multiset</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator!=_id1214676"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/sg_set.html" title="Class template sg_set">sg_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/sg_set.html" title="Class template sg_set">sg_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1214715"></a><span class="keyword">operator</span><span class="special">></span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/sg_set.html" title="Class template sg_set">sg_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/sg_set.html" title="Class template sg_set">sg_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1214754"></a><span class="keyword">operator</span><span class="special"><=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/sg_set.html" title="Class template sg_set">sg_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/sg_set.html" title="Class template sg_set">sg_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1214792"></a><span class="keyword">operator</span><span class="special">>=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/sg_set.html" title="Class template sg_set">sg_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/sg_set.html" title="Class template sg_set">sg_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">void</span> <a name="boost.intrusive.swap_id1214831"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="../boost/intrusive/sg_set.html" title="Class template sg_set">sg_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> <a class="link" href="../boost/intrusive/sg_set.html" title="Class template sg_set">sg_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator!=_id1214867"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/sg_multiset.html" title="Class template sg_multiset">sg_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/sg_multiset.html" title="Class template sg_multiset">sg_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1214906"></a><span class="keyword">operator</span><span class="special">></span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/sg_multiset.html" title="Class template sg_multiset">sg_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/sg_multiset.html" title="Class template sg_multiset">sg_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1214944"></a><span class="keyword">operator</span><span class="special"><=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/sg_multiset.html" title="Class template sg_multiset">sg_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/sg_multiset.html" title="Class template sg_multiset">sg_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1214983"></a><span class="keyword">operator</span><span class="special">>=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/sg_multiset.html" title="Class template sg_multiset">sg_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/sg_multiset.html" title="Class template sg_multiset">sg_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">void</span> <a name="boost.intrusive.swap_id1215022"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="../boost/intrusive/sg_multiset.html" title="Class template sg_multiset">sg_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <a class="link" href="../boost/intrusive/sg_multiset.html" title="Class template sg_multiset">sg_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.sgtree_hpp"></a>Header <<a href="../../../boost/intrusive/sgtree.hpp" target="_top">boost/intrusive/sgtree.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/sgtree.html" title="Class template sgtree">sgtree</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_sgtree.html" title="Struct template make_sgtree">make_sgtree</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1219160"></a><span class="keyword">operator</span><span class="special"><</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/sgtree.html" title="Class template sgtree">sgtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/sgtree.html" title="Class template sgtree">sgtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator==_id1219199"></a><span class="keyword">operator</span><span class="special">==</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/sgtree.html" title="Class template sgtree">sgtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/sgtree.html" title="Class template sgtree">sgtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator!=_id1219238"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/sgtree.html" title="Class template sgtree">sgtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/sgtree.html" title="Class template sgtree">sgtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1219276"></a><span class="keyword">operator</span><span class="special">></span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/sgtree.html" title="Class template sgtree">sgtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/sgtree.html" title="Class template sgtree">sgtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1219315"></a><span class="keyword">operator</span><span class="special"><=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/sgtree.html" title="Class template sgtree">sgtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/sgtree.html" title="Class template sgtree">sgtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1219354"></a><span class="keyword">operator</span><span class="special">>=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/sgtree.html" title="Class template sgtree">sgtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/sgtree.html" title="Class template sgtree">sgtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">void</span> <a name="boost.intrusive.swap_id1219392"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="../boost/intrusive/sgtree.html" title="Class template sgtree">sgtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> <a class="link" href="../boost/intrusive/sgtree.html" title="Class template sgtree">sgtree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.sgtree_algorithms_hpp"></a>Header <<a href="../../../boost/intrusive/sgtree_algorithms.hpp" target="_top">boost/intrusive/sgtree_algorithms.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> NodeTraits<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/sgtree_algorithms.html" title="Class template sgtree_algorithms">sgtree_algorithms</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.slist_hpp"></a>Header <<a href="../../../boost/intrusive/slist.hpp" target="_top">boost/intrusive/slist.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_slist.html" title="Struct template make_slist">make_slist</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1227186"></a><span class="keyword">operator</span><span class="special"><</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator==_id1227225"></a><span class="keyword">operator</span><span class="special">==</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator!=_id1227264"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1227302"></a><span class="keyword">operator</span><span class="special">></span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1227341"></a><span class="keyword">operator</span><span class="special"><=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1227380"></a><span class="keyword">operator</span><span class="special">>=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">void</span> <a name="boost.intrusive.swap_id1227418"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> <a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.slist_hook_hpp"></a>Header <<a href="../../../boost/intrusive/slist_hook.hpp" target="_top">boost/intrusive/slist_hook.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_slist_base_hook.html" title="Struct template make_slist_base_hook">make_slist_base_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/slist_base_hook.html" title="Class template slist_base_hook">slist_base_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_slist_member_hook.html" title="Struct template make_slist_member_hook">make_slist_member_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/slist_member_hook.html" title="Class template slist_member_hook">slist_member_hook</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.splay_set_hpp"></a>Header <<a href="../../../boost/intrusive/splay_set.hpp" target="_top">boost/intrusive/splay_set.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/splay_set.html" title="Class template splay_set">splay_set</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_splay_set.html" title="Struct template make_splay_set">make_splay_set</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/splay_multiset.html" title="Class template splay_multiset">splay_multiset</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_splay_multiset.html" title="Struct template make_splay_multiset">make_splay_multiset</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator!=_id1236500"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/splay_set.html" title="Class template splay_set">splay_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/splay_set.html" title="Class template splay_set">splay_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1236539"></a><span class="keyword">operator</span><span class="special">></span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/splay_set.html" title="Class template splay_set">splay_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/splay_set.html" title="Class template splay_set">splay_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1236577"></a><span class="keyword">operator</span><span class="special"><=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/splay_set.html" title="Class template splay_set">splay_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/splay_set.html" title="Class template splay_set">splay_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1236616"></a><span class="keyword">operator</span><span class="special">>=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/splay_set.html" title="Class template splay_set">splay_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/splay_set.html" title="Class template splay_set">splay_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">void</span> <a name="boost.intrusive.swap_id1236655"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="../boost/intrusive/splay_set.html" title="Class template splay_set">splay_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> <a class="link" href="../boost/intrusive/splay_set.html" title="Class template splay_set">splay_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator!=_id1236691"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/splay_multiset.html" title="Class template splay_multiset">splay_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/splay_multiset.html" title="Class template splay_multiset">splay_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1236729"></a><span class="keyword">operator</span><span class="special">></span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/splay_multiset.html" title="Class template splay_multiset">splay_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/splay_multiset.html" title="Class template splay_multiset">splay_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1236768"></a><span class="keyword">operator</span><span class="special"><=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/splay_multiset.html" title="Class template splay_multiset">splay_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/splay_multiset.html" title="Class template splay_multiset">splay_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1236807"></a><span class="keyword">operator</span><span class="special">>=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/splay_multiset.html" title="Class template splay_multiset">splay_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/splay_multiset.html" title="Class template splay_multiset">splay_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">void</span> <a name="boost.intrusive.swap_id1236845"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="../boost/intrusive/splay_multiset.html" title="Class template splay_multiset">splay_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <a class="link" href="../boost/intrusive/splay_multiset.html" title="Class template splay_multiset">splay_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.splay_set_hook_hpp"></a>Header <<a href="../../../boost/intrusive/splay_set_hook.hpp" target="_top">boost/intrusive/splay_set_hook.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_splay_set_base_hook.html" title="Struct template make_splay_set_base_hook">make_splay_set_base_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/splay_set_base_hook.html" title="Class template splay_set_base_hook">splay_set_base_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_splay_set_member_hook.html" title="Struct template make_splay_set_member_hook">make_splay_set_member_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/splay_set_member_hook.html" title="Class template splay_set_member_hook">splay_set_member_hook</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.splaytree_hpp"></a>Header <<a href="../../../boost/intrusive/splaytree.hpp" target="_top">boost/intrusive/splaytree.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/splaytree.html" title="Class template splaytree">splaytree</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_splaytree.html" title="Struct template make_splaytree">make_splaytree</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1242094"></a><span class="keyword">operator</span><span class="special"><</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/splaytree.html" title="Class template splaytree">splaytree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/splaytree.html" title="Class template splaytree">splaytree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator==_id1242133"></a><span class="keyword">operator</span><span class="special">==</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/splaytree.html" title="Class template splaytree">splaytree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/splaytree.html" title="Class template splaytree">splaytree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator!=_id1242172"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/splaytree.html" title="Class template splaytree">splaytree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/splaytree.html" title="Class template splaytree">splaytree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1242210"></a><span class="keyword">operator</span><span class="special">></span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/splaytree.html" title="Class template splaytree">splaytree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/splaytree.html" title="Class template splaytree">splaytree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1242249"></a><span class="keyword">operator</span><span class="special"><=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/splaytree.html" title="Class template splaytree">splaytree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/splaytree.html" title="Class template splaytree">splaytree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1242288"></a><span class="keyword">operator</span><span class="special">>=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/splaytree.html" title="Class template splaytree">splaytree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/splaytree.html" title="Class template splaytree">splaytree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">void</span> <a name="boost.intrusive.swap_id1242326"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="../boost/intrusive/splaytree.html" title="Class template splaytree">splaytree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> <a class="link" href="../boost/intrusive/splaytree.html" title="Class template splaytree">splaytree</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.splaytree_algorithms_hpp"></a>Header <<a href="../../../boost/intrusive/splaytree_algorithms.hpp" target="_top">boost/intrusive/splaytree_algorithms.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> NodeTraits<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/splaytree_algorithms.html" title="Class template splaytree_algorithms">splaytree_algorithms</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.treap_hpp"></a>Header <<a href="../../../boost/intrusive/treap.hpp" target="_top">boost/intrusive/treap.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/treap.html" title="Class template treap">treap</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_trie.html" title="Struct template make_trie">make_trie</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1248766"></a><span class="keyword">operator</span><span class="special"><</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap.html" title="Class template treap">treap</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap.html" title="Class template treap">treap</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator==_id1248805"></a><span class="keyword">operator</span><span class="special">==</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap.html" title="Class template treap">treap</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap.html" title="Class template treap">treap</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator!=_id1248844"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap.html" title="Class template treap">treap</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap.html" title="Class template treap">treap</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1248882"></a><span class="keyword">operator</span><span class="special">></span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap.html" title="Class template treap">treap</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap.html" title="Class template treap">treap</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1248921"></a><span class="keyword">operator</span><span class="special"><=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap.html" title="Class template treap">treap</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap.html" title="Class template treap">treap</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1248960"></a><span class="keyword">operator</span><span class="special">>=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap.html" title="Class template treap">treap</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap.html" title="Class template treap">treap</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">void</span> <a name="boost.intrusive.swap_id1248998"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="../boost/intrusive/treap.html" title="Class template treap">treap</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> <a class="link" href="../boost/intrusive/treap.html" title="Class template treap">treap</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.treap_algorithms_hpp"></a>Header <<a href="../../../boost/intrusive/treap_algorithms.hpp" target="_top">boost/intrusive/treap_algorithms.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> NodeTraits<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/treap_algorithms.html" title="Class template treap_algorithms">treap_algorithms</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.treap_set_hpp"></a>Header <<a href="../../../boost/intrusive/treap_set.hpp" target="_top">boost/intrusive/treap_set.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/treap_set.html" title="Class template treap_set">treap_set</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_treap_set.html" title="Struct template make_treap_set">make_treap_set</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/treap_multiset.html" title="Class template treap_multiset">treap_multiset</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_treap_multiset.html" title="Struct template make_treap_multiset">make_treap_multiset</a><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator!=_id1260431"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap_set.html" title="Class template treap_set">treap_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap_set.html" title="Class template treap_set">treap_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1260470"></a><span class="keyword">operator</span><span class="special">></span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap_set.html" title="Class template treap_set">treap_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap_set.html" title="Class template treap_set">treap_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1260509"></a><span class="keyword">operator</span><span class="special"><=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap_set.html" title="Class template treap_set">treap_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap_set.html" title="Class template treap_set">treap_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1260547"></a><span class="keyword">operator</span><span class="special">>=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap_set.html" title="Class template treap_set">treap_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap_set.html" title="Class template treap_set">treap_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">void</span> <a name="boost.intrusive.swap_id1260586"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="../boost/intrusive/treap_set.html" title="Class template treap_set">treap_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> <a class="link" href="../boost/intrusive/treap_set.html" title="Class template treap_set">treap_set</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator!=_id1260622"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap_multiset.html" title="Class template treap_multiset">treap_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap_multiset.html" title="Class template treap_multiset">treap_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_id1260661"></a><span class="keyword">operator</span><span class="special">></span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap_multiset.html" title="Class template treap_multiset">treap_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap_multiset.html" title="Class template treap_multiset">treap_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1260699"></a><span class="keyword">operator</span><span class="special"><=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap_multiset.html" title="Class template treap_multiset">treap_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap_multiset.html" title="Class template treap_multiset">treap_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">bool</span> <a name="boost.intrusive.operator_=_id1260738"></a><span class="keyword">operator</span><span class="special">>=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap_multiset.html" title="Class template treap_multiset">treap_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <span class="keyword">const</span> <a class="link" href="../boost/intrusive/treap_multiset.html" title="Class template treap_multiset">treap_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> + <span class="keyword">void</span> <a name="boost.intrusive.swap_id1260777"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="../boost/intrusive/treap_multiset.html" title="Class template treap_multiset">treap_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> x<span class="special">,</span> + <a class="link" href="../boost/intrusive/treap_multiset.html" title="Class template treap_multiset">treap_multiset</a><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">Options</span><span class="special">...</span><span class="special">></span> <span class="special">&</span> y<span class="special">)</span><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.trivial_value_traits_hpp"></a>Header <<a href="../../../boost/intrusive/trivial_value_traits.hpp" target="_top">boost/intrusive/trivial_value_traits.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> NodeTraits<span class="special">,</span> <span class="identifier">link_mode_type</span> LinkMode <span class="special">=</span> <span class="identifier">normal_link</span><span class="special">></span> + <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/trivial_value_traits.html" title="Struct template trivial_value_traits">trivial_value_traits</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.unordered_set_hpp"></a>Header <<a href="../../../boost/intrusive/unordered_set.hpp" target="_top">boost/intrusive/unordered_set.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/unordered_set.html" title="Class template unordered_set">unordered_set</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_unordered_set.html" title="Struct template make_unordered_set">make_unordered_set</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/unordered_multiset.html" title="Class template unordered_multiset">unordered_multiset</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_unordered_multiset.html" title="Struct template make_unordered_multiset">make_unordered_multiset</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="header.boost.intrusive.unordered_set_hook_hpp"></a>Header <<a href="../../../boost/intrusive/unordered_set_hook.hpp" target="_top">boost/intrusive/unordered_set_hook.hpp</a>></h3></div></div></div> +<pre class="synopsis"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> + <span class="keyword">namespace</span> <span class="identifier">intrusive</span> <span class="special">{</span> + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_unordered_set_base_id1268602.html" title="Struct template make_unordered_set_base_hook">make_unordered_set_base_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/unordered_set_base_hook.html" title="Class template unordered_set_base_hook">unordered_set_base_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">struct</span> <a class="link" href="../boost/intrusive/make_unordered_set_memb_id1269058.html" title="Struct template make_unordered_set_member_hook">make_unordered_set_member_hook</a><span class="special">;</span> + + <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span><span class="special">...</span> Options<span class="special">></span> <span class="keyword">class</span> <a class="link" href="../boost/intrusive/unordered_set_member_hook.html" title="Class template unordered_set_member_hook">unordered_set_member_hook</a><span class="special">;</span> + <span class="special">}</span> +<span class="special">}</span></pre> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="index.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="../boost/intrusive/make_any_base_hook.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/references.html b/doc/html/intrusive/references.html new file mode 100755 index 0000000000..57e6442982 --- /dev/null +++ b/doc/html/intrusive/references.html @@ -0,0 +1,59 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>References</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="tested_compilers.html" title="Tested compilers"> +<link rel="next" href="acknowledgements.html" title="Acknowledgements"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="tested_compilers.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="acknowledgements.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.references"></a><a class="link" href="references.html" title="References">References</a> +</h2></div></div></div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + SGI's <a href="http://www.sgi.com/tech/stl/" target="_top">STL Programmer's Guide</a>. + <span class="bold"><strong>Boost.Intrusive</strong></span> is based on STL concepts + and interfaces. + </li> +<li class="listitem"> + Dr. Dobb's, September 1, 2005: <a href="http://www.ddj.com/architect/184402007" target="_top"><span class="emphasis"><em>Implementing + Splay Trees in C++</em></span> </a>. <span class="bold"><strong>Boost.Intrusive</strong></span> + splay containers code is based on this article. + </li> +<li class="listitem"> + Olaf's original intrusive container library: <a href="http://freenet-homepage.de/turtle++/intrusive.html" target="_top"><span class="emphasis"><em>STL-like + intrusive containers</em></span> </a>. + </li> +</ul></div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="tested_compilers.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="acknowledgements.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/release_notes.html b/doc/html/intrusive/release_notes.html new file mode 100755 index 0000000000..bf1d9c1623 --- /dev/null +++ b/doc/html/intrusive/release_notes.html @@ -0,0 +1,240 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Release Notes</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="performance.html" title="Performance"> +<link rel="next" href="tested_compilers.html" title="Tested compilers"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="performance.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="tested_compilers.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.release_notes"></a><a class="link" href="release_notes.html" title="Release Notes">Release Notes</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="release_notes.html#intrusive.release_notes.release_notes_boost_1_49_00">Boost + 1.49 Release</a></span></dt> +<dt><span class="section"><a href="release_notes.html#intrusive.release_notes.release_notes_boost_1_48_00">Boost + 1.48 Release</a></span></dt> +<dt><span class="section"><a href="release_notes.html#intrusive.release_notes.release_notes_boost_1_46_00">Boost + 1.46 Release</a></span></dt> +<dt><span class="section"><a href="release_notes.html#intrusive.release_notes.release_notes_boost_1_45_00">Boost + 1.45 Release</a></span></dt> +<dt><span class="section"><a href="release_notes.html#intrusive.release_notes.release_notes_boost_1_40_00">Boost + 1.40 Release</a></span></dt> +<dt><span class="section"><a href="release_notes.html#intrusive.release_notes.release_notes_boost_1_39_00">Boost + 1.39 Release</a></span></dt> +<dt><span class="section"><a href="release_notes.html#intrusive.release_notes.release_notes_boost_1_38_00">Boost + 1.38 Release</a></span></dt> +<dt><span class="section"><a href="release_notes.html#intrusive.release_notes.release_notes_boost_1_37_00">Boost + 1.37 Release</a></span></dt> +<dt><span class="section"><a href="release_notes.html#intrusive.release_notes.release_notes_boost_1_36_00">Boost + 1.36 Release</a></span></dt> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.release_notes.release_notes_boost_1_49_00"></a><a class="link" href="release_notes.html#intrusive.release_notes.release_notes_boost_1_49_00" title="Boost 1.49 Release">Boost + 1.49 Release</a> +</h3></div></div></div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + Fixed bugs <a href="https://svn.boost.org/trac/boost/ticket/6347" target="_top">#6347</a>, + <a href="https://svn.boost.org/trac/boost/ticket/6223" target="_top">#6223</a>, + <a href="https://svn.boost.org/trac/boost/ticket/6153" target="_top">#6153</a>. + </li></ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.release_notes.release_notes_boost_1_48_00"></a><a class="link" href="release_notes.html#intrusive.release_notes.release_notes_boost_1_48_00" title="Boost 1.48 Release">Boost + 1.48 Release</a> +</h3></div></div></div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + Fixed bugs <a href="https://svn.boost.org/trac/boost/ticket/4797" target="_top">#4797</a>, + <a href="https://svn.boost.org/trac/boost/ticket/5165" target="_top">#5165</a>, + <a href="https://svn.boost.org/trac/boost/ticket/5183" target="_top">#5183</a>, + <a href="https://svn.boost.org/trac/boost/ticket/5191" target="_top">#5191</a>. + </li></ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.release_notes.release_notes_boost_1_46_00"></a><a class="link" href="release_notes.html#intrusive.release_notes.release_notes_boost_1_46_00" title="Boost 1.46 Release">Boost + 1.46 Release</a> +</h3></div></div></div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + Fixed bug <a href="https://svn.boost.org/trac/boost/ticket/4980" target="_top">#4980</a>, + </li></ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.release_notes.release_notes_boost_1_45_00"></a><a class="link" href="release_notes.html#intrusive.release_notes.release_notes_boost_1_45_00" title="Boost 1.45 Release">Boost + 1.45 Release</a> +</h3></div></div></div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + Added <code class="computeroutput"><span class="identifier">function_hook</span></code> option. + </li> +<li class="listitem"> + Fixed bugs <a href="https://svn.boost.org/trac/boost/ticket/2611" target="_top">#2611</a>, + <a href="https://svn.boost.org/trac/boost/ticket/3288" target="_top">#3288</a>, + <a href="https://svn.boost.org/trac/boost/ticket/3304" target="_top">#3304</a>, + <a href="https://svn.boost.org/trac/boost/ticket/3489" target="_top">#3489</a>, + <a href="https://svn.boost.org/trac/boost/ticket/3668" target="_top">#3668</a>, + <a href="https://svn.boost.org/trac/boost/ticket/3339" target="_top">#3688</a>, + <a href="https://svn.boost.org/trac/boost/ticket/3698" target="_top">#3698</a>, + <a href="https://svn.boost.org/trac/boost/ticket/3706" target="_top">#3706</a>, + <a href="https://svn.boost.org/trac/boost/ticket/3721" target="_top">#3721</a>. + <a href="https://svn.boost.org/trac/boost/ticket/3729" target="_top">#3729</a>, + <a href="https://svn.boost.org/trac/boost/ticket/3746" target="_top">#3746</a>, + <a href="https://svn.boost.org/trac/boost/ticket/3781" target="_top">#3781</a>, + <a href="https://svn.boost.org/trac/boost/ticket/3840" target="_top">#3840</a>, + <a href="https://svn.boost.org/trac/boost/ticket/3849" target="_top">#3849</a>, + <a href="https://svn.boost.org/trac/boost/ticket/3339" target="_top">#3339</a>, + <a href="https://svn.boost.org/trac/boost/ticket/3419" target="_top">#3419</a>, + <a href="https://svn.boost.org/trac/boost/ticket/3431" target="_top">#3431</a>, + <a href="https://svn.boost.org/trac/boost/ticket/4021" target="_top">#4021</a>. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.release_notes.release_notes_boost_1_40_00"></a><a class="link" href="release_notes.html#intrusive.release_notes.release_notes_boost_1_40_00" title="Boost 1.40 Release">Boost + 1.40 Release</a> +</h3></div></div></div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + Code cleanup in tree_algorithms.hpp and avl_tree_algorithms.hpp + </li> +<li class="listitem"> + Fixed bug <a href="https://svn.boost.org/trac/boost/ticket/3164" target="_top">#3164</a>. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.release_notes.release_notes_boost_1_39_00"></a><a class="link" href="release_notes.html#intrusive.release_notes.release_notes_boost_1_39_00" title="Boost 1.39 Release">Boost + 1.39 Release</a> +</h3></div></div></div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + Optimized <code class="computeroutput"><span class="identifier">list</span><span class="special">::</span><span class="identifier">merge</span></code> and <code class="computeroutput"><span class="identifier">slist</span><span class="special">::</span><span class="identifier">merge</span></code> + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">list</span><span class="special">::</span><span class="identifier">sort</span></code> and <code class="computeroutput"><span class="identifier">slist</span><span class="special">::</span><span class="identifier">sort</span></code> + are now stable. + </li> +<li class="listitem"> + Fixed bugs <a href="https://svn.boost.org/trac/boost/ticket/2689" target="_top">#2689</a>, + <a href="https://svn.boost.org/trac/boost/ticket/2755" target="_top">#2755</a>, + <a href="https://svn.boost.org/trac/boost/ticket/2786" target="_top">#2786</a>, + <a href="https://svn.boost.org/trac/boost/ticket/2807" target="_top">#2807</a>, + <a href="https://svn.boost.org/trac/boost/ticket/2810" target="_top">#2810</a>, + <a href="https://svn.boost.org/trac/boost/ticket/2862" target="_top">#2862</a>. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.release_notes.release_notes_boost_1_38_00"></a><a class="link" href="release_notes.html#intrusive.release_notes.release_notes_boost_1_38_00" title="Boost 1.38 Release">Boost + 1.38 Release</a> +</h3></div></div></div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + New treap-based containers: treap, treap_set, treap_multiset. + </li> +<li class="listitem"> + Corrected compilation bug for Windows-based 64 bit compilers. + </li> +<li class="listitem"> + Corrected exception-safety bugs in container constructors. + </li> +<li class="listitem"> + Updated documentation to show rvalue-references functions instead of + emulation functions. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.release_notes.release_notes_boost_1_37_00"></a><a class="link" href="release_notes.html#intrusive.release_notes.release_notes_boost_1_37_00" title="Boost 1.37 Release">Boost + 1.37 Release</a> +</h3></div></div></div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + Intrusive now takes advantage of compilers with variadic templates. + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">clone_from</span></code> functions + now copy predicates and hash functions of associative containers. + </li> +<li class="listitem"> + Added incremental hashing to unordered containers via <code class="computeroutput"><span class="identifier">incremental</span><span class="special"><></span></code> option. + </li> +<li class="listitem"> + Update some function parameters from <code class="computeroutput"><span class="identifier">iterator</span></code> + to <code class="computeroutput"><span class="identifier">const_iterator</span></code> in + containers to keep up with the draft of the next standard. + </li> +<li class="listitem"> + Added an option to specify include files for intrusive configurable assertion + macros. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.release_notes.release_notes_boost_1_36_00"></a><a class="link" href="release_notes.html#intrusive.release_notes.release_notes_boost_1_36_00" title="Boost 1.36 Release">Boost + 1.36 Release</a> +</h3></div></div></div> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + Added <code class="computeroutput"><span class="identifier">linear</span><span class="special"><></span></code> + and <code class="computeroutput"><span class="identifier">cache_last</span><span class="special"><></span></code> + options to singly linked lists. + </li> +<li class="listitem"> + Added <code class="computeroutput"><span class="identifier">optimize_multikey</span><span class="special"><></span></code> option to unordered container + hooks. + </li> +<li class="listitem"> + Optimized unordered containers when <code class="computeroutput"><span class="identifier">store_hash</span></code> + option is used in the hook. + </li> +<li class="listitem"> + Implementation changed to be exception agnostic so that it can be used + in environments without exceptions. + </li> +<li class="listitem"> + Added <code class="computeroutput"><span class="identifier">container_from_iterator</span></code> + function to tree-based containers. + </li> +</ul></div> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="performance.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="tested_compilers.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/safe_hook.html b/doc/html/intrusive/safe_hook.html new file mode 100755 index 0000000000..733c31bb0e --- /dev/null +++ b/doc/html/intrusive/safe_hook.html @@ -0,0 +1,133 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Safe hooks</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="presenting_containers.html" title="Presenting Boost.Intrusive containers"> +<link rel="next" href="auto_unlink_hooks.html" title="Auto-unlink hooks"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="presenting_containers.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="auto_unlink_hooks.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.safe_hook"></a><a class="link" href="safe_hook.html" title="Safe hooks">Safe hooks</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="safe_hook.html#intrusive.safe_hook.features">Features of the safe mode</a></span></dt> +<dt><span class="section"><a href="safe_hook.html#intrusive.safe_hook.configuring">Configuring safe-mode + assertions</a></span></dt> +</dl></div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.safe_hook.features"></a><a class="link" href="safe_hook.html#intrusive.safe_hook.features" title="Features of the safe mode">Features of the safe mode</a> +</h3></div></div></div> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> hooks can be configured + to operate in safe-link mode. The safe mode is activated by default, but + it can be also explicitly activated: + </p> +<pre class="programlisting"><span class="comment">//Configuring the safe mode explicitly</span> +<span class="keyword">class</span> <span class="identifier">Foo</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">list_base_hook</span><span class="special"><</span> <span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">safe_link</span><span class="special">></span> <span class="special">></span> +<span class="special">{};</span> +</pre> +<p> + With the safe mode the user can detect if the object is actually inserted + in a container without any external reference. Let's review the basic features + of the safe mode: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + Hook's constructor puts the hook in a well-known default state. + </li> +<li class="listitem"> + Hook's destructor checks if the hook is in the well-known default state. + If not, an assertion is raised. + </li> +<li class="listitem"> + Every time an object is inserted in the intrusive container, the container + checks if the hook is in the well-known default state. If not, an assertion + is raised. + </li> +<li class="listitem"> + Every time an object is being erased from the intrusive container, the + container puts the erased object in the well-known default state. + </li> +</ul></div> +<p> + With these features, without any external reference the user can know if + the object has been inserted in a container by calling the <code class="computeroutput"><span class="identifier">is_linked</span><span class="special">()</span></code> + member function. If the object is not actually inserted in a container, the + hook is in the default state, and if it is inserted in a container, the hook + is not in the default state. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.safe_hook.configuring"></a><a class="link" href="safe_hook.html#intrusive.safe_hook.configuring" title="Configuring safe-mode assertions">Configuring safe-mode + assertions</a> +</h3></div></div></div> +<p> + By default, all safe-mode assertions raised by <span class="bold"><strong>Boost-Intrusive</strong></span> + hooks and containers in are implemented using <code class="computeroutput"><span class="identifier">BOOST_ASSERT</span></code>, + which can be configured by the user. See <a href="http://www.boost.org/libs/utility/assert.html" target="_top">http://www.boost.org/libs/utility/assert.html</a> + for more information about <code class="computeroutput"><span class="identifier">BOOST_ASSERT</span></code>. + </p> +<p> + <code class="computeroutput"><span class="identifier">BOOST_ASSERT</span></code> is globally + configured, so the user might want to redefine intrusive safe-mode assertions + without modifying the global <code class="computeroutput"><span class="identifier">BOOST_ASSERT</span></code>. + This can be achieved redefining the following macros: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT</span></code>: + This assertion will be used in insertion functions of the intrusive containers + to check that the hook of the value to be inserted is default constructed. + </li> +<li class="listitem"> + <code class="computeroutput"><span class="identifier">BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT</span></code>: + This assertion will be used in hooks' destructors to check that the hook + is in a default state. + </li> +</ul></div> +<p> + If any of these macros is not redefined, the assertion will default to <code class="computeroutput"><span class="identifier">BOOST_ASSERT</span></code>. If <code class="computeroutput"><span class="identifier">BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT</span></code> + or <code class="computeroutput"><span class="identifier">BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT</span></code> + is defined and the programmer needs to include a file to configure that assertion, + it can define <code class="computeroutput"><span class="identifier">BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT_INCLUDE</span></code> + or <code class="computeroutput"><span class="identifier">BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT_INCLUDE</span></code> + with the name of the file to include: + </p> +<pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT</span> <span class="identifier">MYASSERT</span> +<span class="preprocessor">#define</span> <span class="identifier">BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT_INCLUDE</span> <span class="special"><</span><span class="identifier">myassert</span><span class="special">.</span><span class="identifier">h</span><span class="special">></span> +</pre> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="presenting_containers.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="auto_unlink_hooks.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/set_multiset.html b/doc/html/intrusive/set_multiset.html new file mode 100755 index 0000000000..e29f75023c --- /dev/null +++ b/doc/html/intrusive/set_multiset.html @@ -0,0 +1,272 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Intrusive associative containers: set, multiset, rbtree</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="list.html" title="Intrusive doubly linked list: list"> +<link rel="next" href="unordered_set_unordered_multiset.html" title="Semi-Intrusive unordered associative containers: unordered_set, unordered_multiset"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="list.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="unordered_set_unordered_multiset.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.set_multiset"></a><a class="link" href="set_multiset.html" title="Intrusive associative containers: set, multiset, rbtree">Intrusive associative containers: + set, multiset, rbtree</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="set_multiset.html#intrusive.set_multiset.set_multiset_hooks">set, multiset + and rbtree hooks</a></span></dt> +<dt><span class="section"><a href="set_multiset.html#intrusive.set_multiset.set_multiset_containers">set, + multiset and rbtree containers</a></span></dt> +<dt><span class="section"><a href="set_multiset.html#intrusive.set_multiset.set_multiset_example">Example</a></span></dt> +</dl></div> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> also offers associative containers + that can be very useful when creating more complex associative containers, + like containers maintaining one or more indices with different sorting semantics. + Boost.Intrusive associative containers, like most STL associative container + implementations are based on red-black trees. + </p> +<p> + The memory overhead of these containers is usually 3 pointers and a bit (with + alignment issues, this means 3 pointers and an integer). This size can be reduced + to 3 pointers if pointers have even alignment (which is usually true in most + systems). + </p> +<p> + An empty, non constant-time size <code class="computeroutput"><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a></code>, + <code class="computeroutput"><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a></code> or <code class="computeroutput"><a class="link" href="../boost/intrusive/rbtree.html" title="Class template rbtree">rbtree</a></code> has also the size of 3 pointers + and an integer (3 pointers when optimized for size). These containers have + logarithmic complexity in many operations like searches, insertions, erasures, + etc. <code class="computeroutput"><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a></code> and <code class="computeroutput"><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a></code> are the intrusive equivalents + of standard <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">set</span></code> and <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">multiset</span></code> + containers. + </p> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/rbtree.html" title="Class template rbtree">rbtree</a></code> is a superset + of <code class="computeroutput"><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a></code> and <code class="computeroutput"><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a></code> + containers that offers functions to insert unique and multiple keys. + </p> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.set_multiset.set_multiset_hooks"></a><a class="link" href="set_multiset.html#intrusive.set_multiset.set_multiset_hooks" title="set, multiset and rbtree hooks">set, multiset + and rbtree hooks</a> +</h3></div></div></div> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a></code>, <code class="computeroutput"><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a></code> + and <code class="computeroutput"><a class="link" href="../boost/intrusive/rbtree.html" title="Class template rbtree">rbtree</a></code> share the + same hooks. This is an advantage, because the same user type can be inserted + first in a <code class="computeroutput"><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a></code> + and after that in <code class="computeroutput"><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a></code> + without changing the definition of the user class. + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">set_base_hook</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <code class="computeroutput"><a class="link" href="../boost/intrusive/set_base_hook.html" title="Class template set_base_hook">set_base_hook</a></code>: + the user class derives publicly from <code class="computeroutput"><a class="link" href="../boost/intrusive/set_base_hook.html" title="Class template set_base_hook">set_base_hook</a></code> + to make it <code class="computeroutput"><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a></code>/<code class="computeroutput"><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a></code>-compatible. + </li></ul></div> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">set_member_hook</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <code class="computeroutput"><a class="link" href="../boost/intrusive/set_member_hook.html" title="Class template set_member_hook">set_member_hook</a></code>: + the user class contains a public <code class="computeroutput"><a class="link" href="../boost/intrusive/set_member_hook.html" title="Class template set_member_hook">set_member_hook</a></code> + to make it <code class="computeroutput"><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a></code>/<code class="computeroutput"><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a></code>-compatible. + </li></ul></div> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/set_base_hook.html" title="Class template set_base_hook">set_base_hook</a></code> + and <code class="computeroutput"><a class="link" href="../boost/intrusive/set_member_hook.html" title="Class template set_member_hook">set_member_hook</a></code> + receive the same options explained in the section <a class="link" href="usage.html" title="How to use Boost.Intrusive">How + to use Boost.Intrusive</a> plus a size optimization option: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">tag</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Tag</span><span class="special">></span></code></strong></span> + (for base hooks only): This argument serves as a tag, so you can derive + from more than one base hook. Default: <code class="computeroutput"><span class="identifier">tag</span><span class="special"><</span><span class="identifier">default_tag</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">link_mode_type</span> + <span class="identifier">LinkMode</span><span class="special">></span></code></strong></span>: + The linking policy. Default: <code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">safe_link</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">void_pointer</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">VoidPointer</span><span class="special">></span></code></strong></span>: + The pointer type to be used internally in the hook and propagated to + the container. Default: <code class="computeroutput"><span class="identifier">void_pointer</span><span class="special"><</span><span class="keyword">void</span><span class="special">*></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">optimize_size</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enable</span><span class="special">></span></code></strong></span>: + The hook will be optimized for size instead of speed. The hook will embed + the color bit of the red-black tree node in the parent pointer if pointer + alignment is even. In some platforms, optimizing the size might reduce + speed performance a bit since masking operations will be needed to access + parent pointer and color attributes, in other platforms this option improves + performance due to improved memory locality. Default: <code class="computeroutput"><span class="identifier">optimize_size</span><span class="special"><</span><span class="keyword">false</span><span class="special">></span></code>. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.set_multiset.set_multiset_containers"></a><a class="link" href="set_multiset.html#intrusive.set_multiset.set_multiset_containers" title="set, multiset and rbtree containers">set, + multiset and rbtree containers</a> +</h3></div></div></div> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">set</span><span class="special">;</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">multiset</span><span class="special">;</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">rbtree</span><span class="special">;</span> +</pre> +<p> + These containers receive the same options explained in the section <a class="link" href="usage.html" title="How to use Boost.Intrusive">How to use Boost.Intrusive</a>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">base_hook</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Hook</span><span class="special">></span></code></strong></span> + / <span class="bold"><strong><code class="computeroutput"><span class="identifier">member_hook</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Hook</span><span class="special">,</span> <span class="identifier">Hook</span> <span class="identifier">T</span><span class="special">::*</span> <span class="identifier">PtrToMember</span><span class="special">></span></code></strong></span> + / <span class="bold"><strong><code class="computeroutput"><span class="identifier">value_traits</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">ValueTraits</span><span class="special">></span></code></strong></span>: + To specify the hook type or value traits used to configure the container. + (To learn about value traits go to the section <a class="link" href="value_traits.html" title="Containers with custom ValueTraits">Containers + with custom ValueTraits</a>.) + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + To activate the constant-time <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code> operation. Default: <code class="computeroutput"><span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">true</span><span class="special">></span></code> + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">size_type</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + To specify the type that will be used to store the size of the container. + Default: <code class="computeroutput"><span class="identifier">size_type</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">></span></code> + </li> +</ul></div> +<p> + And they also can receive an additional option: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">compare</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Compare</span><span class="special">></span></code></strong></span>: + Comparison function for the objects to be inserted in containers. The + comparison functor must induce a strict weak ordering. Default: <code class="computeroutput"><span class="identifier">compare</span><span class="special"><</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="special">></span></code> + </li></ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.set_multiset.set_multiset_example"></a><a class="link" href="set_multiset.html#intrusive.set_multiset.set_multiset_example" title="Example">Example</a> +</h3></div></div></div> +<p> + Now let's see a small example using both hooks and both containers: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">set</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cassert</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + + <span class="comment">//This is a base hook optimized for size</span> +<span class="keyword">class</span> <span class="identifier">MyClass</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">set_base_hook</span><span class="special"><</span><span class="identifier">optimize_size</span><span class="special"><</span><span class="keyword">true</span><span class="special">></span> <span class="special">></span> +<span class="special">{</span> + <span class="keyword">int</span> <span class="identifier">int_</span><span class="special">;</span> + + <span class="keyword">public</span><span class="special">:</span> + <span class="comment">//This is a member hook</span> + <span class="identifier">set_member_hook</span><span class="special"><></span> <span class="identifier">member_hook_</span><span class="special">;</span> + + <span class="identifier">MyClass</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">)</span> + <span class="special">:</span> <span class="identifier">int_</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> + <span class="special">{}</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special"><</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">int_</span> <span class="special"><</span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">></span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">int_</span> <span class="special">></span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">==</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">int_</span> <span class="special">==</span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="comment">//Define a set using the base hook that will store values in reverse order</span> +<span class="keyword">typedef</span> <span class="identifier">set</span><span class="special"><</span> <span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">compare</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">greater</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="special">></span> <span class="special">></span> <span class="identifier">BaseSet</span><span class="special">;</span> + +<span class="comment">//Define an multiset using the member hook</span> +<span class="keyword">typedef</span> <span class="identifier">member_hook</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">set_member_hook</span><span class="special"><>,</span> <span class="special">&</span><span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">member_hook_</span><span class="special">></span> <span class="identifier">MemberOption</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">multiset</span><span class="special"><</span> <span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">MemberOption</span><span class="special">></span> <span class="identifier">MemberMultiset</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">iterator</span> <span class="identifier">VectIt</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">reverse_iterator</span> <span class="identifier">VectRit</span><span class="special">;</span> + + <span class="comment">//Create several MyClass objects, each one with a different value</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">values</span><span class="special">;</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">100</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">values</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">MyClass</span><span class="special">(</span><span class="identifier">i</span><span class="special">));</span> + + <span class="identifier">BaseSet</span> <span class="identifier">baseset</span><span class="special">;</span> + <span class="identifier">MemberMultiset</span> <span class="identifier">membermultiset</span><span class="special">;</span> + + <span class="comment">//Check that size optimization is activated in the base hook </span> + <span class="identifier">assert</span><span class="special">(</span><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">set_base_hook</span><span class="special"><</span><span class="identifier">optimize_size</span><span class="special"><</span><span class="keyword">true</span><span class="special">></span> <span class="special">>)</span> <span class="special">==</span> <span class="number">3</span><span class="special">*</span><span class="keyword">sizeof</span><span class="special">(</span><span class="keyword">void</span><span class="special">*));</span> + <span class="comment">//Check that size optimization is deactivated in the member hook </span> + <span class="identifier">assert</span><span class="special">(</span><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">set_member_hook</span><span class="special"><>)</span> <span class="special">></span> <span class="number">3</span><span class="special">*</span><span class="keyword">sizeof</span><span class="special">(</span><span class="keyword">void</span><span class="special">*));</span> + + <span class="comment">//Now insert them in the reverse order in the base hook set</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">){</span> + <span class="identifier">baseset</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + <span class="identifier">membermultiset</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + <span class="special">}</span> + + <span class="comment">//Now test sets</span> + <span class="special">{</span> + <span class="identifier">BaseSet</span><span class="special">::</span><span class="identifier">reverse_iterator</span> <span class="identifier">rbit</span><span class="special">(</span><span class="identifier">baseset</span><span class="special">.</span><span class="identifier">rbegin</span><span class="special">()),</span> <span class="identifier">rbitend</span><span class="special">(</span><span class="identifier">baseset</span><span class="special">.</span><span class="identifier">rend</span><span class="special">());</span> + <span class="identifier">MemberMultiset</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">mit</span><span class="special">(</span><span class="identifier">membermultiset</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">mitend</span><span class="special">(</span><span class="identifier">membermultiset</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + <span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + + <span class="comment">//Test the objects inserted in the base hook set</span> + <span class="keyword">for</span><span class="special">(;</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">rbit</span><span class="special">)</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">rbit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + + <span class="comment">//Test the objects inserted in the member hook set</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">it</span> <span class="special">=</span> <span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">();</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">mit</span><span class="special">)</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">mit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + <span class="special">}</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="list.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="unordered_set_unordered_multiset.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/sg_set_multiset.html b/doc/html/intrusive/sg_set_multiset.html new file mode 100755 index 0000000000..f58587c3ce --- /dev/null +++ b/doc/html/intrusive/sg_set_multiset.html @@ -0,0 +1,313 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Intrusive scapegoat tree based associative containers: sg_set, sg_multiset and sgtree</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="avl_set_multiset.html" title="Intrusive avl tree based associative containers: avl_set, avl_multiset and avltree"> +<link rel="next" href="treap_set_multiset.html" title="Intrusive treap based associative containers: treap_set, treap_multiset and treap"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="avl_set_multiset.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="treap_set_multiset.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.sg_set_multiset"></a><a class="link" href="sg_set_multiset.html" title="Intrusive scapegoat tree based associative containers: sg_set, sg_multiset and sgtree">Intrusive scapegoat tree based + associative containers: sg_set, sg_multiset and sgtree</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="sg_set_multiset.html#intrusive.sg_set_multiset.sg_set_multiset_hooks">Using + binary search tree hooks: bs_set_base_hook and bs_set_member_hook</a></span></dt> +<dt><span class="section"><a href="sg_set_multiset.html#intrusive.sg_set_multiset.sg_set_multiset_containers">sg_set, + sg_multiset and sgtree containers</a></span></dt> +<dt><span class="section"><a href="sg_set_multiset.html#intrusive.sg_set_multiset.sg_set_multiset_example">Example</a></span></dt> +</dl></div> +<p> + A scapegoat tree is a self-balancing binary search tree, that provides worst-case + O(log n) lookup time, and O(log n) amortized insertion and deletion time. Unlike + other self-balancing binary search trees that provide worst case O(log n) lookup + time, scapegoat trees have no additional per-node overhead compared to a regular + binary search tree. + </p> +<p> + A binary search tree is said to be weight balanced if half the nodes are on + the left of the root, and half on the right. An a-height-balanced tree is defined + with defined with the following equation: + </p> +<p> + <span class="bold"><strong><span class="emphasis"><em>height(tree) <= log1/a(tree.size())</em></span></strong></span> + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><span class="emphasis"><em>a == 1</em></span></strong></span>: A tree forming + a linked list is considered balanced. + </li> +<li class="listitem"> + <span class="bold"><strong><span class="emphasis"><em>a == 0.5</em></span></strong></span>: Only a + perfectly balanced binary is considered balanced. + </li> +</ul></div> +<p> + Scapegoat trees are loosely <span class="emphasis"><em>a-height-balanced</em></span> so: + </p> +<p> + <span class="bold"><strong><span class="emphasis"><em>height(tree) <= log1/a(tree.size()) + 1</em></span></strong></span> + </p> +<p> + Scapegoat trees support any a between 0.5 and 1. If a is higher, the tree is + rebalanced less often, obtaining quicker insertions but slower searches. Lower + a values improve search times. Scapegoat-trees implemented in <span class="bold"><strong>Boost.Intrusive</strong></span> + offer the possibility of <span class="bold"><strong>changing a at run-time</strong></span> + taking advantage of the flexibility of scapegoat trees. For more information + on scapegoat trees see <a href="http://en.wikipedia.org/wiki/Scapegoat_tree" target="_top">Wikipedia + entry</a>. + </p> +<p> + Scapegoat trees also have downsides: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + They need additional storage of data on the root (the size of the tree, + for example) to achieve logarithmic complexity operations so it's not possible + to offer <code class="computeroutput"><span class="identifier">auto_unlink</span></code> hooks. + The size of an empty scapegoat tree is also considerably increased. + </li> +<li class="listitem"> + The operations needed to determine if the tree is unbalanced require floating-point + operations like <span class="emphasis"><em>log1/a</em></span>. If the system has no floating + point operations (like some embedded systems), scapegoat tree operations + might become slow. + </li> +</ul></div> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> offers 3 containers based + on scapegoat trees: <code class="computeroutput"><a class="link" href="../boost/intrusive/sg_set.html" title="Class template sg_set">sg_set</a></code>, + <code class="computeroutput"><a class="link" href="../boost/intrusive/sg_multiset.html" title="Class template sg_multiset">sg_multiset</a></code> and + <code class="computeroutput"><a class="link" href="../boost/intrusive/sgtree.html" title="Class template sgtree">sgtree</a></code>. The first two + are similar to <code class="computeroutput"><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a></code> or <code class="computeroutput"><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a></code> and the latter is a generalization + that offers functions both to insert unique and multiple keys. + </p> +<p> + The memory overhead of these containers with Boost.Intrusive hooks is 3 pointers. + </p> +<p> + An empty, <code class="computeroutput"><a class="link" href="../boost/intrusive/sg_set.html" title="Class template sg_set">sg_set</a></code>, <code class="computeroutput"><a class="link" href="../boost/intrusive/sg_multiset.html" title="Class template sg_multiset">sg_multiset</a></code> or <code class="computeroutput"><a class="link" href="../boost/intrusive/sgtree.html" title="Class template sgtree">sgtree</a></code> + has also the size of 3 pointers, two integers and two floating point values + (equivalent to the size of 7 pointers on most systems). + </p> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.sg_set_multiset.sg_set_multiset_hooks"></a><a class="link" href="sg_set_multiset.html#intrusive.sg_set_multiset.sg_set_multiset_hooks" title="Using binary search tree hooks: bs_set_base_hook and bs_set_member_hook">Using + binary search tree hooks: bs_set_base_hook and bs_set_member_hook</a> +</h3></div></div></div> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/sg_set.html" title="Class template sg_set">sg_set</a></code>, <code class="computeroutput"><a class="link" href="../boost/intrusive/sg_multiset.html" title="Class template sg_multiset">sg_multiset</a></code> and <code class="computeroutput"><a class="link" href="../boost/intrusive/sgtree.html" title="Class template sgtree">sgtree</a></code> don't use their own hooks + but plain binary search tree hooks. This has many advantages since binary + search tree hooks can also be used to insert values in splay and treap containers. + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">bs_set_base_hook</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <code class="computeroutput"><a class="link" href="../boost/intrusive/bs_set_base_hook.html" title="Class template bs_set_base_hook">bs_set_base_hook</a></code>: + the user class derives publicly from this class to make it compatible + with scapegoat tree based containers. + </li></ul></div> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">bs_set_member_hook</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <code class="computeroutput"><a class="link" href="../boost/intrusive/set_member_hook.html" title="Class template set_member_hook">set_member_hook</a></code>: + the user class contains a public member of this class to make it compatible + with scapegoat tree based containers. + </li></ul></div> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/bs_set_base_hook.html" title="Class template bs_set_base_hook">bs_set_base_hook</a></code> + and <code class="computeroutput"><a class="link" href="../boost/intrusive/bs_set_member_hook.html" title="Class template bs_set_member_hook">bs_set_member_hook</a></code> + receive the same options explained in the section <a class="link" href="usage.html" title="How to use Boost.Intrusive">How + to use Boost.Intrusive</a>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">tag</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Tag</span><span class="special">></span></code></strong></span> + (for base hooks only): This argument serves as a tag, so you can derive + from more than one base hook. Default: <code class="computeroutput"><span class="identifier">tag</span><span class="special"><</span><span class="identifier">default_tag</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">link_mode_type</span> + <span class="identifier">LinkMode</span><span class="special">></span></code></strong></span>: + The linking policy. Default: <code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">safe_link</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">void_pointer</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">VoidPointer</span><span class="special">></span></code></strong></span>: + The pointer type to be used internally in the hook and propagated to + the container. Default: <code class="computeroutput"><span class="identifier">void_pointer</span><span class="special"><</span><span class="keyword">void</span><span class="special">*></span></code>. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.sg_set_multiset.sg_set_multiset_containers"></a><a class="link" href="sg_set_multiset.html#intrusive.sg_set_multiset.sg_set_multiset_containers" title="sg_set, sg_multiset and sgtree containers">sg_set, + sg_multiset and sgtree containers</a> +</h3></div></div></div> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">sg_set</span><span class="special">;</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">sg_multiset</span><span class="special">;</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">sgtree</span><span class="special">;</span> +</pre> +<p> + These containers receive the same options explained in the section <a class="link" href="usage.html" title="How to use Boost.Intrusive">How to use Boost.Intrusive</a>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">base_hook</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Hook</span><span class="special">></span></code></strong></span> + / <span class="bold"><strong><code class="computeroutput"><span class="identifier">member_hook</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Hook</span><span class="special">,</span> <span class="identifier">Hook</span> <span class="identifier">T</span><span class="special">::*</span> <span class="identifier">PtrToMember</span><span class="special">></span></code></strong></span> + / <span class="bold"><strong><code class="computeroutput"><span class="identifier">value_traits</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">ValueTraits</span><span class="special">></span></code></strong></span>: + To specify the hook type or value traits used to configure the container. + (To learn about value traits go to the section <a class="link" href="value_traits.html" title="Containers with custom ValueTraits">Containers + with custom ValueTraits</a>.) + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">size_type</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + To specify the type that will be used to store the size of the container. + Default: <code class="computeroutput"><span class="identifier">size_type</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">></span></code> + </li> +</ul></div> +<p> + And they also can receive additional options: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">compare</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Compare</span><span class="special">></span></code></strong></span>: + Comparison function for the objects to be inserted in containers. The + comparison functor must induce a strict weak ordering. Default: <code class="computeroutput"><span class="identifier">compare</span><span class="special"><</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="special">></span></code> + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">floating_point</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enable</span><span class="special">></span></code></strong></span>: + When this option is deactivated, the scapegoat tree loses the ability + to change the balance factor a at run-time, but the size of an empty + container is reduced and no floating point operations are performed, + normally increasing container performance. The fixed a factor that is + used when this option is activated is <span class="emphasis"><em>1/sqrt(2) ~ 0,70711</em></span>. + Default: <code class="computeroutput"><span class="identifier">floating_point</span><span class="special"><</span><span class="keyword">true</span><span class="special">></span></code> + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.sg_set_multiset.sg_set_multiset_example"></a><a class="link" href="sg_set_multiset.html#intrusive.sg_set_multiset.sg_set_multiset_example" title="Example">Example</a> +</h3></div></div></div> +<p> + Now let's see a small example using both hooks and <code class="computeroutput"><a class="link" href="../boost/intrusive/sg_set.html" title="Class template sg_set">sg_set</a></code>/ + <code class="computeroutput"><a class="link" href="../boost/intrusive/sg_multiset.html" title="Class template sg_multiset">sg_multiset</a></code> containers: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">sg_set</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cassert</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="keyword">class</span> <span class="identifier">MyClass</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">bs_set_base_hook</span><span class="special"><></span> +<span class="special">{</span> + <span class="keyword">int</span> <span class="identifier">int_</span><span class="special">;</span> + + <span class="keyword">public</span><span class="special">:</span> + <span class="comment">//This is a member hook</span> + <span class="identifier">bs_set_member_hook</span><span class="special"><></span> <span class="identifier">member_hook_</span><span class="special">;</span> + + <span class="identifier">MyClass</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">)</span> + <span class="special">:</span> <span class="identifier">int_</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> + <span class="special">{}</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special"><</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">int_</span> <span class="special"><</span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">></span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">int_</span> <span class="special">></span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">==</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">int_</span> <span class="special">==</span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="comment">//Define an sg_set using the base hook that will store values in reverse order</span> +<span class="comment">//and won't execute floating point operations.</span> +<span class="keyword">typedef</span> <span class="identifier">sg_set</span> + <span class="special"><</span> <span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">compare</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">greater</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="special">>,</span> <span class="identifier">floating_point</span><span class="special"><</span><span class="keyword">false</span><span class="special">></span> <span class="special">></span> <span class="identifier">BaseSet</span><span class="special">;</span> + +<span class="comment">//Define an multiset using the member hook</span> +<span class="keyword">typedef</span> <span class="identifier">member_hook</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">bs_set_member_hook</span><span class="special"><>,</span> <span class="special">&</span><span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">member_hook_</span><span class="special">></span> <span class="identifier">MemberOption</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">sg_multiset</span><span class="special"><</span> <span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">MemberOption</span><span class="special">></span> <span class="identifier">MemberMultiset</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">iterator</span> <span class="identifier">VectIt</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">reverse_iterator</span> <span class="identifier">VectRit</span><span class="special">;</span> + + <span class="comment">//Create several MyClass objects, each one with a different value</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">values</span><span class="special">;</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">100</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">values</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">MyClass</span><span class="special">(</span><span class="identifier">i</span><span class="special">));</span> + + <span class="identifier">BaseSet</span> <span class="identifier">baseset</span><span class="special">;</span> + <span class="identifier">MemberMultiset</span> <span class="identifier">membermultiset</span><span class="special">;</span> + + <span class="comment">//Now insert them in the reverse order in the base hook sg_set</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">){</span> + <span class="identifier">baseset</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + <span class="identifier">membermultiset</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + <span class="special">}</span> + + <span class="comment">//Change balance factor</span> + <span class="identifier">membermultiset</span><span class="special">.</span><span class="identifier">balance_factor</span><span class="special">(</span><span class="number">0.9f</span><span class="special">);</span> + + <span class="comment">//Now test sg_sets</span> + <span class="special">{</span> + <span class="identifier">BaseSet</span><span class="special">::</span><span class="identifier">reverse_iterator</span> <span class="identifier">rbit</span><span class="special">(</span><span class="identifier">baseset</span><span class="special">.</span><span class="identifier">rbegin</span><span class="special">()),</span> <span class="identifier">rbitend</span><span class="special">(</span><span class="identifier">baseset</span><span class="special">.</span><span class="identifier">rend</span><span class="special">());</span> + <span class="identifier">MemberMultiset</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">mit</span><span class="special">(</span><span class="identifier">membermultiset</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">mitend</span><span class="special">(</span><span class="identifier">membermultiset</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + <span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + + <span class="comment">//Test the objects inserted in the base hook sg_set</span> + <span class="keyword">for</span><span class="special">(;</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">rbit</span><span class="special">)</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">rbit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + + <span class="comment">//Test the objects inserted in the member hook sg_set</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">it</span> <span class="special">=</span> <span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">();</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">mit</span><span class="special">)</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">mit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + <span class="special">}</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="avl_set_multiset.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="treap_set_multiset.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/slist.html b/doc/html/intrusive/slist.html new file mode 100755 index 0000000000..6675eaa0a3 --- /dev/null +++ b/doc/html/intrusive/slist.html @@ -0,0 +1,254 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Intrusive singly linked list: slist</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="auto_unlink_hooks.html" title="Auto-unlink hooks"> +<link rel="next" href="list.html" title="Intrusive doubly linked list: list"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="auto_unlink_hooks.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="list.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.slist"></a><a class="link" href="slist.html" title="Intrusive singly linked list: slist">Intrusive singly linked list: slist</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="slist.html#intrusive.slist.slist_hooks">slist hooks</a></span></dt> +<dt><span class="section"><a href="slist.html#intrusive.slist.slist_container">slist container</a></span></dt> +<dt><span class="section"><a href="slist.html#intrusive.slist.slist_example">Example</a></span></dt> +</dl></div> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a></code> is the simplest + intrusive container of <span class="bold"><strong>Boost.Intrusive</strong></span>: a + singly linked list. The memory overhead it imposes is 1 pointer per node. The + size of an empty, non constant-time size <code class="computeroutput"><a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a></code> + is the size of 1 pointer. This lightweight memory overhead comes with drawbacks, + though: many operations have linear time complexity, even some that usually + are constant time, like <code class="computeroutput">swap</code>. + <code class="computeroutput"><a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a></code> only provides forward + iterators. + </p> +<p> + For most cases, a doubly linked list is preferable because it offers more constant-time + functions with a slightly bigger size overhead. However, for some applications + like constructing more elaborate containers, singly linked lists are essential + because of their low size overhead. + </p> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.slist.slist_hooks"></a><a class="link" href="slist.html#intrusive.slist.slist_hooks" title="slist hooks">slist hooks</a> +</h3></div></div></div> +<p> + Like the rest of <span class="bold"><strong>Boost.Intrusive</strong></span> containers, + <code class="computeroutput"><a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a></code> has two hook types: + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">slist_base_hook</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <code class="computeroutput"><a class="link" href="../boost/intrusive/slist_base_hook.html" title="Class template slist_base_hook">slist_base_hook</a></code>: + the user class derives publicly from <code class="computeroutput"><a class="link" href="../boost/intrusive/slist_base_hook.html" title="Class template slist_base_hook">slist_base_hook</a></code> + to make it <code class="computeroutput"><a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a></code>-compatible. + </li></ul></div> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">slist_member_hook</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <code class="computeroutput"><a class="link" href="../boost/intrusive/slist_member_hook.html" title="Class template slist_member_hook">slist_member_hook</a></code>: + the user class contains a public <code class="computeroutput"><a class="link" href="../boost/intrusive/slist_member_hook.html" title="Class template slist_member_hook">slist_member_hook</a></code> + to make it <code class="computeroutput"><a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a></code>-compatible. + </li></ul></div> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/slist_base_hook.html" title="Class template slist_base_hook">slist_base_hook</a></code> + and <code class="computeroutput"><a class="link" href="../boost/intrusive/slist_member_hook.html" title="Class template slist_member_hook">slist_member_hook</a></code> + receive the same options explained in the section <a class="link" href="usage.html" title="How to use Boost.Intrusive">How + to use Boost.Intrusive</a>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">tag</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Tag</span><span class="special">></span></code></strong></span> + (for base hooks only): This argument serves as a tag, so you can derive + from more than one slist hook. Default: <code class="computeroutput"><span class="identifier">tag</span><span class="special"><</span><span class="identifier">default_tag</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">link_mode_type</span> + <span class="identifier">LinkMode</span><span class="special">></span></code></strong></span>: + The linking policy. Default: <code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">safe_link</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">void_pointer</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">VoidPointer</span><span class="special">></span></code></strong></span>: + The pointer type to be used internally in the hook and propagated to + the container. Default: <code class="computeroutput"><span class="identifier">void_pointer</span><span class="special"><</span><span class="keyword">void</span><span class="special">*></span></code>. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.slist.slist_container"></a><a class="link" href="slist.html#intrusive.slist.slist_container" title="slist container">slist container</a> +</h3></div></div></div> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">slist</span><span class="special">;</span> +</pre> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a></code> receives the options + explained in the section <a class="link" href="usage.html" title="How to use Boost.Intrusive">How to use Boost.Intrusive</a>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">base_hook</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Hook</span><span class="special">></span></code></strong></span> + / <span class="bold"><strong><code class="computeroutput"><span class="identifier">member_hook</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Hook</span><span class="special">,</span> <span class="identifier">Hook</span> <span class="identifier">T</span><span class="special">::*</span> <span class="identifier">PtrToMember</span><span class="special">></span></code></strong></span> + / <span class="bold"><strong><code class="computeroutput"><span class="identifier">value_traits</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">ValueTraits</span><span class="special">></span></code></strong></span>: + To specify the hook type or value traits used to configure the container. + (To learn about value traits go to the section <a class="link" href="value_traits.html" title="Containers with custom ValueTraits">Containers + with custom ValueTraits</a>.) + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + To activate the constant-time <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code> operation. Default: <code class="computeroutput"><span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">true</span><span class="special">></span></code> + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">size_type</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + To specify the type that will be used to store the size of the container. + Default: <code class="computeroutput"><span class="identifier">size_type</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">></span></code>. + </li> +</ul></div> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a></code> can receive additional + options: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">linear</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enable</span><span class="special">></span></code></strong></span>: + the singly linked list is implemented as a null-terminated list instead + of a circular list. This allows <code class="computeroutput"><span class="identifier">O</span><span class="special">(</span><span class="number">1</span><span class="special">)</span></code> + swap, but losses some operations like <code class="computeroutput"><span class="identifier">container_from_end_iterator</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">cache_last</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enable</span><span class="special">></span></code></strong></span>: + the singly linked also stores a pointer to the last element of the singly + linked list. This allows <code class="computeroutput"><span class="identifier">O</span><span class="special">(</span><span class="number">1</span><span class="special">)</span></code> + swap, <code class="computeroutput"><span class="identifier">splice_after</span><span class="special">(</span><span class="identifier">iterator</span><span class="special">,</span> + <span class="identifier">slist</span> <span class="special">&)</span></code> + and makes the list offer new functions like <code class="computeroutput"><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">reference</span><span class="special">)</span></code> and <code class="computeroutput"><span class="identifier">back</span><span class="special">()</span></code>. Logically, the size an empty list + is increased in <code class="computeroutput"><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">void_pointer</span><span class="special">)</span></code> + and the the cached last node pointer must be updated in every operation, + and that might incur in a slight performance impact. + </li> +</ul></div> +<p> + <code class="computeroutput"><span class="identifier">auto_unlink</span></code> hooks are not + usable if <code class="computeroutput"><span class="identifier">linear</span><span class="special"><</span><span class="keyword">true</span><span class="special">></span></code> and/or + <code class="computeroutput"><span class="identifier">cache_last</span><span class="special"><</span><span class="keyword">true</span><span class="special">></span></code> options + are used. If <code class="computeroutput"><span class="identifier">auto_unlink</span></code> + hooks are used and those options are specified, a static assertion will be + raised. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.slist.slist_example"></a><a class="link" href="slist.html#intrusive.slist.slist_example" title="Example">Example</a> +</h3></div></div></div> +<p> + Now let's see a small example using both hooks: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">slist</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + + <span class="comment">//This is a base hook</span> +<span class="keyword">class</span> <span class="identifier">MyClass</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">slist_base_hook</span><span class="special"><></span> +<span class="special">{</span> + <span class="keyword">int</span> <span class="identifier">int_</span><span class="special">;</span> + + <span class="keyword">public</span><span class="special">:</span> + <span class="comment">//This is a member hook</span> + <span class="identifier">slist_member_hook</span><span class="special"><></span> <span class="identifier">member_hook_</span><span class="special">;</span> + + <span class="identifier">MyClass</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">)</span> + <span class="special">:</span> <span class="identifier">int_</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> + <span class="special">{}</span> +<span class="special">};</span> + +<span class="comment">//Define an slist that will store MyClass using the public base hook</span> +<span class="keyword">typedef</span> <span class="identifier">slist</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">BaseList</span><span class="special">;</span> + +<span class="comment">//Define an slist that will store MyClass using the public member hook</span> +<span class="keyword">typedef</span> <span class="identifier">member_hook</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">slist_member_hook</span><span class="special"><>,</span> <span class="special">&</span><span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">member_hook_</span><span class="special">></span> <span class="identifier">MemberOption</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">slist</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">MemberOption</span><span class="special">></span> <span class="identifier">MemberList</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">iterator</span> <span class="identifier">VectIt</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">reverse_iterator</span> <span class="identifier">VectRit</span><span class="special">;</span> + + <span class="comment">//Create several MyClass objects, each one with a different value</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">values</span><span class="special">;</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">100</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">values</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">MyClass</span><span class="special">(</span><span class="identifier">i</span><span class="special">));</span> + + <span class="identifier">BaseList</span> <span class="identifier">baselist</span><span class="special">;</span> + <span class="identifier">MemberList</span> <span class="identifier">memberlist</span><span class="special">;</span> + + <span class="comment">//Now insert them in the reverse order in the base hook list</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">)</span> + <span class="identifier">baselist</span><span class="special">.</span><span class="identifier">push_front</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + + <span class="comment">//Now insert them in the same order as in vector in the member hook list</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">BaseList</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">baselist</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">baselist</span><span class="special">.</span><span class="identifier">end</span><span class="special">())</span> + <span class="special">;</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">){</span> + <span class="identifier">memberlist</span><span class="special">.</span><span class="identifier">push_front</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + <span class="special">}</span> + + <span class="comment">//Now test lists</span> + <span class="special">{</span> + <span class="identifier">BaseList</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">bit</span><span class="special">(</span><span class="identifier">baselist</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">bitend</span><span class="special">(</span><span class="identifier">baselist</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + <span class="identifier">MemberList</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">mit</span><span class="special">(</span><span class="identifier">memberlist</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">mitend</span><span class="special">(</span><span class="identifier">memberlist</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + <span class="identifier">VectRit</span> <span class="identifier">rit</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">rbegin</span><span class="special">()),</span> <span class="identifier">ritend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">rend</span><span class="special">());</span> + <span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + + <span class="comment">//Test the objects inserted in the base hook list</span> + <span class="keyword">for</span><span class="special">(;</span> <span class="identifier">rit</span> <span class="special">!=</span> <span class="identifier">ritend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">rit</span><span class="special">,</span> <span class="special">++</span><span class="identifier">bit</span><span class="special">)</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">bit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">rit</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + + <span class="comment">//Test the objects inserted in the member hook list</span> + <span class="keyword">for</span><span class="special">(;</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">mit</span><span class="special">)</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">mit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + <span class="special">}</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="auto_unlink_hooks.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="list.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/splay_set_multiset.html b/doc/html/intrusive/splay_set_multiset.html new file mode 100755 index 0000000000..4aab46f615 --- /dev/null +++ b/doc/html/intrusive/splay_set_multiset.html @@ -0,0 +1,321 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Intrusive splay tree based associative containers: splay_set, splay_multiset and , splay_tree</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="unordered_set_unordered_multiset.html" title="Semi-Intrusive unordered associative containers: unordered_set, unordered_multiset"> +<link rel="next" href="avl_set_multiset.html" title="Intrusive avl tree based associative containers: avl_set, avl_multiset and avltree"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="unordered_set_unordered_multiset.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="avl_set_multiset.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.splay_set_multiset"></a><a class="link" href="splay_set_multiset.html" title="Intrusive splay tree based associative containers: splay_set, splay_multiset and , splay_tree">Intrusive splay tree based + associative containers: splay_set, splay_multiset and , splay_tree</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="splay_set_multiset.html#intrusive.splay_set_multiset.splay_set_multiset_disadvantages">Advantages + and disadvantages of splay tree based containers</a></span></dt> +<dt><span class="section"><a href="splay_set_multiset.html#intrusive.splay_set_multiset.splay_set_multiset_hooks">splay_set, + splay_multiset and splaytree hooks</a></span></dt> +<dt><span class="section"><a href="splay_set_multiset.html#intrusive.splay_set_multiset.set_multiset_containers">splay_set, + splay_multiset and splaytree containers</a></span></dt> +<dt><span class="section"><a href="splay_set_multiset.html#intrusive.splay_set_multiset.splay_set_bst_hook">Splay + trees with BST hooks</a></span></dt> +<dt><span class="section"><a href="splay_set_multiset.html#intrusive.splay_set_multiset.splay_set_multiset_example">Example</a></span></dt> +</dl></div> +<p> + C++ associative containers are usually based on red-black tree implementations + (e.g.: STL, Boost.Intrusive associative containers). However, there are other + interesting data structures that offer some advantages (and also disadvantages). + </p> +<p> + Splay trees are self-adjusting binary search trees used typically in caches, + memory allocators and other applications, because splay trees have a "caching + effect": recently accessed elements have better access times than elements + accessed less frequently. For more information on splay trees see <a href="http://en.wikipedia.org/wiki/Splay_tree" target="_top">Wikipedia + entry</a>. + </p> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> offers 3 containers based + on splay trees: <code class="computeroutput"><a class="link" href="../boost/intrusive/splay_set.html" title="Class template splay_set">splay_set</a></code>, + <code class="computeroutput"><a class="link" href="../boost/intrusive/splay_multiset.html" title="Class template splay_multiset">splay_multiset</a></code> + and <code class="computeroutput"><a class="link" href="../boost/intrusive/splaytree.html" title="Class template splaytree">splaytree</a></code>. The + first two are similar to <code class="computeroutput"><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a></code> + or <code class="computeroutput"><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a></code> and the + latter is a generalization that offers functions both to insert unique and + multiple keys. + </p> +<p> + The memory overhead of these containers with Boost.Intrusive hooks is usually + 3 pointers. An empty, non constant-time size splay container has also a size + of 3 pointers. + </p> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.splay_set_multiset.splay_set_multiset_disadvantages"></a><a class="link" href="splay_set_multiset.html#intrusive.splay_set_multiset.splay_set_multiset_disadvantages" title="Advantages and disadvantages of splay tree based containers">Advantages + and disadvantages of splay tree based containers</a> +</h3></div></div></div> +<p> + Splay tree based intrusive containers have logarithmic complexity in many + operations like searches, insertions, erasures, etc., but if some elements + are more frequently accessed than others, splay trees perform faster searches + than equivalent balanced binary trees (such as red-black trees). + </p> +<p> + The caching effect offered by splay trees comes with a cost: the tree must + be rebalanced when an element is searched. This disallows const versions + of search functions like <code class="computeroutput"><span class="identifier">find</span><span class="special">()</span></code>, <code class="computeroutput"><span class="identifier">lower_bound</span><span class="special">()</span></code>, <code class="computeroutput"><span class="identifier">upper_bound</span><span class="special">()</span></code>, <code class="computeroutput"><span class="identifier">equal_range</span><span class="special">()</span></code>, <code class="computeroutput"><span class="identifier">count</span><span class="special">()</span></code>, etc. + </p> +<p> + Because of this, splay-tree based associative containers are not drop-in + replacements of <code class="computeroutput"><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a></code>/ + <code class="computeroutput"><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a></code>. + </p> +<p> + Apart from this, if element searches are randomized, the tree will be rebalanced + without taking advantage of the cache effect, so splay trees can offer worse + performance than other balanced trees for some search patterns. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.splay_set_multiset.splay_set_multiset_hooks"></a><a class="link" href="splay_set_multiset.html#intrusive.splay_set_multiset.splay_set_multiset_hooks" title="splay_set, splay_multiset and splaytree hooks">splay_set, + splay_multiset and splaytree hooks</a> +</h3></div></div></div> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/splay_set.html" title="Class template splay_set">splay_set</a></code>, <code class="computeroutput"><a class="link" href="../boost/intrusive/splay_multiset.html" title="Class template splay_multiset">splay_multiset</a></code> and <code class="computeroutput"><a class="link" href="../boost/intrusive/splaytree.html" title="Class template splaytree">splaytree</a></code> share the same hooks. + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">splay_set_base_hook</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <code class="computeroutput"><a class="link" href="../boost/intrusive/splay_set_base_hook.html" title="Class template splay_set_base_hook">splay_set_base_hook</a></code>: + the user class derives publicly from this class to make it compatible + with splay tree based containers. + </li></ul></div> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">splay_set_member_hook</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <code class="computeroutput"><a class="link" href="../boost/intrusive/set_member_hook.html" title="Class template set_member_hook">set_member_hook</a></code>: + the user class contains a public member of this class to make it compatible + with splay tree based containers. + </li></ul></div> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/splay_set_base_hook.html" title="Class template splay_set_base_hook">splay_set_base_hook</a></code> + and <code class="computeroutput"><a class="link" href="../boost/intrusive/splay_set_member_hook.html" title="Class template splay_set_member_hook">splay_set_member_hook</a></code> + receive the same options explained in the section <a class="link" href="usage.html" title="How to use Boost.Intrusive">How + to use Boost.Intrusive</a>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">tag</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Tag</span><span class="special">></span></code></strong></span> + (for base hooks only): This argument serves as a tag, so you can derive + from more than one base hook. Default: <code class="computeroutput"><span class="identifier">tag</span><span class="special"><</span><span class="identifier">default_tag</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">link_mode_type</span> + <span class="identifier">LinkMode</span><span class="special">></span></code></strong></span>: + The linking policy. Default: <code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">safe_link</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">void_pointer</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">VoidPointer</span><span class="special">></span></code></strong></span>: + The pointer type to be used internally in the hook and propagated to + the container. Default: <code class="computeroutput"><span class="identifier">void_pointer</span><span class="special"><</span><span class="keyword">void</span><span class="special">*></span></code>. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.splay_set_multiset.set_multiset_containers"></a><a class="link" href="splay_set_multiset.html#intrusive.splay_set_multiset.set_multiset_containers" title="splay_set, splay_multiset and splaytree containers">splay_set, + splay_multiset and splaytree containers</a> +</h3></div></div></div> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">splay_set</span><span class="special">;</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">splay_multiset</span><span class="special">;</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">splaytree</span><span class="special">;</span> +</pre> +<p> + These containers receive the same options explained in the section <a class="link" href="usage.html" title="How to use Boost.Intrusive">How to use Boost.Intrusive</a>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">base_hook</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Hook</span><span class="special">></span></code></strong></span> + / <span class="bold"><strong><code class="computeroutput"><span class="identifier">member_hook</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Hook</span><span class="special">,</span> <span class="identifier">Hook</span> <span class="identifier">T</span><span class="special">::*</span> <span class="identifier">PtrToMember</span><span class="special">></span></code></strong></span> + / <span class="bold"><strong><code class="computeroutput"><span class="identifier">value_traits</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">ValueTraits</span><span class="special">></span></code></strong></span>: + To specify the hook type or value traits used to configure the container. + (To learn about value traits go to the section <a class="link" href="value_traits.html" title="Containers with custom ValueTraits">Containers + with custom ValueTraits</a>.) + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + To activate the constant-time <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code> operation. Default: <code class="computeroutput"><span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">true</span><span class="special">></span></code> + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">size_type</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + To specify the type that will be used to store the size of the container. + Default: <code class="computeroutput"><span class="identifier">size_type</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">></span></code> + </li> +</ul></div> +<p> + And they also can receive an additional option: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">compare</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Compare</span><span class="special">></span></code></strong></span>: + Comparison function for the objects to be inserted in containers. The + comparison functor must induce a strict weak ordering. Default: <code class="computeroutput"><span class="identifier">compare</span><span class="special"><</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="special">></span></code> + </li></ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.splay_set_multiset.splay_set_bst_hook"></a><a class="link" href="splay_set_multiset.html#intrusive.splay_set_multiset.splay_set_bst_hook" title="Splay trees with BST hooks">Splay + trees with BST hooks</a> +</h3></div></div></div> +<p> + Intrusive splay containers can also use plain binary search tree hooks <code class="computeroutput"><a class="link" href="../boost/intrusive/bs_set_base_hook.html" title="Class template bs_set_base_hook">bs_set_base_hook</a></code> and + <code class="computeroutput"><a class="link" href="../boost/intrusive/bs_set_base_hook.html" title="Class template bs_set_base_hook">bs_set_base_hook</a></code>. + These hooks can be used by other intrusive containers like intrusive scapegoat + containers <code class="computeroutput"><a class="link" href="../boost/intrusive/sg_set.html" title="Class template sg_set">sg_set</a></code> and + <code class="computeroutput"><a class="link" href="../boost/intrusive/sg_multiset.html" title="Class template sg_multiset">sg_multiset</a></code>. A + programmer might prefer using a binary search tree hook so that the same + type can be inserted in some situations in a splay container but also inserted + in other compatible containers when the hook is not being used in a splay + container. + </p> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/bs_set_base_hook.html" title="Class template bs_set_base_hook">bs_set_base_hook</a></code> + and <code class="computeroutput"><a class="link" href="../boost/intrusive/bs_set_base_hook.html" title="Class template bs_set_base_hook">bs_set_member_hook</a></code> + admit the same options as <code class="computeroutput"><a class="link" href="../boost/intrusive/splay_set_base_hook.html" title="Class template splay_set_base_hook">splay_set_base_hook</a></code>. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.splay_set_multiset.splay_set_multiset_example"></a><a class="link" href="splay_set_multiset.html#intrusive.splay_set_multiset.splay_set_multiset_example" title="Example">Example</a> +</h3></div></div></div> +<p> + Now let's see a small example using both splay hooks, binary search tree + hooks and <code class="computeroutput"><a class="link" href="../boost/intrusive/splay_set.html" title="Class template splay_set">splay_set</a></code>/ + <code class="computeroutput"><a class="link" href="../boost/intrusive/splay_multiset.html" title="Class template splay_multiset">splay_multiset</a></code> + containers: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">splay_set</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">bs_set_hook</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="keyword">class</span> <span class="identifier">MyClass</span> + <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">splay_set_base_hook</span><span class="special"><></span> <span class="comment">//This is an splay tree base hook</span> + <span class="special">,</span> <span class="keyword">public</span> <span class="identifier">bs_set_base_hook</span><span class="special"><></span> <span class="comment">//This is a binary search tree base hook</span> + +<span class="special">{</span> + <span class="keyword">int</span> <span class="identifier">int_</span><span class="special">;</span> + + <span class="keyword">public</span><span class="special">:</span> + <span class="comment">//This is a member hook</span> + <span class="identifier">splay_set_member_hook</span><span class="special"><></span> <span class="identifier">member_hook_</span><span class="special">;</span> + + <span class="identifier">MyClass</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">)</span> + <span class="special">:</span> <span class="identifier">int_</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> + <span class="special">{}</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special"><</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">int_</span> <span class="special"><</span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">></span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">int_</span> <span class="special">></span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">==</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">int_</span> <span class="special">==</span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="comment">//Define a set using the base hook that will store values in reverse order</span> +<span class="keyword">typedef</span> <span class="identifier">splay_set</span><span class="special"><</span> <span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">compare</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">greater</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="special">></span> <span class="special">></span> <span class="identifier">BaseSplaySet</span><span class="special">;</span> + +<span class="comment">//Define a set using the binary search tree hook</span> +<span class="keyword">typedef</span> <span class="identifier">splay_set</span><span class="special"><</span> <span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">base_hook</span><span class="special"><</span><span class="identifier">bs_set_base_hook</span><span class="special"><></span> <span class="special">></span> <span class="special">></span> <span class="identifier">BaseBsSplaySet</span><span class="special">;</span> + +<span class="comment">//Define an multiset using the member hook</span> +<span class="keyword">typedef</span> <span class="identifier">member_hook</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">splay_set_member_hook</span><span class="special"><>,</span> <span class="special">&</span><span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">member_hook_</span><span class="special">></span> <span class="identifier">MemberOption</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">splay_multiset</span><span class="special"><</span> <span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">MemberOption</span><span class="special">></span> <span class="identifier">MemberSplayMultiset</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">iterator</span> <span class="identifier">VectIt</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">reverse_iterator</span> <span class="identifier">VectRit</span><span class="special">;</span> + + <span class="comment">//Create several MyClass objects, each one with a different value</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">values</span><span class="special">;</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">100</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">values</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">MyClass</span><span class="special">(</span><span class="identifier">i</span><span class="special">));</span> + + <span class="identifier">BaseSplaySet</span> <span class="identifier">baseset</span><span class="special">;</span> + <span class="identifier">BaseBsSplaySet</span> <span class="identifier">bsbaseset</span><span class="special">;</span> + <span class="identifier">MemberSplayMultiset</span> <span class="identifier">membermultiset</span><span class="special">;</span> + + + <span class="comment">//Insert values in the container</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">){</span> + <span class="identifier">baseset</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + <span class="identifier">bsbaseset</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + <span class="identifier">membermultiset</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + <span class="special">}</span> + + <span class="comment">//Now test sets</span> + <span class="special">{</span> + <span class="identifier">BaseSplaySet</span><span class="special">::</span><span class="identifier">reverse_iterator</span> <span class="identifier">rbit</span><span class="special">(</span><span class="identifier">baseset</span><span class="special">.</span><span class="identifier">rbegin</span><span class="special">()),</span> <span class="identifier">rbitend</span><span class="special">(</span><span class="identifier">baseset</span><span class="special">.</span><span class="identifier">rend</span><span class="special">());</span> + <span class="identifier">BaseBsSplaySet</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">bsit</span><span class="special">(</span><span class="identifier">bsbaseset</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">bsitend</span><span class="special">(</span><span class="identifier">bsbaseset</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + <span class="identifier">MemberSplayMultiset</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">mit</span><span class="special">(</span><span class="identifier">membermultiset</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">mitend</span><span class="special">(</span><span class="identifier">membermultiset</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + <span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + + <span class="comment">//Test the objects inserted in the base hook set</span> + <span class="keyword">for</span><span class="special">(;</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">rbit</span><span class="special">){</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">rbit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + <span class="special">}</span> + + <span class="comment">//Test the objects inserted in member and binary search hook sets</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">it</span> <span class="special">=</span> <span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">();</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">bsit</span><span class="special">,</span> <span class="special">++</span><span class="identifier">mit</span><span class="special">){</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">bsit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">mit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + <span class="special">}</span> + <span class="special">}</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="unordered_set_unordered_multiset.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="avl_set_multiset.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/tested_compilers.html b/doc/html/intrusive/tested_compilers.html new file mode 100755 index 0000000000..7c4a02b11f --- /dev/null +++ b/doc/html/intrusive/tested_compilers.html @@ -0,0 +1,58 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Tested compilers</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="release_notes.html" title="Release Notes"> +<link rel="next" href="references.html" title="References"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="release_notes.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="references.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.tested_compilers"></a><a class="link" href="tested_compilers.html" title="Tested compilers">Tested compilers</a> +</h2></div></div></div> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> has been tested on the following + compilers/platforms: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + Visual >= 7.1 + </li> +<li class="listitem"> + GCC >= 4.1 + </li> +<li class="listitem"> + Intel 11 + </li> +</ul></div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="release_notes.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="references.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/thread_safety.html b/doc/html/intrusive/thread_safety.html new file mode 100755 index 0000000000..a8ae2f7ee6 --- /dev/null +++ b/doc/html/intrusive/thread_safety.html @@ -0,0 +1,91 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Thread safety guarantees</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="value_traits.html" title="Containers with custom ValueTraits"> +<link rel="next" href="obtaining_same_type_reducing_space.html" title="Obtaining the same types and reducing symbol length"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="value_traits.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="obtaining_same_type_reducing_space.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.thread_safety"></a><a class="link" href="thread_safety.html" title="Thread safety guarantees">Thread safety guarantees</a> +</h2></div></div></div> +<p> + Intrusive containers have thread safety guarantees similar to STL containers. + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + Several threads having read or write access to different instances is safe + as long as inserted objects are different. + </li> +<li class="listitem"> + Concurrent read-only access to the same container is safe. + </li> +</ul></div> +<p> + Some Intrusive hooks (auto-unlink hooks, for example) modify containers without + having a reference to them: this is considered a write access to the container. + </p> +<p> + Other functions, like checking if an object is already inserted in a container + using the <code class="computeroutput"><span class="identifier">is_linked</span><span class="special">()</span></code> + member of safe hooks, constitute read access on the container without having + a reference to it, so no other thread should have write access (direct or indirect) + to that container. + </p> +<p> + Since the same object can be inserted in several containers at the same time + using different hooks, the thread safety of <span class="bold"><strong>Boost.Intrusive</strong></span> + is related to the containers and also to the object whose lifetime is manually + managed by the user. + </p> +<p> + As we can see, the analysis of the thread-safety of a program using <span class="bold"><strong>Boost.Intrusive</strong></span> is harder than with non-intrusive containers. + </p> +<p> + To analyze the thread safety, consider the following points: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + The auto-unlink hook's destructor and <code class="computeroutput"><span class="identifier">unlink</span><span class="special">()</span></code> functions modify the container indirectly. + </li> +<li class="listitem"> + The safe mode and auto-unlink hooks' <code class="computeroutput"><span class="identifier">is_linked</span><span class="special">()</span></code> functions are a read access to the container. + </li> +<li class="listitem"> + Inserting an object in containers that will be modified by different threads + has no thread safety guarantee, although in most platforms it will be thread-safe + without locking. + </li> +</ul></div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="value_traits.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="obtaining_same_type_reducing_space.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/treap_set_multiset.html b/doc/html/intrusive/treap_set_multiset.html new file mode 100755 index 0000000000..9b2fb8f4b1 --- /dev/null +++ b/doc/html/intrusive/treap_set_multiset.html @@ -0,0 +1,370 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Intrusive treap based associative containers: treap_set, treap_multiset and treap</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="sg_set_multiset.html" title="Intrusive scapegoat tree based associative containers: sg_set, sg_multiset and sgtree"> +<link rel="next" href="advanced_lookups_insertions.html" title="Advanced lookup and insertion functions for associative containers"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="sg_set_multiset.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="advanced_lookups_insertions.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.treap_set_multiset"></a><a class="link" href="treap_set_multiset.html" title="Intrusive treap based associative containers: treap_set, treap_multiset and treap">Intrusive treap based associative + containers: treap_set, treap_multiset and treap</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="treap_set_multiset.html#intrusive.treap_set_multiset.treap_set_multiset_hooks">Using + binary search tree hooks: bs_set_base_hook and bs_set_member_hook</a></span></dt> +<dt><span class="section"><a href="treap_set_multiset.html#intrusive.treap_set_multiset.treap_set_multiset_containers">treap_set, + treap_multiset and treap containers</a></span></dt> +<dt><span class="section"><a href="treap_set_multiset.html#intrusive.treap_set_multiset.treap_set_exceptions">Exception + safety of treap-based intrusive containers</a></span></dt> +<dt><span class="section"><a href="treap_set_multiset.html#intrusive.treap_set_multiset.treap_set_multiset_example">Example</a></span></dt> +</dl></div> +<p> + The name <span class="emphasis"><em>treap</em></span> is a mixture of <span class="emphasis"><em>tree</em></span> + and <span class="emphasis"><em>heap</em></span> indicating that Treaps exhibit the properties + of both binary search trees and heaps. A treap is a binary search tree that + orders the nodes by a key but also by a priority attribute. The nodes are ordered + so that the keys form a binary search tree and the priorities obey the max + heap order property. + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + If v is a left descendant of u, then key[v] < key[u]; + </li> +<li class="listitem"> + If v is a right descendant of u, then key[v] > key[u]; + </li> +<li class="listitem"> + If v is a child of u, then priority[v] <= priority[u]; + </li> +</ul></div> +<p> + If priorities are non-random, the tree will usually be unbalanced; this worse + theoretical average-case behavior may be outweighed by better expected-case + behavior, as the most important items will be near the root. This means most + important objects will be retrieved faster than less important items and for + items keys with equal keys most important objects will be found first. These + properties are important for some applications. + </p> +<p> + The priority comparison will be provided just like the key comparison, via + a function object that will be stored in the intrusive container. This means + that the priority can be stored in the value to be introduced in the treap + or computed on flight (via hashing or similar). + </p> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> offers 3 containers based + on treaps: <code class="computeroutput"><a class="link" href="../boost/intrusive/treap_set.html" title="Class template treap_set">treap_set</a></code>, + <code class="computeroutput"><a class="link" href="../boost/intrusive/treap_multiset.html" title="Class template treap_multiset">treap_multiset</a></code> + and <code class="computeroutput"><a class="link" href="../boost/intrusive/treap.html" title="Class template treap">treap</a></code>. The first two + are similar to <code class="computeroutput"><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a></code> or <code class="computeroutput"><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a></code> and the latter is a generalization + that offers functions both to insert unique and multiple keys. + </p> +<p> + The memory overhead of these containers with Boost.Intrusive hooks is 3 pointers. + </p> +<p> + An empty, <code class="computeroutput"><a class="link" href="../boost/intrusive/treap_set.html" title="Class template treap_set">treap_set</a></code>, + <code class="computeroutput"><a class="link" href="../boost/intrusive/treap_multiset.html" title="Class template treap_multiset">treap_multiset</a></code> + or <code class="computeroutput"><a class="link" href="../boost/intrusive/treap.html" title="Class template treap">treap</a></code> has also the + size of 3 pointers and an integer (supposing empty function objects for key + and priority comparison and constant-time size). + </p> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.treap_set_multiset.treap_set_multiset_hooks"></a><a class="link" href="treap_set_multiset.html#intrusive.treap_set_multiset.treap_set_multiset_hooks" title="Using binary search tree hooks: bs_set_base_hook and bs_set_member_hook">Using + binary search tree hooks: bs_set_base_hook and bs_set_member_hook</a> +</h3></div></div></div> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/treap_set.html" title="Class template treap_set">treap_set</a></code>, <code class="computeroutput"><a class="link" href="../boost/intrusive/treap_multiset.html" title="Class template treap_multiset">treap_multiset</a></code> and <code class="computeroutput"><a class="link" href="../boost/intrusive/treap.html" title="Class template treap">treap</a></code> don't use their own hooks + but plain binary search tree hooks. This has many advantages since binary + search tree hooks can also be used to insert values in splay containers and + scapegoat trees. + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">bs_set_base_hook</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <code class="computeroutput"><a class="link" href="../boost/intrusive/bs_set_base_hook.html" title="Class template bs_set_base_hook">bs_set_base_hook</a></code>: + the user class derives publicly from this class to make it compatible + with scapegoat tree based containers. + </li></ul></div> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">bs_set_member_hook</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <code class="computeroutput"><a class="link" href="../boost/intrusive/set_member_hook.html" title="Class template set_member_hook">set_member_hook</a></code>: + the user class contains a public member of this class to make it compatible + with scapegoat tree based containers. + </li></ul></div> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/bs_set_base_hook.html" title="Class template bs_set_base_hook">bs_set_base_hook</a></code> + and <code class="computeroutput"><a class="link" href="../boost/intrusive/bs_set_member_hook.html" title="Class template bs_set_member_hook">bs_set_member_hook</a></code> + receive the same options explained in the section <a class="link" href="usage.html" title="How to use Boost.Intrusive">How + to use Boost.Intrusive</a>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">tag</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Tag</span><span class="special">></span></code></strong></span> + (for base hooks only): This argument serves as a tag, so you can derive + from more than one base hook. Default: <code class="computeroutput"><span class="identifier">tag</span><span class="special"><</span><span class="identifier">default_tag</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">link_mode_type</span> + <span class="identifier">LinkMode</span><span class="special">></span></code></strong></span>: + The linking policy. Default: <code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">safe_link</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">void_pointer</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">VoidPointer</span><span class="special">></span></code></strong></span>: + The pointer type to be used internally in the hook and propagated to + the container. Default: <code class="computeroutput"><span class="identifier">void_pointer</span><span class="special"><</span><span class="keyword">void</span><span class="special">*></span></code>. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.treap_set_multiset.treap_set_multiset_containers"></a><a class="link" href="treap_set_multiset.html#intrusive.treap_set_multiset.treap_set_multiset_containers" title="treap_set, treap_multiset and treap containers">treap_set, + treap_multiset and treap containers</a> +</h3></div></div></div> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">treap_set</span><span class="special">;</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">treap_multiset</span><span class="special">;</span> + +<span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">treap</span><span class="special">;</span> +</pre> +<p> + These containers receive the same options explained in the section <a class="link" href="usage.html" title="How to use Boost.Intrusive">How to use Boost.Intrusive</a>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">base_hook</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Hook</span><span class="special">></span></code></strong></span> + / <span class="bold"><strong><code class="computeroutput"><span class="identifier">member_hook</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Hook</span><span class="special">,</span> <span class="identifier">Hook</span> <span class="identifier">T</span><span class="special">::*</span> <span class="identifier">PtrToMember</span><span class="special">></span></code></strong></span> + / <span class="bold"><strong><code class="computeroutput"><span class="identifier">value_traits</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">ValueTraits</span><span class="special">></span></code></strong></span>: + To specify the hook type or value traits used to configure the container. + (To learn about value traits go to the section <a class="link" href="value_traits.html" title="Containers with custom ValueTraits">Containers + with custom ValueTraits</a>.) + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + To activate the constant-time <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code> operation. Default: <code class="computeroutput"><span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">true</span><span class="special">></span></code> + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">size_type</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + To specify the type that will be used to store the size of the container. + Default: <code class="computeroutput"><span class="identifier">size_type</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">></span></code> + </li> +</ul></div> +<p> + And they also can receive additional options: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">compare</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Compare</span><span class="special">></span></code></strong></span>: + Comparison function for the objects to be inserted in containers. The + comparison functor must induce a strict weak ordering. Default: <code class="computeroutput"><span class="identifier">compare</span><span class="special"><</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">less</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="special">></span></code> + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">priority</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">PriorityCompare</span><span class="special">></span></code></strong></span>: + Priority Comparison function for the objects to be inserted in containers. + The comparison functor must induce a strict weak ordering. Default: + <code class="computeroutput"><span class="identifier">priority</span><span class="special"><</span> + <span class="identifier">priority_compare</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="special">></span></code> + </li> +</ul></div> +<p> + The default <code class="computeroutput"><span class="identifier">priority_compare</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code> + object function will call an unqualified function <code class="computeroutput"><span class="identifier">priority_order</span></code> + passing two constant <code class="computeroutput"><span class="identifier">T</span></code> references + as arguments and should return true if the first argument has higher priority + (it will be searched faster), inducing strict weak ordering. The function + will be found using ADL lookup so that the user just needs to define a <code class="computeroutput"><span class="identifier">priority_order</span></code> function in the same namespace + as his class: + </p> +<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">MyType</span> +<span class="special">{</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="identifier">priority_order</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyType</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyType</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{...}</span> +<span class="special">};</span> +</pre> +<p> + or + </p> +<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">mytype</span> <span class="special">{</span> + +<span class="keyword">struct</span> <span class="identifier">MyType</span><span class="special">{</span> <span class="special">...</span> <span class="special">};</span> + +<span class="keyword">bool</span> <span class="identifier">priority_order</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyType</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyType</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> +<span class="special">{...}</span> + +<span class="special">}</span> <span class="comment">//namespace mytype {</span> +</pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.treap_set_multiset.treap_set_exceptions"></a><a class="link" href="treap_set_multiset.html#intrusive.treap_set_multiset.treap_set_exceptions" title="Exception safety of treap-based intrusive containers">Exception + safety of treap-based intrusive containers</a> +</h3></div></div></div> +<p> + In general, intrusive containers offer strong safety guarantees, but treap + containers must deal with two possibly throwing functors (one for value ordering, + another for priority ordering). Moreover, treap erasure operations require + rotations based on the priority order function and this issue degrades usual + <code class="computeroutput"><span class="identifier">erase</span><span class="special">(</span><span class="identifier">const_iterator</span><span class="special">)</span></code> + no-throw guarantee. However, intrusive offers the strongest possible behaviour + in these situations. In summary: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + If the priority order functor does not throw, treap-based containers, + offer exactly the same guarantees as other tree-based containers. + </li> +<li class="listitem"> + If the priority order functor throws, treap-based containers offer strong + guarantee. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.treap_set_multiset.treap_set_multiset_example"></a><a class="link" href="treap_set_multiset.html#intrusive.treap_set_multiset.treap_set_multiset_example" title="Example">Example</a> +</h3></div></div></div> +<p> + Now let's see a small example using both hooks and <code class="computeroutput"><a class="link" href="../boost/intrusive/treap_set.html" title="Class template treap_set">treap_set</a></code>/ + <code class="computeroutput"><a class="link" href="../boost/intrusive/treap_multiset.html" title="Class template treap_multiset">treap_multiset</a></code> + containers: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">treap_set</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cassert</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="keyword">class</span> <span class="identifier">MyClass</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">bs_set_base_hook</span><span class="special"><></span> <span class="comment">//This is a base hook</span> +<span class="special">{</span> + <span class="keyword">int</span> <span class="identifier">int_</span><span class="special">;</span> + <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">prio_</span><span class="special">;</span> + + <span class="keyword">public</span><span class="special">:</span> + <span class="comment">//This is a member hook</span> + <span class="identifier">bs_set_member_hook</span><span class="special"><></span> <span class="identifier">member_hook_</span><span class="special">;</span> + + <span class="identifier">MyClass</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">prio</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">int_</span><span class="special">(</span><span class="identifier">i</span><span class="special">),</span> <span class="identifier">prio_</span><span class="special">(</span><span class="identifier">prio</span><span class="special">)</span> + <span class="special">{}</span> + + <span class="keyword">unsigned</span> <span class="keyword">int</span> <span class="identifier">get_priority</span><span class="special">()</span> <span class="keyword">const</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="keyword">this</span><span class="special">-></span><span class="identifier">prio_</span><span class="special">;</span> <span class="special">}</span> + + <span class="comment">//Less and greater operators</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special"><</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">int_</span> <span class="special"><</span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">></span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">int_</span> <span class="special">></span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> + <span class="comment">//Default priority compare</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="identifier">priority_order</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">prio_</span> <span class="special"><</span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">prio_</span><span class="special">;</span> <span class="special">}</span> <span class="comment">//Lower value means higher priority</span> + <span class="comment">//Inverse priority compare</span> + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="identifier">priority_inverse_order</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">prio_</span> <span class="special">></span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">prio_</span><span class="special">;</span> <span class="special">}</span> <span class="comment">//Higher value means higher priority</span> +<span class="special">};</span> + +<span class="keyword">struct</span> <span class="identifier">inverse_priority</span> +<span class="special">{</span> + <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">()(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> <span class="keyword">const</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">priority_inverse_order</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">);</span> <span class="special">}</span> +<span class="special">};</span> + + +<span class="comment">//Define an treap_set using the base hook that will store values in reverse order</span> +<span class="keyword">typedef</span> <span class="identifier">treap_set</span><span class="special"><</span> <span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">compare</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">greater</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="special">></span> <span class="special">></span> <span class="identifier">BaseSet</span><span class="special">;</span> + +<span class="comment">//Define an multiset using the member hook that will store</span> +<span class="keyword">typedef</span> <span class="identifier">member_hook</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">bs_set_member_hook</span><span class="special"><>,</span> <span class="special">&</span><span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">member_hook_</span><span class="special">></span> <span class="identifier">MemberOption</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">treap_multiset</span> + <span class="special"><</span> <span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">MemberOption</span><span class="special">,</span> <span class="identifier">priority</span><span class="special"><</span><span class="identifier">inverse_priority</span><span class="special">></span> <span class="special">></span> <span class="identifier">MemberMultiset</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">iterator</span> <span class="identifier">VectIt</span><span class="special">;</span> + + <span class="comment">//Create several MyClass objects, each one with a different value</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">values</span><span class="special">;</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">100</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">values</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">MyClass</span><span class="special">(</span><span class="identifier">i</span><span class="special">,</span> <span class="special">(</span><span class="identifier">i</span> <span class="special">%</span> <span class="number">10</span><span class="special">)));</span> + + <span class="identifier">BaseSet</span> <span class="identifier">baseset</span><span class="special">;</span> + <span class="identifier">MemberMultiset</span> <span class="identifier">membermultiset</span><span class="special">;</span> + + <span class="comment">//Now insert them in the sets</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">){</span> + <span class="identifier">baseset</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + <span class="identifier">membermultiset</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + <span class="special">}</span> + + <span class="comment">//Now test treap_sets</span> + <span class="special">{</span> + <span class="identifier">BaseSet</span><span class="special">::</span><span class="identifier">reverse_iterator</span> <span class="identifier">rbit</span><span class="special">(</span><span class="identifier">baseset</span><span class="special">.</span><span class="identifier">rbegin</span><span class="special">()),</span> <span class="identifier">rbitend</span><span class="special">(</span><span class="identifier">baseset</span><span class="special">.</span><span class="identifier">rend</span><span class="special">());</span> + <span class="identifier">MemberMultiset</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">mit</span><span class="special">(</span><span class="identifier">membermultiset</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">mitend</span><span class="special">(</span><span class="identifier">membermultiset</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + <span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + + <span class="comment">//Test the objects inserted in the base hook treap_set</span> + <span class="keyword">for</span><span class="special">(;</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">rbit</span><span class="special">)</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">rbit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + + <span class="comment">//Test the objects inserted in the member hook treap_set</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">it</span> <span class="special">=</span> <span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">();</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">mit</span><span class="special">)</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">mit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + + <span class="comment">//Test priority order</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">100</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">){</span> + <span class="keyword">if</span><span class="special">(</span><span class="identifier">baseset</span><span class="special">.</span><span class="identifier">top</span><span class="special">()-></span><span class="identifier">get_priority</span><span class="special">()</span> <span class="special">!=</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="keyword">unsigned</span> <span class="keyword">int</span><span class="special">>(</span><span class="identifier">i</span><span class="special">/</span><span class="number">10</span><span class="special">))</span> + <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + <span class="keyword">if</span><span class="special">(</span><span class="identifier">membermultiset</span><span class="special">.</span><span class="identifier">top</span><span class="special">()-></span><span class="identifier">get_priority</span><span class="special">()</span> <span class="special">!=</span> <span class="number">9u</span> <span class="special">-</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="keyword">unsigned</span> <span class="keyword">int</span><span class="special">>(</span><span class="identifier">i</span><span class="special">/</span><span class="number">10</span><span class="special">))</span> + <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + <span class="identifier">baseset</span><span class="special">.</span><span class="identifier">erase</span><span class="special">(</span><span class="identifier">baseset</span><span class="special">.</span><span class="identifier">top</span><span class="special">());</span> + <span class="identifier">membermultiset</span><span class="special">.</span><span class="identifier">erase</span><span class="special">(</span><span class="identifier">membermultiset</span><span class="special">.</span><span class="identifier">top</span><span class="special">());</span> + <span class="special">}</span> + <span class="special">}</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="sg_set_multiset.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="advanced_lookups_insertions.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/unordered_set_unordered_multiset.html b/doc/html/intrusive/unordered_set_unordered_multiset.html new file mode 100755 index 0000000000..bb7f299148 --- /dev/null +++ b/doc/html/intrusive/unordered_set_unordered_multiset.html @@ -0,0 +1,513 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Semi-Intrusive unordered associative containers: unordered_set, unordered_multiset</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="set_multiset.html" title="Intrusive associative containers: set, multiset, rbtree"> +<link rel="next" href="splay_set_multiset.html" title="Intrusive splay tree based associative containers: splay_set, splay_multiset and , splay_tree"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="set_multiset.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="splay_set_multiset.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.unordered_set_unordered_multiset"></a><a class="link" href="unordered_set_unordered_multiset.html" title="Semi-Intrusive unordered associative containers: unordered_set, unordered_multiset">Semi-Intrusive + unordered associative containers: unordered_set, unordered_multiset</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="unordered_set_unordered_multiset.html#intrusive.unordered_set_unordered_multiset.unordered_set_unordered_multiset_performance">unordered_set + and unordered_multiset performance notes</a></span></dt> +<dt><span class="section"><a href="unordered_set_unordered_multiset.html#intrusive.unordered_set_unordered_multiset.unordered_set_unordered_multiset_hooks">unordered_set + and unordered_multiset hooks</a></span></dt> +<dt><span class="section"><a href="unordered_set_unordered_multiset.html#intrusive.unordered_set_unordered_multiset.unordered_set_unordered_multiset_containers">unordered_set + and unordered_multiset containers</a></span></dt> +<dt><span class="section"><a href="unordered_set_unordered_multiset.html#intrusive.unordered_set_unordered_multiset.unordered_set_unordered_multiset_example">Example</a></span></dt> +<dt><span class="section"><a href="unordered_set_unordered_multiset.html#intrusive.unordered_set_unordered_multiset.custom_bucket_traits">Custom + bucket traits</a></span></dt> +</dl></div> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> also offers hashed containers + that can be very useful to implement fast-lookup containers. These containers + (<code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set.html" title="Class template unordered_set">unordered_set</a></code> + and <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_multiset.html" title="Class template unordered_multiset">unordered_multiset</a></code>) + are semi-intrusive containers: they need additional memory apart from the hook + stored in the <code class="computeroutput"><span class="identifier">value_type</span></code>. This + additional memory must be passed in the constructor of the container. + </p> +<p> + Unlike C++ TR1 unordered associative containers (which are also hashed containers), + the contents of these semi-intrusive containers are not rehashed to maintain + a load factor: that would require memory management and intrusive containers + don't implement any memory management at all. However, the user can request + an explicit rehashing passing a new bucket array. This also offers an additional + guarantee over TR1 unordered associative containers: <span class="bold"><strong>iterators + are not invalidated when inserting an element</strong></span> in the container. + </p> +<p> + As with TR1 unordered associative containers, rehashing invalidates iterators, + changes ordering between elements and changes which buckets elements appear + in, but does not invalidate pointers or references to elements. + </p> +<p> + Apart from expected hash and equality function objects, <span class="bold"><strong>Boost.Intrusive</strong></span> + unordered associative containers' constructors take an argument specifying + an auxiliary bucket vector to be used by the container. + </p> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.unordered_set_unordered_multiset.unordered_set_unordered_multiset_performance"></a><a class="link" href="unordered_set_unordered_multiset.html#intrusive.unordered_set_unordered_multiset.unordered_set_unordered_multiset_performance" title="unordered_set and unordered_multiset performance notes">unordered_set + and unordered_multiset performance notes</a> +</h3></div></div></div> +<p> + The size overhead for a hashed container is moderate: 1 pointer per value + plus a bucket array per container. The size of an element of the bucket array + is usually one pointer. To obtain a good performance hashed container, the + bucket length is usually the same as the number of elements that the container + contains, so a well-balanced hashed container (<code class="computeroutput"><span class="identifier">bucket_count</span><span class="special">()</span></code> is equal to <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code> ) will have an equivalent overhead of two + pointers per element. + </p> +<p> + An empty, non constant-time size <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set.html" title="Class template unordered_set">unordered_set</a></code> + or <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_multiset.html" title="Class template unordered_multiset">unordered_multiset</a></code> + has also the size of <code class="computeroutput"><span class="identifier">bucket_count</span><span class="special">()</span></code> pointers. + </p> +<p> + Insertions, erasures, and searches, have amortized constant-time complexity + in hashed containers. However, some worst-case guarantees are linear. See + <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set.html" title="Class template unordered_set">unordered_set</a></code> + or <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_multiset.html" title="Class template unordered_multiset">unordered_multiset</a></code> + for complexity guarantees of each operation. + </p> +<p> + <span class="bold"><strong>Be careful with non constant-time size hashed containers</strong></span>: + some operations, like <code class="computeroutput"><span class="identifier">empty</span><span class="special">()</span></code>, have linear complexity, unlike other + <span class="bold"><strong>Boost.Intrusive</strong></span> containers. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.unordered_set_unordered_multiset.unordered_set_unordered_multiset_hooks"></a><a class="link" href="unordered_set_unordered_multiset.html#intrusive.unordered_set_unordered_multiset.unordered_set_unordered_multiset_hooks" title="unordered_set and unordered_multiset hooks">unordered_set + and unordered_multiset hooks</a> +</h3></div></div></div> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set.html" title="Class template unordered_set">unordered_set</a></code> + and <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_multiset.html" title="Class template unordered_multiset">unordered_multiset</a></code> + share the same hooks. This is an advantage, because the same user type can + be inserted first in a <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_multiset.html" title="Class template unordered_multiset">unordered_multiset</a></code> + and after that in <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set.html" title="Class template unordered_set">unordered_set</a></code> + without changing the definition of the user class. + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">unordered_set_base_hook</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set_base_hook.html" title="Class template unordered_set_base_hook">unordered_set_base_hook</a></code>: + the user class derives publicly from <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set_base_hook.html" title="Class template unordered_set_base_hook">unordered_set_base_hook</a></code> + to make it <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set.html" title="Class template unordered_set">unordered_set</a></code>/<code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_multiset.html" title="Class template unordered_multiset">unordered_multiset</a></code>-compatible. + </li></ul></div> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">unordered_set_member_hook</span><span class="special">;</span> +</pre> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"> + <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set_member_hook.html" title="Class template unordered_set_member_hook">unordered_set_member_hook</a></code>: + the user class contains a public <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set_member_hook.html" title="Class template unordered_set_member_hook">unordered_set_member_hook</a></code> + to make it <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set.html" title="Class template unordered_set">unordered_set</a></code>/<code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_multiset.html" title="Class template unordered_multiset">unordered_multiset</a></code>-compatible. + </li></ul></div> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set_base_hook.html" title="Class template unordered_set_base_hook">unordered_set_base_hook</a></code> + and <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set_member_hook.html" title="Class template unordered_set_member_hook">unordered_set_member_hook</a></code> + receive the same options explained in the section <a class="link" href="usage.html" title="How to use Boost.Intrusive">How + to use Boost.Intrusive</a>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">tag</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Tag</span><span class="special">></span></code></strong></span> + (for base hooks only): This argument serves as a tag, so you can derive + from more than one base hook. Default: <code class="computeroutput"><span class="identifier">tag</span><span class="special"><</span><span class="identifier">default_tag</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">link_mode_type</span> + <span class="identifier">LinkMode</span><span class="special">></span></code></strong></span>: + The linking policy. Default: <code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">safe_link</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">void_pointer</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">VoidPointer</span><span class="special">></span></code></strong></span>: + The pointer type to be used internally in the hook and propagated to + the container. Default: <code class="computeroutput"><span class="identifier">void_pointer</span><span class="special"><</span><span class="keyword">void</span><span class="special">*></span></code>. + </li> +</ul></div> +<p> + Apart from them, these hooks offer additional options: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">store_hash</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + This option reserves additional space in the hook to store the hash value + of the object once it's introduced in the container. When this option + is used, the unordered container will store the calculated hash value + in the hook and rehashing operations won't need to recalculate the hash + of the value. This option will improve the performance of unordered containers + when rehashing is frequent or hashing the value is a slow operation. + Default: <code class="computeroutput"><span class="identifier">store_hash</span><span class="special"><</span><span class="keyword">false</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">optimize_multikey</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + This option reserves additional space in the hook that will be used to + group equal elements in unordered multisets, improving significantly + the performance when many equal values are inserted in these containers. + Default: <code class="computeroutput"><span class="identifier">optimize_multikey</span><span class="special"><</span><span class="keyword">false</span><span class="special">></span></code>. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.unordered_set_unordered_multiset.unordered_set_unordered_multiset_containers"></a><a class="link" href="unordered_set_unordered_multiset.html#intrusive.unordered_set_unordered_multiset.unordered_set_unordered_multiset_containers" title="unordered_set and unordered_multiset containers">unordered_set + and unordered_multiset containers</a> +</h3></div></div></div> +<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">unordered_set</span><span class="special">;</span> + +<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">unordered_multiset</span><span class="special">;</span> +</pre> +<p> + As mentioned, unordered containers need an auxiliary array to work. <span class="bold"><strong>Boost.Intrusive</strong></span> unordered containers receive this + auxiliary array packed in a type called <code class="computeroutput"><span class="identifier">bucket_traits</span></code> + (which can be also customized by a container option). All unordered containers + receive a <code class="computeroutput"><span class="identifier">bucket_traits</span></code> object + in their constructors. The default <code class="computeroutput"><span class="identifier">bucket_traits</span></code> + class is initialized with a pointer to an array of buckets and its size: + </p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">unordered_set</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="keyword">struct</span> <span class="identifier">MyClass</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">unordered_set_base_hook</span><span class="special"><></span> +<span class="special">{};</span> + +<span class="keyword">typedef</span> <span class="identifier">unordered_set</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">bucket_type</span> <span class="identifier">bucket_type</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">unordered_set</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">bucket_traits</span> <span class="identifier">bucket_traits</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="identifier">bucket_type</span> <span class="identifier">buckets</span><span class="special">[</span><span class="number">100</span><span class="special">];</span> + <span class="identifier">unordered_set</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">uset</span><span class="special">(</span><span class="identifier">bucket_traits</span><span class="special">(</span><span class="identifier">buckets</span><span class="special">,</span> <span class="number">100</span><span class="special">));</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + Each hashed container needs <span class="bold"><strong>its own bucket traits</strong></span>, + that is, <span class="bold"><strong>its own bucket vector</strong></span>. Two hashed + containers <span class="bold"><strong>can't</strong></span> share the same <code class="computeroutput"><span class="identifier">bucket_type</span></code> elements. The bucket array + <span class="bold"><strong>must</strong></span> be destroyed <span class="bold"><strong>after</strong></span> + the container using it is destroyed, otherwise, the result is undefined. + </p> +<p> + <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set.html" title="Class template unordered_set">unordered_set</a></code> + and <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_multiset.html" title="Class template unordered_multiset">unordered_multiset</a></code> + receive the same options explained in the section <a class="link" href="usage.html" title="How to use Boost.Intrusive">How + to use Boost.Intrusive</a>: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">base_hook</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Hook</span><span class="special">></span></code></strong></span> + / <span class="bold"><strong><code class="computeroutput"><span class="identifier">member_hook</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Hook</span><span class="special">,</span> <span class="identifier">Hook</span> <span class="identifier">T</span><span class="special">::*</span> <span class="identifier">PtrToMember</span><span class="special">></span></code></strong></span> + / <span class="bold"><strong><code class="computeroutput"><span class="identifier">value_traits</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">ValueTraits</span><span class="special">></span></code></strong></span>: + To specify the hook type or value traits used to configure the container. + (To learn about value traits go to the section <a class="link" href="value_traits.html" title="Containers with custom ValueTraits">Containers + with custom ValueTraits</a>.) + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + To activate the constant-time <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code> operation. Default: <code class="computeroutput"><span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">true</span><span class="special">></span></code> + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">size_type</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + To specify the type that will be used to store the size of the container. + Default: <code class="computeroutput"><span class="identifier">size_type</span><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">></span></code> + </li> +</ul></div> +<p> + And they also can receive additional options: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">equal</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Equal</span><span class="special">></span></code></strong></span>: + Equality function for the objects to be inserted in containers. Default: + <code class="computeroutput"><span class="identifier">equal</span><span class="special"><</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">equal_to</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="special">></span></code> + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">hash</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Hash</span><span class="special">></span></code></strong></span>: + Hash function to be used in the container. Default: <code class="computeroutput"><span class="identifier">hash</span><span class="special"><</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">hash</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> <span class="special">></span></code> + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">bucket_traits</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">BucketTraits</span><span class="special">></span></code></strong></span>: + A type that wraps the bucket vector to be used by the unordered container. + Default: a type initialized by the address and size of a bucket array + and stores both variables internally. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">power_2_buckets</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + The user guarantees that only bucket arrays with power of two length + will be used. The container will then use masks instead of modulo operations + to obtain the bucket number from the hash value. Masks are faster than + modulo operations and for some applications modulo operations can impose + a considerable overhead. In debug mode an assertion will be raised if + the user provides a bucket length that is not power of two. Default: + <code class="computeroutput"><span class="identifier">power_2_buckets</span><span class="special"><</span><span class="keyword">false</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">cache_begin</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + <span class="bold"><strong>Note: this option is not compatible with <code class="computeroutput"><span class="identifier">auto_unlink</span></code> hooks</strong></span>. Due to + its internal structure, finding the first element of an unordered container + (<code class="computeroutput"><span class="identifier">begin</span><span class="special">()</span></code> + operation) is amortized constant-time. It's possible to speed up <code class="computeroutput"><span class="identifier">begin</span><span class="special">()</span></code> + and other operations related to it (like <code class="computeroutput"><span class="identifier">clear</span><span class="special">()</span></code>) if the container caches internally + the position of the first element. This imposes the overhead of one pointer + to the size of the container. Default: <code class="computeroutput"><span class="identifier">cache_begin</span><span class="special"><</span><span class="keyword">false</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">compare_hash</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + <span class="bold"><strong>Note: this option requires <code class="computeroutput"><span class="identifier">store_hash</span><span class="special"><</span><span class="keyword">true</span><span class="special">></span></code> option in the hook</strong></span>. When + the comparison function is expensive, (e.g. strings with a long common + predicate) sometimes (specially when the load factor is high or we have + many equivalent elements in an <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_multiset.html" title="Class template unordered_multiset">unordered_multiset</a></code> + and no <code class="computeroutput"><span class="identifier">optimize_multikey</span><span class="special"><></span></code> is activated in the hook) the + equality function is a performance problem. Two equal values must have + equal hashes, so comparing the hash values of two elements before using + the comparison functor can speed up some implementations. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">incremental</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + Activates incremental hashing (also known as Linear Hashing). This option + implies <code class="computeroutput"><span class="identifier">power_2_buckets</span><span class="special"><</span><span class="keyword">true</span><span class="special">></span></code> and the container will require power + of two buckets. For more information on incremental hashing, see <a href="http://en.wikipedia.org/wiki/Linear_hashing" target="_top"><code class="computeroutput"><span class="identifier">Linear</span> + <span class="identifier">hash</span></code> on Wikipedia</a> Default: + <code class="computeroutput"><span class="identifier">incremental</span><span class="special"><</span><span class="keyword">false</span><span class="special">></span></code> + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.unordered_set_unordered_multiset.unordered_set_unordered_multiset_example"></a><a class="link" href="unordered_set_unordered_multiset.html#intrusive.unordered_set_unordered_multiset.unordered_set_unordered_multiset_example" title="Example">Example</a> +</h3></div></div></div> +<p> + Now let's see a small example using both hooks and both containers: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">unordered_set</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">algorithm</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">functional</span><span class="special">/</span><span class="identifier">hash</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="keyword">class</span> <span class="identifier">MyClass</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">unordered_set_base_hook</span><span class="special"><></span> +<span class="special">{</span> <span class="comment">//This is a derivation hook</span> + <span class="keyword">int</span> <span class="identifier">int_</span><span class="special">;</span> + + <span class="keyword">public</span><span class="special">:</span> + <span class="identifier">unordered_set_member_hook</span><span class="special"><></span> <span class="identifier">member_hook_</span><span class="special">;</span> <span class="comment">//This is a member hook</span> + + <span class="identifier">MyClass</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">)</span> + <span class="special">:</span> <span class="identifier">int_</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> + <span class="special">{}</span> + + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">==</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">b</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">a</span><span class="special">.</span><span class="identifier">int_</span> <span class="special">==</span> <span class="identifier">b</span><span class="special">.</span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> + + <span class="keyword">friend</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">hash_value</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">value</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span><span class="special">(</span><span class="identifier">value</span><span class="special">.</span><span class="identifier">int_</span><span class="special">);</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="comment">//Define an unordered_set that will store MyClass objects using the base hook</span> +<span class="keyword">typedef</span> <span class="identifier">unordered_set</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">BaseSet</span><span class="special">;</span> + +<span class="comment">//Define an unordered_multiset that will store MyClass using the member hook</span> +<span class="keyword">typedef</span> <span class="identifier">member_hook</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">unordered_set_member_hook</span><span class="special"><>,</span> <span class="special">&</span><span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">member_hook_</span><span class="special">></span> + <span class="identifier">MemberOption</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">unordered_multiset</span><span class="special"><</span> <span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">MemberOption</span><span class="special">></span> <span class="identifier">MemberMultiSet</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">iterator</span> <span class="identifier">VectIt</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">reverse_iterator</span> <span class="identifier">VectRit</span><span class="special">;</span> + + <span class="comment">//Create a vector with 100 different MyClass objects</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">values</span><span class="special">;</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">100</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">values</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">MyClass</span><span class="special">(</span><span class="identifier">i</span><span class="special">));</span> + + <span class="comment">//Create a copy of the vector</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">values2</span><span class="special">(</span><span class="identifier">values</span><span class="special">);</span> + + <span class="comment">//Create a bucket array for base_set</span> + <span class="identifier">BaseSet</span><span class="special">::</span><span class="identifier">bucket_type</span> <span class="identifier">base_buckets</span><span class="special">[</span><span class="number">100</span><span class="special">];</span> + + <span class="comment">//Create a bucket array for member_multi_set</span> + <span class="identifier">MemberMultiSet</span><span class="special">::</span><span class="identifier">bucket_type</span> <span class="identifier">member_buckets</span><span class="special">[</span><span class="number">200</span><span class="special">];</span> + + <span class="comment">//Create unordered containers taking buckets as arguments</span> + <span class="identifier">BaseSet</span> <span class="identifier">base_set</span><span class="special">(</span><span class="identifier">BaseSet</span><span class="special">::</span><span class="identifier">bucket_traits</span><span class="special">(</span><span class="identifier">base_buckets</span><span class="special">,</span> <span class="number">100</span><span class="special">));</span> + <span class="identifier">MemberMultiSet</span> <span class="identifier">member_multi_set</span> + <span class="special">(</span><span class="identifier">MemberMultiSet</span><span class="special">::</span><span class="identifier">bucket_traits</span><span class="special">(</span><span class="identifier">member_buckets</span><span class="special">,</span> <span class="number">200</span><span class="special">));</span> + + <span class="comment">//Now insert values's elements in the unordered_set</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">)</span> + <span class="identifier">base_set</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + + <span class="comment">//Now insert values's and values2's elements in the unordered_multiset</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">()),</span> + <span class="identifier">it2</span><span class="special">(</span><span class="identifier">values2</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span><span class="identifier">itend2</span><span class="special">(</span><span class="identifier">values2</span><span class="special">.</span><span class="identifier">end</span><span class="special">())</span> + <span class="special">;</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">it2</span><span class="special">){</span> + <span class="identifier">member_multi_set</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + <span class="identifier">member_multi_set</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(*</span><span class="identifier">it2</span><span class="special">);</span> + <span class="special">}</span> + + <span class="comment">//Now find every element</span> + <span class="special">{</span> + <span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + + <span class="keyword">for</span><span class="special">(;</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">){</span> + <span class="comment">//base_set should contain one element for each key</span> + <span class="keyword">if</span><span class="special">(</span><span class="identifier">base_set</span><span class="special">.</span><span class="identifier">count</span><span class="special">(*</span><span class="identifier">it</span><span class="special">)</span> <span class="special">!=</span> <span class="number">1</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + <span class="comment">//member_multi_set should contain two elements for each key</span> + <span class="keyword">if</span><span class="special">(</span><span class="identifier">member_multi_set</span><span class="special">.</span><span class="identifier">count</span><span class="special">(*</span><span class="identifier">it</span><span class="special">)</span> <span class="special">!=</span> <span class="number">2</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + <span class="special">}</span> + <span class="special">}</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.unordered_set_unordered_multiset.custom_bucket_traits"></a><a class="link" href="unordered_set_unordered_multiset.html#intrusive.unordered_set_unordered_multiset.custom_bucket_traits" title="Custom bucket traits">Custom + bucket traits</a> +</h3></div></div></div> +<p> + Instead of using the default <code class="computeroutput"><span class="identifier">bucket_traits</span></code> + class to store the bucket array, a user can define his own class to store + the bucket array using the <span class="bold"><strong><span class="emphasis"><em>bucket_traits<></em></span></strong></span> + option. A user-defined bucket-traits must fulfill the following interface: + </p> +<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">my_bucket_traits</span> +<span class="special">{</span> + <span class="identifier">bucket_ptr</span> <span class="identifier">bucket_begin</span><span class="special">();</span> + <span class="identifier">const_bucket_ptr</span> <span class="identifier">bucket_begin</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">bucket_count</span><span class="special">()</span> <span class="keyword">const</span><span class="special">;</span> +<span class="special">};</span> +</pre> +<p> + The following bucket traits just stores a pointer to the bucket array but + the size is a compile-time constant. Note the use of the auxiliary <code class="computeroutput">unordered_bucket</code> and + <code class="computeroutput">unordered_bucket_ptr</code> + utilities to obtain the type of the bucket and its pointer before defining + the unordered container: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">unordered_set</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">functional</span><span class="special">/</span><span class="identifier">hash</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="comment">//A class to be inserted in an unordered_set</span> +<span class="keyword">class</span> <span class="identifier">MyClass</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">unordered_set_base_hook</span><span class="special"><></span> +<span class="special">{</span> + <span class="keyword">int</span> <span class="identifier">int_</span><span class="special">;</span> + + <span class="keyword">public</span><span class="special">:</span> + <span class="identifier">MyClass</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">int_</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> + <span class="special">{}</span> + + <span class="keyword">friend</span> <span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">==(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">l</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">r</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">l</span><span class="special">.</span><span class="identifier">int_</span> <span class="special">==</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">int_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">friend</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">hash_value</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">MyClass</span> <span class="special">&</span><span class="identifier">v</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">hash_value</span><span class="special">(</span><span class="identifier">v</span><span class="special">.</span><span class="identifier">int_</span><span class="special">);</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="comment">//Define the base hook option</span> +<span class="keyword">typedef</span> <span class="identifier">base_hook</span><span class="special"><</span> <span class="identifier">unordered_set_base_hook</span><span class="special"><></span> <span class="special">></span> <span class="identifier">BaseHookOption</span><span class="special">;</span> + +<span class="comment">//Obtain the types of the bucket and the bucket pointer</span> +<span class="keyword">typedef</span> <span class="identifier">unordered_bucket</span><span class="special"><</span><span class="identifier">BaseHookOption</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">BucketType</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">unordered_bucket_ptr</span><span class="special"><</span><span class="identifier">BaseHookOption</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">BucketPtr</span><span class="special">;</span> + +<span class="comment">//The custom bucket traits.</span> +<span class="keyword">class</span> <span class="identifier">custom_bucket_traits</span> +<span class="special">{</span> + <span class="keyword">public</span><span class="special">:</span> + <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">NumBuckets</span> <span class="special">=</span> <span class="number">100</span><span class="special">;</span> + + <span class="identifier">custom_bucket_traits</span><span class="special">(</span><span class="identifier">BucketPtr</span> <span class="identifier">buckets</span><span class="special">)</span> + <span class="special">:</span> <span class="identifier">buckets_</span><span class="special">(</span><span class="identifier">buckets</span><span class="special">)</span> + <span class="special">{}</span> + + <span class="comment">//Functions to be implemented by custom bucket traits</span> + <span class="identifier">BucketPtr</span> <span class="identifier">bucket_begin</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">buckets_</span><span class="special">;</span> <span class="special">}</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">bucket_count</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">NumBuckets</span><span class="special">;}</span> + + <span class="keyword">private</span><span class="special">:</span> + <span class="identifier">BucketPtr</span> <span class="identifier">buckets_</span><span class="special">;</span> +<span class="special">};</span> + +<span class="comment">//Define the container using the custom bucket traits</span> +<span class="keyword">typedef</span> <span class="identifier">unordered_set</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">bucket_traits</span><span class="special"><</span><span class="identifier">custom_bucket_traits</span><span class="special">></span> <span class="special">></span> <span class="identifier">BucketTraitsUset</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">iterator</span> <span class="identifier">VectIt</span><span class="special">;</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">values</span><span class="special">;</span> + + <span class="comment">//Fill values</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">100</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">values</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">MyClass</span><span class="special">(</span><span class="identifier">i</span><span class="special">));</span> + + <span class="comment">//Now create the bucket array and the custom bucket traits object</span> + <span class="identifier">BucketType</span> <span class="identifier">buckets</span><span class="special">[</span><span class="identifier">custom_bucket_traits</span><span class="special">::</span><span class="identifier">NumBuckets</span><span class="special">];</span> + <span class="identifier">custom_bucket_traits</span> <span class="identifier">btraits</span><span class="special">(</span><span class="identifier">buckets</span><span class="special">);</span> + + <span class="comment">//Now create the unordered set</span> + <span class="identifier">BucketTraitsUset</span> <span class="identifier">uset</span><span class="special">(</span><span class="identifier">btraits</span><span class="special">);</span> + + <span class="comment">//Insert the values in the unordered set</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">)</span> + <span class="identifier">uset</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="set_multiset.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="splay_set_multiset.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/usage.html b/doc/html/intrusive/usage.html new file mode 100755 index 0000000000..82671683f4 --- /dev/null +++ b/doc/html/intrusive/usage.html @@ -0,0 +1,368 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>How to use Boost.Intrusive</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="intrusive_vs_nontrusive.html" title="Intrusive and non-intrusive containers"> +<link rel="next" href="usage_when.html" title="When to use?"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="intrusive_vs_nontrusive.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="usage_when.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.usage"></a><a class="link" href="usage.html" title="How to use Boost.Intrusive">How to use Boost.Intrusive</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="usage.html#intrusive.usage.usage_base_hook">Using base hooks</a></span></dt> +<dt><span class="section"><a href="usage.html#intrusive.usage.usage_member_hook">Using member hooks</a></span></dt> +<dt><span class="section"><a href="usage.html#intrusive.usage.usage_both_hooks">Using both hooks</a></span></dt> +<dt><span class="section"><a href="usage.html#intrusive.usage.usage_lifetime">Object lifetime</a></span></dt> +</dl></div> +<p> + If you plan to insert a class in an intrusive container, you have to make some + decisions influencing the class definition itself. Each class that will be + used in an intrusive container needs some appropriate data members storing + the information needed by the container. We will take a simple intrusive container, + the intrusive list (<code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">boost::intrusive::list</a></code>), + for the following examples, but all <span class="bold"><strong>Boost.Intrusive</strong></span> + containers are very similar. To compile the example using <code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">boost::intrusive::list</a></code>, + just include: + </p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +</pre> +<p> + Every class to be inserted in an intrusive container, needs to contain a hook + that will offer the necessary data and resources to be insertable in the container. + With <span class="bold"><strong>Boost.Intrusive</strong></span> you just choose the hook + to be a public base class or a public member of the class to be inserted. + <span class="bold"><strong>Boost.Intrusive</strong></span> also offers more flexible + hooks for advanced users, as explained in the chapter <a class="link" href="function_hooks.html" title="Using function hooks">Using + function hooks</a>, but usually base or member hooks are good enough for + most users. + </p> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.usage.usage_base_hook"></a><a class="link" href="usage.html#intrusive.usage.usage_base_hook" title="Using base hooks">Using base hooks</a> +</h3></div></div></div> +<p> + For <code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a></code>, you can publicly + derive from <code class="computeroutput"><a class="link" href="../boost/intrusive/list_base_hook.html" title="Class template list_base_hook">list_base_hook</a></code>. + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">list_base_hook</span><span class="special">;</span> +</pre> +<p> + The class can take several options. <span class="bold"><strong>Boost.Intrusive</strong></span> + classes receive arguments in the form <code class="computeroutput"><span class="identifier">option_name</span><span class="special"><</span><span class="identifier">option_value</span><span class="special">></span></code>. You can specify the following options: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">tag</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Tag</span><span class="special">></span></code></strong></span>: + this argument serves as a tag, so you can derive from more than one + <code class="computeroutput"><a class="link" href="../boost/intrusive/list_base_hook.html" title="Class template list_base_hook">list_base_hook</a></code> + and hence put an object in multiple intrusive lists at the same time. + An incomplete type can serve as a tag. If you specify two base hooks, + you <span class="bold"><strong>must</strong></span> specify a different tag for + each one. Example: <code class="computeroutput"><span class="identifier">list_base_hook</span><span class="special"><</span> <span class="identifier">tag</span><span class="special"><</span><span class="identifier">tag1</span><span class="special">></span> <span class="special">></span></code>. + If no tag is specified a default one will be used (more on default tags + later). + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">link_mode_type</span> + <span class="identifier">LinkMode</span><span class="special">></span></code></strong></span>: + The second template argument controls the linking policy. <span class="bold"><strong>Boost.Intrusive</strong></span> + currently supports 3 modes: <code class="computeroutput"><span class="identifier">normal_link</span></code>, + <code class="computeroutput"><span class="identifier">safe_link</span></code> and <code class="computeroutput"><span class="identifier">auto_unlink</span></code>. By default, <code class="computeroutput"><span class="identifier">safe_link</span></code> mode is used. More about + these in sections <a class="link" href="safe_hook.html" title="Safe hooks">Safe hooks</a> + and <a class="link" href="auto_unlink_hooks.html" title="Auto-unlink hooks">Auto-unlink hooks</a>. + Example: <code class="computeroutput"><span class="identifier">list_base_hook</span><span class="special"><</span> <span class="identifier">link_mode</span><span class="special"><</span><span class="identifier">auto_unlink</span><span class="special">></span> <span class="special">></span></code> + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">void_pointer</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">VoidPointer</span><span class="special">></span></code></strong></span>: + this option is the pointer type to be used internally in the hook. The + default value is <code class="computeroutput"><span class="keyword">void</span> <span class="special">*</span></code>, + which means that raw pointers will be used in the hook. More about this + in the section titled <a class="link" href="using_smart_pointers.html" title="Using smart pointers with Boost.Intrusive containers">Using + smart pointers with Boost.Intrusive containers</a>. Example: <code class="computeroutput"><span class="identifier">list_base_hook</span><span class="special"><</span> + <span class="identifier">void_pointer</span><span class="special"><</span> + <span class="identifier">my_smart_ptr</span><span class="special"><</span><span class="keyword">void</span><span class="special">></span> <span class="special">></span></code> + </li> +</ul></div> +<p> + For the following examples, let's forget the options and use the default + values: + </p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="keyword">class</span> <span class="identifier">Foo</span> + <span class="comment">//Base hook with default tag, raw pointers and safe_link mode</span> + <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">list_base_hook</span><span class="special"><></span> +<span class="special">{</span> <span class="comment">/**/</span> <span class="special">};</span> +</pre> +<p> + After that, we can define the intrusive list: + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">list</span><span class="special">;</span> +</pre> +<p> + <code class="computeroutput"><span class="identifier">list</span></code> receives the type to + be inserted in the container (<code class="computeroutput"><span class="identifier">T</span></code>) + as the first parameter and optionally, the user can specify options. We have + 3 option types: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">base_hook</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">Hook</span><span class="special">></span></code></strong></span> + / <span class="bold"><strong><code class="computeroutput"><span class="identifier">member_hook</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Hook</span><span class="special">,</span> <span class="identifier">Hook</span> <span class="identifier">T</span><span class="special">::*</span> <span class="identifier">PtrToMember</span><span class="special">></span></code></strong></span> + / <span class="bold"><strong><code class="computeroutput"><span class="identifier">value_traits</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">ValueTraits</span><span class="special">></span></code></strong></span>: + All these options specify the relationship between the type <code class="computeroutput"><span class="identifier">T</span></code> to be inserted in the list and the + hook (since we can have several hooks in the same <code class="computeroutput"><span class="identifier">T</span></code> + type). <code class="computeroutput"><span class="identifier">member_hook</span></code> will + be explained a bit later and <code class="computeroutput"><span class="identifier">value_traits</span></code> + will be explained in the <a class="link" href="value_traits.html" title="Containers with custom ValueTraits">Containers + with custom ValueTraits</a> section. <span class="bold"><strong>If no option + is specified, the container will be configured to use the base hook with + the default tag</strong></span>. Some options configured for the hook (the + type of the pointers, link mode, etc.) will be propagated to the container. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + Specifies if a constant time <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code> function is demanded for the container. + This will instruct the intrusive container to store an additional member + to keep track of the current size of the container. By default, constant-time + size is activated. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">size_type</span><span class="special"><</span><span class="keyword">bool</span> <span class="identifier">Enabled</span><span class="special">></span></code></strong></span>: + Specifies a type that can hold the size of the container. This type will + be the type returned by <code class="computeroutput"><span class="identifier">list</span><span class="special">.</span><span class="identifier">size</span><span class="special">()</span></code> and the type stored in the intrusive + container if <code class="computeroutput"><span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">true</span><span class="special">></span></code> is requested. The user normally will + not need to change this type, but some containers can have a <code class="computeroutput"><span class="identifier">size_type</span></code> that might be different from + <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code> (for example, STL-like containers + use the <code class="computeroutput"><span class="identifier">size_type</span></code> defined + by their allocator). <span class="bold"><strong>Boost.Intrusive</strong></span> + can be used to implement such containers specifying the the type of the + size. By default the type is <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code>. + </li> +</ul></div> +<p> + Example of a constant-time size intrusive list that will store Foo objects, + using the base hook with the default tag: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span><span class="identifier">Foo</span><span class="special">></span> <span class="identifier">FooList</span><span class="special">;</span> +</pre> +<p> + Example of a intrusive list with non constant-time size that will store Foo + objects: + </p> +<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span><span class="identifier">Foo</span><span class="special">,</span> <span class="identifier">constant_time_size</span><span class="special"><</span><span class="keyword">false</span><span class="special">></span> <span class="special">></span> <span class="identifier">FooList</span><span class="special">;</span> +</pre> +<p> + Remember that the user must specify the base hook if the base hook has no + default tag (e.g: if more than one base hook is used): + </p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="keyword">struct</span> <span class="identifier">my_tag</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">list_base_hook</span><span class="special"><</span> <span class="identifier">tag</span><span class="special"><</span><span class="identifier">my_tag</span><span class="special">></span> <span class="special">></span> <span class="identifier">BaseHook</span><span class="special">;</span> +<span class="keyword">class</span> <span class="identifier">Foo</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">BaseHook</span> +<span class="special">{</span> <span class="comment">/**/</span> <span class="special">};</span> + +<span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span> <span class="identifier">Foo</span><span class="special">,</span> <span class="identifier">base_hook</span><span class="special"><</span><span class="identifier">BaseHook</span><span class="special">></span> <span class="special">></span> <span class="identifier">FooList</span><span class="special">;</span> +</pre> +<p> + Once the list is defined, we can use it: + </p> +<pre class="programlisting"><span class="comment">//An object to be inserted in the list</span> +<span class="identifier">Foo</span> <span class="identifier">foo_object</span><span class="special">;</span> +<span class="identifier">FooList</span> <span class="identifier">list</span><span class="special">;</span> + +<span class="identifier">list</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">object</span><span class="special">);</span> + +<span class="identifier">assert</span><span class="special">(&</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">front</span><span class="special">()</span> <span class="special">==</span> <span class="special">&</span><span class="identifier">foo_object</span><span class="special">);</span> +</pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.usage.usage_member_hook"></a><a class="link" href="usage.html#intrusive.usage.usage_member_hook" title="Using member hooks">Using member hooks</a> +</h3></div></div></div> +<p> + Sometimes an 'is-a' relationship between list hooks and the list value types + is not desirable. In this case, using a member hook as a data member instead + of 'disturbing' the hierarchy might be the right way: you can add a public + data member <code class="computeroutput"><span class="identifier">list_member_hook</span><span class="special"><...></span></code> to your class. This class can + be configured with the same options as <code class="computeroutput"><span class="identifier">list_base_hook</span></code> + except the option <code class="computeroutput"><span class="identifier">tag</span></code>: + </p> +<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="special">...</span><span class="identifier">Options</span><span class="special">></span> +<span class="keyword">class</span> <span class="identifier">list_member_hook</span><span class="special">;</span> +</pre> +<p> + Example: + </p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">class</span> <span class="identifier">Foo</span> +<span class="special">{</span> + <span class="keyword">public</span><span class="special">:</span> + <span class="identifier">list_member_hook</span><span class="special"><></span> <span class="identifier">hook_</span><span class="special">;</span> + <span class="comment">//...</span> +<span class="special">};</span> +</pre> +<p> + When member hooks are used, the <code class="computeroutput"><span class="identifier">member_hook</span></code> + option is used to configure the list: + </p> +<pre class="programlisting"><span class="comment">//This option will configure "list" to use the member hook</span> +<span class="keyword">typedef</span> <span class="identifier">member_hook</span><span class="special"><</span><span class="identifier">Foo</span><span class="special">,</span> <span class="identifier">list_member_hook</span><span class="special"><>,</span> <span class="special">&</span><span class="identifier">Foo</span><span class="special">::</span><span class="identifier">hook_</span><span class="special">></span> <span class="identifier">MemberHookOption</span><span class="special">;</span> + +<span class="comment">//This list will use the member hook</span> +<span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span><span class="identifier">Foo</span><span class="special">,</span> <span class="identifier">MemberHookOption</span><span class="special">></span> <span class="identifier">FooList</span><span class="special">;</span> +</pre> +<p> + Now we can use the container: + </p> +<pre class="programlisting"><span class="comment">//An object to be inserted in the list</span> +<span class="identifier">Foo</span> <span class="identifier">foo_object</span><span class="special">;</span> +<span class="identifier">FooList</span> <span class="identifier">list</span><span class="special">;</span> + +<span class="identifier">list</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">object</span><span class="special">);</span> + +<span class="identifier">assert</span><span class="special">(&</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">front</span><span class="special">()</span> <span class="special">==</span> <span class="special">&</span><span class="identifier">foo_object</span><span class="special">);</span> +</pre> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.usage.usage_both_hooks"></a><a class="link" href="usage.html#intrusive.usage.usage_both_hooks" title="Using both hooks">Using both hooks</a> +</h3></div></div></div> +<p> + You can insert the same object in several intrusive containers at the same + time, using one hook per container. This is a full example using base and + member hooks: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="keyword">class</span> <span class="identifier">MyClass</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">list_base_hook</span><span class="special"><></span> +<span class="special">{</span> + <span class="keyword">int</span> <span class="identifier">int_</span><span class="special">;</span> + + <span class="keyword">public</span><span class="special">:</span> + <span class="identifier">list_member_hook</span><span class="special"><></span> <span class="identifier">member_hook_</span><span class="special">;</span> + + <span class="identifier">MyClass</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span><span class="special">)</span> <span class="special">:</span> <span class="identifier">int_</span><span class="special">(</span><span class="identifier">i</span><span class="special">)</span> <span class="special">{}</span> +<span class="special">};</span> + +<span class="comment">//Define a list that will store MyClass using the base hook</span> +<span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">BaseList</span><span class="special">;</span> + +<span class="comment">//Define a list that will store MyClass using the member hook</span> +<span class="keyword">typedef</span> <span class="identifier">member_hook</span> + <span class="special"><</span> <span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">list_member_hook</span><span class="special"><>,</span> <span class="special">&</span><span class="identifier">MyClass</span><span class="special">::</span><span class="identifier">member_hook_</span><span class="special">></span> <span class="identifier">MemberOption</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">,</span> <span class="identifier">MemberOption</span><span class="special">></span> <span class="identifier">MemberList</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">iterator</span> <span class="identifier">VectIt</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">>::</span><span class="identifier">reverse_iterator</span> <span class="identifier">VectRit</span><span class="special">;</span> + + <span class="comment">//Create several MyClass objects, each one with a different value</span> + <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">MyClass</span><span class="special">></span> <span class="identifier">values</span><span class="special">;</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">100</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">values</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">MyClass</span><span class="special">(</span><span class="identifier">i</span><span class="special">));</span> + + <span class="identifier">BaseList</span> <span class="identifier">baselist</span><span class="special">;</span> + <span class="identifier">MemberList</span> <span class="identifier">memberlist</span><span class="special">;</span> + + <span class="comment">//Now insert them in the reverse order in the base hook list</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">())</span> + <span class="special">;</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span> <span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">){</span> + <span class="identifier">baselist</span><span class="special">.</span><span class="identifier">push_front</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + <span class="special">}</span> + + <span class="comment">//Now insert them in the same order as in vector in the member hook list</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">)</span> + <span class="identifier">memberlist</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + + <span class="comment">//Now test lists</span> + <span class="special">{</span> + <span class="identifier">BaseList</span><span class="special">::</span><span class="identifier">reverse_iterator</span> <span class="identifier">rbit</span><span class="special">(</span><span class="identifier">baselist</span><span class="special">.</span><span class="identifier">rbegin</span><span class="special">()),</span> <span class="identifier">rbitend</span><span class="special">(</span><span class="identifier">baselist</span><span class="special">.</span><span class="identifier">rend</span><span class="special">());</span> + <span class="identifier">MemberList</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">mit</span><span class="special">(</span><span class="identifier">memberlist</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">mitend</span><span class="special">(</span><span class="identifier">memberlist</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + <span class="identifier">VectIt</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">values</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + + <span class="comment">//Test the objects inserted in the base hook list</span> + <span class="keyword">for</span><span class="special">(;</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">rbit</span><span class="special">)</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">rbit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + + <span class="comment">//Test the objects inserted in the member hook list</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">it</span> <span class="special">=</span> <span class="identifier">values</span><span class="special">.</span><span class="identifier">begin</span><span class="special">();</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">mit</span><span class="special">)</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">mit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + <span class="special">}</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.usage.usage_lifetime"></a><a class="link" href="usage.html#intrusive.usage.usage_lifetime" title="Object lifetime">Object lifetime</a> +</h3></div></div></div> +<p> + Even if the interface of <code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a></code> + is similar to <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span></code>, its usage is a bit different: You + always have to keep in mind that you directly store objects in intrusive + containers, not copies. The lifetime of a stored object is not bound to or + managed by the container: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + When the container gets destroyed before the object, the object is not + destroyed, so you have to be careful to avoid resource leaks. + </li> +<li class="listitem"> + When the object is destroyed before the container, your program is likely + to crash, because the container contains a pointer to an non-existing + object. + </li> +</ul></div> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="intrusive_vs_nontrusive.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="usage_when.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/usage_when.html b/doc/html/intrusive/usage_when.html new file mode 100755 index 0000000000..f16bf52d41 --- /dev/null +++ b/doc/html/intrusive/usage_when.html @@ -0,0 +1,183 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>When to use?</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="usage.html" title="How to use Boost.Intrusive"> +<link rel="next" href="concepts_summary.html" title="Concept summary"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="usage.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="concepts_summary.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.usage_when"></a><a class="link" href="usage_when.html" title="When to use?">When to use?</a> +</h2></div></div></div> +<p> + Intrusive containers can be used for highly optimized algorithms, where speed + is a crucial issue and: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + additional memory management should be avoided. + </li> +<li class="listitem"> + the programmer needs to efficiently track the construction and destruction + of objects. + </li> +<li class="listitem"> + exception safety, especially the no-throw guarantee, is needed. + </li> +<li class="listitem"> + the computation of an iterator to an element from a pointer or reference + to that element should be a constant time operation. + </li> +<li class="listitem"> + it's important to achieve a well-known worst-time system response. + </li> +<li class="listitem"> + localization of data (e.g. for cache hit optimization) leads to measurable + effects. + </li> +</ul></div> +<p> + The last point is important if you have a lot of containers over a set of elements. + E.g. if you have a vector of objects (say, <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">Object</span><span class="special">></span></code>), and you also have a list storing a subset + of those objects (<code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span><span class="identifier">Object</span><span class="special">*></span></code>), + then operating on an Object from the list iterator (<code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span><span class="identifier">Object</span><span class="special">*>::</span><span class="identifier">iterator</span></code>) requires two steps: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + Access from the iterator (usually on the stack) to the list node storing + a pointer to <code class="computeroutput"><span class="identifier">Object</span></code>. + </li> +<li class="listitem"> + Access from the pointer to <code class="computeroutput"><span class="identifier">Object</span></code> + to the Object stored in the vector. + </li> +</ul></div> +<p> + While the objects themselves are tightly packed in the memory of the vector + (a vector's memory is guaranteed to be contiguous), and form something like + a data block, list nodes may be dispersed in the heap memory. Hence depending + on your system you might get a lot of cache misses. The same doesn't hold for + an intrusive list. Indeed, dereferencing an iterator from an intrusive list + is performed in the same two steps as described above. But the list node is + already embedded in the Object, so the memory is directly tracked from the + iterator to the Object. + </p> +<p> + It's also possible to use intrusive containers when the objects to be stored + can have different or unknown size. This allows storing base and derived objects + in the same container, as shown in the following example: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="comment">//An abstract class that can be inserted in an intrusive list</span> +<span class="keyword">class</span> <span class="identifier">Window</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">list_base_hook</span><span class="special"><></span> +<span class="special">{</span> + <span class="keyword">public</span><span class="special">:</span> + <span class="comment">//This is a container those value is an abstract class: you can't do this with std::list.</span> + <span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span><span class="identifier">Window</span><span class="special">></span> <span class="identifier">win_list</span><span class="special">;</span> + + <span class="comment">//A static intrusive list declaration</span> + <span class="keyword">static</span> <span class="identifier">win_list</span> <span class="identifier">all_windows</span><span class="special">;</span> + + <span class="comment">//Constructor. Includes this window in the list</span> + <span class="identifier">Window</span><span class="special">()</span> <span class="special">{</span> <span class="identifier">all_windows</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(*</span><span class="keyword">this</span><span class="special">);</span> <span class="special">}</span> + <span class="comment">//Destructor. Removes this node from the list</span> + <span class="keyword">virtual</span> <span class="special">~</span><span class="identifier">Window</span><span class="special">()</span> <span class="special">{</span> <span class="identifier">all_windows</span><span class="special">.</span><span class="identifier">erase</span><span class="special">(</span><span class="identifier">win_list</span><span class="special">::</span><span class="identifier">s_iterator_to</span><span class="special">(*</span><span class="keyword">this</span><span class="special">));</span> <span class="special">}</span> + <span class="comment">//Pure virtual function to be implemented by derived classes</span> + <span class="keyword">virtual</span> <span class="keyword">void</span> <span class="identifier">Paint</span><span class="special">()</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> +<span class="special">};</span> + +<span class="comment">//The static intrusive list declaration</span> +<span class="identifier">Window</span><span class="special">::</span><span class="identifier">win_list</span> <span class="identifier">Window</span><span class="special">::</span><span class="identifier">all_windows</span><span class="special">;</span> + +<span class="comment">//Some Window derived classes</span> +<span class="keyword">class</span> <span class="identifier">FrameWindow</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">Window</span> +<span class="special">{</span> <span class="keyword">void</span> <span class="identifier">Paint</span><span class="special">(){/**/}</span> <span class="special">};</span> + +<span class="keyword">class</span> <span class="identifier">EditWindow</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">Window</span> +<span class="special">{</span> <span class="keyword">void</span> <span class="identifier">Paint</span><span class="special">(){/**/}</span> <span class="special">};</span> + +<span class="keyword">class</span> <span class="identifier">CanvasWindow</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">Window</span> +<span class="special">{</span> <span class="keyword">void</span> <span class="identifier">Paint</span><span class="special">(){/**/}</span> <span class="special">};</span> + +<span class="comment">//A function that prints all windows stored in the intrusive list</span> +<span class="keyword">void</span> <span class="identifier">paint_all_windows</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">Window</span><span class="special">::</span><span class="identifier">win_list</span><span class="special">::</span><span class="identifier">iterator</span> <span class="identifier">i</span><span class="special">(</span><span class="identifier">Window</span><span class="special">::</span><span class="identifier">all_windows</span><span class="special">.</span><span class="identifier">begin</span><span class="special">())</span> + <span class="special">,</span> <span class="identifier">e</span><span class="special">(</span><span class="identifier">Window</span><span class="special">::</span><span class="identifier">all_windows</span><span class="special">.</span><span class="identifier">end</span><span class="special">())</span> + <span class="special">;</span> <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">e</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> + <span class="identifier">i</span><span class="special">-></span><span class="identifier">Paint</span><span class="special">();</span> +<span class="special">}</span> + +<span class="comment">//...</span> + +<span class="comment">//A class derived from Window</span> +<span class="keyword">class</span> <span class="identifier">MainWindow</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">Window</span> +<span class="special">{</span> + <span class="identifier">FrameWindow</span> <span class="identifier">frame_</span><span class="special">;</span> <span class="comment">//these are derived from Window too</span> + <span class="identifier">EditWindow</span> <span class="identifier">edit_</span><span class="special">;</span> + <span class="identifier">CanvasWindow</span> <span class="identifier">canvas_</span><span class="special">;</span> + + <span class="keyword">public</span><span class="special">:</span> + <span class="keyword">void</span> <span class="identifier">Paint</span><span class="special">(){/**/}</span> + <span class="comment">//...</span> +<span class="special">};</span> + +<span class="comment">//Main function</span> +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="comment">//When a Window class is created, is automatically registered in the global list</span> + <span class="identifier">MainWindow</span> <span class="identifier">window</span><span class="special">;</span> + + <span class="comment">//Paint all the windows, sub-windows and so on</span> + <span class="identifier">paint_all_windows</span><span class="special">();</span> + + <span class="comment">//All the windows are automatically unregistered in their destructors.</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + Due to certain properties of intrusive containers they are often more difficult + to use than their STL-counterparts. That's why you should avoid them in public + interfaces of libraries. Classes to be stored in intrusive containers must + change their implementation to store the hook and this is not always possible + or desirable. + </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"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="usage.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="concepts_summary.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/using_smart_pointers.html b/doc/html/intrusive/using_smart_pointers.html new file mode 100755 index 0000000000..855956addc --- /dev/null +++ b/doc/html/intrusive/using_smart_pointers.html @@ -0,0 +1,159 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Using smart pointers with Boost.Intrusive containers</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="recursive.html" title="Recursive Boost.Intrusive containers"> +<link rel="next" href="obtaining_iterators_from_values.html" title="Obtaining iterators from values"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="recursive.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="obtaining_iterators_from_values.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.using_smart_pointers"></a><a class="link" href="using_smart_pointers.html" title="Using smart pointers with Boost.Intrusive containers">Using smart pointers with + Boost.Intrusive containers</a> +</h2></div></div></div> +<div class="toc"><dl><dt><span class="section"><a href="using_smart_pointers.html#intrusive.using_smart_pointers.smart_pointers_requirements">Requirements + for smart pointers compatible with Boost.Intrusive</a></span></dt></dl></div> +<p> + <span class="bold"><strong>Boost.Intrusive</strong></span> hooks can be configured to + use other pointers than raw pointers. When a <span class="bold"><strong>Boost.Intrusive</strong></span> + hook is configured with a smart pointer as an argument, this pointer configuration + is passed to the containers. For example, if the following hook is configured + with a smart pointer (for example, an offset pointer from <span class="bold"><strong>Boost.Interprocess</strong></span>): + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">interprocess</span><span class="special">/</span><span class="identifier">offset_ptr</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> +<span class="keyword">namespace</span> <span class="identifier">ip</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">interprocess</span><span class="special">;</span> + +<span class="keyword">class</span> <span class="identifier">shared_memory_data</span> + <span class="comment">//Declare the hook with an offset_ptr from Boost.Interprocess</span> + <span class="comment">//to make this class compatible with shared memory</span> + <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">list_base_hook</span><span class="special"><</span> <span class="identifier">void_pointer</span><span class="special"><</span> <span class="identifier">ip</span><span class="special">::</span><span class="identifier">offset_ptr</span><span class="special"><</span><span class="keyword">void</span><span class="special">></span> <span class="special">></span> <span class="special">></span> +<span class="special">{</span> + <span class="keyword">int</span> <span class="identifier">data_id_</span><span class="special">;</span> + <span class="keyword">public</span><span class="special">:</span> + + <span class="keyword">int</span> <span class="identifier">get</span><span class="special">()</span> <span class="keyword">const</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">data_id_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">void</span> <span class="identifier">set</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">id</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">data_id_</span> <span class="special">=</span> <span class="identifier">id</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> +</pre> +<p> + </p> +<p> + Any intrusive list constructed using this hook will be ready for shared memory, + because the intrusive list will also use offset pointers internally. For example, + we can create an intrusive list in shared memory combining <span class="bold"><strong>Boost.Interprocess</strong></span> + and <span class="bold"><strong>Boost.Intrusive</strong></span>: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">interprocess</span><span class="special">/</span><span class="identifier">managed_shared_memory</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">interprocess</span><span class="special">/</span><span class="identifier">containers</span><span class="special">/</span><span class="identifier">vector</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">interprocess</span><span class="special">/</span><span class="identifier">containers</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">interprocess</span><span class="special">/</span><span class="identifier">allocators</span><span class="special">/</span><span class="identifier">allocator</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="comment">//Definition of the shared memory friendly intrusive list</span> +<span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span><span class="identifier">shared_memory_data</span><span class="special">></span> <span class="identifier">intrusive_list_t</span><span class="special">;</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="comment">//Now create an intrusive list in shared memory:</span> + <span class="comment">//nodes and the container itself must be created in shared memory</span> + <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">MaxElem</span> <span class="special">=</span> <span class="number">100</span><span class="special">;</span> + <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">ShmSize</span> <span class="special">=</span> <span class="number">50000</span><span class="special">;</span> + <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span><span class="identifier">ShmName</span> <span class="special">=</span> <span class="identifier">get_shared_memory_name</span><span class="special">();</span> + <span class="special">{</span> + <span class="comment">//Erase all old shared memory </span> + <span class="identifier">ip</span><span class="special">::</span><span class="identifier">shared_memory_object</span><span class="special">::</span><span class="identifier">remove</span><span class="special">(</span><span class="identifier">ShmName</span><span class="special">);</span> + <span class="identifier">ip</span><span class="special">::</span><span class="identifier">managed_shared_memory</span> <span class="identifier">shm</span><span class="special">(</span><span class="identifier">ip</span><span class="special">::</span><span class="identifier">create_only</span><span class="special">,</span> <span class="identifier">ShmName</span><span class="special">,</span> <span class="identifier">ShmSize</span><span class="special">);</span> + + <span class="comment">//Create all nodes in shared memory using a shared memory vector</span> + <span class="comment">//See Boost.Interprocess documentation for more information on this</span> + <span class="keyword">typedef</span> <span class="identifier">ip</span><span class="special">::</span><span class="identifier">allocator</span> + <span class="special"><</span> <span class="identifier">shared_memory_data</span><span class="special">,</span> <span class="identifier">ip</span><span class="special">::</span><span class="identifier">managed_shared_memory</span><span class="special">::</span><span class="identifier">segment_manager</span><span class="special">></span> + <span class="identifier">shm_allocator_t</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">ip</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">shared_memory_data</span><span class="special">,</span> <span class="identifier">shm_allocator_t</span><span class="special">></span> <span class="identifier">shm_vector_t</span><span class="special">;</span> + <span class="identifier">shm_allocator_t</span> <span class="identifier">shm_alloc</span><span class="special">(</span><span class="identifier">shm</span><span class="special">.</span><span class="identifier">get_segment_manager</span><span class="special">());</span> + <span class="identifier">shm_vector_t</span> <span class="special">*</span><span class="identifier">pshm_vect</span> <span class="special">=</span> + <span class="identifier">shm</span><span class="special">.</span><span class="identifier">construct</span><span class="special"><</span><span class="identifier">shm_vector_t</span><span class="special">>(</span><span class="identifier">ip</span><span class="special">::</span><span class="identifier">anonymous_instance</span><span class="special">)(</span><span class="identifier">shm_alloc</span><span class="special">);</span> + <span class="identifier">pshm_vect</span><span class="special">-></span><span class="identifier">resize</span><span class="special">(</span><span class="identifier">MaxElem</span><span class="special">);</span> + + <span class="comment">//Initialize all the nodes</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="identifier">MaxElem</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="special">(*</span><span class="identifier">pshm_vect</span><span class="special">)[</span><span class="identifier">i</span><span class="special">].</span><span class="identifier">set</span><span class="special">(</span><span class="identifier">i</span><span class="special">);</span> + + <span class="comment">//Now create the shared memory intrusive list</span> + <span class="identifier">intrusive_list_t</span> <span class="special">*</span><span class="identifier">plist</span> <span class="special">=</span> <span class="identifier">shm</span><span class="special">.</span><span class="identifier">construct</span><span class="special"><</span><span class="identifier">intrusive_list_t</span><span class="special">>(</span><span class="identifier">ip</span><span class="special">::</span><span class="identifier">anonymous_instance</span><span class="special">)();</span> + + <span class="comment">//Insert objects stored in shared memory vector in the intrusive list</span> + <span class="identifier">plist</span><span class="special">-></span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">plist</span><span class="special">-></span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">pshm_vect</span><span class="special">-></span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">pshm_vect</span><span class="special">-></span><span class="identifier">end</span><span class="special">());</span> + + <span class="comment">//Check all the inserted nodes</span> + <span class="keyword">int</span> <span class="identifier">checker</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> + <span class="keyword">for</span><span class="special">(</span> <span class="identifier">intrusive_list_t</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="identifier">it</span> <span class="special">=</span> <span class="identifier">plist</span><span class="special">-></span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">plist</span><span class="special">-></span><span class="identifier">end</span><span class="special">())</span> + <span class="special">;</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">checker</span><span class="special">){</span> + <span class="keyword">if</span><span class="special">(</span><span class="identifier">it</span><span class="special">-></span><span class="identifier">get</span><span class="special">()</span> <span class="special">!=</span> <span class="identifier">checker</span><span class="special">)</span> <span class="keyword">return</span> <span class="keyword">false</span><span class="special">;</span> + <span class="special">}</span> + + <span class="comment">//Now delete the list and after that, the nodes</span> + <span class="identifier">shm</span><span class="special">.</span><span class="identifier">destroy_ptr</span><span class="special">(</span><span class="identifier">plist</span><span class="special">);</span> + <span class="identifier">shm</span><span class="special">.</span><span class="identifier">destroy_ptr</span><span class="special">(</span><span class="identifier">pshm_vect</span><span class="special">);</span> + <span class="special">}</span> + <span class="identifier">ip</span><span class="special">::</span><span class="identifier">shared_memory_object</span><span class="special">::</span><span class="identifier">remove</span><span class="special">(</span><span class="identifier">ShmName</span><span class="special">);</span> + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.using_smart_pointers.smart_pointers_requirements"></a><a class="link" href="using_smart_pointers.html#intrusive.using_smart_pointers.smart_pointers_requirements" title="Requirements for smart pointers compatible with Boost.Intrusive">Requirements + for smart pointers compatible with Boost.Intrusive</a> +</h3></div></div></div> +<p> + Not every smart pointer is compatible with <span class="bold"><strong>Boost.Intrusive</strong></span>: + </p> +<pre class="programlisting"><span class="special">*</span> <span class="identifier">It</span> <span class="identifier">must</span> <span class="identifier">be</span> <span class="identifier">compatible</span> <span class="identifier">with</span> <span class="identifier">C</span><span class="special">++</span><span class="number">11</span> <span class="special">[</span><span class="error">@</span><span class="identifier">http</span><span class="special">://</span><span class="identifier">en</span><span class="special">.</span><span class="identifier">cppreference</span><span class="special">.</span><span class="identifier">com</span><span class="special">/</span><span class="identifier">w</span><span class="special">/</span><span class="identifier">cpp</span><span class="special">/</span><span class="identifier">memory</span><span class="special">/</span><span class="identifier">pointer_traits</span> <span class="error">`</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">pointer_traits</span><span class="error">`</span><span class="special">]</span> + <span class="identifier">requirements</span><span class="special">.</span> <span class="special">[*</span><span class="identifier">Boost</span><span class="special">.</span><span class="identifier">Intrusive</span><span class="special">]</span> <span class="identifier">uses</span> <span class="identifier">its</span> <span class="identifier">own</span> <span class="special">[</span><span class="identifier">classref</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">::</span><span class="identifier">pointer_traits</span> <span class="identifier">pointer_traits</span><span class="special">]</span> + <span class="keyword">class</span> <span class="identifier">to</span> <span class="identifier">implement</span> <span class="identifier">those</span> <span class="identifier">features</span> <span class="identifier">in</span> <span class="identifier">both</span> <span class="identifier">C</span><span class="special">++</span><span class="number">11</span> <span class="keyword">and</span> <span class="identifier">C</span><span class="special">++</span><span class="number">03</span> <span class="identifier">compilers</span><span class="special">.</span> +<span class="special">*</span> <span class="identifier">It</span> <span class="identifier">must</span> <span class="identifier">have</span> <span class="identifier">the</span> <span class="identifier">same</span> <span class="identifier">ownership</span> <span class="identifier">semantics</span> <span class="identifier">as</span> <span class="identifier">a</span> <span class="identifier">raw</span> <span class="identifier">pointer</span><span class="special">.</span> <span class="identifier">This</span> <span class="identifier">means</span> <span class="identifier">that</span> + <span class="identifier">resource</span> <span class="identifier">management</span> <span class="identifier">smart</span> <span class="identifier">pointers</span> <span class="special">(</span><span class="identifier">like</span> <span class="error">`</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">shared_ptr</span><span class="error">`</span><span class="special">)</span> <span class="identifier">can</span><span class="error">'</span><span class="identifier">t</span> <span class="identifier">be</span> <span class="identifier">used</span><span class="special">.</span> +</pre> +<p> + The conversion from the smart pointer to a raw pointer will be implemented + as a recursive call to <code class="computeroutput"><span class="keyword">operator</span><span class="special">->()</span></code> until the function returns a raw pointer. + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="recursive.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="obtaining_iterators_from_values.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> diff --git a/doc/html/intrusive/value_traits.html b/doc/html/intrusive/value_traits.html new file mode 100755 index 0000000000..2dd078fa17 --- /dev/null +++ b/doc/html/intrusive/value_traits.html @@ -0,0 +1,703 @@ +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title>Containers with custom ValueTraits</title> +<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> +<meta name="generator" content="DocBook XSL Stylesheets V1.76.1"> +<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> +<link rel="up" href="../intrusive.html" title="Chapter 13. Boost.Intrusive"> +<link rel="prev" href="node_algorithms.html" title="Node algorithms with custom NodeTraits"> +<link rel="next" href="thread_safety.html" title="Thread safety guarantees"> +</head> +<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> +<table cellpadding="2" width="100%"><tr> +<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> +<td align="center"><a href="../../../index.html">Home</a></td> +<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> +<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> +<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> +<td align="center"><a href="../../../more/index.htm">More</a></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="node_algorithms.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="thread_safety.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +<div class="section"> +<div class="titlepage"><div><div><h2 class="title" style="clear: both"> +<a name="intrusive.value_traits"></a><a class="link" href="value_traits.html" title="Containers with custom ValueTraits">Containers with custom ValueTraits</a> +</h2></div></div></div> +<div class="toc"><dl> +<dt><span class="section"><a href="value_traits.html#intrusive.value_traits.value_traits_interface">ValueTraits + interface</a></span></dt> +<dt><span class="section"><a href="value_traits.html#intrusive.value_traits.value_traits_example">Custom ValueTraits + example</a></span></dt> +<dt><span class="section"><a href="value_traits.html#intrusive.value_traits.reusing_node_algorithms">Reusing + node algorithms for different values</a></span></dt> +<dt><span class="section"><a href="value_traits.html#intrusive.value_traits.simplifying_value_traits">Simplifying + value traits definition</a></span></dt> +<dt><span class="section"><a href="value_traits.html#intrusive.value_traits.stateful_value_traits">Stateful + value traits</a></span></dt> +</dl></div> +<p> + As explained in the <a class="link" href="concepts.html" title="Concepts explained">Concepts</a> section, + <span class="bold"><strong>Boost.Intrusive</strong></span> containers need a <code class="computeroutput"><span class="identifier">ValueTraits</span></code> class to perform transformations + between nodes and user values. <code class="computeroutput"><span class="identifier">ValueTraits</span></code> + can be explicitly configured (using the <code class="computeroutput"><span class="identifier">value_traits</span><span class="special"><></span></code> option) or implicitly configured (using + hooks and their <code class="computeroutput"><span class="identifier">base_hook</span><span class="special"><></span></code>/<code class="computeroutput"><span class="identifier">member_hook</span><span class="special"><></span></code> + options). <code class="computeroutput"><span class="identifier">ValueTraits</span></code> contains + all the information to glue the <code class="computeroutput"><span class="identifier">value_type</span></code> + of the containers and the node to be used in node algorithms, since these types + can be different. Apart from this, <code class="computeroutput"><span class="identifier">ValueTraits</span></code> + also stores information about the link policy of the values to be inserted. + </p> +<p> + Instead of using <span class="bold"><strong>Boost.Intrusive</strong></span> predefined + hooks a user might want to develop customized containers, for example, using + nodes that are optimized for a specific application or that are compatible + with a legacy ABI. A user might want to have only two additional pointers in + his class and insert the class in a doubly linked list sometimes and in a singly + linked list in other situations. You can't achieve this using <span class="bold"><strong>Boost.Intrusive</strong></span> + predefined hooks. Now, instead of using <code class="computeroutput"><span class="identifier">base_hook</span><span class="special"><...></span></code> or <code class="computeroutput"><span class="identifier">member_hook</span><span class="special"><...></span></code> options the user will specify the + <code class="computeroutput"><span class="identifier">value_traits</span><span class="special"><...></span></code> + options. Let's see how we can do this: + </p> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.value_traits.value_traits_interface"></a><a class="link" href="value_traits.html#intrusive.value_traits.value_traits_interface" title="ValueTraits interface">ValueTraits + interface</a> +</h3></div></div></div> +<p> + <code class="computeroutput"><span class="identifier">ValueTraits</span></code> has the following + interface: + </p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">pointer_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">link_mode</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">struct</span> <span class="identifier">my_value_traits</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">implementation_defined</span> <span class="identifier">node_traits</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">implementation_defined</span> <span class="identifier">value_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">node_traits</span><span class="special">::</span><span class="identifier">node_ptr</span> <span class="identifier">node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">node_traits</span><span class="special">::</span><span class="identifier">const_node_ptr</span> <span class="identifier">const_node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">::</span><span class="identifier">pointer_traits</span><span class="special"><</span><span class="identifier">node_ptr</span><span class="special">>::</span><span class="identifier">rebind_traits</span> + <span class="special"><</span><span class="identifier">value_type</span><span class="special">>::</span><span class="identifier">type</span><span class="special">::</span><span class="identifier">pointer</span> <span class="identifier">pointer</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">::</span><span class="identifier">pointer_traits</span><span class="special"><</span><span class="identifier">node_ptr</span><span class="special">>::</span><span class="identifier">rebind_traits</span> + <span class="special"><</span><span class="keyword">const</span> <span class="identifier">value_type</span><span class="special">>::</span><span class="identifier">type</span><span class="special">::</span><span class="identifier">pointer</span> <span class="identifier">const_pointer</span><span class="special">;</span> + + <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">link_mode_type</span> <span class="identifier">link_mode</span> <span class="special">=</span> <span class="identifier">some_linking_policy</span><span class="special">;</span> + + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">to_node_ptr</span> <span class="special">(</span><span class="identifier">value_type</span> <span class="special">&</span><span class="identifier">value</span><span class="special">);</span> + <span class="keyword">static</span> <span class="identifier">const_node_ptr</span> <span class="identifier">to_node_ptr</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span><span class="identifier">value</span><span class="special">);</span> + <span class="keyword">static</span> <span class="identifier">pointer</span> <span class="identifier">to_value_ptr</span> <span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">);</span> + <span class="keyword">static</span> <span class="identifier">const_pointer</span> <span class="identifier">to_value_ptr</span> <span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">);</span> +<span class="special">};</span> +</pre> +<p> + Let's explain each type and function: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong><span class="emphasis"><em>node_traits</em></span></strong></span>: The + node configuration that is needed by node algorithms. These node traits + and algorithms are described in the previous chapter: <a class="link" href="node_algorithms.html" title="Node algorithms with custom NodeTraits">Node + Algorithms</a>. + <div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + If my_value_traits is meant to be used with <code class="computeroutput"><a class="link" href="../boost/intrusive/slist.html" title="Class template slist">slist</a></code>, + <code class="computeroutput"><span class="identifier">node_traits</span></code> should + follow the interface needed by <code class="computeroutput"><a class="link" href="../boost/intrusive/circular_slist_algorithms.html" title="Class template circular_slist_algorithms">circular_slist_algorithms</a></code>. + </li> +<li class="listitem"> + If my_value_traits is meant to be used with <code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a></code>, + <code class="computeroutput"><span class="identifier">node_traits</span></code> should + follow the interface needed by <code class="computeroutput"><a class="link" href="../boost/intrusive/circular_list_algorithms.html" title="Class template circular_list_algorithms">circular_list_algorithms</a></code>. + </li> +<li class="listitem"> + If my_value_traits is meant to be used with <code class="computeroutput"><a class="link" href="../boost/intrusive/set.html" title="Class template set">set</a></code>/<code class="computeroutput"><a class="link" href="../boost/intrusive/multiset.html" title="Class template multiset">multiset</a></code>, <code class="computeroutput"><span class="identifier">node_traits</span></code> should follow the + interface needed by <code class="computeroutput"><a class="link" href="../boost/intrusive/rbtree_algorithms.html" title="Class template rbtree_algorithms">rbtree_algorithms</a></code>. + </li> +<li class="listitem"> + If my_value_traits is meant to be used with <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_set.html" title="Class template unordered_set">unordered_set</a></code>/ + <code class="computeroutput"><a class="link" href="../boost/intrusive/unordered_multiset.html" title="Class template unordered_multiset">unordered_multiset</a></code>, + <code class="computeroutput"><span class="identifier">node_traits</span></code> should + follow the interface needed by <code class="computeroutput"><a class="link" href="../boost/intrusive/circular_slist_algorithms.html" title="Class template circular_slist_algorithms">circular_slist_algorithms</a></code>. + </li> +</ul></div> + </li> +<li class="listitem"> + <span class="bold"><strong><span class="emphasis"><em>node_ptr</em></span></strong></span>: A typedef + for <code class="computeroutput"><span class="identifier">node_traits</span><span class="special">::</span><span class="identifier">node_ptr</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><span class="emphasis"><em>const_node_ptr</em></span></strong></span>: + A typedef for <code class="computeroutput"><span class="identifier">node_traits</span><span class="special">::</span><span class="identifier">const_node_ptr</span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><span class="emphasis"><em>value_type</em></span></strong></span>: The + type that the user wants to insert in the container. This type can be + the same as <code class="computeroutput"><span class="identifier">node_traits</span><span class="special">::</span><span class="identifier">node</span></code> + but it can be different (for example, <code class="computeroutput"><span class="identifier">node_traits</span><span class="special">::</span><span class="identifier">node</span></code> + can be a member type of <code class="computeroutput"><span class="identifier">value_type</span></code>). + If <code class="computeroutput"><span class="identifier">value_type</span></code> and <code class="computeroutput"><span class="identifier">node_traits</span><span class="special">::</span><span class="identifier">node</span></code> are the same type, the <code class="computeroutput"><span class="identifier">to_node_ptr</span></code> and <code class="computeroutput"><span class="identifier">to_value_ptr</span></code> + functions are trivial. + </li> +<li class="listitem"> + <span class="bold"><strong><span class="emphasis"><em>pointer</em></span></strong></span>: The type + of a pointer to a <code class="computeroutput"><span class="identifier">value_type</span></code>. + It must be the same pointer type as <code class="computeroutput"><span class="identifier">node_ptr</span></code>: + If <code class="computeroutput"><span class="identifier">node_ptr</span></code> is <code class="computeroutput"><span class="identifier">node</span><span class="special">*</span></code>, + <code class="computeroutput"><span class="identifier">pointer</span></code> must be <code class="computeroutput"><span class="identifier">value_type</span><span class="special">*</span></code>. + If <code class="computeroutput"><span class="identifier">node_ptr</span></code> is <code class="computeroutput"><span class="identifier">smart_ptr</span><span class="special"><</span><span class="identifier">node_traits</span><span class="special">::</span><span class="identifier">node</span><span class="special">></span></code>, + <code class="computeroutput"><span class="identifier">pointer</span></code> must be <code class="computeroutput"><span class="identifier">smart_ptr</span><span class="special"><</span><span class="identifier">value_type</span><span class="special">></span></code>. + This can be generically achieved using <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">::</span><span class="identifier">pointer_traits</span></code> + (portable implementation of C++11 <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pointer_traits</span></code>) + or <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">pointer_to_other</span></code> utility from <span class="bold"><strong>Boost SmartPointers</strong></span> defined in <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">pointer_to_other</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><span class="emphasis"><em>const_pointer</em></span></strong></span>: + The type of a pointer to a <code class="computeroutput"><span class="keyword">const</span> + <span class="identifier">value_type</span></code>. It must be the + same pointer type as <code class="computeroutput"><span class="identifier">node_ptr</span></code>: + If <code class="computeroutput"><span class="identifier">node_ptr</span></code> is <code class="computeroutput"><span class="identifier">node</span><span class="special">*</span></code>, + <code class="computeroutput"><span class="identifier">const_pointer</span></code> must be + <code class="computeroutput"><span class="keyword">const</span> <span class="identifier">value_type</span><span class="special">*</span></code>. If <code class="computeroutput"><span class="identifier">node_ptr</span></code> + is <code class="computeroutput"><span class="identifier">smart_ptr</span><span class="special"><</span><span class="identifier">node_traits</span><span class="special">::</span><span class="identifier">node</span><span class="special">></span></code>, + <code class="computeroutput"><span class="identifier">const_pointer</span></code> must be + <code class="computeroutput"><span class="identifier">smart_ptr</span><span class="special"><</span><span class="keyword">const</span> <span class="identifier">value_type</span><span class="special">></span></code>. + </li> +<li class="listitem"> + <span class="bold"><strong><span class="emphasis"><em>link_mode</em></span></strong></span>: Indicates + that <code class="computeroutput"><span class="identifier">value_traits</span></code> needs + some additional work or checks from the container. The types are enumerations + defined in the <code class="computeroutput"><span class="identifier">link_mode</span><span class="special">.</span><span class="identifier">hpp</span></code> + header. These are the possible types: + <div class="itemizedlist"><ul class="itemizedlist" type="circle"> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">normal_link</span></code></strong></span>: + If this linking policy is specified in a <code class="computeroutput"><span class="identifier">ValueTraits</span></code> + class as the link mode, containers configured with such <code class="computeroutput"><span class="identifier">ValueTraits</span></code> won't set the hooks + of the erased values to a default state. Containers also won't + check that the hooks of the new values are default initialized. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">safe_link</span></code></strong></span>: + If this linking policy is specified as the link mode in a <code class="computeroutput"><span class="identifier">ValueTraits</span></code> class, containers + configured with this <code class="computeroutput"><span class="identifier">ValueTraits</span></code> + will set the hooks of the erased values to a default state. Containers + also will check that the hooks of the new values are default initialized. + </li> +<li class="listitem"> + <span class="bold"><strong><code class="computeroutput"><span class="identifier">auto_unlink</span></code></strong></span>: + Same as "safe_link" but containers with constant-time + size features won't be compatible with <code class="computeroutput"><span class="identifier">ValueTraits</span></code> + configured with this policy. Containers also know that a value + can be silently erased from the container without using any function + provided by the containers. + </li> +</ul></div> + </li> +<li class="listitem"> + <span class="bold"><strong><span class="emphasis"><em>static node_ptr to_node_ptr (value_type + &value)</em></span></strong></span> and <span class="bold"><strong><span class="emphasis"><em>static + const_node_ptr to_node_ptr (const value_type &value)</em></span></strong></span>: + These functions take a reference to a value_type and return a pointer + to the node to be used with node algorithms. + </li> +<li class="listitem"> + <span class="bold"><strong><span class="emphasis"><em>static pointer to_value_ptr (node_ptr + n)</em></span></strong></span> and <span class="bold"><strong><span class="emphasis"><em>static const_pointer + to_value_ptr (const_node_ptr n)</em></span></strong></span>: These functions + take a pointer to a node and return a pointer to the value that contains + the node. + </li> +</ul></div> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.value_traits.value_traits_example"></a><a class="link" href="value_traits.html#intrusive.value_traits.value_traits_example" title="Custom ValueTraits example">Custom ValueTraits + example</a> +</h3></div></div></div> +<p> + Let's define our own <code class="computeroutput"><span class="identifier">value_traits</span></code> + class to be able to use <span class="bold"><strong>Boost.Intrusive</strong></span> + containers with an old C structure whose definition can't be changed. That + legacy type has two pointers that can be used to build singly and doubly + linked lists: in singly linked lists we only need a pointer, whereas in doubly + linked lists, we need two pointers. Since we only have two pointers, we can't + insert the object in both a singly and a doubly linked list at the same time. + This is the definition of the old node: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">link_mode</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">slist</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span> + +<span class="comment">//This node is the legacy type we can't modify and we want to insert in</span> +<span class="comment">//intrusive list and slist containers using only two pointers, since</span> +<span class="comment">//we know the object will never be at the same time in both lists. </span> +<span class="keyword">struct</span> <span class="identifier">legacy_value</span> +<span class="special">{</span> + <span class="identifier">legacy_value</span> <span class="special">*</span><span class="identifier">prev_</span><span class="special">;</span> + <span class="identifier">legacy_value</span> <span class="special">*</span><span class="identifier">next_</span><span class="special">;</span> + <span class="keyword">int</span> <span class="identifier">id_</span><span class="special">;</span> +<span class="special">};</span> +</pre> +<p> + </p> +<p> + Now we have to define a NodeTraits class that will implement the functions/typedefs + that will make the legacy node compatible with <span class="bold"><strong>Boost.Intrusive</strong></span> + algorithms. After that, we'll define a ValueTraits class that will configure + <span class="bold"><strong>Boost.Intrusive</strong></span> containers: + </p> +<p> +</p> +<pre class="programlisting"><span class="comment">//Define our own NodeTraits that will configure singly and doubly linked</span> +<span class="comment">//list algorithms. Note that this node traits is compatible with</span> +<span class="comment">//circular_slist_algorithms and circular_list_algorithms.</span> + +<span class="keyword">namespace</span> <span class="identifier">bi</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="keyword">struct</span> <span class="identifier">legacy_node_traits</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">legacy_value</span> <span class="identifier">node</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">legacy_value</span> <span class="special">*</span> <span class="identifier">node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">legacy_value</span> <span class="special">*</span> <span class="identifier">const_node_ptr</span><span class="special">;</span> + + <span class="keyword">static</span> <span class="identifier">node</span> <span class="special">*</span><span class="identifier">get_next</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">node</span> <span class="special">*</span><span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">next_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_next</span><span class="special">(</span><span class="identifier">node</span> <span class="special">*</span><span class="identifier">n</span><span class="special">,</span> <span class="identifier">node</span> <span class="special">*</span><span class="identifier">next</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">next_</span> <span class="special">=</span> <span class="identifier">next</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">node</span> <span class="special">*</span><span class="identifier">get_previous</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">node</span> <span class="special">*</span><span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">prev_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_previous</span><span class="special">(</span><span class="identifier">node</span> <span class="special">*</span><span class="identifier">n</span><span class="special">,</span> <span class="identifier">node</span> <span class="special">*</span><span class="identifier">prev</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">prev_</span> <span class="special">=</span> <span class="identifier">prev</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="comment">//This ValueTraits will configure list and slist. In this case,</span> +<span class="comment">//legacy_node_traits::node is the same as the </span> +<span class="comment">//legacy_value_traits::value_type so to_node_ptr/to_value_ptr</span> +<span class="comment">//functions are trivial.</span> +<span class="keyword">struct</span> <span class="identifier">legacy_value_traits</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">legacy_node_traits</span> <span class="identifier">node_traits</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">node_traits</span><span class="special">::</span><span class="identifier">node_ptr</span> <span class="identifier">node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">node_traits</span><span class="special">::</span><span class="identifier">const_node_ptr</span> <span class="identifier">const_node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">legacy_value</span> <span class="identifier">value_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">legacy_value</span> <span class="special">*</span> <span class="identifier">pointer</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">legacy_value</span> <span class="special">*</span> <span class="identifier">const_pointer</span><span class="special">;</span> + <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">bi</span><span class="special">::</span><span class="identifier">link_mode_type</span> <span class="identifier">link_mode</span> <span class="special">=</span> <span class="identifier">bi</span><span class="special">::</span><span class="identifier">normal_link</span><span class="special">;</span> + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">to_node_ptr</span> <span class="special">(</span><span class="identifier">value_type</span> <span class="special">&</span><span class="identifier">value</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">node_ptr</span><span class="special">(&</span><span class="identifier">value</span><span class="special">);</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">const_node_ptr</span> <span class="identifier">to_node_ptr</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span><span class="identifier">value</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">const_node_ptr</span><span class="special">(&</span><span class="identifier">value</span><span class="special">);</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">pointer</span> <span class="identifier">to_value_ptr</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">pointer</span><span class="special">(</span><span class="identifier">n</span><span class="special">);</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">const_pointer</span> <span class="identifier">to_value_ptr</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">const_pointer</span><span class="special">(</span><span class="identifier">n</span><span class="special">);</span> <span class="special">}</span> +<span class="special">};</span> +</pre> +<p> + </p> +<p> + Defining a value traits class that simply defines <code class="computeroutput"><span class="identifier">value_type</span></code> + as <code class="computeroutput"><span class="identifier">legacy_node_traits</span><span class="special">::</span><span class="identifier">node</span></code> is a common approach when defining + customized intrusive containers, so <span class="bold"><strong>Boost.Intrusive</strong></span> + offers a templatized <code class="computeroutput"><a class="link" href="../boost/intrusive/trivial_value_traits.html" title="Struct template trivial_value_traits">trivial_value_traits</a></code> + class that does exactly what we want: + </p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">trivial_value_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="comment">//Now we can define legacy_value_traits just with a single line</span> +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">trivial_value_traits</span><span class="special"><</span><span class="identifier">legacy_node_traits</span><span class="special">,</span> <span class="identifier">normal_link</span><span class="special">></span> <span class="identifier">legacy_value_traits</span><span class="special">;</span> +</pre> +<p> + Now we can just define the containers that will store the legacy abi objects + and write a little test: + </p> +<p> +</p> +<pre class="programlisting"><span class="comment">//Now define an intrusive list and slist that will store legacy_value objects</span> +<span class="keyword">typedef</span> <span class="identifier">bi</span><span class="special">::</span><span class="identifier">value_traits</span><span class="special"><</span><span class="identifier">legacy_value_traits</span><span class="special">></span> <span class="identifier">ValueTraitsOption</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">bi</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span><span class="identifier">legacy_value</span><span class="special">,</span> <span class="identifier">ValueTraitsOption</span><span class="special">></span> <span class="identifier">LegacyAbiList</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">bi</span><span class="special">::</span><span class="identifier">slist</span><span class="special"><</span><span class="identifier">legacy_value</span><span class="special">,</span> <span class="identifier">ValueTraitsOption</span><span class="special">></span> <span class="identifier">LegacyAbiSlist</span><span class="special">;</span> + +<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">List</span><span class="special">></span> +<span class="keyword">bool</span> <span class="identifier">test_list</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">legacy_value</span><span class="special">></span> <span class="identifier">Vect</span><span class="special">;</span> + + <span class="comment">//Create legacy_value objects, with a different internal number</span> + <span class="identifier">Vect</span> <span class="identifier">legacy_vector</span><span class="special">;</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">100</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">){</span> + <span class="identifier">legacy_value</span> <span class="identifier">value</span><span class="special">;</span> <span class="identifier">value</span><span class="special">.</span><span class="identifier">id_</span> <span class="special">=</span> <span class="identifier">i</span><span class="special">;</span> <span class="identifier">legacy_vector</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">value</span><span class="special">);</span> + <span class="special">}</span> + + <span class="comment">//Create the list with the objects</span> + <span class="identifier">List</span> <span class="identifier">mylist</span><span class="special">(</span><span class="identifier">legacy_vector</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">legacy_vector</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + + <span class="comment">//Now test both lists</span> + <span class="keyword">typename</span> <span class="identifier">List</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="identifier">bit</span><span class="special">(</span><span class="identifier">mylist</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">bitend</span><span class="special">(</span><span class="identifier">mylist</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + <span class="keyword">typename</span> <span class="identifier">Vect</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="identifier">it</span><span class="special">(</span><span class="identifier">legacy_vector</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()),</span> <span class="identifier">itend</span><span class="special">(</span><span class="identifier">legacy_vector</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span> + + <span class="comment">//Test the objects inserted in our list</span> + <span class="keyword">for</span><span class="special">(;</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">,</span> <span class="special">++</span><span class="identifier">bit</span><span class="special">)</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">bit</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">it</span><span class="special">)</span> <span class="keyword">return</span> <span class="keyword">false</span><span class="special">;</span> + <span class="keyword">return</span> <span class="keyword">true</span><span class="special">;</span> +<span class="special">}</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">return</span> <span class="identifier">test_list</span><span class="special"><</span><span class="identifier">LegacyAbiList</span><span class="special">>()</span> <span class="special">&&</span> <span class="identifier">test_list</span><span class="special"><</span><span class="identifier">LegacyAbiSlist</span><span class="special">>()</span> <span class="special">?</span> <span class="number">0</span> <span class="special">:</span> <span class="number">1</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +<p> + As seen, several key elements of <span class="bold"><strong>Boost.Intrusive</strong></span> + can be reused with custom user types, if the user does not want to use the + provided <span class="bold"><strong>Boost.Intrusive</strong></span> facilities. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.value_traits.reusing_node_algorithms"></a><a class="link" href="value_traits.html#intrusive.value_traits.reusing_node_algorithms" title="Reusing node algorithms for different values">Reusing + node algorithms for different values</a> +</h3></div></div></div> +<p> + In the previous example, <code class="computeroutput"><span class="identifier">legacy_node_traits</span><span class="special">::</span><span class="identifier">node</span></code> + type and <code class="computeroutput"><span class="identifier">legacy_value_traits</span><span class="special">::</span><span class="identifier">value_type</span></code> + are the same type, but this is not necessary. It's possible to have several + <code class="computeroutput"><span class="identifier">ValueTraits</span></code> defining the + same <code class="computeroutput"><span class="identifier">node_traits</span></code> type (and + thus, the same <code class="computeroutput"><span class="identifier">node_traits</span><span class="special">::</span><span class="identifier">node</span></code>). + This reduces the number of node algorithm instantiations, but now <code class="computeroutput"><span class="identifier">ValueTraits</span><span class="special">::</span><span class="identifier">to_node_ptr</span></code> and <code class="computeroutput"><span class="identifier">ValueTraits</span><span class="special">::</span><span class="identifier">to_value_ptr</span></code> + functions need to offer conversions between both types. Let's see a small + example: + </p> +<p> + First, we'll define the node to be used in the algorithms. For a linked list, + we just need a node that stores two pointers: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">link_mode</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> +<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">vector</span><span class="special">></span> + +<span class="comment">//This is the node that will be used with algorithms. </span> +<span class="keyword">struct</span> <span class="identifier">simple_node</span> +<span class="special">{</span> + <span class="identifier">simple_node</span> <span class="special">*</span><span class="identifier">prev_</span><span class="special">;</span> + <span class="identifier">simple_node</span> <span class="special">*</span><span class="identifier">next_</span><span class="special">;</span> +<span class="special">};</span> +</pre> +<p> + </p> +<p> + Now we'll define two different types that will be inserted in intrusive lists + and a templatized <code class="computeroutput"><span class="identifier">ValueTraits</span></code> + that will work for both types: + </p> +<p> +</p> +<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">base_1</span><span class="special">{};</span> +<span class="keyword">class</span> <span class="identifier">base_2</span><span class="special">{};</span> + +<span class="keyword">struct</span> <span class="identifier">value_1</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">base_1</span><span class="special">,</span> <span class="keyword">public</span> <span class="identifier">simple_node</span> +<span class="special">{</span> <span class="keyword">int</span> <span class="identifier">id_</span><span class="special">;</span> <span class="special">};</span> + +<span class="keyword">struct</span> <span class="identifier">value_2</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">base_1</span><span class="special">,</span> <span class="keyword">public</span> <span class="identifier">base_2</span><span class="special">,</span> <span class="keyword">public</span> <span class="identifier">simple_node</span> +<span class="special">{</span> <span class="keyword">float</span> <span class="identifier">id_</span><span class="special">;</span> <span class="special">};</span> + +<span class="comment">//Define the node traits. A single node_traits will be enough.</span> +<span class="keyword">struct</span> <span class="identifier">simple_node_traits</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">simple_node</span> <span class="identifier">node</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">node</span> <span class="special">*</span> <span class="identifier">node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">node</span> <span class="special">*</span> <span class="identifier">const_node_ptr</span><span class="special">;</span> + <span class="keyword">static</span> <span class="identifier">node</span> <span class="special">*</span><span class="identifier">get_next</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">node</span> <span class="special">*</span><span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">next_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_next</span><span class="special">(</span><span class="identifier">node</span> <span class="special">*</span><span class="identifier">n</span><span class="special">,</span> <span class="identifier">node</span> <span class="special">*</span><span class="identifier">next</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">next_</span> <span class="special">=</span> <span class="identifier">next</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">node</span> <span class="special">*</span><span class="identifier">get_previous</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">node</span> <span class="special">*</span><span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">prev_</span><span class="special">;</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">set_previous</span><span class="special">(</span><span class="identifier">node</span> <span class="special">*</span><span class="identifier">n</span><span class="special">,</span> <span class="identifier">node</span> <span class="special">*</span><span class="identifier">prev</span><span class="special">)</span> <span class="special">{</span> <span class="identifier">n</span><span class="special">-></span><span class="identifier">prev_</span> <span class="special">=</span> <span class="identifier">prev</span><span class="special">;</span> <span class="special">}</span> +<span class="special">};</span> + +<span class="comment">//A templatized value traits for value_1 and value_2</span> +<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">ValueType</span><span class="special">></span> +<span class="keyword">struct</span> <span class="identifier">simple_value_traits</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">simple_node_traits</span> <span class="identifier">node_traits</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">node_traits</span><span class="special">::</span><span class="identifier">node_ptr</span> <span class="identifier">node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">node_traits</span><span class="special">::</span><span class="identifier">const_node_ptr</span> <span class="identifier">const_node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">ValueType</span> <span class="identifier">value_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">ValueType</span> <span class="special">*</span> <span class="identifier">pointer</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">ValueType</span> <span class="special">*</span> <span class="identifier">const_pointer</span><span class="special">;</span> + <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">::</span><span class="identifier">link_mode_type</span> <span class="identifier">link_mode</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">::</span><span class="identifier">normal_link</span><span class="special">;</span> + <span class="keyword">static</span> <span class="identifier">node_ptr</span> <span class="identifier">to_node_ptr</span> <span class="special">(</span><span class="identifier">value_type</span> <span class="special">&</span><span class="identifier">value</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">node_ptr</span><span class="special">(&</span><span class="identifier">value</span><span class="special">);</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">const_node_ptr</span> <span class="identifier">to_node_ptr</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span><span class="identifier">value</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">const_node_ptr</span><span class="special">(&</span><span class="identifier">value</span><span class="special">);</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">pointer</span> <span class="identifier">to_value_ptr</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">value_type</span><span class="special">*>(</span><span class="identifier">n</span><span class="special">);</span> <span class="special">}</span> + <span class="keyword">static</span> <span class="identifier">const_pointer</span> <span class="identifier">to_value_ptr</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="special">{</span> <span class="keyword">return</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="keyword">const</span> <span class="identifier">value_type</span><span class="special">*>(</span><span class="identifier">n</span><span class="special">);</span> <span class="special">}</span> +<span class="special">};</span> +</pre> +<p> + </p> +<p> + Now define two containers. Both containers will instantiate the same list + algorithms (<code class="computeroutput"><span class="identifier">circular_list_algorithms</span><span class="special"><</span><span class="identifier">simple_node_traits</span><span class="special">></span></code>), due to the fact that the value traits + used to define the containers provide the same <code class="computeroutput"><span class="identifier">node_traits</span></code> + type: + </p> +<p> +</p> +<pre class="programlisting"><span class="comment">//Now define two intrusive lists. Both lists will use the same algorithms:</span> +<span class="comment">// circular_list_algorithms<simple_node_traits></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">list</span> <span class="special"><</span><span class="identifier">value_1</span><span class="special">,</span> <span class="identifier">value_traits</span><span class="special"><</span><span class="identifier">simple_value_traits</span><span class="special"><</span><span class="identifier">value_1</span><span class="special">></span> <span class="special">></span> <span class="special">></span> <span class="identifier">Value1List</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">list</span> <span class="special"><</span><span class="identifier">value_2</span><span class="special">,</span> <span class="identifier">value_traits</span><span class="special"><</span><span class="identifier">simple_value_traits</span><span class="special"><</span><span class="identifier">value_2</span><span class="special">></span> <span class="special">></span> <span class="special">></span> <span class="identifier">Value2List</span><span class="special">;</span> +</pre> +<p> + </p> +<p> + All <span class="bold"><strong>Boost.Intrusive</strong></span> containers using predefined + hooks use this technique to minimize code size: all possible <code class="computeroutput"><a class="link" href="../boost/intrusive/list.html" title="Class template list">list</a></code> + containers created with predefined hooks that define the same <code class="computeroutput"><span class="identifier">VoidPointer</span></code> type share the same list algorithms. + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.value_traits.simplifying_value_traits"></a><a class="link" href="value_traits.html#intrusive.value_traits.simplifying_value_traits" title="Simplifying value traits definition">Simplifying + value traits definition</a> +</h3></div></div></div> +<p> + The previous example can be further simplified using the <code class="computeroutput"><a class="link" href="../boost/intrusive/derivation_value_traits.html" title="Struct template derivation_value_traits">derivation_value_traits</a></code> + class to define a value traits class with a value that stores the <code class="computeroutput"><span class="identifier">simple_node</span></code> as a base class: + </p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">derivation_value_traits</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="comment">//value_1, value_2, simple_node and simple_node_traits are defined</span> +<span class="comment">//as in the previous example...</span> +<span class="comment">//...</span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="comment">//Now define the needed value traits using </span> +<span class="keyword">typedef</span> <span class="identifier">derivation_value_traits</span><span class="special"><</span><span class="identifier">value_1</span><span class="special">,</span> <span class="identifier">simple_node_traits</span><span class="special">,</span> <span class="identifier">normal_link</span><span class="special">></span> <span class="identifier">ValueTraits1</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">derivation_value_traits</span><span class="special"><</span><span class="identifier">value_2</span><span class="special">,</span> <span class="identifier">simple_node_traits</span><span class="special">,</span> <span class="identifier">normal_link</span><span class="special">></span> <span class="identifier">ValueTraits2</span><span class="special">;</span> + +<span class="comment">//Now define the containers</span> +<span class="keyword">typedef</span> <span class="identifier">list</span> <span class="special"><</span><span class="identifier">value1</span><span class="special">,</span> <span class="identifier">value_traits</span><span class="special"><</span><span class="identifier">ValueTraits1</span><span class="special">></span> <span class="special">></span> <span class="identifier">Value1List</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">list</span> <span class="special"><</span><span class="identifier">value2</span><span class="special">,</span> <span class="identifier">value_traits</span><span class="special"><</span><span class="identifier">ValueTraits2</span><span class="special">></span> <span class="special">></span> <span class="identifier">Value2List</span><span class="special">;</span> +</pre> +<p> + We can even choose to store <code class="computeroutput"><span class="identifier">simple_node</span></code> + as a member of <code class="computeroutput"><span class="identifier">value_1</span></code> and + <code class="computeroutput"><span class="identifier">value_2</span></code> classes and use + <code class="computeroutput"><a class="link" href="../boost/intrusive/member_value_traits.html" title="Struct template member_value_traits">member_value_traits</a></code> + to define the needed value traits classes: + </p> +<p> +</p> +<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">base_1</span><span class="special">{};</span> +<span class="keyword">class</span> <span class="identifier">base_2</span><span class="special">{};</span> + +<span class="keyword">struct</span> <span class="identifier">value_1</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">base_1</span><span class="special">,</span> <span class="keyword">public</span> <span class="identifier">simple_node</span> +<span class="special">{</span> + <span class="keyword">int</span> <span class="identifier">id_</span><span class="special">;</span> + <span class="identifier">simple_node</span> <span class="identifier">node_</span><span class="special">;</span> +<span class="special">};</span> + +<span class="keyword">struct</span> <span class="identifier">value_2</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">base_1</span><span class="special">,</span> <span class="keyword">public</span> <span class="identifier">base_2</span><span class="special">,</span> <span class="keyword">public</span> <span class="identifier">simple_node</span> +<span class="special">{</span> + <span class="identifier">simple_node</span> <span class="identifier">node_</span><span class="special">;</span> + <span class="keyword">float</span> <span class="identifier">id_</span><span class="special">;</span> +<span class="special">};</span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="keyword">typedef</span> <span class="identifier">member_value_traits</span> + <span class="special"><</span><span class="identifier">value_1</span><span class="special">,</span> <span class="identifier">simple_node_traits</span><span class="special">,</span> <span class="special">&</span><span class="identifier">value_1</span><span class="special">::</span><span class="identifier">node_</span><span class="special">,</span> <span class="identifier">normal_link</span><span class="special">></span> <span class="identifier">ValueTraits1</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">member_value_traits</span> +<span class="special"><</span><span class="identifier">value_2</span><span class="special">,</span> <span class="identifier">simple_node_traits</span><span class="special">,</span> <span class="special">&</span><span class="identifier">value_2</span><span class="special">::</span><span class="identifier">node_</span><span class="special">,</span> <span class="identifier">normal_link</span><span class="special">></span> <span class="identifier">ValueTraits2</span><span class="special">;</span> + +<span class="comment">//Now define two intrusive lists. Both lists will use the same algorithms:</span> +<span class="comment">// circular_list_algorithms<simple_node_traits></span> +<span class="keyword">typedef</span> <span class="identifier">list</span> <span class="special"><</span><span class="identifier">value_1</span><span class="special">,</span> <span class="identifier">value_traits</span><span class="special"><</span><span class="identifier">ValueTraits1</span><span class="special">></span> <span class="special">></span> <span class="identifier">Value1List</span><span class="special">;</span> +<span class="keyword">typedef</span> <span class="identifier">list</span> <span class="special"><</span><span class="identifier">value_2</span><span class="special">,</span> <span class="identifier">value_traits</span><span class="special"><</span><span class="identifier">ValueTraits2</span><span class="special">></span> <span class="special">></span> <span class="identifier">Value2List</span><span class="special">;</span> +</pre> +<p> + </p> +</div> +<div class="section"> +<div class="titlepage"><div><div><h3 class="title"> +<a name="intrusive.value_traits.stateful_value_traits"></a><a class="link" href="value_traits.html#intrusive.value_traits.stateful_value_traits" title="Stateful value traits">Stateful + value traits</a> +</h3></div></div></div> +<p> + Until now all shown custom value traits are stateless, that is, <span class="bold"><strong>the transformation between nodes and values is implemented in + terms of static functions</strong></span>. It's possible to use <span class="bold"><strong>stateful</strong></span> + value traits so that we can separate nodes and values and <span class="bold"><strong>avoid + modifying types to insert nodes</strong></span>. <span class="bold"><strong>Boost.Intrusive</strong></span> + differentiates between stateful and stateless value traits by checking if + all Node <-> Value transformation functions are static or not (except + for Visual 7.1, since overloaded static function detection is not possible, + in this case the implementation checks if the class is empty): + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + If all Node <-> Value transformation functions are static , a + <span class="bold"><strong>stateless</strong></span> value traits is assumed. transformations + must be static functions. + </li> +<li class="listitem"> + Otherwise a <span class="bold"><strong>stateful</strong></span> value traits is + assumed. + </li> +</ul></div> +<p> + Using stateful value traits it's possible to create containers of non-copyable/movable + objects <span class="bold"><strong>without modifying</strong></span> the definition + of the class to be inserted. This interesting property is achieved without + using global variables (stateless value traits could use global variables + to achieve the same goal), so: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Thread-safety guarantees</strong></span>: Better thread-safety + guarantees can be achieved with stateful value traits, since accessing + global resources might require synchronization primitives that can be + avoided when using internal state. + </li> +<li class="listitem"> + <span class="bold"><strong>Flexibility</strong></span>: A stateful value traits + type can be configured at run-time. + </li> +<li class="listitem"> + <span class="bold"><strong>Run-time polymorphism</strong></span>: A value traits + might implement node <-> value transformations as virtual functions. + A single container type could be configured at run-time to use different + node <-> value relationships. + </li> +</ul></div> +<p> + Stateful value traits have many advantages but also some downsides: + </p> +<div class="itemizedlist"><ul class="itemizedlist" type="disc"> +<li class="listitem"> + <span class="bold"><strong>Performance</strong></span>: Value traits operations + should be very efficient since they are basic operations used by containers. + <span class="bold"><strong>A heavy node <-> value transformation will + hurt intrusive containers' performance</strong></span>. + </li> +<li class="listitem"> + <span class="bold"><strong>Exception guarantees</strong></span>: The stateful ValueTraits + must maintain no-throw guarantees, otherwise, the container invariants + won't be preserved. + </li> +<li class="listitem"> + <span class="bold"><strong>Static functions</strong></span>: Some static functions + offered by intrusive containers are not available because node <-> + value transformations are not static. + </li> +<li class="listitem"> + <span class="bold"><strong>Bigger iterators</strong></span>: The size of some iterators + is increased because the iterator needs to store a pointer to the stateful + value traits to implement node to value transformations (e.g. <code class="computeroutput"><span class="keyword">operator</span><span class="special">*()</span></code> + and <code class="computeroutput"><span class="keyword">operator</span><span class="special">->()</span></code>). + </li> +</ul></div> +<p> + An easy and useful example of stateful value traits is when an array of values + can be indirectly introduced in a list guaranteeing no additional allocation + apart from the initial resource reservation: + </p> +<p> +</p> +<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">intrusive</span><span class="special">/</span><span class="identifier">list</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> + +<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intrusive</span><span class="special">;</span> + +<span class="comment">//This type is not modifiable so we can't store hooks or custom nodes</span> +<span class="keyword">typedef</span> <span class="keyword">int</span> <span class="identifier">identifier_t</span><span class="special">;</span> + +<span class="comment">//This value traits will associate elements from an array of identifiers with</span> +<span class="comment">//elements of an array of nodes. The element i of the value array will use the</span> +<span class="comment">//node i of the node array:</span> +<span class="keyword">struct</span> <span class="identifier">stateful_value_traits</span> +<span class="special">{</span> + <span class="keyword">typedef</span> <span class="identifier">list_node_traits</span><span class="special"><</span><span class="keyword">void</span><span class="special">*></span> <span class="identifier">node_traits</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">node_traits</span><span class="special">::</span><span class="identifier">node</span> <span class="identifier">node</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">node</span> <span class="special">*</span> <span class="identifier">node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">node</span> <span class="special">*</span> <span class="identifier">const_node_ptr</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">identifier_t</span> <span class="identifier">value_type</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="identifier">identifier_t</span> <span class="special">*</span> <span class="identifier">pointer</span><span class="special">;</span> + <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">identifier_t</span> <span class="special">*</span> <span class="identifier">const_pointer</span><span class="special">;</span> + <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">link_mode_type</span> <span class="identifier">link_mode</span> <span class="special">=</span> <span class="identifier">normal_link</span><span class="special">;</span> + + <span class="identifier">stateful_value_traits</span><span class="special">(</span><span class="identifier">pointer</span> <span class="identifier">ids</span><span class="special">,</span> <span class="identifier">node_ptr</span> <span class="identifier">node_array</span><span class="special">)</span> + <span class="special">:</span> <span class="identifier">ids_</span><span class="special">(</span><span class="identifier">ids</span><span class="special">),</span> <span class="identifier">nodes_</span><span class="special">(</span><span class="identifier">node_array</span><span class="special">)</span> + <span class="special">{}</span> + + <span class="comment">///Note: non static functions!</span> + <span class="identifier">node_ptr</span> <span class="identifier">to_node_ptr</span> <span class="special">(</span><span class="identifier">value_type</span> <span class="special">&</span><span class="identifier">value</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="keyword">this</span><span class="special">-></span><span class="identifier">nodes_</span> <span class="special">+</span> <span class="special">(&</span><span class="identifier">value</span> <span class="special">-</span> <span class="keyword">this</span><span class="special">-></span><span class="identifier">ids_</span><span class="special">);</span> <span class="special">}</span> + <span class="identifier">const_node_ptr</span> <span class="identifier">to_node_ptr</span> <span class="special">(</span><span class="keyword">const</span> <span class="identifier">value_type</span> <span class="special">&</span><span class="identifier">value</span><span class="special">)</span> <span class="keyword">const</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="keyword">this</span><span class="special">-></span><span class="identifier">nodes_</span> <span class="special">+</span> <span class="special">(&</span><span class="identifier">value</span> <span class="special">-</span> <span class="keyword">this</span><span class="special">-></span><span class="identifier">ids_</span><span class="special">);</span> <span class="special">}</span> + <span class="identifier">pointer</span> <span class="identifier">to_value_ptr</span><span class="special">(</span><span class="identifier">node_ptr</span> <span class="identifier">n</span><span class="special">)</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="keyword">this</span><span class="special">-></span><span class="identifier">ids_</span> <span class="special">+</span> <span class="special">(</span><span class="identifier">n</span> <span class="special">-</span> <span class="keyword">this</span><span class="special">-></span><span class="identifier">nodes_</span><span class="special">);</span> <span class="special">}</span> + <span class="identifier">const_pointer</span> <span class="identifier">to_value_ptr</span><span class="special">(</span><span class="identifier">const_node_ptr</span> <span class="identifier">n</span><span class="special">)</span> <span class="keyword">const</span> + <span class="special">{</span> <span class="keyword">return</span> <span class="keyword">this</span><span class="special">-></span><span class="identifier">ids_</span> <span class="special">+</span> <span class="special">(</span><span class="identifier">n</span> <span class="special">-</span> <span class="keyword">this</span><span class="special">-></span><span class="identifier">nodes_</span><span class="special">);</span> <span class="special">}</span> + + <span class="keyword">private</span><span class="special">:</span> + <span class="identifier">pointer</span> <span class="identifier">ids_</span><span class="special">;</span> + <span class="identifier">node_ptr</span> <span class="identifier">nodes_</span><span class="special">;</span> +<span class="special">};</span> + +<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> +<span class="special">{</span> + <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">NumElements</span> <span class="special">=</span> <span class="number">100</span><span class="special">;</span> + + <span class="comment">//This is an array of ids that we want to "store"</span> + <span class="identifier">identifier_t</span> <span class="identifier">ids</span> <span class="special">[</span><span class="identifier">NumElements</span><span class="special">];</span> + + <span class="comment">//This is an array of nodes that is necessary to form the linked list</span> + <span class="identifier">list_node_traits</span><span class="special"><</span><span class="keyword">void</span><span class="special">*>::</span><span class="identifier">node</span> <span class="identifier">nodes</span> <span class="special">[</span><span class="identifier">NumElements</span><span class="special">];</span> + + <span class="comment">//Initialize id objects, each one with a different number</span> + <span class="keyword">for</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">NumElements</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span> <span class="identifier">ids</span><span class="special">[</span><span class="identifier">i</span><span class="special">]</span> <span class="special">=</span> <span class="identifier">i</span><span class="special">;</span> + + <span class="comment">//Define a list that will "link" identifiers using external nodes</span> + <span class="keyword">typedef</span> <span class="identifier">list</span><span class="special"><</span><span class="identifier">identifier_t</span><span class="special">,</span> <span class="identifier">value_traits</span><span class="special"><</span><span class="identifier">stateful_value_traits</span><span class="special">></span> <span class="special">></span> <span class="identifier">List</span><span class="special">;</span> + + <span class="comment">//This list will store ids without modifying identifier_t instances</span> + <span class="comment">//Stateful value traits must be explicitly passed in the constructor.</span> + <span class="identifier">List</span> <span class="identifier">my_list</span> <span class="special">(</span><span class="identifier">stateful_value_traits</span> <span class="special">(</span><span class="identifier">ids</span><span class="special">,</span> <span class="identifier">nodes</span><span class="special">));</span> + + <span class="comment">//Insert ids in reverse order in the list</span> + <span class="keyword">for</span><span class="special">(</span><span class="identifier">identifier_t</span> <span class="special">*</span> <span class="identifier">it</span><span class="special">(&</span><span class="identifier">ids</span><span class="special">[</span><span class="number">0</span><span class="special">]),</span> <span class="special">*</span><span class="identifier">itend</span><span class="special">(&</span><span class="identifier">ids</span><span class="special">[</span><span class="identifier">NumElements</span><span class="special">]);</span> <span class="identifier">it</span> <span class="special">!=</span> <span class="identifier">itend</span><span class="special">;</span> <span class="special">++</span><span class="identifier">it</span><span class="special">)</span> + <span class="identifier">my_list</span><span class="special">.</span><span class="identifier">push_front</span><span class="special">(*</span><span class="identifier">it</span><span class="special">);</span> + + <span class="comment">//Now test lists</span> + <span class="identifier">List</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="identifier">list_it</span> <span class="special">(</span><span class="identifier">my_list</span><span class="special">.</span><span class="identifier">cbegin</span><span class="special">());</span> + <span class="identifier">identifier_t</span> <span class="special">*</span><span class="identifier">it_val</span><span class="special">(&</span><span class="identifier">ids</span><span class="special">[</span><span class="identifier">NumElements</span><span class="special">-</span><span class="number">1</span><span class="special">]),</span> <span class="special">*</span><span class="identifier">it_rbeg_val</span><span class="special">(&</span><span class="identifier">ids</span><span class="special">[</span><span class="number">0</span><span class="special">]-</span><span class="number">1</span><span class="special">);</span> + + <span class="comment">//Test the objects inserted in the base hook list</span> + <span class="keyword">for</span><span class="special">(;</span> <span class="identifier">it_val</span> <span class="special">!=</span> <span class="identifier">it_rbeg_val</span><span class="special">;</span> <span class="special">--</span><span class="identifier">it_val</span><span class="special">,</span> <span class="special">++</span><span class="identifier">list_it</span><span class="special">)</span> + <span class="keyword">if</span><span class="special">(&*</span><span class="identifier">list_it</span> <span class="special">!=</span> <span class="special">&*</span><span class="identifier">it_val</span><span class="special">)</span> <span class="keyword">return</span> <span class="number">1</span><span class="special">;</span> + + <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> +<span class="special">}</span> +</pre> +<p> + </p> +</div> +</div> +<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> +<td align="left"></td> +<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2011 Ion Gaztanaga<p> + Distributed under the Boost Software License, Version 1.0. (See accompanying + 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>) + </p> +</div></td> +</tr></table> +<hr> +<div class="spirit-nav"> +<a accesskey="p" href="node_algorithms.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../intrusive.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="thread_safety.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> +</div> +</body> +</html> |