/Src/Dependencies/Boost/libs/range/doc/html/range/reference/algorithms/mutating/nth_element.html

http://hadesmem.googlecode.com/ · HTML · 150 lines · 146 code · 4 blank · 0 comment · 0 complexity · c79c20d8a46662c51481913a87108f0a MD5 · raw file

  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  4. <title>nth_element</title>
  5. <link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
  6. <meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
  7. <link rel="home" href="../../../../index.html" title="Chapter&#160;1.&#160;Range 2.0">
  8. <link rel="up" href="../mutating.html" title="Mutating algorithms">
  9. <link rel="prev" href="merge.html" title="merge">
  10. <link rel="next" href="partial_sort.html" title="partial_sort">
  11. </head>
  12. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
  13. <table cellpadding="2" width="100%"><tr>
  14. <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
  15. <td align="center"><a href="../../../../../../../../index.html">Home</a></td>
  16. <td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td>
  17. <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
  18. <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
  19. <td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
  20. </tr></table>
  21. <hr>
  22. <div class="spirit-nav">
  23. <a accesskey="p" href="merge.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../mutating.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="partial_sort.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
  24. </div>
  25. <div class="section">
  26. <div class="titlepage"><div><div><h5 class="title">
  27. <a name="range.reference.algorithms.mutating.nth_element"></a><a class="link" href="nth_element.html" title="nth_element">nth_element</a>
  28. </h5></div></div></div>
  29. <a name="range.reference.algorithms.mutating.nth_element.prototype"></a><h6>
  30. <a name="id691010"></a>
  31. <a class="link" href="nth_element.html#range.reference.algorithms.mutating.nth_element.prototype">Prototype</a>
  32. </h6>
  33. <p>
  34. </p>
  35. <pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">RandomAccessRange</span><span class="special">&gt;</span>
  36. <span class="identifier">RandomAccessRange</span><span class="special">&amp;</span> <span class="identifier">nth_element</span><span class="special">(</span>
  37. <span class="identifier">RandomAccessRange</span><span class="special">&amp;</span> <span class="identifier">rng</span><span class="special">,</span>
  38. <span class="keyword">typename</span> <span class="identifier">range_iterator</span><span class="special">&lt;</span><span class="identifier">RandomAccessRange</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">nth</span><span class="special">);</span>
  39. <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">RandomAccessRange</span><span class="special">&gt;</span>
  40. <span class="keyword">const</span> <span class="identifier">RandomAccessRange</span><span class="special">&amp;</span> <span class="identifier">nth_element</span><span class="special">(</span>
  41. <span class="keyword">const</span> <span class="identifier">RandomAccessRange</span><span class="special">&amp;</span> <span class="identifier">rng</span><span class="special">,</span>
  42. <span class="keyword">typename</span> <span class="identifier">range_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="identifier">RandomAccessRange</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">nth</span><span class="special">);</span>
  43. <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">RandomAccessRange</span><span class="special">&gt;</span>
  44. <span class="identifier">RandomAccessRange</span><span class="special">&amp;</span> <span class="identifier">nth_element</span><span class="special">(</span>
  45. <span class="identifier">RandomAccessRange</span><span class="special">&amp;</span> <span class="identifier">rng</span><span class="special">,</span>
  46. <span class="keyword">typename</span> <span class="identifier">range_iterator</span><span class="special">&lt;</span><span class="identifier">RandomAccessRange</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">nth</span><span class="special">,</span>
  47. <span class="identifier">BinaryPredicate</span> <span class="identifier">sort_pred</span><span class="special">);</span>
  48. <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">RandomAccessRange</span><span class="special">&gt;</span>
  49. <span class="keyword">const</span> <span class="identifier">RandomAccessRange</span><span class="special">&amp;</span> <span class="identifier">nth_element</span><span class="special">(</span>
  50. <span class="keyword">const</span> <span class="identifier">RandomAccessRange</span><span class="special">&amp;</span> <span class="identifier">rng</span><span class="special">,</span>
  51. <span class="keyword">typename</span> <span class="identifier">range_iterator</span><span class="special">&lt;</span><span class="keyword">const</span> <span class="identifier">RandomAccessRange</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">nth</span><span class="special">,</span>
  52. <span class="identifier">BinaryPredicate</span> <span class="identifier">sort_pred</span><span class="special">);</span>
  53. </pre>
  54. <p>
  55. </p>
  56. <a name="range.reference.algorithms.mutating.nth_element.description"></a><h6>
  57. <a name="id691529"></a>
  58. <a class="link" href="nth_element.html#range.reference.algorithms.mutating.nth_element.description">Description</a>
  59. </h6>
  60. <p>
  61. <code class="computeroutput"><span class="identifier">nth_element</span></code> partially
  62. orders a range of elements. <code class="computeroutput"><span class="identifier">nth_element</span></code>
  63. arranges the range <code class="computeroutput"><span class="identifier">rng</span></code>
  64. such that the element corresponding with the iterator <code class="computeroutput"><span class="identifier">nth</span></code>
  65. is the same as the element that would be in that position if <code class="computeroutput"><span class="identifier">rng</span></code> has been sorted.
  66. </p>
  67. <a name="range.reference.algorithms.mutating.nth_element.definition"></a><h6>
  68. <a name="id691606"></a>
  69. <a class="link" href="nth_element.html#range.reference.algorithms.mutating.nth_element.definition">Definition</a>
  70. </h6>
  71. <p>
  72. Defined in the header file <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">range</span><span class="special">/</span><span class="identifier">algorithm</span><span class="special">/</span><span class="identifier">nth_element</span><span class="special">.</span><span class="identifier">hpp</span></code>
  73. </p>
  74. <a name="range.reference.algorithms.mutating.nth_element.requirements"></a><h6>
  75. <a name="id691676"></a>
  76. <a class="link" href="nth_element.html#range.reference.algorithms.mutating.nth_element.requirements">Requirements</a>
  77. </h6>
  78. <p>
  79. <span class="bold"><strong>For the non-predicate version:</strong></span>
  80. </p>
  81. <div class="itemizedlist"><ul class="itemizedlist" type="disc">
  82. <li class="listitem">
  83. <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code>
  84. is a model of the <a class="link" href="../../../concepts/random_access_range.html" title="Random Access Range">Random
  85. Access Range</a> Concept.
  86. </li>
  87. <li class="listitem">
  88. <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code>
  89. is mutable.
  90. </li>
  91. <li class="listitem">
  92. <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code>'s
  93. value type is a model of the <code class="computeroutput"><span class="identifier">LessThanComparableConcept</span></code>.
  94. </li>
  95. <li class="listitem">
  96. The ordering relation on <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code>'s
  97. value type is a <span class="bold"><strong><span class="emphasis"><em>strict weak ordering</em></span></strong></span>,
  98. as defined in the <code class="computeroutput"><span class="identifier">LessThanComparableConcept</span></code>
  99. requirements.
  100. </li>
  101. </ul></div>
  102. <p>
  103. <span class="bold"><strong>For the predicate version:</strong></span>
  104. </p>
  105. <div class="itemizedlist"><ul class="itemizedlist" type="disc">
  106. <li class="listitem">
  107. <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code>
  108. is a model of the <a class="link" href="../../../concepts/random_access_range.html" title="Random Access Range">Random
  109. Access Range</a> Concept.
  110. </li>
  111. <li class="listitem">
  112. <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code>
  113. is mutable.
  114. </li>
  115. <li class="listitem">
  116. <code class="computeroutput"><span class="identifier">BinaryPredicate</span></code> is
  117. a model of the <code class="computeroutput"><span class="identifier">StrictWeakOrderingConcept</span></code>.
  118. </li>
  119. <li class="listitem">
  120. <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code>'s
  121. value type is convertible to both of <code class="computeroutput"><span class="identifier">BinaryPredicate</span></code>'s
  122. argument types.
  123. </li>
  124. </ul></div>
  125. <a name="range.reference.algorithms.mutating.nth_element.complexity"></a><h6>
  126. <a name="id691923"></a>
  127. <a class="link" href="nth_element.html#range.reference.algorithms.mutating.nth_element.complexity">Complexity</a>
  128. </h6>
  129. <p>
  130. On average, linear in <code class="computeroutput"><span class="identifier">distance</span><span class="special">(</span><span class="identifier">rng</span><span class="special">)</span></code>.
  131. </p>
  132. </div>
  133. <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
  134. <td align="left"></td>
  135. <td align="right"><div class="copyright-footer">Copyright &#169; 2003 -2010 Thorsten Ottosen, Neil Groves<p>
  136. Distributed under the Boost Software License, Version 1.0. (See accompanying
  137. 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>)
  138. </p>
  139. </div></td>
  140. </tr></table>
  141. <hr>
  142. <div class="spirit-nav">
  143. <a accesskey="p" href="merge.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../mutating.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="partial_sort.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
  144. </div>
  145. </body>
  146. </html>