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

Functions

template<typename RandomAccessIterator1 , typename RandomAccessIterator2 >
void bolt::amp::stable_sort_by_key (RandomAccessIterator1 keys_first, RandomAccessIterator1 keys_last, RandomAccessIterator2 values_first)
 
template<typename RandomAccessIterator1 , typename RandomAccessIterator2 , typename StrictWeakOrdering >
void bolt::amp::stable_sort_by_key (RandomAccessIterator1 keys_first, RandomAccessIterator1 keys_last, RandomAccessIterator2 values_first, StrictWeakOrdering comp)
 
template<typename RandomAccessIterator1 , typename RandomAccessIterator2 >
void bolt::amp::stable_sort_by_key (bolt::amp::control &ctl, RandomAccessIterator1 keys_first, RandomAccessIterator1 keys_last, RandomAccessIterator2 values_first)
 
template<typename RandomAccessIterator1 , typename RandomAccessIterator2 , typename StrictWeakOrdering >
void bolt::amp::stable_sort_by_key (bolt::amp::control &ctl, RandomAccessIterator1 keys_first, RandomAccessIterator1 keys_last, RandomAccessIterator2 values_first, StrictWeakOrdering comp)
 

Detailed Description

Function Documentation

template<typename RandomAccessIterator1 , typename RandomAccessIterator2 >
void bolt::amp::stable_sort_by_key ( RandomAccessIterator1  keys_first,
RandomAccessIterator1  keys_last,
RandomAccessIterator2  values_first 
)

stable_sort_by_key returns the sorted result of all the elements in the range specified given by the first and last RandomAccessIterator1 key iterators. This routine recieves two input ranges, the first represents the range of keys to base the sort on, and the second to represent values that should identically be sorted. The permutation of elements returned in value range will be identical to the permutation of elements applied to the key range. This routine arranges the elements in ascending order assuming that an operator < exists for the value_type given by the iterator. No comparison operator needs to be provided for the value array.

stable_sort_by_key is a stable operation with respect to the key data, in that if two elements are equivalent in the key 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
keys_firstDefines the beginning of the key range to be sorted
keys_lastDefines the end of the key range to be sorted
values_firstDefines the beginning of the value range to be sorted, whose length equals std::distance( keys_first, keys_last )
Returns
The data is sorted in place within the range [first,last)
Template Parameters
RandomAccessIterator1models a random access iterator; iterator for the key range
RandomAccessIterator2models a random access iterator; iterator for the value range
 The following code example shows the use of \p stable_sort_by_key to sort the elements in ascending order
#include "bolt/amp/stablesort_by_key.h"
int i[ 10 ] = { 2, 9, 3, 7, 5, 6, 3, 8, 9, 0 };
float f[ 10 ] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f };
\\ results i[] = { 0, 2, 3, 3, 5, 6, 7, 8, 9, 9 }
\\ results f[] = { 9.0f, 0.0f, 2.0f, 6.0f, 4.0f, 5.0f, 3.0f, 7.0f, 1.0f, 8.0f }
\\ The 3s and the 9s kept their respective ordering from the original input
See Also
bolt::amp::stablesort
http://www.sgi.com/tech/stl/RandomAccessIterator.html
template<typename RandomAccessIterator1 , typename RandomAccessIterator2 , typename StrictWeakOrdering >
void bolt::amp::stable_sort_by_key ( RandomAccessIterator1  keys_first,
RandomAccessIterator1  keys_last,
RandomAccessIterator2  values_first,
StrictWeakOrdering  comp 
)

stable_sort_by_key returns the sorted result of all the elements in the range specified given by the first and last RandomAccessIterator1 key iterators. This routine recieves two input ranges, the first represents the range of keys to base the sort on, and the second to represent values that should identically be sorted. The permutation of elements returned in value range will be identical to the permutation of elements applied to the key range. This routine arranges the elements in ascending order assuming that an operator < exists for the value_type given by the iterator. No comparison operator needs to be provided for the value array.

stable_sort_by_key is a stable operation with respect to the key data, in that if two elements are equivalent in the key 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
keys_firstDefines the beginning of the key range to be sorted
keys_lastDefines the end of the key range to be sorted
values_firstDefines the beginning of the value range to be sorted, whose length equals std::distance( keys_first, keys_last )
compA user defined comparison function or functor that models a strict weak < operator
Returns
The data is sorted in place within the range [first,last)
Template Parameters
RandomAccessIterator1models a random access iterator; iterator for the key range
RandomAccessIterator2models a random access iterator; iterator for the value range
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_by_key to sort the elements in ascending order
#include "bolt/amp/stablesort_by_key.h"
int i[ 10 ] = { 2, 9, 3, 7, 5, 6, 3, 8, 9, 0 };
float f[ 10 ] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f };
\\ results a[] = { 9, 9, 8, 7, 6, 5, 3, 3, 2, 0 }
\\ results f[] = { 1.0f, 8.0f, 7.0f, 3.0f, 5.0f, 4.0f, 2.0f, 6.0f, 0.0f, 9.0f }
\\ The 3s and the 9s kept their respective ordering from the original input
See Also
bolt::amp::stablesort
http://www.sgi.com/tech/stl/RandomAccessIterator.html
http://www.sgi.com/tech/stl/StrictWeakOrdering.html
template<typename RandomAccessIterator1 , typename RandomAccessIterator2 >
void bolt::amp::stable_sort_by_key ( bolt::amp::control ctl,
RandomAccessIterator1  keys_first,
RandomAccessIterator1  keys_last,
RandomAccessIterator2  values_first 
)

stable_sort_by_key returns the sorted result of all the elements in the range specified given by the first and last RandomAccessIterator1 key iterators. This routine recieves two input ranges, the first represents the range of keys to base the sort on, and the second to represent values that should identically be sorted. The permutation of elements returned in value range will be identical to the permutation of elements applied to the key range. This routine arranges the elements in ascending order assuming that an operator < exists for the value_type given by the iterator. No comparison operator needs to be provided for the value array.

stable_sort_by_key is a stable operation with respect to the key data, in that if two elements are equivalent in the key 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
ctlA control object passed into stable_sort_by_key used to make runtime decisions
keys_firstDefines the beginning of the key range to be sorted
keys_lastDefines the end of the key range to be sorted
values_firstDefines the beginning of the value range to be sorted, whose length equals std::distance( keys_first, keys_last )
Returns
The data is sorted in place within the range [first,last)
Template Parameters
RandomAccessIterator1models a random access iterator; iterator for the key range
RandomAccessIterator2models a random access iterator; iterator for the value range
 The following code example shows the use of \p stable_sort_by_key to sort the elements in ascending order
#include "bolt/amp/stablesort_by_key.h"
int i[ 10 ] = { 2, 9, 3, 7, 5, 6, 3, 8, 9, 0 };
float f[ 10 ] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f };
\\ results i[] = { 0, 2, 3, 3, 5, 6, 7, 8, 9, 9 }
\\ results f[] = { 9.0f, 0.0f, 2.0f, 6.0f, 4.0f, 5.0f, 3.0f, 7.0f, 1.0f, 8.0f }
\\ The 3s and the 9s kept their respective ordering from the original input
See Also
bolt::amp::stablesort
bolt::amp::control
http://www.sgi.com/tech/stl/RandomAccessIterator.html
template<typename RandomAccessIterator1 , typename RandomAccessIterator2 , typename StrictWeakOrdering >
void bolt::amp::stable_sort_by_key ( bolt::amp::control ctl,
RandomAccessIterator1  keys_first,
RandomAccessIterator1  keys_last,
RandomAccessIterator2  values_first,
StrictWeakOrdering  comp 
)

stable_sort_by_key returns the sorted result of all the elements in the range specified given by the first and last RandomAccessIterator1 key iterators. This routine recieves two input ranges, the first represents the range of keys to base the sort on, and the second to represent values that should identically be sorted. The permutation of elements returned in value range will be identical to the permutation of elements applied to the key range. This routine arranges the elements in ascending order assuming that an operator < exists for the value_type given by the iterator. No comparison operator needs to be provided for the value array.

stable_sort_by_key is a stable operation with respect to the key data, in that if two elements are equivalent in the key 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
ctlA control object passed into stable_sort_by_key used to make runtime decisions
keys_firstDefines the beginning of the key range to be sorted
keys_lastDefines the end of the key range to be sorted
values_firstDefines the beginning of the value range to be sorted, whose length equals std::distance( keys_first, keys_last )
compA user defined comparison function or functor that models a strict weak < operator
Returns
The data is sorted in place within the range [first,last)
Template Parameters
RandomAccessIterator1models a random access iterator; iterator for the key range
RandomAccessIterator2models a random access iterator; iterator for the value range
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_by_key to sort the elements in ascending order
#include "bolt/amp/stablesort_by_key.h"
int i[ 10 ] = { 2, 9, 3, 7, 5, 6, 3, 8, 9, 0 };
float f[ 10 ] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f };
\\ results a[] = { 9, 9, 8, 7, 6, 5, 3, 3, 2, 0 }
\\ results f[] = { 1.0f, 8.0f, 7.0f, 3.0f, 5.0f, 4.0f, 2.0f, 6.0f, 0.0f, 9.0f }
\\ The 3s and the 9s kept their respective ordering from the original input
See Also
bolt::amp::stablesort
bolt::amp::control
http://www.sgi.com/tech/stl/RandomAccessIterator.html