<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Function template reverse_string_sort</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Boost. Sort">
<link rel="up" href="../../../header/boost/sort/spreadsort/string_sort_hpp.html" title="Header &lt;boost/sort/spreadsort/string_sort.hpp&gt;">
<link rel="prev" href="string_sort_idp52427776.html" title="Function template string_sort">
<link rel="next" href="reverse_string_idp52482416.html" title="Function template reverse_string_sort">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="string_sort_idp52427776.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../header/boost/sort/spreadsort/string_sort_hpp.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="reverse_string_idp52482416.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.sort.spreadsort.reverse_string_idp52453344"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Function template reverse_string_sort</span></h2>
<p>boost::sort::spreadsort::reverse_string_sort &#8212; Reverse String sort algorithm using random access iterators.  </p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../../header/boost/sort/spreadsort/string_sort_hpp.html" title="Header &lt;boost/sort/spreadsort/string_sort.hpp&gt;">boost/sort/spreadsort/string_sort.hpp</a>&gt;

</span>
<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> RandomAccessIter<span class="special">,</span> <span class="keyword">typename</span> Get_char<span class="special">,</span> <span class="keyword">typename</span> Get_length<span class="special">,</span> 
         <span class="keyword">typename</span> Compare<span class="special">&gt;</span> 
  <span class="keyword">void</span> <span class="identifier">reverse_string_sort</span><span class="special">(</span><span class="identifier">RandomAccessIter</span> first<span class="special">,</span> <span class="identifier">RandomAccessIter</span> last<span class="special">,</span> 
                           <span class="identifier">Get_char</span> get_character<span class="special">,</span> <span class="identifier">Get_length</span> length<span class="special">,</span> 
                           <span class="identifier">Compare</span> comp<span class="special">)</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="idp95442592"></a><h2>Description</h2>
<p>(All variants fall back to <code class="computeroutput">boost::sort::pdqsort</code> if the data size is too small, &lt; <code class="computeroutput">detail::min_sort_size</code>).</p>
<p><code class="computeroutput">string_sort</code> is a fast templated in-place hybrid radix/comparison algorithm, which in testing tends to be roughly 50% to 2X faster than <code class="computeroutput">std::sort</code> for large tests (&gt;=100kB).<br>
</p>
<p><b>&#160;</b>Worst-case performance is <span class="emphasis"><em> O(N * (lg(range)/s + s)) </em></span>, so <code class="computeroutput">string_sort</code> is asymptotically faster than pure comparison-based algorithms.  <br>
<br>
Some performance plots of runtime vs. n and log(range) are provided:<br>
<a href="../../../../../doc/graph/windows_string_sort.htm" target="_top">windows_string_sort</a><br>
<a href="../../../../../doc/graph/osx_string_sort.htm" target="_top">osx_string_sort</a></p>
<p>





</p>
<div class="warning"><table border="0" summary="Warning">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../../../doc/src/images/warning.png"></td>
<th align="left">Warning</th>
</tr>
<tr><td align="left" valign="top">
<p>Throwing an exception may cause data loss.  This will also throw if a small vector resize throws, in which case there will be no data loss.  </p>
<p>Invalid arguments cause undefined behaviour.  </p>
</td></tr>
</table></div>
<p>
</p>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p><code class="computeroutput">spreadsort</code> function provides a wrapper that calls the fastest sorting algorithm available for a data type, enabling faster generic-programming.</p></td></tr>
</table></div>
<p>
</p>
<p>The lesser of <span class="emphasis"><em> O(N*log(N)) </em></span> comparisons and <span class="emphasis"><em> O(N*log(K/S + S)) </em></span>operations worst-case, where: </p>
<p>* N is <code class="computeroutput">last</code> - <code class="computeroutput">first</code>, </p>
<p>* K is the log of the range in bits (32 for 32-bit integers using their full range), </p>
<p>* S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size).  </p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="computeroutput">comp</code></span></p></td>
<td><p>A binary functor that returns whether the first element passed to it should go before the second in order.</p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">first</code></span></p></td>
<td><p>Iterator pointer to first element.  </p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">get_character</code></span></p></td>
<td><p>Bracket functor equivalent to <code class="computeroutput">operator</code>[], taking a number corresponding to the character offset.  </p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">last</code></span></p></td>
<td><p>Iterator pointing to one beyond the end of data.  </p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">length</code></span></p></td>
<td><p>Functor to get the length of the string in characters.  </p></td>
</tr>
</tbody>
</table></div></td>
</tr>
<tr>
<td><p><span class="term">Requires:</span></p></td>
<td>
<p>[<code class="computeroutput">first</code>, <code class="computeroutput">last</code>) is a valid range.  </p>
<p><code class="computeroutput">RandomAccessIter</code> <code class="computeroutput">value_type</code> is mutable.  </p>
<p><code class="computeroutput">RandomAccessIter</code> <code class="computeroutput">value_type</code> is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable" target="_top">LessThanComparable</a> </p>
</td>
</tr>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p>The elements in the range [<code class="computeroutput">first</code>, <code class="computeroutput">last</code>) are sorted in ascending order.</p></td>
</tr>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p><code class="computeroutput">void</code>.</p></td>
</tr>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td>std::exception Propagates exceptions if any of the element comparisons, the element swaps (or moves), the right shift, subtraction of right-shifted elements, functors, or any operations on iterators throw.</td>
</tr>
</tbody>
</table></div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2014-2017 Steven
      Ross, Francisco Tapia, Orson Peters<p>
        Distributed under the <a href="http://boost.org/LICENSE_1_0.txt" target="_top">Boost
        Software License, Version 1.0</a>. 
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="string_sort_idp52427776.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../header/boost/sort/spreadsort/string_sort_hpp.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="reverse_string_idp52482416.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
