summaryrefslogtreecommitdiff
path: root/libs/sort/doc/html/sort/sort_hpp.html
blob: 5efc81c1c34570e0bb320f1afa8576c7117b5150 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Spreadsort</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="../index.html" title="Boost.Sort">
<link rel="up" href="../index.html" title="Boost.Sort">
<link rel="prev" href="../index.html" title="Boost.Sort">
<link rel="next" href="sort_hpp/integer_sort.html" title="Integer 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="../index.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.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="sort_hpp/integer_sort.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="sort.sort_hpp"></a><a class="link" href="sort_hpp.html" title="Spreadsort">Spreadsort</a>
</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="sort_hpp.html#sort.sort_hpp.header_spreadsort">Header <code class="computeroutput"><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">spreadsort</span><span class="special">/</span><span class="identifier">spreadsort</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code></a></span></dt>
<dd><dl><dt><span class="section"><a href="sort_hpp.html#sort.sort_hpp.header_spreadsort.spreadsort_examples">Spreadsort
        Examples</a></span></dt></dl></dd>
<dt><span class="section"><a href="sort_hpp/integer_sort.html">Integer Sort</a></span></dt>
<dd><dl><dt><span class="section"><a href="sort_hpp/integer_sort.html#sort.sort_hpp.integer_sort.integersort_examples">Integer
        Sort Examples</a></span></dt></dl></dd>
<dt><span class="section"><a href="sort_hpp/float_sort.html">Float Sort</a></span></dt>
<dd><dl><dt><span class="section"><a href="sort_hpp/float_sort.html#sort.sort_hpp.float_sort.floatsort_examples">Float
        Sort Examples</a></span></dt></dl></dd>
<dt><span class="section"><a href="sort_hpp/string_sort.html">String Sort</a></span></dt>
<dd><dl><dt><span class="section"><a href="sort_hpp/string_sort.html#sort.sort_hpp.string_sort.stringsort_examples">String
        Sort Examples</a></span></dt></dl></dd>
<dt><span class="section"><a href="sort_hpp/rationale.html">Rationale</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="sort_hpp/rationale.html#sort.sort_hpp.rationale.radix_sorting">Radix Sorting</a></span></dt>
<dt><span class="section"><a href="sort_hpp/rationale/hybrid_radix.html">Hybrid Radix</a></span></dt>
<dt><span class="section"><a href="sort_hpp/rationale/why_spreadsort.html">Why spreadsort?</a></span></dt>
<dt><span class="section"><a href="sort_hpp/rationale/unstable_sort.html">Unstable Sorting</a></span></dt>
<dt><span class="section"><a href="sort_hpp/rationale/optimization.html">Unused X86 optimization</a></span></dt>
<dt><span class="section"><a href="sort_hpp/rationale/lookup.html">Lookup Table?</a></span></dt>
</dl></dd>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="sort.sort_hpp.header_spreadsort"></a><a class="link" href="sort_hpp.html#sort.sort_hpp.header_spreadsort" title="Header &lt;boost/sort/spreadsort/spreadsort.hpp&gt;">Header <code class="computeroutput"><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">spreadsort</span><span class="special">/</span><span class="identifier">spreadsort</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code></a>
</h3></div></div></div>
<p>
        <code class="literal"><code class="computeroutput"><a class="link" href="../boost/sort/spreadsort/spreadsort_idp47957744.html" title="Function template spreadsort">spreadsort</a></code></code>
        checks whether the data-type provided is an integer, castable float, string,
        or wstring.
      </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
            If data-type is an integer, <code class="literal"><code class="computeroutput"><a class="link" href="../boost/sort/spreadsort/integer_sort_idp41299456.html" title="Function template integer_sort">integer_sort</a></code></code>
            is used.
          </li>
<li class="listitem">
            If data-type is a float, <code class="literal"><code class="computeroutput"><a class="link" href="../boost/sort/spreadsort/float_sort_idp47034528.html" title="Function template float_sort">float_sort</a></code></code>
            is used.
          </li>
<li class="listitem">
            If data-type is a string or wstring, <code class="literal"><code class="computeroutput"><a class="link" href="../boost/sort/spreadsort/string_sort_idp48004640.html" title="Function template string_sort">string_sort</a></code></code>
            is used.
          </li>
<li class="listitem">
            Sorting other data-types requires picking between <code class="literal"><code class="computeroutput"><a class="link" href="../boost/sort/spreadsort/integer_sort_idp41299456.html" title="Function template integer_sort">integer_sort</a></code></code>,
            <code class="literal"><code class="computeroutput"><a class="link" href="../boost/sort/spreadsort/float_sort_idp47034528.html" title="Function template float_sort">float_sort</a></code></code>
            and <code class="literal"><code class="computeroutput"><a class="link" href="../boost/sort/spreadsort/string_sort_idp48004640.html" title="Function template string_sort">string_sort</a></code></code>
            directly, as <code class="literal"><code class="computeroutput"><a class="link" href="../boost/sort/spreadsort/spreadsort_idp47957744.html" title="Function template spreadsort">spreadsort</a></code></code>
            won't accept types that don't have the appropriate type traits.
          </li>
</ul></div>
<p>
        Overloading variants are provided that permit use of user-defined right-shift
        functors and comparison functors.
      </p>
<p>
        Each function is optimized for its set of arguments; default functors are
        not provided to avoid the risk of any reduction of performance.
      </p>
<p>
        See <a class="link" href="../index.html#sort.overview.overloading" title="Overloading">overloading</a> section.
      </p>
<h6>
<a name="sort.sort_hpp.header_spreadsort.h0"></a>
        <span class="phrase"><a name="sort.sort_hpp.header_spreadsort.rationale"></a></span><a class="link" href="sort_hpp.html#sort.sort_hpp.header_spreadsort.rationale">Rationale:</a>
      </h6>
<p>
        <code class="literal"><code class="computeroutput"><a class="link" href="../boost/sort/spreadsort/spreadsort_idp47957744.html" title="Function template spreadsort">spreadsort</a></code></code>
        function provides a wrapper that calls the fastest sorting algorithm available
        for a data-type, enabling faster generic programming.
      </p>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="sort.sort_hpp.header_spreadsort.spreadsort_examples"></a><a class="link" href="sort_hpp.html#sort.sort_hpp.header_spreadsort.spreadsort_examples" title="Spreadsort Examples">Spreadsort
        Examples</a>
</h4></div></div></div>
<p>
          See <a href="../../../example/" target="_top">example</a> folder for all examples.
        </p>
<p>
          See <a href="../../../example/sample.cpp" target="_top">sample.cpp</a> for a simple
          working example.
        </p>
<p>
          For an example of 64-bit integer sorting, see <a href="../../../example/int64.cpp" target="_top">int64.cpp</a>.
        </p>
<p>
          This example sets the element type of a vector to 64-bit integer
        </p>
<pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">DATA_TYPE</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">int64_t</span>
</pre>
<p>
          and calls the sort
        </p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">sort</span><span class="special">::</span><span class="identifier">spreadsort</span><span class="special">::</span><span class="identifier">spreadsort</span><span class="special">(</span><span class="identifier">array</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">array</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span>
</pre>
<p>
          For a simple example sorting <code class="computeroutput"><span class="keyword">float</span></code>s,
        </p>
<pre class="programlisting"><span class="identifier">vector</span><span class="special">&lt;</span><span class="keyword">float</span><span class="special">&gt;</span> <span class="identifier">vec</span><span class="special">;</span>
<span class="identifier">vec</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="number">1.0</span><span class="special">);</span>
<span class="identifier">vec</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="number">2.3</span><span class="special">);</span>
<span class="identifier">vec</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="number">1.3</span><span class="special">);</span>
<span class="special">...</span>
<span class="identifier">spreadsort</span><span class="special">(</span><span class="identifier">vec</span><span class="special">.</span><span class="identifier">begin</span><span class="special">(),</span> <span class="identifier">vec</span><span class="special">.</span><span class="identifier">end</span><span class="special">());</span>
<span class="comment">//The sorted vector contains "1.0 1.3 2.3 ..."</span>
</pre>
<p>
          See also <a href="../../../example/floatsample.cpp" target="_top">floatsample.cpp</a>
          which checks for abnormal values.
        </p>
</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 Steven Ross<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="../index.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.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="sort_hpp/integer_sort.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>