• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Programming</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="Boost.Sort">
8<link rel="up" href="../spinsort.html" title="2.3.- spinsort">
9<link rel="prev" href="spinsort_benchmark.html" title="Benchmark">
10<link rel="next" href="../flat_stable_sort.html" title="2.4.- flat_stable_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="spinsort_benchmark.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../spinsort.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="../flat_stable_sort.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h4 class="title">
27<a name="sort.single_thread.spinsort.spinsort_programming"></a><a class="link" href="spinsort_programming.html" title="Programming">Programming</a>
28</h4></div></div></div>
29<div class="blockquote"><blockquote class="blockquote">
30<p>
31            You only need to include the file boost/sort/sort.hpp to use spinsort.
32          </p>
33<p>
34            The spinsort function is in the namespace boost::sort
35          </p>
36<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">sort</span><span class="special">/</span><span class="identifier">sort</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
37
38
39<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">iter_t</span><span class="special">,</span>  <span class="keyword">typename</span> <span class="identifier">compare</span><span class="special">&gt;</span>
40<span class="keyword">void</span> <span class="identifier">spinsort</span> <span class="special">(</span><span class="identifier">iter_t</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">iter_t</span> <span class="identifier">last</span><span class="special">,</span> <span class="identifier">compare</span> <span class="identifier">comp</span> <span class="special">=</span> <span class="identifier">compare</span><span class="special">());</span>
41</pre>
42<p>
43            This algorithm uses a <span class="bold"><strong>comparison object</strong></span>,
44            in the same way as the standard library sort algorithms. If you don't
45            define it, the comparison object defaults to std::less, which uses the
46            &lt; operator internally for comparisons.
47          </p>
48<p>
49            This algorithm is <span class="bold"><strong>exception safe</strong></span>, meaning
50            that, the exceptions generated by the algorithm guarantee the integrity
51            of the objects to sort, but not their relative order. If the exception
52            is generated inside the objects (in the move or copy constructors) the
53            results are undefined.
54          </p>
55</blockquote></div>
56</div>
57<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
58<td align="left"></td>
59<td align="right"><div class="copyright-footer">Copyright © 2014-2017 Steven
60      Ross, Francisco Tapia, Orson Peters<p>
61        Distributed under the <a href="http://boost.org/LICENSE_1_0.txt" target="_top">Boost
62        Software License, Version 1.0</a>.
63      </p>
64</div></td>
65</tr></table>
66<hr>
67<div class="spirit-nav">
68<a accesskey="p" href="spinsort_benchmark.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../spinsort.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="../flat_stable_sort.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
69</div>
70</body>
71</html>
72