| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
| <meta http-equiv="X-UA-Compatible" content="IE=9"/> |
| <meta name="generator" content="Doxygen 1.8.9.1"/> |
| <title>Boost.Sort: /example/sample.cpp</title> |
| <link href="tabs.css" rel="stylesheet" type="text/css"/> |
| <script type="text/javascript" src="jquery.js"></script> |
| <script type="text/javascript" src="dynsections.js"></script> |
| <link href="search/search.css" rel="stylesheet" type="text/css"/> |
| <script type="text/javascript" src="search/searchdata.js"></script> |
| <script type="text/javascript" src="search/search.js"></script> |
| <script type="text/javascript"> |
| $(document).ready(function() { init_search(); }); |
| </script> |
| <link href="doxygen.css" rel="stylesheet" type="text/css" /> |
| </head> |
| <body> |
| <div id="top"><!-- do not remove this div, it is closed by doxygen! --> |
| <div id="titlearea"> |
| <table cellspacing="0" cellpadding="0"> |
| <tbody> |
| <tr style="height: 56px;"> |
| <td style="padding-left: 0.5em;"> |
| <div id="projectname">Boost.Sort |
| </div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <!-- end header part --> |
| <!-- Generated by Doxygen 1.8.9.1 --> |
| <script type="text/javascript"> |
| var searchBox = new SearchBox("searchBox", "search",false,'Search'); |
| </script> |
| <div id="navrow1" class="tabs"> |
| <ul class="tablist"> |
| <li><a href="index.html"><span>Main Page</span></a></li> |
| <li><a href="namespaces.html"><span>Namespaces</span></a></li> |
| <li><a href="annotated.html"><span>Classes</span></a></li> |
| <li><a href="files.html"><span>Files</span></a></li> |
| <li><a href="examples.html"><span>Examples</span></a></li> |
| <li> |
| <div id="MSearchBox" class="MSearchBoxInactive"> |
| <span class="left"> |
| <img id="MSearchSelect" src="search/mag_sel.png" |
| onmouseover="return searchBox.OnSearchSelectShow()" |
| onmouseout="return searchBox.OnSearchSelectHide()" |
| alt=""/> |
| <input type="text" id="MSearchField" value="Search" accesskey="S" |
| onfocus="searchBox.OnSearchFieldFocus(true)" |
| onblur="searchBox.OnSearchFieldFocus(false)" |
| onkeyup="searchBox.OnSearchFieldChange(event)"/> |
| </span><span class="right"> |
| <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> |
| </span> |
| </div> |
| </li> |
| </ul> |
| </div> |
| </div><!-- top --> |
| <!-- window showing the filter options --> |
| <div id="MSearchSelectWindow" |
| onmouseover="return searchBox.OnSearchSelectShow()" |
| onmouseout="return searchBox.OnSearchSelectHide()" |
| onkeydown="return searchBox.OnSearchSelectKey(event)"> |
| </div> |
| |
| <!-- iframe showing the search results (closed by default) --> |
| <div id="MSearchResultsWindow"> |
| <iframe src="javascript:void(0)" frameborder="0" |
| name="MSearchResults" id="MSearchResults"> |
| </iframe> |
| </div> |
| |
| <div class="header"> |
| <div class="headertitle"> |
| <div class="title">/example/sample.cpp</div> </div> |
| </div><!--header--> |
| <div class="contents"> |
| <p>Integer sort algorithm using random access iterators. All variants fall back to <code>std::sort</code> if the data is too small.<code>integer_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>std::sort</code> for large tests (>=100kB).<br /> |
| Worst-case performance is <em> O(N * (lg(range)/s + s)) </em>, so <code>integer_sort</code> is asymptotically faster than pure comparison-based algorithms. <code>s</code> is <code>max_splits</code>, which defaults to 11, so its worst-case with default settings for 32-bit integers is <em> O(N * ((32/11) </em> slow radix-based iterations fast comparison-based iterations).<br /> |
| <br /> |
| Some performance plots of runtime vs. n and log(range) are provided:<br /> |
| <a href="../../../graph/windows_integer_sort.htm">windows_integer_sort</a> <br /> |
| <a href="../../../graph/osx_integer_sort.htm">osx_integer_sort</a></p> |
| <dl class="tparams"><dt>Template Parameters</dt><dd> |
| <table class="tparams"> |
| <tr><td class="paramname">RandomAccessIter</td><td><a href="http://www.cplusplus.com/reference/iterator/RandomAccessIterator/">Random access iterator</a> </td></tr> |
| </table> |
| </dd> |
| </dl> |
| <dl class="params"><dt>Parameters</dt><dd> |
| <table class="params"> |
| <tr><td class="paramdir">[in]</td><td class="paramname">first</td><td>Iterator pointer to first element. </td></tr> |
| <tr><td class="paramdir">[in]</td><td class="paramname">last</td><td>Iterator pointing to one beyond the end of data.</td></tr> |
| </table> |
| </dd> |
| </dl> |
| <dl class="section pre"><dt>Precondition</dt><dd>[<code>first</code>, <code>last</code>) is a valid range. </dd> |
| <dd> |
| <code>RandomAccessIter</code> <code>value_type</code> is mutable. </dd> |
| <dd> |
| <code>RandomAccessIter</code> <code>value_type</code> is <a href="http://en.cppreference.com/w/cpp/concept/LessThanComparable">LessThanComparable</a> </dd> |
| <dd> |
| <code>RandomAccessIter</code> <code>value_type</code> supports the <code>operator>></code>, which returns an integer-type right-shifted a specified number of bits. </dd></dl> |
| <dl class="section post"><dt>Postcondition</dt><dd>The elements in the range [<code>first</code>, <code>last</code>) are sorted in ascending order.</dd></dl> |
| <dl class="section return"><dt>Returns</dt><dd><code>void</code>.</dd></dl> |
| <dl class="exception"><dt>Exceptions</dt><dd> |
| <table class="exception"> |
| <tr><td class="paramname">Propagates</td><td>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> |
| </table> |
| </dd> |
| </dl> |
| <dl class="section warning"><dt>Warning</dt><dd>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. </dd> |
| <dd> |
| Invalid arguments cause undefined behaviour. </dd></dl> |
| <dl class="section note"><dt>Note</dt><dd><code>spreadsort</code> function provides a wrapper that calls the fastest sorting algorithm available for a data type, enabling faster generic-programming.</dd></dl> |
| <dl class="section remark"><dt>Remarks</dt><dd>The lesser of <em> O(N*log(N)) </em> comparisons and <em> O(N*log(K/S + S)) </em>operations worst-case, where: </dd> |
| <dd> |
| * N is <code>last</code> - <code>first</code>, </dd> |
| <dd> |
| * K is the log of the range in bits (32 for 32-bit integers using their full range), </dd> |
| <dd> |
| * S is a constant called max_splits, defaulting to 11 (except for strings where it is the log of the character size).</dd></dl> |
| <div class="fragment"></div><!-- fragment --> </div><!-- contents --> |
| <!-- start footer part --> |
| <hr class="footer"/><address class="footer"><small> |
| Generated on Tue Jan 6 2015 16:36:35 for Boost.Sort by  <a href="http://www.doxygen.org/index.html"> |
| <img class="footer" src="doxygen.png" alt="doxygen"/> |
| </a> 1.8.9.1 |
| </small></address> |
| </body> |
| </html> |