Bolt  1.3
C++ template library with support for OpenCL
Functions
CL-stable_sort

Functions

template<typename RandomAccessIterator >
void bolt::cl::stable_sort (RandomAccessIterator first, RandomAccessIterator last, const std::string &cl_code="")
 
template<typename RandomAccessIterator , typename StrictWeakOrdering >
void bolt::cl::stable_sort (RandomAccessIterator first, RandomAccessIterator last, StrictWeakOrdering comp, const std::string &cl_code="")
 
template<typename RandomAccessIterator >
void bolt::cl::stable_sort (bolt::cl::control &ctl, RandomAccessIterator first, RandomAccessIterator last, const std::string &cl_code="")
 
template<typename RandomAccessIterator , typename StrictWeakOrdering >
void bolt::cl::stable_sort (bolt::cl::control &ctl, RandomAccessIterator first, RandomAccessIterator last, StrictWeakOrdering comp, const std::string &cl_code="")
 

Detailed Description

Function Documentation

template<typename RandomAccessIterator >
void bolt::cl::stable_sort ( RandomAccessIterator  first,
RandomAccessIterator  last,
const std::string &  cl_code = "" 
)

Stable_sort returns the sorted result of all the elements in the range specified between the the first and last RandomAccessIterator iterators. This routine arranges the elements in ascending order assuming that an operator < exists for the value_type given by the iterator.

The stable_sort operation is analogus to the std::stable_sort function. It is a stable operation with respect to the input data, in that if two elements are equivalent in the input range, and element X appears before element Y, then element X has to maintain that relationship and appear before element Y after the sorting operation. In general, stable sorts are usually prefered over unstable sorting algorithms, but may sacrifice a little performance to maintain this relationship.

Parameters
firstDefines the beginning of the range to be sorted
lastDefines the end of the range to be sorted
cl_codeOptional OpenCL ™ code to be passed to the OpenCL compiler. The cl_code is inserted first in the generated code, before the cl_code traits. This can be used for any extra cl code to be passed when compiling the OpenCl Kernel.
Returns
The data is sorted in place in the range [first,last)
Template Parameters
RandomAccessIteratormodels a random access iterator
 The following code example shows the use of \p stable_sort to sort the elements in ascending order
#include "bolt/cl/stablesort.h"
int a[ 10 ] = { 2, 9, 3, 7, 5, 6, 3, 8, 9, 0 };
bolt::cl::stable_sort( a, a + 10 );
\\ results a[] = { 0, 2, 3, 3, 5, 6, 7, 8, 9, 9 }
\\ The 3s and the 9s kept their respective ordering from the original input
See Also
http://www.sgi.com/tech/stl/stable_sort.html
http://www.sgi.com/tech/stl/RandomAccessIterator.html
template<typename RandomAccessIterator , typename StrictWeakOrdering >
void bolt::cl::stable_sort ( RandomAccessIterator  first,
RandomAccessIterator  last,
StrictWeakOrdering  comp,
const std::string &  cl_code = "" 
)

Stable_sort returns the sorted result of all the elements in the range specified between the the first and last RandomAccessIterator iterators. This routine arranges the elements in ascending order assuming that an operator < exists for the value_type given by the iterator.

The stable_sort operation is analogus to the std::stable_sort function. It is a stable operation with respect to the input data, in that if two elements are equivalent in the input range, and element X appears before element Y, then element X has to maintain that relationship and appear before element Y after the sorting operation. In general, stable sorts are usually prefered over unstable sorting algorithms, but may sacrifice a little performance to maintain this relationship. This overload of stable_sort accepts an additional comparator functor that allows the user to specify the comparison operator to use.

Parameters
firstDefines the beginning of the range to be sorted
lastDefines the end of the range to be sorted
compA user defined comparison function or functor that models a strict weak < operator
cl_codeOptional OpenCL ™ code to be passed to the OpenCL compiler. The cl_code is inserted first in the generated code, before the cl_code traits. This can be used for any extra cl code to be passed when compiling the OpenCl Kernel.
Returns
The data is sorted in place in the range [first,last)
Template Parameters
RandomAccessIteratormodels a random access iterator
StrictWeakOrderingmodels a binary predicate which returns true if the first element is 'less than' the second
 The following code example shows the use of \p stable_sort to sort the elements in ascending order
#include "bolt/cl/stablesort.h"
int a[ 10 ] = { 2, 9, 3, 7, 5, 6, 3, 8, 9, 0 };
bolt::cl::stable_sort( a, a + 10, bolt::cl::greater< int >( ) );
\\ results a[] = { 9, 9, 8, 7, 6, 5, 3, 3, 2, 0 }
See Also
http://www.sgi.com/tech/stl/stable_sort.html
http://www.sgi.com/tech/stl/RandomAccessIterator.html
template<typename RandomAccessIterator >
void bolt::cl::stable_sort ( bolt::cl::control ctl,
RandomAccessIterator  first,
RandomAccessIterator  last,
const std::string &  cl_code = "" 
)

Stable_sort returns the sorted result of all the elements in the range specified between the the first and last RandomAccessIterator iterators. This routine arranges the elements in ascending order assuming that an operator < exists for the value_type given by the iterator.

The stable_sort operation is analogus to the std::stable_sort function. It is a stable operation with respect to the input data, in that if two elements are equivalent in the input range, and element X appears before element Y, then element X has to maintain that relationship and appear before element Y after the sorting operation. In general, stable sorts are usually prefered over unstable sorting algorithms, but may sacrifice a little performance to maintain this relationship. This overload of stable_sort accepts an additional bolt::cl::control object that allows the user to change the state that the function uses to make runtime decisions.

Parameters
ctlA control object passed into stable_sort that the function uses to make runtime decisions
firstDefines the beginning of the range to be sorted
lastDefines the end of the range to be sorted
cl_codeOptional OpenCL ™ code to be passed to the OpenCL compiler. The cl_code is inserted first in the generated code, before the cl_code traits. This can be used for any extra cl code to be passed when compiling the OpenCl Kernel.
Returns
The data is sorted in place in the range [first,last)
Template Parameters
RandomAccessIteratormodels a random access iterator
 The following code example shows the use of \p stable_sort to sort the elements in ascending order
#include "bolt/cl/stablesort.h"
int a[ 10 ] = { 2, 9, 3, 7, 5, 6, 3, 8, 9, 0 };
bolt::cl::stable_sort( a, a + 10, bolt::cl::greater< int >( ) );
\\ results a[] = { 9, 9, 8, 7, 6, 5, 3, 3, 2, 0 }
See Also
bolt::cl::control
http://www.sgi.com/tech/stl/stable_sort.html
http://www.sgi.com/tech/stl/RandomAccessIterator.html
template<typename RandomAccessIterator , typename StrictWeakOrdering >
void bolt::cl::stable_sort ( bolt::cl::control ctl,
RandomAccessIterator  first,
RandomAccessIterator  last,
StrictWeakOrdering  comp,
const std::string &  cl_code = "" 
)

Stable_sort returns the sorted result of all the elements in the range specified between the the first and last RandomAccessIterator iterators. This routine arranges the elements in ascending order assuming that an operator < exists for the value_type given by the iterator.

The stable_sort operation is analogus to the std::stable_sort function. It is a stable operation with respect to the input data, in that if two elements are equivalent in the input range, and element X appears before element Y, then element X has to maintain that relationship and appear before element Y after the sorting operation. In general, stable sorts are usually prefered over unstable sorting algorithms, but may sacrifice a little performance to maintain this relationship. This overload of stable_sort accepts an additional comparator functor that allows the user to specify the comparison operator to use. This overload also accepts an additional bolt::cl::control object that allows the user to change the state that the function uses to make runtime decisions.

Parameters
ctlA control object passed into stable_sort that the function uses to make runtime decisions
firstDefines the beginning of the range to be sorted
lastDefines the end of the range to be sorted
compA user defined comparison function or functor that models a strict weak < operator
cl_codeOptional OpenCL ™ code to be passed to the OpenCL compiler. The cl_code is inserted first in the generated code, before the cl_code traits. This can be used for any extra cl code to be passed when compiling the OpenCl Kernel.
Returns
The data is sorted in place in the range [first,last)
Template Parameters
RandomAccessIteratormodels a random access iterator
StrictWeakOrderingmodels a binary predicate which returns true if the first element is 'less than' the second
 The following code example shows the use of \p stable_sort to sort the elements in ascending order
#include "bolt/cl/stablesort.h"
int a[ 10 ] = { 2, 9, 3, 7, 5, 6, 3, 8, 9, 0 };
bolt::cl::stable_sort( a, a + 10, bolt::cl::greater< int >( ) );
\\ results a[] = { 9, 9, 8, 7, 6, 5, 3, 3, 2, 0 }
See Also
bolt::cl::control
http://www.sgi.com/tech/stl/stable_sort.html
http://www.sgi.com/tech/stl/RandomAccessIterator.html