• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>sort_heap</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="../heap.html" title="Heap algorithms">
9<link rel="prev" href="make_heap.html" title="make_heap">
10<link rel="next" href="../permutation.html" title="Permutation algorithms">
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="make_heap.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../heap.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="../permutation.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.heap.sort_heap"></a><a class="link" href="sort_heap.html" title="sort_heap">sort_heap</a>
28</h5></div></div></div>
29<h6>
30<a name="range.reference.algorithms.heap.sort_heap.h0"></a>
31            <span class="phrase"><a name="range.reference.algorithms.heap.sort_heap.prototype"></a></span><a class="link" href="sort_heap.html#range.reference.algorithms.heap.sort_heap.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">sort_heap</span><span class="special">(</span><span class="identifier">RandomAccessRange</span><span class="special">&amp;</span> <span class="identifier">rng</span><span class="special">);</span>
37
38<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>
39<span class="keyword">const</span> <span class="identifier">RandomAccessRange</span><span class="special">&amp;</span> <span class="identifier">sort_heap</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">RandomAccessRange</span><span class="special">&amp;</span> <span class="identifier">rng</span><span class="special">);</span>
40
41<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">RandomAccessRange</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Compare</span><span class="special">&gt;</span>
42<span class="identifier">RandomAccessRange</span><span class="special">&amp;</span> <span class="identifier">sort_heap</span><span class="special">(</span><span class="identifier">RandomAccessRange</span><span class="special">&amp;</span> <span class="identifier">rng</span><span class="special">,</span> <span class="identifier">Compare</span> <span class="identifier">pred</span><span class="special">);</span>
43
44<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">RandomAccessRange</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Compare</span><span class="special">&gt;</span>
45<span class="keyword">const</span> <span class="identifier">RandomAccessRange</span><span class="special">&amp;</span> <span class="identifier">sort_heap</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">RandomAccessRange</span><span class="special">&amp;</span> <span class="identifier">rng</span><span class="special">,</span> <span class="identifier">Compare</span> <span class="identifier">pred</span><span class="special">);</span>
46</pre>
47<p>
48          </p>
49<h6>
50<a name="range.reference.algorithms.heap.sort_heap.h1"></a>
51            <span class="phrase"><a name="range.reference.algorithms.heap.sort_heap.description"></a></span><a class="link" href="sort_heap.html#range.reference.algorithms.heap.sort_heap.description">Description</a>
52          </h6>
53<p>
54            <code class="computeroutput"><span class="identifier">sort_heap</span></code> turns a heap
55            into a sorted range.
56          </p>
57<p>
58            The ordering relationship is determined by using <code class="computeroutput"><span class="keyword">operator</span><span class="special">&lt;</span></code> in the non-predicate versions, and
59            by evaluating <code class="computeroutput"><span class="identifier">pred</span></code> in
60            the predicate versions.
61          </p>
62<h6>
63<a name="range.reference.algorithms.heap.sort_heap.h2"></a>
64            <span class="phrase"><a name="range.reference.algorithms.heap.sort_heap.definition"></a></span><a class="link" href="sort_heap.html#range.reference.algorithms.heap.sort_heap.definition">Definition</a>
65          </h6>
66<p>
67            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">heap_algorithm</span><span class="special">.</span><span class="identifier">hpp</span></code>
68          </p>
69<h6>
70<a name="range.reference.algorithms.heap.sort_heap.h3"></a>
71            <span class="phrase"><a name="range.reference.algorithms.heap.sort_heap.requirements"></a></span><a class="link" href="sort_heap.html#range.reference.algorithms.heap.sort_heap.requirements">Requirements</a>
72          </h6>
73<p>
74            <span class="bold"><strong>For the non-predicate versions:</strong></span>
75          </p>
76<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
77<li class="listitem">
78                <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code>
79                is a model of the <a class="link" href="../../../concepts/random_access_range.html" title="Random Access Range">Random
80                Access Range</a> Concept.
81              </li>
82<li class="listitem">
83                <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code>
84                is mutable.
85              </li>
86<li class="listitem">
87                <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code>'s
88                value type is a model of the <code class="computeroutput"><span class="identifier">LessThanComparableConcept</span></code>.
89              </li>
90<li class="listitem">
91                The ordering of objects of type <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code>'s
92                value type is a <span class="bold"><strong><span class="emphasis"><em>strict weak ordering</em></span></strong></span>,
93                as defined in the <code class="computeroutput"><span class="identifier">LessThanComparableConcept</span></code>
94                requirements.
95              </li>
96</ul></div>
97<p>
98            <span class="bold"><strong>For the predicate versions:</strong></span>
99          </p>
100<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
101<li class="listitem">
102                <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code>
103                is a model of the <a class="link" href="../../../concepts/random_access_range.html" title="Random Access Range">Random
104                Access Range</a> Concept.
105              </li>
106<li class="listitem">
107                <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code>
108                is mutable.
109              </li>
110<li class="listitem">
111                <code class="computeroutput"><span class="identifier">Compare</span></code> is a model
112                of the <code class="computeroutput"><span class="identifier">StrictWeakOrderingConcept</span></code>.
113              </li>
114<li class="listitem">
115                <code class="computeroutput"><span class="identifier">RandomAccessRange</span></code>'s
116                value type is convertible to both of <code class="computeroutput"><span class="identifier">Compare</span></code>'s
117                argument types.
118              </li>
119</ul></div>
120<h6>
121<a name="range.reference.algorithms.heap.sort_heap.h4"></a>
122            <span class="phrase"><a name="range.reference.algorithms.heap.sort_heap.precondition_"></a></span><a class="link" href="sort_heap.html#range.reference.algorithms.heap.sort_heap.precondition_">Precondition:</a>
123          </h6>
124<p>
125            <code class="computeroutput"><span class="identifier">rng</span></code> is a heap.
126          </p>
127<h6>
128<a name="range.reference.algorithms.heap.sort_heap.h5"></a>
129            <span class="phrase"><a name="range.reference.algorithms.heap.sort_heap.complexity"></a></span><a class="link" href="sort_heap.html#range.reference.algorithms.heap.sort_heap.complexity">Complexity</a>
130          </h6>
131<p>
132            At most <code class="computeroutput"><span class="identifier">N</span> <span class="special">*</span>
133            <span class="identifier">log</span><span class="special">(</span><span class="identifier">N</span><span class="special">)</span></code>
134            comparisons, where <code class="computeroutput"><span class="identifier">N</span></code>
135            is <code class="computeroutput"><span class="identifier">distance</span><span class="special">(</span><span class="identifier">rng</span><span class="special">)</span></code>.
136          </p>
137</div>
138<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
139<td align="left"></td>
140<td align="right"><div class="copyright-footer">Copyright © 2003-2010 Thorsten Ottosen,
141      Neil Groves<p>
142        Distributed under the Boost Software License, Version 1.0. (See accompanying
143        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>)
144      </p>
145</div></td>
146</tr></table>
147<hr>
148<div class="spirit-nav">
149<a accesskey="p" href="make_heap.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../heap.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="../permutation.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
150</div>
151</body>
152</html>
153