1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>partial_sort</title> 5<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../../../index.html" title="Chapter 1. Range 2.0"> 8<link rel="up" href="../mutating.html" title="Mutating algorithms"> 9<link rel="prev" href="nth_element.html" title="nth_element"> 10<link rel="next" href="partition.html" title="partition"> 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="nth_element.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="partition.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.partial_sort"></a><a class="link" href="partial_sort.html" title="partial_sort">partial_sort</a> 28</h5></div></div></div> 29<h6> 30<a name="range.reference.algorithms.mutating.partial_sort.h0"></a> 31 <span class="phrase"><a name="range.reference.algorithms.mutating.partial_sort.prototype"></a></span><a class="link" href="partial_sort.html#range.reference.algorithms.mutating.partial_sort.prototype">Prototype</a> 32 </h6> 33<p> 34</p> 35<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">RandomAccessRange</span><span class="special">></span> 36<span class="identifier">RandomAccessRange</span><span class="special">&</span> <span class="identifier">partial_sort</span><span class="special">(</span> 37 <span class="identifier">RandomAccessRange</span><span class="special">&</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"><</span><span class="identifier">RandomAccessRange</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">middle</span><span class="special">);</span> 39 40<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">RandomAccessRange</span><span class="special">></span> 41<span class="keyword">const</span> <span class="identifier">RandomAccessRange</span><span class="special">&</span> <span class="identifier">partial_sort</span><span class="special">(</span> 42 <span class="keyword">const</span> <span class="identifier">RandomAccessRange</span><span class="special">&</span> <span class="identifier">rng</span><span class="special">,</span> 43 <span class="keyword">typename</span> <span class="identifier">range_iterator</span><span class="special"><</span><span class="keyword">const</span> <span class="identifier">RandomAccessRange</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">middle</span><span class="special">);</span> 44 45<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">RandomAccessRange</span><span class="special">></span> 46<span class="identifier">RandomAccessRange</span><span class="special">&</span> <span class="identifier">partial_sort</span><span class="special">(</span> 47 <span class="identifier">RandomAccessRange</span><span class="special">&</span> <span class="identifier">rng</span><span class="special">,</span> 48 <span class="keyword">typename</span> <span class="identifier">range_iterator</span><span class="special"><</span><span class="identifier">RandomAccessRange</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">middle</span><span class="special">,</span> 49 <span class="identifier">BinaryPredicate</span> <span class="identifier">sort_pred</span><span class="special">);</span> 50 51<span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">RandomAccessRange</span><span class="special">></span> 52<span class="keyword">const</span> <span class="identifier">RandomAccessRange</span><span class="special">&</span> <span class="identifier">partial_sort</span><span class="special">(</span> 53 <span class="keyword">const</span> <span class="identifier">RandomAccessRange</span><span class="special">&</span> <span class="identifier">rng</span><span class="special">,</span> 54 <span class="keyword">typename</span> <span class="identifier">range_iterator</span><span class="special"><</span><span class="keyword">const</span> <span class="identifier">RandomAccessRange</span><span class="special">>::</span><span class="identifier">type</span> <span class="identifier">middle</span><span class="special">,</span> 55 <span class="identifier">BinaryPredicate</span> <span class="identifier">sort_pred</span><span class="special">);</span> 56</pre> 57<p> 58 </p> 59<h6> 60<a name="range.reference.algorithms.mutating.partial_sort.h1"></a> 61 <span class="phrase"><a name="range.reference.algorithms.mutating.partial_sort.description"></a></span><a class="link" href="partial_sort.html#range.reference.algorithms.mutating.partial_sort.description">Description</a> 62 </h6> 63<p> 64 <code class="computeroutput"><span class="identifier">partial_sort</span></code> rearranges 65 the elements in <code class="computeroutput"><span class="identifier">rng</span></code>. 66 It places the smallest <code class="computeroutput"><span class="identifier">distance</span><span class="special">(</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">rng</span><span class="special">),</span> <span class="identifier">middle</span><span class="special">)</span></code> elements, sorted in ascending order, 67 into the range <code class="computeroutput"><span class="special">[</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">rng</span><span class="special">),</span> <span class="identifier">middle</span><span class="special">)</span></code>. The remaining elements are placed in 68 an unspecified order into <code class="computeroutput"><span class="special">[</span><span class="identifier">middle</span><span class="special">,</span> <span class="identifier">last</span><span class="special">)</span></code>. 69 </p> 70<p> 71 The non-predicative versions of this function specify that one element 72 is less than another by using <code class="computeroutput"><span class="keyword">operator</span><span class="special"><()</span></code>. The predicate versions use the 73 predicate instead. 74 </p> 75<h6> 76<a name="range.reference.algorithms.mutating.partial_sort.h2"></a> 77 <span class="phrase"><a name="range.reference.algorithms.mutating.partial_sort.definition"></a></span><a class="link" href="partial_sort.html#range.reference.algorithms.mutating.partial_sort.definition">Definition</a> 78 </h6> 79<p> 80 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">partial_sort</span><span class="special">.</span><span class="identifier">hpp</span></code> 81 </p> 82<h6> 83<a name="range.reference.algorithms.mutating.partial_sort.h3"></a> 84 <span class="phrase"><a name="range.reference.algorithms.mutating.partial_sort.requirements"></a></span><a class="link" href="partial_sort.html#range.reference.algorithms.mutating.partial_sort.requirements">Requirements</a> 85 </h6> 86<p> 87 <span class="bold"><strong>For the non-predicate version:</strong></span> 88 </p> 89<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 90<li class="listitem"> 91 <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code> 92 is a model of the <a class="link" href="../../../concepts/random_access_range.html" title="Random Access Range">Random 93 Access Range</a> Concept. 94 </li> 95<li class="listitem"> 96 <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code> 97 is mutable. 98 </li> 99<li class="listitem"> 100 <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code>'s 101 value type is a model of the <code class="computeroutput"><span class="identifier">LessThanComparableConcept</span></code>. 102 </li> 103<li class="listitem"> 104 The ordering relation on <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code>'s 105 value type is a <span class="bold"><strong><span class="emphasis"><em>strict weak ordering</em></span></strong></span>, 106 as defined in the <code class="computeroutput"><span class="identifier">LessThanComparableConcept</span></code> 107 requirements. 108 </li> 109</ul></div> 110<p> 111 <span class="bold"><strong>For the predicate version:</strong></span> 112 </p> 113<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 114<li class="listitem"> 115 <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code> 116 is a model of the <a class="link" href="../../../concepts/random_access_range.html" title="Random Access Range">Random 117 Access Range</a> Concept. 118 </li> 119<li class="listitem"> 120 <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code> 121 is mutable. 122 </li> 123<li class="listitem"> 124 <code class="computeroutput"><span class="identifier">BinaryPredicate</span></code> is 125 a model of the <code class="computeroutput"><span class="identifier">StrictWeakOrderingConcept</span></code>. 126 </li> 127<li class="listitem"> 128 <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code>'s 129 value type is convertible to both of <code class="computeroutput"><span class="identifier">BinaryPredicate</span></code>'s 130 argument types. 131 </li> 132</ul></div> 133<h6> 134<a name="range.reference.algorithms.mutating.partial_sort.h4"></a> 135 <span class="phrase"><a name="range.reference.algorithms.mutating.partial_sort.complexity"></a></span><a class="link" href="partial_sort.html#range.reference.algorithms.mutating.partial_sort.complexity">Complexity</a> 136 </h6> 137<p> 138 Approximately <code class="computeroutput"><span class="identifier">distance</span><span class="special">(</span><span class="identifier">rng</span><span class="special">)</span> <span class="special">*</span> <span class="identifier">log</span><span class="special">(</span><span class="identifier">distance</span><span class="special">(</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">rng</span><span class="special">),</span> <span class="identifier">middle</span><span class="special">))</span></code> comparisons. 139 </p> 140</div> 141<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 142<td align="left"></td> 143<td align="right"><div class="copyright-footer">Copyright © 2003-2010 Thorsten Ottosen, 144 Neil Groves<p> 145 Distributed under the Boost Software License, Version 1.0. (See accompanying 146 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>) 147 </p> 148</div></td> 149</tr></table> 150<hr> 151<div class="spirit-nav"> 152<a accesskey="p" href="nth_element.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="partition.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a> 153</div> 154</body> 155</html> 156