ord_indices.html 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0.1 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  5. <title>Boost.MultiIndex Documentation - Ordered indices reference</title>
  6. <link rel="stylesheet" href="../style.css" type="text/css">
  7. <link rel="start" href="../index.html">
  8. <link rel="prev" href="indices.html">
  9. <link rel="up" href="index.html">
  10. <link rel="next" href="hash_indices.html">
  11. </head>
  12. <body>
  13. <h1><img src="../../../../boost.png" alt="boost.png (6897 bytes)" align=
  14. "middle" width="277" height="86">Boost.MultiIndex Ordered indices reference</h1>
  15. <div class="prev_link"><a href="indices.html"><img src="../prev.gif" alt="index reference" border="0"><br>
  16. Index reference
  17. </a></div>
  18. <div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.MultiIndex reference" border="0"><br>
  19. Boost.MultiIndex reference
  20. </a></div>
  21. <div class="next_link"><a href="rnk_indices.html"><img src="../next.gif" alt="ranked indices" border="0"><br>
  22. Ranked indices
  23. </a></div><br clear="all" style="clear: all;">
  24. <hr>
  25. <h2>Contents</h2>
  26. <ul>
  27. <li><a href="#ord_index_fwd_synopsis">Header
  28. <code>"boost/multi_index/ordered_index_fwd.hpp"</code> synopsis</a></li>
  29. <li><a href="#synopsis">Header
  30. <code>"boost/multi_index/ordered_index.hpp"</code> synopsis</a>
  31. <ul>
  32. <li><a href="#unique_non_unique">
  33. Index specifiers <code>ordered_unique</code> and <code>ordered_non_unique</code>
  34. </a></li>
  35. <li><a href="#ord_indices">Ordered indices</a>
  36. <ul>
  37. <li><a href="#complexity_signature">Complexity signature</a></li>
  38. <li><a href="#instantiation_types">Instantiation types</a></li>
  39. <li><a href="#constructors">Constructors, copy and assignment</a></li>
  40. <li><a href="#iterators">Iterators</a></li>
  41. <li><a href="#modifiers">Modifiers</a></li>
  42. <li><a href="#observers">Observers</a></li>
  43. <li><a href="#set_operations">Set operations</a></li>
  44. <li><a href="#range_operations">Range operations</a></li>
  45. <li><a href="#serialization">Serialization</a></li>
  46. </ul>
  47. </li>
  48. </ul>
  49. </li>
  50. </ul>
  51. <h2>
  52. <a name="ord_index_fwd_synopsis">Header
  53. <a href="../../../../boost/multi_index/ordered_index_fwd.hpp">
  54. <code>"boost/multi_index/ordered_index_fwd.hpp"</code></a> synopsis</a></h2>
  55. <blockquote><pre>
  56. <span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
  57. <span class=keyword>namespace</span> <span class=identifier>multi_index</span><span class=special>{</span>
  58. <span class=comment>// index specifiers ordered_unique and ordered_non_unique</span>
  59. <span class=keyword>template</span><span class=special>&lt;</span><b>consult ordered_unique reference for arguments</b><span class=special>&gt;</span>
  60. <span class=keyword>struct</span> <span class=identifier>ordered_unique</span><span class=special>;</span>
  61. <span class=keyword>template</span><span class=special>&lt;</span><b>consult ordered_non_unique reference for arguments</b><span class=special>&gt;</span>
  62. <span class=keyword>struct</span> <span class=identifier>ordered_non_unique</span><span class=special>;</span>
  63. <span class=comment>// indices</span>
  64. <span class=keyword>namespace</span> <span class=identifier>detail</span><span class=special>{</span>
  65. <span class=keyword>template</span><span class=special>&lt;</span><b>implementation defined</b><span class=special>&gt;</span> <span class=keyword>class</span> <b>index name is implementation defined</b><span class=special>;</span>
  66. <span class=special>}</span> <span class=comment>// namespace boost::multi_index::detail</span>
  67. <span class=special>}</span> <span class=comment>// namespace boost::multi_index</span>
  68. <span class=special>}</span> <span class=comment>// namespace boost</span>
  69. </pre></blockquote>
  70. <p>
  71. <code>ordered_index_fwd.hpp</code> provides forward declarations for index specifiers
  72. <a href="#unique_non_unique"><code>ordered_unique</code> and <code>ordered_non_unique</code></a> and
  73. their associated <a href="#ord_indices">ordered index</a> classes.
  74. </p>
  75. <h2>
  76. <a name="synopsis">Header
  77. <a href="../../../../boost/multi_index/ordered_index.hpp">
  78. <code>"boost/multi_index/ordered_index.hpp"</code></a> synopsis</a></h2>
  79. <blockquote><pre>
  80. <span class=preprocessor>#include</span> <span class=special>&lt;</span><span class=identifier>initializer_list</span><span class=special>&gt;</span>
  81. <span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
  82. <span class=keyword>namespace</span> <span class=identifier>multi_index</span><span class=special>{</span>
  83. <span class=comment>// index specifiers ordered_unique and ordered_non_unique</span>
  84. <span class=keyword>template</span><span class=special>&lt;</span><b>consult ordered_unique reference for arguments</b><span class=special>&gt;</span>
  85. <span class=keyword>struct</span> <span class=identifier>ordered_unique</span><span class=special>;</span>
  86. <span class=keyword>template</span><span class=special>&lt;</span><b>consult ordered_non_unique reference for arguments</b><span class=special>&gt;</span>
  87. <span class=keyword>struct</span> <span class=identifier>ordered_non_unique</span><span class=special>;</span>
  88. <span class=comment>// indices</span>
  89. <span class=keyword>namespace</span> <span class=identifier>detail</span><span class=special>{</span>
  90. <span class=keyword>template</span><span class=special>&lt;</span><b>implementation defined</b><span class=special>&gt;</span> <span class=keyword>class</span> <b>index class name implementation defined</b><span class=special>;</span>
  91. <span class=comment>// index comparison:</span>
  92. <span class=comment>// <b>OP</b> is any of ==,&lt;,!=,&gt;,&gt;=,&lt;=</span>
  93. <span class=keyword>template</span><span class=special>&lt;</span><b>arg set 1</b><span class=special>,</span><b>arg set 2</b><span class=special>&gt;</span>
  94. <span class=keyword>bool</span> <span class=keyword>operator</span> <b><i>OP</i></b><span class=special>(</span>
  95. <span class=keyword>const</span> <b>index class name</b><span class=special>&lt;</span><b>arg set 1</b><span class=special>&gt;&amp;</span> <span class=identifier>x</span><span class=special>,</span><span class=keyword>const</span> <b>index class name</b><span class=special>&lt;</span><b>arg set 2</b><span class=special>&gt;&amp;</span> <span class=identifier>y</span><span class=special>);</span>
  96. <span class=comment>// index specialized algorithms:</span>
  97. <span class=keyword>template</span><span class=special>&lt;</span><b>implementation defined</b><span class=special>&gt;</span>
  98. <span class=keyword>void</span> <span class=identifier>swap</span><span class=special>(</span><b>index class name</b><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>,</span><b>index class name</b><span class=special>&amp;</span> <span class=identifier>y</span><span class=special>);</span>
  99. <span class=special>}</span> <span class=comment>// namespace boost::multi_index::detail</span>
  100. <span class=special>}</span> <span class=comment>// namespace boost::multi_index</span>
  101. <span class=special>}</span> <span class=comment>// namespace boost</span>
  102. </pre></blockquote>
  103. <h3><a name="unique_non_unique">
  104. Index specifiers <code>ordered_unique</code> and <code>ordered_non_unique</code>
  105. </a></h3>
  106. <p>
  107. These <a href="indices.html#index_specification">index specifiers</a> allow
  108. for insertion of <a href="#ord_indices">ordered indices</a> without and with
  109. allowance of duplicate elements, respectively. The syntax of <code>ordered_unique</code>
  110. and <code>ordered_non_unique</code> coincide, thus we describe them in a grouped manner.
  111. <code>ordered_unique</code> and <code>ordered_non_unique</code> can be instantiated in
  112. two different forms, according to whether a tag list for the index is provided or not:
  113. </p>
  114. <blockquote><pre>
  115. <span class=keyword>template</span><span class=special>&lt;</span>
  116. <span class=keyword>typename</span> <span class=identifier>KeyFromValue</span><span class=special>,</span>
  117. <span class=keyword>typename</span> <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>&lt;</span><span class=identifier>KeyFromValue</span><span class=special>::</span><span class=identifier>result_type</span><span class=special>&gt;</span>
  118. <span class=special>&gt;</span>
  119. <span class=keyword>struct</span> <span class=special>(</span><span class=identifier>ordered_unique</span> <span class=special>|</span> <span class=identifier>ordered_non_unique</span><span class=special>)</span><span class=special>;</span>
  120. <span class=keyword>template</span><span class=special>&lt;</span>
  121. <span class=keyword>typename</span> <span class=identifier>TagList</span><span class=special>,</span>
  122. <span class=keyword>typename</span> <span class=identifier>KeyFromValue</span><span class=special>,</span>
  123. <span class=keyword>typename</span> <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>&lt;</span><span class=identifier>KeyFromValue</span><span class=special>::</span><span class=identifier>result_type</span><span class=special>&gt;</span>
  124. <span class=special>&gt;</span>
  125. <span class=keyword>struct</span> <span class=special>(</span><span class=identifier>ordered_unique</span> <span class=special>|</span> <span class=identifier>ordered_non_unique</span><span class=special>)</span><span class=special>;</span>
  126. </pre></blockquote>
  127. <p>
  128. If provided, <code>TagList</code> must be an instantiation of the class template
  129. <a href="indices.html#tag"><code>tag</code></a>.
  130. The template arguments are used by the corresponding index implementation,
  131. refer to the <a href="#ord_indices">ordered indices</a> reference section for further
  132. explanations on their acceptable type values.
  133. </p>
  134. <h3><a name="ord_indices">Ordered indices</a></h3>
  135. <p>
  136. An ordered index provides a set-like interface to the underlying heap of
  137. elements contained in a <code>multi_index_container</code>. An ordered index is
  138. particularized according to a given
  139. <a href="key_extraction.html#key_extractors"><code>Key Extractor</code></a>
  140. that retrieves keys from elements of <code>multi_index_container</code> and a comparison
  141. predicate.
  142. </p>
  143. <p>
  144. There are two variants of ordered indices: <i>unique</i>, which do
  145. not allow duplicate elements (with respect to its associated comparison
  146. predicate) and <i>non-unique</i>, which accept those duplicates.
  147. The interface of these two variants is the same, so they are documented
  148. together, with minor differences explicitly stated when they exist.
  149. </p>
  150. <p>
  151. Except where noted or if the corresponding interface does not exist,
  152. ordered indices (both unique and non-unique) satisfy the C++ requirements
  153. for associative containers at <b>[associative.reqmts]</b>
  154. (supporting unique and equivalent keys, respectively.)
  155. Accordingly, validity of iterators and references to elements is
  156. preserved. We only provide descriptions of those types and operations that
  157. do not exactly conform to or are not mandated by the standard requirements.
  158. </p>
  159. <blockquote><pre>
  160. <span class=keyword>namespace</span> <span class=identifier>boost</span><span class=special>{</span>
  161. <span class=keyword>namespace</span> <span class=identifier>multi_index</span><span class=special>{</span>
  162. <b>implementation defined </b><span class=identifier>unbounded</span><span class=special>;</span> <span class=comment>// see range()</span>
  163. <span class=keyword>namespace</span> <span class=identifier>detail</span><span class=special>{</span>
  164. <span class=keyword>template</span><span class=special>&lt;</span><b>implementation defined: dependent on types Value, Allocator,
  165. TagList, KeyFromValue, Compare</b><span class=special>&gt;</span>
  166. <span class=keyword>class</span> <b>name is implementation defined</b>
  167. <span class=special>{</span>
  168. <span class=keyword>public</span><span class=special>:</span>
  169. <span class=comment>// types:</span>
  170. <span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>KeyFromValue</span><span class=special>::</span><span class=identifier>result_type</span> <span class=identifier>key_type</span><span class=special>;</span>
  171. <span class=keyword>typedef</span> <span class=identifier>Value</span> <span class=identifier>value_type</span><span class=special>;</span>
  172. <span class=keyword>typedef</span> <span class=identifier>KeyFromValue</span> <span class=identifier>key_from_value</span><span class=special>;</span>
  173. <span class=keyword>typedef</span> <span class=identifier>Compare</span> <span class=identifier>key_compare</span><span class=special>;</span>
  174. <span class=keyword>typedef</span> <b>implementation defined </b><span class=identifier>value_compare</span><span class=special>;</span>
  175. <span class=keyword>typedef</span> <span class=identifier>boost</span><span class=special>::</span><span class=identifier>tuple</span><span class=special>&lt;</span><span class=identifier>key_from_value</span><span class=special>,</span><span class=identifier>key_compare</span><span class=special>&gt;</span> <span class=identifier>ctor_args</span><span class=special>;</span>
  176. <span class=keyword>typedef</span> <span class=identifier>TagList</span> <span class=identifier>tag_list</span><span class=special>;</span>
  177. <span class=keyword>typedef</span> <span class=identifier>Allocator</span> <span class=identifier>allocator_type</span><span class=special>;</span>
  178. <span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>Allocator</span><span class=special>::</span><span class=identifier>reference</span> <span class=identifier>reference</span><span class=special>;</span>
  179. <span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>Allocator</span><span class=special>::</span><span class=identifier>const_reference</span> <span class=identifier>const_reference</span><span class=special>;</span>
  180. <span class=keyword>typedef</span> <b>implementation defined </b><span class=identifier>iterator</span><span class=special>;</span>
  181. <span class=keyword>typedef</span> <b>implementation defined </b><span class=identifier>const_iterator</span><span class=special>;</span>
  182. <span class=keyword>typedef</span> <b>implementation defined </b><span class=identifier>size_type</span><span class=special>;</span>
  183. <span class=keyword>typedef</span> <b>implementation defined </b><span class=identifier>difference_type</span><span class=special>;</span>
  184. <span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>Allocator</span><span class=special>::</span><span class=identifier>pointer</span> <span class=identifier>pointer</span><span class=special>;</span>
  185. <span class=keyword>typedef</span> <span class=keyword>typename</span> <span class=identifier>Allocator</span><span class=special>::</span><span class=identifier>const_pointer</span> <span class=identifier>const_pointer</span><span class=special>;</span>
  186. <span class=keyword>typedef</span> <b>equivalent to
  187. std::reverse_iterator&lt;iterator&gt;</b> <span class=identifier>reverse_iterator</span><span class=special>;</span>
  188. <span class=keyword>typedef</span> <b>equivalent to
  189. std::reverse_iterator&lt;const_iterator&gt;</b> <span class=identifier>const_reverse_iterator</span><span class=special>;</span>
  190. <span class=comment>// construct/copy/destroy:</span>
  191. <b>index class name</b><span class=special>&amp;</span> <span class=keyword>operator</span><span class=special>=(</span><span class=keyword>const</span> <b>index class name</b><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>);</span>
  192. <b>index class name</b><span class=special>&amp;</span> <span class=keyword>operator</span><span class=special>=(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>initializer_list</span><span class=special>&lt;</span><span class=identifier>value_type</span><span class=special>&gt;</span> <span class=identifier>list</span><span class=special>);</span>
  193. <span class=identifier>allocator_type</span> <span class=identifier>get_allocator</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
  194. <span class=comment>// iterators:</span>
  195. <span class=identifier>iterator</span> <span class=identifier>begin</span><span class=special>()</span><span class=keyword>noexcept</span><span class=special>;</span>
  196. <span class=identifier>const_iterator</span> <span class=identifier>begin</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
  197. <span class=identifier>iterator</span> <span class=identifier>end</span><span class=special>()</span><span class=keyword>noexcept</span><span class=special>;</span>
  198. <span class=identifier>const_iterator</span> <span class=identifier>end</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
  199. <span class=identifier>reverse_iterator</span> <span class=identifier>rbegin</span><span class=special>()</span><span class=keyword>noexcept</span><span class=special>;</span>
  200. <span class=identifier>const_reverse_iterator</span> <span class=identifier>rbegin</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
  201. <span class=identifier>reverse_iterator</span> <span class=identifier>rend</span><span class=special>()</span><span class=keyword>noexcept</span><span class=special>;</span>
  202. <span class=identifier>const_reverse_iterator</span> <span class=identifier>rend</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
  203. <span class=identifier>const_iterator</span> <span class=identifier>cbegin</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
  204. <span class=identifier>const_iterator</span> <span class=identifier>cend</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
  205. <span class=identifier>const_reverse_iterator</span> <span class=identifier>crbegin</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
  206. <span class=identifier>const_reverse_iterator</span> <span class=identifier>crend</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
  207. <span class=identifier>iterator</span> <span class=identifier>iterator_to</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>value_type</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>);</span>
  208. <span class=identifier>const_iterator</span> <span class=identifier>iterator_to</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>value_type</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>)</span><span class=keyword>const</span><span class=special>;</span>
  209. <span class=comment>// capacity:</span>
  210. <span class=keyword>bool</span> <span class=identifier>empty</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
  211. <span class=identifier>size_type</span> <span class=identifier>size</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
  212. <span class=identifier>size_type</span> <span class=identifier>max_size</span><span class=special>()</span><span class=keyword>const</span> <span class=keyword>noexcept</span><span class=special>;</span>
  213. <span class=comment>// modifiers:</span>
  214. <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span><span class=special>...</span> <span class=identifier>Args</span><span class=special>&gt;</span>
  215. <span class=identifier>std</span><span class=special>::</span><span class=identifier>pair</span><span class=special>&lt;</span><span class=identifier>iterator</span><span class=special>,</span><span class=keyword>bool</span><span class=special>&gt;</span> <span class=identifier>emplace</span><span class=special>(</span><span class=identifier>Args</span><span class=special>&amp;&amp;...</span> <span class=identifier>args</span><span class=special>);</span>
  216. <span class=keyword>template</span> <span class=special>&lt;</span><span class=keyword>typename</span><span class=special>...</span> <span class=identifier>Args</span><span class=special>&gt;</span>
  217. <span class=identifier>iterator</span> <span class=identifier>emplace_hint</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Args</span><span class=special>&amp;&amp;...</span> <span class=identifier>args</span><span class=special>);</span>
  218. <span class=identifier>std</span><span class=special>::</span><span class=identifier>pair</span><span class=special>&lt;</span><span class=identifier>iterator</span><span class=special>,</span><span class=keyword>bool</span><span class=special>&gt;</span> <span class=identifier>insert</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>value_type</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>);</span>
  219. <span class=identifier>std</span><span class=special>::</span><span class=identifier>pair</span><span class=special>&lt;</span><span class=identifier>iterator</span><span class=special>,</span><span class=keyword>bool</span><span class=special>&gt;</span> <span class=identifier>insert</span><span class=special>(</span><span class=identifier>value_type</span><span class=special>&amp;&amp;</span> <span class=identifier>x</span><span class=special>);</span>
  220. <span class=identifier>iterator</span> <span class=identifier>insert</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=keyword>const</span> <span class=identifier>value_type</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>);</span>
  221. <span class=identifier>iterator</span> <span class=identifier>insert</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>value_type</span><span class=special>&amp;&amp;</span> <span class=identifier>x</span><span class=special>);</span>
  222. <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>InputIterator</span><span class=special>&gt;</span>
  223. <span class=keyword>void</span> <span class=identifier>insert</span><span class=special>(</span><span class=identifier>InputIterator</span> <span class=identifier>first</span><span class=special>,</span><span class=identifier>InputIterator</span> <span class=identifier>last</span><span class=special>);</span>
  224. <span class=keyword>void</span> <span class=identifier>insert</span><span class=special>(</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>initializer_list</span><span class=special>&lt;</span><span class=identifier>value_type</span><span class=special>&gt;</span> <span class=identifier>list</span><span class=special>);</span>
  225. <span class=identifier>iterator</span> <span class=identifier>erase</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>);</span>
  226. <span class=identifier>size_type</span> <span class=identifier>erase</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>key_type</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>);</span>
  227. <span class=identifier>iterator</span> <span class=identifier>erase</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>first</span><span class=special>,</span><span class=identifier>iterator</span> <span class=identifier>last</span><span class=special>);</span>
  228. <span class=keyword>bool</span> <span class=identifier>replace</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=keyword>const</span> <span class=identifier>value_type</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>);</span>
  229. <span class=keyword>bool</span> <span class=identifier>replace</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>value_type</span><span class=special>&amp;&amp;</span> <span class=identifier>x</span><span class=special>);</span>
  230. <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>Modifier</span><span class=special>&gt;</span> <span class=keyword>bool</span> <span class=identifier>modify</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Modifier</span> <span class=identifier>mod</span><span class=special>);</span>
  231. <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>Modifier</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Rollback</span><span class=special>&gt;</span>
  232. <span class=keyword>bool</span> <span class=identifier>modify</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Modifier</span> <span class=identifier>mod</span><span class=special>,</span><span class=identifier>Rollback</span> <span class=identifier>back</span><span class=special>);</span>
  233. <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>Modifier</span><span class=special>&gt;</span> <span class=keyword>bool</span> <span class=identifier>modify_key</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Modifier</span> <span class=identifier>mod</span><span class=special>);</span>
  234. <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>Modifier</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>Rollback</span><span class=special>&gt;</span>
  235. <span class=keyword>bool</span> <span class=identifier>modify_key</span><span class=special>(</span><span class=identifier>iterator</span> <span class=identifier>position</span><span class=special>,</span><span class=identifier>Modifier</span> <span class=identifier>mod</span><span class=special>,</span><span class=identifier>Rollback</span> <span class=identifier>back</span><span class=special>);</span>
  236. <span class=keyword>void</span> <span class=identifier>swap</span><span class=special>(</span><b>index class name</b><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>);</span>
  237. <span class=keyword>void</span> <span class=identifier>clear</span><span class=special>()</span><span class=keyword>noexcept</span><span class=special>;</span>
  238. <span class=comment>// observers:</span>
  239. <span class=identifier>key_from_value</span> <span class=identifier>key_extractor</span><span class=special>()</span><span class=keyword>const</span><span class=special>;</span>
  240. <span class=identifier>key_compare</span> <span class=identifier>key_comp</span><span class=special>()</span><span class=keyword>const</span><span class=special>;</span>
  241. <span class=identifier>value_compare</span> <span class=identifier>value_comp</span><span class=special>()</span><span class=keyword>const</span><span class=special>;</span>
  242. <span class=comment>// set operations:</span>
  243. <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>CompatibleKey</span><span class=special>&gt;</span>
  244. <span class=identifier>iterator</span> <span class=identifier>find</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>CompatibleKey</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>)</span><span class=keyword>const</span><span class=special>;</span>
  245. <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>CompatibleKey</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>CompatibleCompare</span><span class=special>&gt;</span>
  246. <span class=identifier>iterator</span> <span class=identifier>find</span><span class=special>(</span>
  247. <span class=keyword>const</span> <span class=identifier>CompatibleKey</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>,</span><span class=keyword>const</span> <span class=identifier>CompatibleCompare</span><span class=special>&amp;</span> <span class=identifier>comp</span><span class=special>)</span><span class=keyword>const</span><span class=special>;</span>
  248. <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>CompatibleKey</span><span class=special>&gt;</span>
  249. <span class=identifier>size_type</span> <span class=identifier>count</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>CompatibleKey</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>)</span><span class=keyword>const</span><span class=special>;</span>
  250. <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>CompatibleKey</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>CompatibleCompare</span><span class=special>&gt;</span>
  251. <span class=identifier>size_type</span> <span class=identifier>count</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>CompatibleKey</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>,</span><span class=keyword>const</span> <span class=identifier>CompatibleCompare</span><span class=special>&amp;</span> <span class=identifier>comp</span><span class=special>)</span><span class=keyword>const</span><span class=special>;</span>
  252. <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>CompatibleKey</span><span class=special>&gt;</span>
  253. <span class=identifier>iterator</span> <span class=identifier>lower_bound</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>CompatibleKey</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>)</span><span class=keyword>const</span><span class=special>;</span>
  254. <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>CompatibleKey</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>CompatibleCompare</span><span class=special>&gt;</span>
  255. <span class=identifier>iterator</span> <span class=identifier>lower_bound</span><span class=special>(</span>
  256. <span class=keyword>const</span> <span class=identifier>CompatibleKey</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>,</span><span class=keyword>const</span> <span class=identifier>CompatibleCompare</span><span class=special>&amp;</span> <span class=identifier>comp</span><span class=special>)</span><span class=keyword>const</span><span class=special>;</span>
  257. <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>CompatibleKey</span><span class=special>&gt;</span>
  258. <span class=identifier>iterator</span> <span class=identifier>upper_bound</span><span class=special>(</span><span class=keyword>const</span> <span class=identifier>CompatibleKey</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>)</span><span class=keyword>const</span><span class=special>;</span>
  259. <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>CompatibleKey</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>CompatibleCompare</span><span class=special>&gt;</span>
  260. <span class=identifier>iterator</span> <span class=identifier>upper_bound</span><span class=special>(</span>
  261. <span class=keyword>const</span> <span class=identifier>CompatibleKey</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>,</span><span class=keyword>const</span> <span class=identifier>CompatibleCompare</span><span class=special>&amp;</span> <span class=identifier>comp</span><span class=special>)</span><span class=keyword>const</span><span class=special>;</span>
  262. <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>CompatibleKey</span><span class=special>&gt;</span>
  263. <span class=identifier>std</span><span class=special>::</span><span class=identifier>pair</span><span class=special>&lt;</span><span class=identifier>iterator</span><span class=special>,</span><span class=identifier>iterator</span><span class=special>&gt;</span> <span class=identifier>equal_range</span><span class=special>(</span>
  264. <span class=keyword>const</span> <span class=identifier>CompatibleKey</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>)</span><span class=keyword>const</span><span class=special>;</span>
  265. <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>CompatibleKey</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>CompatibleCompare</span><span class=special>&gt;</span>
  266. <span class=identifier>std</span><span class=special>::</span><span class=identifier>pair</span><span class=special>&lt;</span><span class=identifier>iterator</span><span class=special>,</span><span class=identifier>iterator</span><span class=special>&gt;</span> <span class=identifier>equal_range</span><span class=special>(</span>
  267. <span class=keyword>const</span> <span class=identifier>CompatibleKey</span><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>,</span><span class=keyword>const</span> <span class=identifier>CompatibleCompare</span><span class=special>&amp;</span> <span class=identifier>comp</span><span class=special>)</span><span class=keyword>const</span><span class=special>;</span>
  268. <span class=comment>// range:</span>
  269. <span class=keyword>template</span><span class=special>&lt;</span><span class=keyword>typename</span> <span class=identifier>LowerBounder</span><span class=special>,</span><span class=keyword>typename</span> <span class=identifier>UpperBounder</span><span class=special>&gt;</span>
  270. <span class=identifier>std</span><span class=special>::</span><span class=identifier>pair</span><span class=special>&lt;</span><span class=identifier>iterator</span><span class=special>,</span><span class=identifier>iterator</span><span class=special>&gt;</span> <span class=identifier>range</span><span class=special>(</span>
  271. <span class=identifier>LowerBounder</span> <span class=identifier>lower</span><span class=special>,</span><span class=identifier>UpperBounder</span> <span class=identifier>upper</span><span class=special>)</span><span class=keyword>const</span><span class=special>;</span>
  272. <span class=special>};</span>
  273. <span class=comment>// index comparison:</span>
  274. <span class=keyword>template</span><span class=special>&lt;</span><b>arg set 1</b><span class=special>,</span><b>arg set 2</b><span class=special>&gt;</span>
  275. <span class=keyword>bool</span> <span class=keyword>operator</span><span class=special>==(</span>
  276. <span class=keyword>const</span> <b>index class name</b><span class=special>&lt;</span><b>arg set 1</b><span class=special>&gt;&amp;</span> <span class=identifier>x</span><span class=special>,</span>
  277. <span class=keyword>const</span> <b>index class name</b><span class=special>&lt;</span><b>arg set 2</b><span class=special>&gt;&amp;</span> <span class=identifier>y</span><span class=special>)</span>
  278. <span class=special>{</span>
  279. <span class=keyword>return</span> <span class=identifier>x</span><span class=special>.</span><span class=identifier>size</span><span class=special>()==</span><span class=identifier>y</span><span class=special>.</span><span class=identifier>size</span><span class=special>()&amp;&amp;</span><span class=identifier>std</span><span class=special>::</span><span class=identifier>equal</span><span class=special>(</span><span class=identifier>x</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>x</span><span class=special>.</span><span class=identifier>end</span><span class=special>(),</span><span class=identifier>y</span><span class=special>.</span><span class=identifier>begin</span><span class=special>());</span>
  280. <span class=special>}</span>
  281. <span class=keyword>template</span><span class=special>&lt;</span><b>arg set 1</b><span class=special>,</span><b>arg set 2</b><span class=special>&gt;</span>
  282. <span class=keyword>bool</span> <span class=keyword>operator</span><span class=special>&lt;(</span>
  283. <span class=keyword>const</span> <b>index class name</b><span class=special>&lt;</span><b>arg set 1</b><span class=special>&gt;&amp;</span> <span class=identifier>x</span><span class=special>,</span>
  284. <span class=keyword>const</span> <b>index class name</b><span class=special>&lt;</span><b>arg set 2</b><span class=special>&gt;&amp;</span> <span class=identifier>y</span><span class=special>)</span>
  285. <span class=special>{</span>
  286. <span class=keyword>return</span> <span class=identifier>std</span><span class=special>::</span><span class=identifier>lexicographical_compare</span><span class=special>(</span><span class=identifier>x</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>x</span><span class=special>.</span><span class=identifier>end</span><span class=special>(),</span><span class=identifier>y</span><span class=special>.</span><span class=identifier>begin</span><span class=special>(),</span><span class=identifier>y</span><span class=special>.</span><span class=identifier>end</span><span class=special>());</span>
  287. <span class=special>}</span>
  288. <span class=keyword>template</span><span class=special>&lt;</span><b>arg set 1</b><span class=special>,</span><b>arg set 2</b><span class=special>&gt;</span>
  289. <span class=keyword>bool</span> <span class=keyword>operator</span><span class=special>!=(</span>
  290. <span class=keyword>const</span> <b>index class name</b><span class=special>&lt;</span><b>arg set 1</b><span class=special>&gt;&amp;</span> <span class=identifier>x</span><span class=special>,</span>
  291. <span class=keyword>const</span> <b>index class name</b><span class=special>&lt;</span><b>arg set 2</b><span class=special>&gt;&amp;</span> <span class=identifier>y</span><span class=special>)</span>
  292. <span class=special>{</span>
  293. <span class=keyword>return</span> <span class=special>!(</span><span class=identifier>x</span><span class=special>==</span><span class=identifier>y</span><span class=special>);</span>
  294. <span class=special>}</span>
  295. <span class=keyword>template</span><span class=special>&lt;</span><b>arg set 1</b><span class=special>,</span><b>arg set 2</b><span class=special>&gt;</span>
  296. <span class=keyword>bool</span> <span class=keyword>operator</span><span class=special>&gt;(</span>
  297. <span class=keyword>const</span> <b>index class name</b><span class=special>&lt;</span><b>arg set 1</b><span class=special>&gt;&amp;</span> <span class=identifier>x</span><span class=special>,</span>
  298. <span class=keyword>const</span> <b>index class name</b><span class=special>&lt;</span><b>arg set 2</b><span class=special>&gt;&amp;</span> <span class=identifier>y</span><span class=special>)</span>
  299. <span class=special>{</span>
  300. <span class=keyword>return</span> <span class=identifier>y</span><span class=special>&lt;</span><span class=identifier>x</span><span class=special>;</span>
  301. <span class=special>}</span>
  302. <span class=keyword>template</span><span class=special>&lt;</span><b>arg set 1</b><span class=special>,</span><b>arg set 2</b><span class=special>&gt;</span>
  303. <span class=keyword>bool</span> <span class=keyword>operator</span><span class=special>&gt;=(</span>
  304. <span class=keyword>const</span> <b>index class name</b><span class=special>&lt;</span><b>arg set 1</b><span class=special>&gt;&amp;</span> <span class=identifier>x</span><span class=special>,</span>
  305. <span class=keyword>const</span> <b>index class name</b><span class=special>&lt;</span><b>arg set 2</b><span class=special>&gt;&amp;</span> <span class=identifier>y</span><span class=special>)</span>
  306. <span class=special>{</span>
  307. <span class=keyword>return</span> <span class=special>!(</span><span class=identifier>x</span><span class=special>&lt;</span><span class=identifier>y</span><span class=special>);</span>
  308. <span class=special>}</span>
  309. <span class=keyword>template</span><span class=special>&lt;</span><b>arg set 1</b><span class=special>,</span><b>arg set 2</b><span class=special>&gt;</span>
  310. <span class=keyword>bool</span> <span class=keyword>operator</span><span class=special>&lt;=(</span>
  311. <span class=keyword>const</span> <b>index class name</b><span class=special>&lt;</span><b>arg set 1</b><span class=special>&gt;&amp;</span> <span class=identifier>x</span><span class=special>,</span>
  312. <span class=keyword>const</span> <b>index class name</b><span class=special>&lt;</span><b>arg set 2</b><span class=special>&gt;&amp;</span> <span class=identifier>y</span><span class=special>)</span>
  313. <span class=special>{</span>
  314. <span class=keyword>return</span> <span class=special>!(</span><span class=identifier>x</span><span class=special>&gt;</span><span class=identifier>y</span><span class=special>);</span>
  315. <span class=special>}</span>
  316. <span class=comment>// index specialized algorithms:</span>
  317. <span class=keyword>template</span><span class=special>&lt;</span><b>implementation defined</b><span class=special>&gt;</span>
  318. <span class=keyword>void</span> <span class=identifier>swap</span><span class=special>(</span><b>index class name</b><span class=special>&amp;</span> <span class=identifier>x</span><span class=special>,</span><b>index class name</b><span class=special>&amp;</span> <span class=identifier>y</span><span class=special>);</span>
  319. <span class=special>}</span> <span class=comment>// namespace boost::multi_index::detail</span>
  320. <span class=special>}</span> <span class=comment>// namespace boost::multi_index</span>
  321. <span class=special>}</span> <span class=comment>// namespace boost</span>
  322. </pre></blockquote>
  323. <h4><a name="complexity_signature">Complexity signature</a></h4>
  324. <p>
  325. Here and in the descriptions of operations of ordered indices, we adopt the
  326. scheme outlined in the
  327. <a href="indices.html#complexity_signature">complexity signature
  328. section</a>. The complexity signature of ordered indices is:
  329. <ul>
  330. <li>copying: <code>c(n)=n*log(n)</code>,</li>
  331. <li>insertion: <code>i(n)=log(n)</code>,</li>
  332. <li>hinted insertion: <code>h(n)=1</code> (constant) if the hint element
  333. is immediately after the point of insertion, <code>h(n)=log(n)</code> otherwise,</li>
  334. <li>deletion: <code>d(n)=1</code> (amortized constant),</li>
  335. <li>replacement: <code>r(n)=1</code> (constant) if the element position does not
  336. change, <code>r(n)=log(n)</code> otherwise,</li>
  337. <li>modifying: <code>m(n)=1</code> (constant) if the element position does not
  338. change, <code>m(n)=log(n)</code> otherwise.</li>
  339. </ul>
  340. </p>
  341. <h4><a name="instantiation_types">Instantiation types</a></h4>
  342. <p>Ordered indices are instantiated internally to <code>multi_index_container</code> and
  343. specified by means of <a href="indices.html#indexed_by"><code>indexed_by</code></a>
  344. with <a href="#unique_non_unique"> index specifiers <code>ordered_unique</code>
  345. and <code>ordered_non_unique</code></a>. Instantiations are dependent on the
  346. following types:
  347. <ul>
  348. <li><code>Value</code> from <code>multi_index_container</code>,</li>
  349. <li><code>Allocator</code> from <code>multi_index_container</code>,</li>
  350. <li><code>TagList</code> from the index specifier (if provided, otherwise <code>tag&lt;&gt;</code> is assumed),</li>
  351. <li><code>KeyFromValue</code> from the index specifier,</li>
  352. <li><code>Compare</code> from the index specifier.</li>
  353. </ul>
  354. <code>TagList</code> must be an instantiation of
  355. <a href="indices.html#tag"><code>tag</code></a>. The type <code>KeyFromValue</code>,
  356. which determines the mechanism for extracting a key from <code>Value</code>,
  357. must be a model of <a href="key_extraction.html#key_extractors">
  358. <code>Key Extractor</code></a> from <code>Value</code>. <code>Compare</code> is a
  359. <code>CopyConstructible</code> binary predicate inducing a strict weak order
  360. on elements of <code>KeyFromValue::result_type</code>.
  361. </p>
  362. <h4><a name="constructors">Constructors, copy and assignment</a></h4>
  363. <p>
  364. As explained in the <a href="indices.html#index_concepts">index
  365. concepts section</a>, indices do not have public constructors or destructors.
  366. Assignment, on the other hand, is provided.
  367. </p>
  368. <code><b>index class name</b>&amp; operator=(const <b>index class name</b>&amp; x);</code>
  369. <blockquote>
  370. <b>Effects:</b>
  371. <blockquote><pre>
  372. <span class=identifier>a</span><span class=special>=</span><span class=identifier>b</span><span class=special>;</span>
  373. </pre></blockquote>
  374. where <code>a</code> and <code>b</code> are the <code>multi_index_container</code>
  375. objects to which <code>*this</code> and <code>x</code> belong, respectively.<br>
  376. <b>Returns:</b> <code>*this</code>.<br>
  377. </blockquote>
  378. <code><b>index class name</b>&amp; operator=(std::initializer_list&lt;value_type&gt; list);</code>
  379. <blockquote>
  380. <b>Effects:</b>
  381. <blockquote><pre>
  382. <span class=identifier>a</span><span class=special>=</span><span class=identifier>list</span><span class=special>;</span>
  383. </pre></blockquote>
  384. where <code>a</code> is the <code>multi_index_container</code>
  385. object to which <code>*this</code> belongs.<br>
  386. <b>Returns:</b> <code>*this</code>.<br>
  387. </blockquote>
  388. <h4><a name="iterators">Iterators</a></h4>
  389. <code>iterator&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;iterator_to(const value_type&amp; x);<br>
  390. const_iterator iterator_to(const value_type&amp; x)const;</code>
  391. <blockquote>
  392. <b>Requires:</b> <code>x</code> is a reference to an element of the container.<br>
  393. <b>Returns:</b> An iterator to <code>x</code>.<br>
  394. <b>Complexity:</b> Constant.<br>
  395. <b>Exception safety:</b> <code>nothrow</code>.<br>
  396. </blockquote>
  397. <h4><a name="modifiers">Modifiers</a></h4>
  398. <code>template&lt;typename... Args&gt;<br>
  399. std::pair&lt;iterator,bool&gt; emplace(Args&amp;&amp;... args);</code>
  400. <blockquote>
  401. <b>Requires:</b> <code>value_type</code> is <code>EmplaceConstructible</code>
  402. into <code>multi_index_container</code> from <code>args</code>.<br>
  403. <b>Effects:</b> Inserts a <code>value_type</code> object constructed with
  404. <code>std::forward&lt;Args&gt;(args)...</code> into the <code>multi_index_container</code> to which
  405. the index belongs if
  406. <ul>
  407. <li>the index is non-unique OR no other element exists with
  408. equivalent key,</li>
  409. <li>AND insertion is allowed by all other indices of the
  410. <code>multi_index_container</code>.</li>
  411. </ul>
  412. <b>Returns:</b> The return value is a pair <code>p</code>. <code>p.second</code>
  413. is <code>true</code> if and only if insertion took place. On successful insertion,
  414. <code>p.first</code> points to the element inserted; otherwise, <code>p.first</code>
  415. points to an element that caused the insertion to be banned. Note that more than
  416. one element can be causing insertion not to be allowed.<br>
  417. <b>Complexity:</b> <code>O(I(n))</code>.<br>
  418. <b>Exception safety:</b> Strong.<br>
  419. </blockquote>
  420. <code>template&lt;typename... Args&gt;<br>
  421. iterator emplace_hint(iterator position, Args&amp;&amp;... args);</code>
  422. <blockquote>
  423. <b>Requires:</b> <code>value_type</code> is <code>EmplaceConstructible</code>
  424. into <code>multi_index_container</code> from <code>args</code>.
  425. <code>position</code> is a valid iterator of the index.<br>
  426. <b>Effects:</b> Inserts a <code>value_type</code> object constructed with
  427. <code>std::forward&lt;Args&gt;(args)...</code> into the <code>multi_index_container</code> to which
  428. the index belongs if
  429. <ul>
  430. <li>the index is non-unique OR no other element exists with
  431. equivalent key,</li>
  432. <li>AND insertion is allowed by all other indices of the
  433. <code>multi_index_container</code>.</li>
  434. </ul>
  435. <code>position</code> is used as a hint to improve the efficiency of the
  436. operation. If successful, insertion happens as close as possible to the
  437. location just prior to <code>position</code>.<br>
  438. <b>Returns:</b> On successful insertion, an iterator to the newly inserted
  439. element. Otherwise, an iterator to an element that caused the insertion to be
  440. banned. Note that more than one element can be causing insertion not to be
  441. allowed.<br>
  442. <b>Complexity:</b> <code>O(H(n))</code>.<br>
  443. <b>Exception safety:</b> Strong.<br>
  444. </blockquote>
  445. <code>std::pair&lt;iterator,bool> insert(const value_type&amp; x);</code><br>
  446. <code>std::pair&lt;iterator,bool> insert(value_type&amp;&amp; x);</code>
  447. <blockquote>
  448. <b>Requires (first version):</b> <code>value_type</code> is <code>CopyInsertable</code>
  449. into <code>multi_index_container</code>.<br>
  450. <b>Requires (second version):</b> <code>value_type</code> is <code>MoveInsertable</code>
  451. into <code>multi_index_container</code>.<br>
  452. <b>Effects:</b> Inserts <code>x</code> into the <code>multi_index_container</code> to which
  453. the index belongs if
  454. <ul>
  455. <li>the index is non-unique OR no other element exists with
  456. equivalent key,</li>
  457. <li>AND insertion is allowed by all other indices of the
  458. <code>multi_index_container</code>.</li>
  459. </ul>
  460. <b>Returns:</b> The return value is a pair <code>p</code>. <code>p.second</code>
  461. is <code>true</code> if and only if insertion took place. On successful insertion,
  462. <code>p.first</code> points to the element inserted; otherwise, <code>p.first</code>
  463. points to an element that caused the insertion to be banned. Note that more than
  464. one element can be causing insertion not to be allowed.<br>
  465. <b>Complexity:</b> <code>O(I(n))</code>.<br>
  466. <b>Exception safety:</b> Strong.<br>
  467. </blockquote>
  468. <code>iterator insert(iterator position,const value_type&amp; x);</code><br>
  469. <code>iterator insert(iterator position,value_type&amp;&amp; x);</code>
  470. <blockquote>
  471. <b>Requires (first version):</b> <code>value_type</code> is <code>CopyInsertable</code>
  472. into <code>multi_index_container</code>.
  473. <code>position</code> is a valid iterator of the index.<br>
  474. <b>Requires (second version):</b> <code>value_type</code> is <code>MoveInsertable</code>
  475. into <code>multi_index_container</code>.
  476. <code>position</code> is a valid iterator of the index.<br>
  477. <b>Effects:</b> Inserts <code>x</code> into the <code>multi_index_container</code> to which
  478. the index belongs if
  479. <ul>
  480. <li>the index is non-unique OR no other element exists with
  481. equivalent key,</li>
  482. <li>AND insertion is allowed by all other indices of the
  483. <code>multi_index_container</code>.</li>
  484. </ul>
  485. <code>position</code> is used as a hint to improve the efficiency of the
  486. operation. If successful, insertion happens as close as possible to the
  487. location just prior to <code>position</code>.<br>
  488. <b>Returns:</b> On successful insertion, an iterator to the newly inserted
  489. element. Otherwise, an iterator to an element that caused the insertion to be
  490. banned. Note that more than one element can be causing insertion not to be
  491. allowed.<br>
  492. <b>Complexity:</b> <code>O(H(n))</code>.<br>
  493. <b>Exception safety:</b> Strong.<br>
  494. </blockquote>
  495. <code>template&lt;typename InputIterator><br>
  496. void insert(InputIterator first,InputIterator last);</code>
  497. <blockquote>
  498. <b>Requires:</b> <code>InputIterator</code> is an input iterator.
  499. <code>value_type</code> is <code>EmplaceConstructible</code> into
  500. <code>multi_index_container</code> from <code>*first</code>.
  501. <code>first</code> and <code>last</code> are not iterators into any
  502. index of the <code>multi_index_container</code> to which this index belongs.
  503. <code>last</code> is reachable from <code>first</code>.<br>
  504. <b>Effects:</b>
  505. For each element of [<code>first</code>, <code>last</code>), in this
  506. order, inserts it into the <code>multi_index_container</code>
  507. to which this index belongs if
  508. <ul>
  509. <li>the index is non-unique OR no other element exists with
  510. equivalent key,</li>
  511. <li>AND insertion is allowed by all other indices of the
  512. <code>multi_index_container</code>.</li>
  513. </ul>
  514. <b>Complexity:</b> <code>O(m*H(n+m))</code>, where
  515. <code>m</code> is the number of elements in [<code>first</code>,
  516. <code>last</code>).<br>
  517. <b>Exception safety:</b> Basic.<br>
  518. </blockquote>
  519. <code>void insert(std::initializer_list&lt;value_type&gt; list);</code>
  520. <blockquote>
  521. <b>Effects:</b>
  522. <blockquote><pre>
  523. <span class=identifier>insert</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=special>;</span>
  524. </pre></blockquote>
  525. </blockquote>
  526. <code>iterator erase(iterator position);</code>
  527. <blockquote>
  528. <b>Requires:</b> <code>position</code> is a valid dereferenceable iterator
  529. of the index.<br>
  530. <b>Effects:</b> Deletes the element pointed to by <code>position</code>.<br>
  531. <b>Returns:</b> An iterator pointing to the element immediately following
  532. the one that was deleted, or <code>end()</code>
  533. if no such element exists.<br>
  534. <b>Complexity:</b> <code>O(D(n))</code>.<br>
  535. <b>Exception safety:</b> <code>nothrow</code>.<br>
  536. </blockquote>
  537. <code>size_type erase(const key_type&amp; x);</code>
  538. <blockquote>
  539. <b>Effects:</b> Deletes the elements with key equivalent to <code>x</code>.<br>
  540. <b>Returns:</b> Number of elements deleted.<br>
  541. <b>Complexity:</b> <code>O(log(n) + m*D(n))</code>, where <code>m</code> is
  542. the number of elements deleted.<br>
  543. <b>Exception safety:</b> Basic.<br>
  544. </blockquote>
  545. <code>iterator erase(iterator first,iterator last);</code>
  546. <blockquote>
  547. <b>Requires:</b> [<code>first</code>,<code>last</code>) is a valid
  548. range of the index.<br>
  549. <b>Effects:</b> Deletes the elements in [<code>first</code>,<code>last</code>).<br>
  550. <b>Returns:</b> <code>last</code>.<br>
  551. <b>Complexity:</b> <code>O(log(n) + m*D(n))</code>, where <code>m</code> is
  552. the number of elements in [<code>first</code>,<code>last</code>).<br>
  553. <b>Exception safety:</b> <code>nothrow</code>.<br>
  554. </blockquote>
  555. <a name="replace"><code>bool replace(iterator position,const value_type&amp; x);</code></a><br>
  556. <code>bool replace(iterator position,value_type&amp;&amp; x);</code>
  557. <blockquote>
  558. <b>Requires (first version):</b> <code>value_type</code> is <code>CopyAssignable</code>.
  559. <code>position</code> is a valid dereferenceable iterator of the index.<br>
  560. <b>Requires (second version):</b> <code>value_type</code> is <code>MoveAssignable</code>.
  561. <code>position</code> is a valid dereferenceable iterator of the index.<br>
  562. <b>Effects:</b> Assigns the value <code>x</code> to the element pointed
  563. to by <code>position</code> into the <code>multi_index_container</code> to which
  564. the index belongs if, for the value <code>x</code>
  565. <ul>
  566. <li>the index is non-unique OR no other element exists
  567. (except possibly <code>*position</code>) with equivalent key,</li>
  568. <li>AND replacing is allowed by all other indices of the
  569. <code>multi_index_container</code>.</li>
  570. </ul>
  571. <b>Postconditions:</b> Validity of <code>position</code> is preserved
  572. in all cases. If the key of the new value is equivalent to that of the
  573. replaced value, the position of the element does not change.<br>
  574. <b>Returns:</b> <code>true</code> if the replacement took place,
  575. <code>false</code> otherwise.<br>
  576. <b>Complexity:</b> <code>O(R(n))</code>.<br>
  577. <b>Exception safety:</b> Strong. If an exception is thrown by some
  578. user-provided operation the <code>multi_index_container</code> to which the index
  579. belongs remains in its original state.
  580. </blockquote>
  581. <a name="modify">
  582. <code>template&lt;typename Modifier> bool modify(iterator position,Modifier mod);</code></a>
  583. <blockquote>
  584. <b>Requires:</b> <code>mod</code> is a unary function object
  585. accepting arguments of type
  586. <code>value_type&amp;</code>. <code>position</code> is a valid dereferenceable
  587. iterator of the index.
  588. The execution of <code>mod(e)</code>, where <code>e</code> is the element
  589. pointed to by <code>position</code>, does not invoke any operation of the
  590. <code>multi_index_container</code> after <code>e</code> is directly modified
  591. or, before modification, if the operation would invalidate <code>position</code>.<br>
  592. <b>Effects:</b> Calls <code>mod(e)</code> where <code>e</code> is the element
  593. pointed to by <code>position</code> and rearranges <code>*position</code> into
  594. all the indices of the <code>multi_index_container</code>. Rearrangement is successful if
  595. <ul>
  596. <li>the index is non-unique OR no other element exists
  597. with equivalent key,</li>
  598. <li>AND rearrangement is allowed by all other indices of the
  599. <code>multi_index_container</code>.</li>
  600. </ul>
  601. If the rearrangement fails, the element is erased.<br>
  602. <b>Postconditions:</b> Validity of <code>position</code> is preserved if the
  603. operation succeeds. If the key of the modified value is equivalent to that of the
  604. original value, the position of the element does not change.<br>
  605. <b>Returns:</b> <code>true</code> if the operation succeeded, <code>false</code>
  606. otherwise.<br>
  607. <b>Complexity:</b> <code>O(M(n))</code>.<br>
  608. <b>Exception safety:</b> Basic. If an exception is thrown by some
  609. user-provided operation (including <code>mod</code>), then
  610. the element pointed to by <code>position</code> is erased.
  611. </blockquote>
  612. <code>template&lt;typename Modifier,typename Rollback><br>
  613. bool modify(iterator position,Modifier mod,Rollback back);</code>
  614. <blockquote>
  615. <b>Requires:</b> <code>mod</code> and <code>back</code> are unary function
  616. objects accepting arguments of type
  617. <code>value_type&amp;</code>. <code>position</code> is a valid dereferenceable
  618. iterator of the index.
  619. The execution of <code>mod(e)</code>, where <code>e</code> is the element
  620. pointed to by <code>position</code>, does not invoke any operation of the
  621. <code>multi_index_container</code> after <code>e</code> is directly modified
  622. or, before modification, if the operation would invalidate <code>position</code>.
  623. <code>back(e)</code> does not invoke any operation of the
  624. <code>multi_index_container</code>.<br>
  625. <b>Effects:</b> Calls <code>mod(e)</code> where <code>e</code> is the element
  626. pointed to by <code>position</code> and tries to rearrange <code>*position</code> into
  627. all the indices of the <code>multi_index_container</code>. Rearrangement is successful if
  628. <ul>
  629. <li>the index is non-unique OR no other element exists
  630. with equivalent key,</li>
  631. <li>AND rearrangement is allowed by all other indices of the
  632. <code>multi_index_container</code>.</li>
  633. </ul>
  634. If the rearrangement fails, <code>back(e)</code> is invoked: if the resulting value
  635. of <code>e</code> is consistent with its original position and constraints in all
  636. indices, the element is kept, otherwise it is erased.<br>
  637. <b>Postconditions:</b> Validity of <code>position</code> is preserved except if
  638. the element is erased under the conditions described below.
  639. If the key of the modified value is equivalent to that of the
  640. original value, the position of the element does not change.<br>
  641. <b>Returns:</b> <code>true</code> if the operation succeeded, <code>false</code>
  642. otherwise.<br>
  643. <b>Complexity:</b> <code>O(M(n))</code>.<br>
  644. <b>Exception safety:</b> Strong, except if <code>mod</code> or <code>back</code> throw an
  645. exception or <code>back(e)</code> fails to properly restore the element or there is
  646. a throwing user-provided operation after invoking <code>back(e)</code>, in which cases
  647. the modified element is erased. If <code>back</code>
  648. throws inside the handling code executing after some other user-provided
  649. operation has thrown, it is the exception generated by <code>back</code> that
  650. is rethrown.
  651. </blockquote>
  652. <a name="modify_key">
  653. <code>template&lt;typename Modifier> bool modify_key(iterator position,Modifier mod);</code></a>
  654. <blockquote>
  655. <b>Requires:</b> <code>key_from_value</code> is a read/write
  656. <a href="key_extraction.html#key_extractors"><code>Key Extractor</code></a>
  657. from <code>value_type</code>. <code>mod</code> is a
  658. unary function object accepting arguments of type
  659. <code>key_type&amp;</code>. <code>position</code> is a valid dereferenceable
  660. iterator of the index.
  661. The execution of <code>mod(k)</code>, where <code>k</code> is the key of the element
  662. pointed to by <code>position</code>, does not invoke any operation of the
  663. <code>multi_index_container</code> after <code>k</code> is directly modified
  664. or, before modification, if the operation would invalidate <code>position</code>.<br>
  665. <b>Effects:</b> Equivalent to <code>modify(position,mod')</code>,
  666. with <code>mod'</code> defined in such a way that
  667. <code>mod'(x)</code> is the same as <code>mod(key(x))</code>, where
  668. <code>key</code> is the internal <code>KeyFromValue</code> object of the index.
  669. </blockquote>
  670. <code>template&lt;typename Modifier,typename Rollback><br>
  671. bool modify_key(iterator position,Modifier mod,Rollback back);</code>
  672. <blockquote>
  673. <b>Requires:</b> <code>key_from_value</code> is a read/write
  674. <a href="key_extraction.html#key_extractors"><code>Key Extractor</code></a>
  675. from <code>value_type</code>. <code>mod</code> and <code>back</code>
  676. are unary function objects accepting arguments of type
  677. <code>key_type&amp;</code>. <code>position</code> is a valid dereferenceable
  678. iterator of the index.
  679. The execution of <code>mod(k)</code>, where <code>k</code> is the key of the element
  680. pointed to by <code>position</code>, does not invoke any operation of the
  681. <code>multi_index_container</code> after <code>k</code> is directly modified
  682. or, before modification, if the operation would invalidate <code>position</code>.
  683. <code>back(k)</code> does not invoke any operation of the
  684. <code>multi_index_container</code>.<br>
  685. <b>Effects:</b> Equivalent to <code>modify(position,mod',back')</code>,
  686. with <code>mod'</code> and <code>back</code> defined in such a way that
  687. <code>mod'(x)</code> is the same as <code>mod(key(x))</code> and
  688. <code>back'(x)</code> is the same as <code>back(key(x))</code>, where
  689. <code>key</code> is the internal <code>KeyFromValue</code> object of the index.
  690. </blockquote>
  691. <h4><a name="observers">Observers</a></h4>
  692. <p>Apart from standard <code>key_comp</code> and <code>value_comp</code>,
  693. ordered indices have a member function for retrieving the internal key extractor
  694. used.
  695. </p>
  696. <code>key_from_value key_extractor()const;</code>
  697. <blockquote>
  698. Returns a copy of the <code>key_from_value</code> object used to construct
  699. the index.<br>
  700. <b>Complexity:</b> Constant.
  701. </blockquote>
  702. <h4><a name="set_operations">Set operations</a></h4>
  703. <p>
  704. Ordered indices provide the full lookup functionality required by
  705. <b>[associative.reqmts]</b>, namely <code>find</code>,
  706. <code>count</code>, <code>lower_bound</code>, <code>upper_bound</code>
  707. and <code>equal_range</code>. Additionally, these member functions are
  708. templatized to allow for non-standard arguments, so extending
  709. the types of search operations allowed. The kind of arguments permissible
  710. when invoking the lookup member functions is defined by the following
  711. concept.
  712. </p>
  713. <p>
  714. Consider a binary predicate <code>Compare</code> inducing a strict
  715. weak order over values of type <code>Key</code>. A pair of types (<code>CompatibleKey</code>,
  716. <code>CompatibleCompare</code>) is said to be a <i>compatible extension</i>
  717. of <code>Compare</code> if
  718. <ol>
  719. <li><code>CompatibleCompare</code> is a binary predicate over (<code>Key</code>,
  720. <code>CompatibleKey</code>),</li>
  721. <li><code>CompatibleCompare</code> is a binary predicate over (<code>CompatibleKey</code>,
  722. <code>Key</code>),</li>
  723. <li>if <code>c_comp(ck,k1)</code> then <code>!c_comp(k1,ck)</code>,</li>
  724. <li>if <code>!c_comp(ck,k1)</code> and <code>!comp(k1,k2)</code> then
  725. <code>!c_comp(ck,k2)</code>,</li>
  726. <li>if <code>!c_comp(k1,ck)</code> and <code>!comp(k2,k1)</code> then
  727. <code>!c_comp(k2,ck)</code>,</li>
  728. </ol>
  729. for every <code>c_comp</code> of type <code>CompatibleCompare</code>,
  730. <code>comp</code> of type <code>Compare</code>, <code>ck</code> of type
  731. <code>CompatibleKey</code> and <code>k1</code>, <code>k2</code> of type
  732. <code>Key</code>.
  733. </p>
  734. <p>Additionally, a type <code>CompatibleKey</code> is said to be a
  735. <i>compatible key</i> of <code>Compare</code> if (<code>CompatibleKey</code>,
  736. <code>Compare</code>) is a compatible extension of <code>Compare</code>.
  737. This implies that <code>Compare</code>, as well as being a strict
  738. weak ordering, accepts arguments of type <code>CompatibleKey</code>,
  739. which usually means it has several overloads of <code>operator()</code>.
  740. </p>
  741. <p>
  742. In the context of a compatible extension or a compatible key, the expressions
  743. "equivalent", "less than" and "greater than" take on their obvious
  744. interpretations.
  745. </p>
  746. <code>template&lt;typename CompatibleKey> iterator find(const CompatibleKey&amp; x)const;
  747. </code>
  748. <blockquote>
  749. <b>Requires:</b> <code>CompatibleKey</code> is a compatible key of
  750. <code>key_compare</code>.<br>
  751. <b>Effects:</b> Returns a pointer to an element whose key is equivalent to
  752. <code>x</code>, or <code>end()</code> if such an element does not exist.<br>
  753. <b>Complexity:</b> <code>O(log(n))</code>.<br>
  754. </blockquote>
  755. <code>template&lt;typename CompatibleKey,typename CompatibleCompare><br>
  756. iterator find(const CompatibleKey&amp; x,const CompatibleCompare&amp; comp)const;
  757. </code>
  758. <blockquote>
  759. <b>Requires:</b> (<code>CompatibleKey</code>, <code>CompatibleCompare</code>)
  760. is a compatible extension of <code>key_compare</code>.<br>
  761. <b>Effects:</b> Returns a pointer to an element whose key is equivalent to
  762. <code>x</code>, or <code>end()</code> if such an element does not exist.<br>
  763. <b>Complexity:</b> <code>O(log(n))</code>.<br>
  764. </blockquote>
  765. <code>template&lt;typename CompatibleKey> size_type<br>
  766. count(const CompatibleKey&amp; x)const;
  767. </code>
  768. <blockquote>
  769. <b>Requires:</b> <code>CompatibleKey</code> is a compatible key of
  770. <code>key_compare</code>.<br>
  771. <b>Effects:</b> Returns the number of elements with key equivalent to <code>x</code>.<br>
  772. <b>Complexity:</b> <code>O(log(n) + count(x))</code>.<br>
  773. </blockquote>
  774. <code>template&lt;typename CompatibleKey,typename CompatibleCompare><br>
  775. size_type count(const CompatibleKey&amp; x,const CompatibleCompare&amp; comp)const;
  776. </code>
  777. <blockquote>
  778. <b>Requires:</b> (<code>CompatibleKey</code>, <code>CompatibleCompare</code>)
  779. is a compatible extension of <code>key_compare</code>.<br>
  780. <b>Effects:</b> Returns the number of elements with key equivalent to <code>x</code>.<br>
  781. <b>Complexity:</b> <code>O(log(n) + count(x,comp))</code>.<br>
  782. </blockquote>
  783. <code>template&lt;typename CompatibleKey><br>
  784. iterator lower_bound(const CompatibleKey&amp; x)const;
  785. </code>
  786. <blockquote>
  787. <b>Requires:</b> <code>CompatibleKey</code> is a compatible key of
  788. <code>key_compare</code>.<br>
  789. <b>Effects:</b> Returns an iterator pointing to the first element with
  790. key not less than <code>x</code>, or <code>end()</code> if such an element does
  791. not exist.<br>
  792. <b>Complexity:</b> <code>O(log(n))</code>.<br>
  793. </blockquote>
  794. <code>template&lt;typename CompatibleKey,typename CompatibleCompare><br>
  795. iterator lower_bound(const CompatibleKey&amp; x,const CompatibleCompare&amp; comp)const;
  796. </code>
  797. <blockquote>
  798. <b>Requires:</b> (<code>CompatibleKey</code>, <code>CompatibleCompare</code>)
  799. is a compatible extension of <code>key_compare</code>.<br>
  800. <b>Effects:</b> Returns an iterator pointing to the first element with
  801. key not less than <code>x</code>, or <code>end()</code> if such an element does
  802. not exist.<br>
  803. <b>Complexity:</b> <code>O(log(n))</code>.<br>
  804. </blockquote>
  805. <code>template&lt;typename CompatibleKey><br>
  806. iterator upper_bound(const CompatibleKey&amp; x)const;
  807. </code>
  808. <blockquote>
  809. <b>Requires:</b> <code>CompatibleKey</code> is a compatible key of
  810. <code>key_compare</code>.<br>
  811. <b>Effects:</b> Returns an iterator pointing to the first element with
  812. key greater than <code>x</code>, or <code>end()</code> if such an element does
  813. not exist.<br>
  814. <b>Complexity:</b> <code>O(log(n))</code>.<br>
  815. </blockquote>
  816. <code>template&lt;typename CompatibleKey,typename CompatibleCompare><br>
  817. iterator upper_bound(const CompatibleKey&amp; x,const CompatibleCompare&amp; comp)const;
  818. </code>
  819. <blockquote>
  820. <b>Requires:</b> (<code>CompatibleKey</code>, <code>CompatibleCompare</code>)
  821. is a compatible extension of <code>key_compare</code>.<br>
  822. <b>Effects:</b> Returns an iterator pointing to the first element with
  823. key greater than <code>x</code>, or <code>end()</code> if such an element does
  824. not exist.<br>
  825. <b>Complexity:</b> <code>O(log(n))</code>.<br>
  826. </blockquote>
  827. <code>template&lt;typename CompatibleKey><br>
  828. std::pair&lt;iterator,iterator> equal_range(<br>
  829. &nbsp;&nbsp;const CompatibleKey&amp; x)const;
  830. </code>
  831. <blockquote>
  832. <b>Requires:</b> <code>CompatibleKey</code> is a compatible key of
  833. <code>key_compare</code>.<br>
  834. <b>Effects:</b> Equivalent to <code>make_pair(lower_bound(x),upper_bound(x))</code>.<br>
  835. <b>Complexity:</b> <code>O(log(n))</code>.<br>
  836. </blockquote>
  837. <code>template&lt;typename CompatibleKey,typename CompatibleCompare><br>
  838. std::pair&lt;iterator,iterator> equal_range(<br>
  839. &nbsp;&nbsp;const CompatibleKey&amp; x,const CompatibleCompare&amp; comp)const;
  840. </code>
  841. <blockquote>
  842. <b>Requires:</b> (<code>CompatibleKey</code>, <code>CompatibleCompare</code>)
  843. is a compatible extension of <code>key_compare</code>.<br>
  844. <b>Effects:</b> Equivalent to
  845. <code>make_pair(lower_bound(x,comp),upper_bound(x,comp))</code>.<br>
  846. <b>Complexity:</b> <code>O(log(n))</code>.<br>
  847. </blockquote>
  848. <h4><a name="range_operations">Range operations</a></h4>
  849. <p>
  850. The member function <code>range</code> is not defined for sorted associative
  851. containers, but ordered indices provide it as a convenient utility. A range
  852. or interval is defined by two conditions for the lower and upper bounds, which
  853. are modeled after the following concepts.
  854. </p>
  855. <p>
  856. Consider a binary predicate <code>Compare</code> inducing a strict
  857. weak order over values of type <code>Key</code>. A type <code>LowerBounder</code> is said to be
  858. a <i>lower bounder</i> of <code>Compare</code> if
  859. <ol>
  860. <li><code>LowerBounder</code> is a predicate over <code>Key</code>,</li>
  861. <li>if <code>lower(k1)</code> and <code>!comp(k2,k1)</code> then
  862. <code>lower(k2)</code>,</li>
  863. </ol>
  864. for every <code>lower</code> of type <code>LowerBounder</code>,
  865. <code>comp</code> of type <code>Compare</code>, and <code>k1</code>,
  866. <code>k2</code> of type <code>Key</code>. Similarly, an <i>upper bounder</i>
  867. is a type <code>UpperBounder</code> such that
  868. <ol>
  869. <li><code>UpperBounder</code> is a predcate over <code>Key</code>,</li>
  870. <li>if <code>upper(k1)</code> and <code>!comp(k1,k2)</code> then
  871. <code>upper(k2)</code>,</li>
  872. </ol>
  873. for every <code>upper</code> of type <code>UpperBounder</code>,
  874. <code>comp</code> of type <code>Compare</code>, and <code>k1</code>,
  875. <code>k2</code> of type <code>Key</code>.
  876. </p>
  877. <code>template&lt;typename LowerBounder,typename UpperBounder><br>
  878. std::pair&lt;iterator,iterator> range(<br>
  879. &nbsp;&nbsp;LowerBounder lower,UpperBounder upper)const;
  880. </code>
  881. <blockquote>
  882. <b>Requires:</b> <code>LowerBounder</code> and <code>UpperBounder</code> are
  883. a lower and upper bounder of <code>key_compare</code>, respectively.<br>
  884. <b>Effects:</b> Returns a pair of iterators pointing to the beginning and one
  885. past the end of the subsequence of elements satisfying <code>lower</code> and
  886. <code>upper</code> simultaneously. If no such elements exist, the iterators
  887. both point to the first element satisfying <code>lower</code>, or else
  888. are equal to <code>end()</code> if this latter element does not exist.<br>
  889. <b>Complexity:</b> <code>O(log(n))</code>.<br>
  890. <b>Variants:</b> In place of <code>lower</code> or <code>upper</code> (or both),
  891. the singular value <code>boost::multi_index::unbounded</code> can be
  892. provided. This acts as a predicate which all values of type <code>key_type</code>
  893. satisfy.<br>
  894. </blockquote>
  895. <h4><a name="serialization">Serialization</a></h4>
  896. <p>
  897. Indices cannot be serialized on their own, but only as part of the
  898. <code>multi_index_container</code> into which they are embedded. In describing
  899. the additional preconditions and guarantees associated to ordered indices
  900. with respect to serialization of their embedding containers, we
  901. use the concepts defined in the <code>multi_index_container</code>
  902. <a href="multi_index_container.html#serialization">serialization section</a>.
  903. </p>
  904. Operation: saving of a <code>multi_index_container</code> <code>m</code> to an
  905. output archive (XML archive) <code>ar</code>.
  906. <blockquote>
  907. <b>Requires:</b> No additional requirements to those imposed by the container.
  908. </blockquote>
  909. Operation: loading of a <code>multi_index_container</code> <code>m'</code> from an
  910. input archive (XML archive) <code>ar</code>.
  911. <blockquote>
  912. <b>Requires:</b> Additionally to the general requirements, <code>value_comp()</code>
  913. must be serialization-compatible with <code>m.get&lt;i&gt;().value_comp()</code>,
  914. where <code>i</code> is the position of the ordered index in the container.<br>
  915. <b>Postconditions:</b> On successful loading, each of the elements of
  916. [<code>begin()</code>, <code>end()</code>) is a restored copy of the corresponding
  917. element in [<code>m.get&lt;i&gt;().begin()</code>, <code>m.get&lt;i&gt;().end()</code>).
  918. </blockquote>
  919. Operation: saving of an <code>iterator</code> or <code>const_iterator</code>
  920. <code>it</code> to an output archive (XML archive) <code>ar</code>.
  921. <blockquote>
  922. <b>Requires:</b> <code>it</code> is a valid iterator of the index. The associated
  923. <code>multi_index_container</code> has been previously saved.
  924. </blockquote>
  925. Operation: loading of an <code>iterator</code> or <code>const_iterator</code>
  926. <code>it'</code> from an input archive (XML archive) <code>ar</code>.
  927. <blockquote>
  928. <b>Postconditions:</b> On successful loading, if <code>it</code> was dereferenceable
  929. then <code>*it'</code> is the restored copy of <code>*it</code>, otherwise
  930. <code>it'==end()</code>.<br>
  931. <b>Note:</b> It is allowed that <code>it</code> be a <code>const_iterator</code>
  932. and the restored <code>it'</code> an <code>iterator</code>, or viceversa.
  933. </blockquote>
  934. <hr>
  935. <div class="prev_link"><a href="indices.html"><img src="../prev.gif" alt="index reference" border="0"><br>
  936. Index reference
  937. </a></div>
  938. <div class="up_link"><a href="index.html"><img src="../up.gif" alt="Boost.MultiIndex reference" border="0"><br>
  939. Boost.MultiIndex reference
  940. </a></div>
  941. <div class="next_link"><a href="rnk_indices.html"><img src="../next.gif" alt="ranked indices" border="0"><br>
  942. Ranked indices
  943. </a></div><br clear="all" style="clear: all;">
  944. <br>
  945. <p>Revised August 24th 2017</p>
  946. <p>&copy; Copyright 2003-2017 Joaqu&iacute;n M L&oacute;pez Mu&ntilde;oz.
  947. Distributed under the Boost Software
  948. License, Version 1.0. (See accompanying file <a href="../../../../LICENSE_1_0.txt">
  949. LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
  950. http://www.boost.org/LICENSE_1_0.txt</a>)
  951. </p>
  952. </body>
  953. </html>