1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<head> 4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5<title>Stability and insertion with hint in ordered associative containers with equivalent keys</title> 6<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> 7<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 8<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> 9<link rel="up" href="../intrusive.html" title="Chapter 19. Boost.Intrusive"> 10<link rel="prev" href="boost_intrusive_iterators.html" title="Boost.Intrusive Iterator features"> 11<link rel="next" href="obtaining_same_type_reducing_space.html" title="Obtaining the same types and reducing symbol length"> 12</head> 13<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 14<table cellpadding="2" width="100%"><tr> 15<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> 16<td align="center"><a href="../../../index.html">Home</a></td> 17<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> 18<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 19<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 20<td align="center"><a href="../../../more/index.htm">More</a></td> 21</tr></table> 22<hr> 23<div class="spirit-nav"> 24<a accesskey="p" href="boost_intrusive_iterators.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> 25</div> 26<div class="section"> 27<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 28<a name="intrusive.equal_range_stability"></a><a class="link" href="equal_range_stability.html" title="Stability and insertion with hint in ordered associative containers with equivalent keys">Stability and insertion 29 with hint in ordered associative containers with equivalent keys</a> 30</h2></div></div></div> 31<p> 32 <span class="bold"><strong>Boost.Intrusive</strong></span> ordered associative containers 33 with equivalent keys offer stability guarantees, following <a href="http://open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#233" target="_top">C++ 34 standard library's defect #233 resolution</a>, explained in document <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1780.html" target="_top">Comments 35 on LWG issue 233: Insertion hints in associative containers</a>. This means 36 that: 37 </p> 38<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 39<li class="listitem"> 40 A <span class="emphasis"><em>Insert without hint</em></span> member function always insert 41 at the upper bound of an equal range. 42 </li> 43<li class="listitem"> 44 A <span class="emphasis"><em>Insert with hint</em></span> member function inserts the new 45 value <span class="bold"><strong>before the hint</strong></span> if hint's and new 46 node's keys are equivalent. 47 </li> 48<li class="listitem"> 49 Implements Andrew Koenig <span class="emphasis"><em>as close as possible to hint</em></span> 50 proposal. A new element is always be inserted as close to the hint as possible. 51 So, for example, if there is a subsequence of equivalent values, <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span></code> as the hint means that the new element 52 should be inserted before the subsequence even if <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">begin</span><span class="special">()</span></code> is far away. This allows code to always 53 append (or prepend) an equal range with something as simple as: <code class="computeroutput"><span class="identifier">m</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">m</span><span class="special">.</span><span class="identifier">end</span><span class="special">(),</span> <span class="identifier">new_node</span><span class="special">);</span></code> 54 or <code class="computeroutput"><span class="identifier">m</span><span class="special">.</span><span class="identifier">insert</span><span class="special">(</span><span class="identifier">m</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">new_node</span><span class="special">);</span></code> 55 </li> 56</ul></div> 57</div> 58<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 59<td align="left"></td> 60<td align="right"><div class="copyright-footer">Copyright © 2005 Olaf Krzikalla<br>Copyright © 2006-2015 Ion Gaztanaga<p> 61 Distributed under the Boost Software License, Version 1.0. (See accompanying 62 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>) 63 </p> 64</div></td> 65</tr></table> 66<hr> 67<div class="spirit-nav"> 68<a accesskey="p" href="boost_intrusive_iterators.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> 69</div> 70</body> 71</html> 72