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

Functions

template<typename RandomAccessIterator >
void bolt::amp::stable_sort (RandomAccessIterator first, RandomAccessIterator last)
 
template<typename RandomAccessIterator , typename StrictWeakOrdering >
void bolt::amp::stable_sort (RandomAccessIterator first, RandomAccessIterator last, StrictWeakOrdering comp)
 
template<typename RandomAccessIterator >
void bolt::amp::stable_sort (bolt::amp::control &ctl, RandomAccessIterator first, RandomAccessIterator last)
 
template<typename RandomAccessIterator , typename StrictWeakOrdering >
void bolt::amp::stable_sort (bolt::amp::control &ctl, RandomAccessIterator first, RandomAccessIterator last, StrictWeakOrdering comp)
 

Detailed Description

Function Documentation

template<typename RandomAccessIterator >
void bolt::amp::stable_sort ( RandomAccessIterator  first,
RandomAccessIterator  last 
)

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
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/amp/stablesort.h"
int a[ 10 ] = { 2, 9, 3, 7, 5, 6, 3, 8, 9, 0 };
\\ 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::amp::stable_sort ( RandomAccessIterator  first,
RandomAccessIterator  last,
StrictWeakOrdering  comp 
)

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
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/amp/stablesort.h"
int a[ 10 ] = { 2, 9, 3, 7, 5, 6, 3, 8, 9, 0 };
\\ 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::amp::stable_sort ( bolt::amp::control ctl,
RandomAccessIterator  first,
RandomAccessIterator  last 
)

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::amp::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
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/amp/stablesort.h"
int a[ 10 ] = { 2, 9, 3, 7, 5, 6, 3, 8, 9, 0 };
\\ results a[] = { 9, 9, 8, 7, 6, 5, 3, 3, 2, 0 }
See Also
bolt::amp::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::amp::stable_sort ( bolt::amp::control ctl,
RandomAccessIterator  first,
RandomAccessIterator  last,
StrictWeakOrdering  comp 
)

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::amp::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
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/amp/stablesort.h"
int a[ 10 ] = { 2, 9, 3, 7, 5, 6, 3, 8, 9, 0 };
\\ results a[] = { 9, 9, 8, 7, 6, 5, 3, 3, 2, 0 }
See Also
bolt::amp::control
http://www.sgi.com/tech/stl/stable_sort.html
http://www.sgi.com/tech/stl/RandomAccessIterator.html