Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Spreadsort

Header <boost/sort/spreadsort/spreadsort.hpp>
Spreadsort Examples
Integer Sort
Integer Sort Examples
Float Sort
Float Sort Examples
String Sort
String Sort Examples
Rationale
Radix Sorting
Hybrid Radix
Why spreadsort?
Unstable Sorting
Unused X86 optimization
Lookup Table?

spreadsort checks whether the data-type provided is an integer, castable float, string, or wstring.

Overloading variants are provided that permit use of user-defined right-shift functors and comparison functors.

Each function is optimized for its set of arguments; default functors are not provided to avoid the risk of any reduction of performance.

See overloading section.

Rationale:

spreadsort function provides a wrapper that calls the fastest sorting algorithm available for a data-type, enabling faster generic programming.

See example folder for all examples.

See sample.cpp for a simple working example.

For an example of 64-bit integer sorting, see int64.cpp.

This example sets the element type of a vector to 64-bit integer

#define DATA_TYPE boost::int64_t

and calls the sort

boost::sort::spreadsort::spreadsort(array.begin(), array.end());

For a simple example sorting floats,

vector<float> vec;
vec.push_back(1.0);
vec.push_back(2.3);
vec.push_back(1.3);
...
spreadsort(vec.begin(), vec.end());
//The sorted vector contains "1.0 1.3 2.3 ..."

See also floatsample.cpp which checks for abnormal values.


PrevUpHomeNext