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

Functions

template<typename RandomAccessIterator1 , typename RandomAccessIterator2 >
void bolt::amp::sort_by_key (bolt::amp::control &ctl, RandomAccessIterator1 keys_first, RandomAccessIterator1 keys_last, RandomAccessIterator2 values_first)
 This version of sort_by_key returns the sorted result of all the elements in the RandomAccessIterator between the the first and last elements key elements and corresponding values. The routine arranges the elements in an ascending order.
 
template<typename RandomAccessIterator1 , typename RandomAccessIterator2 >
void bolt::amp::sort_by_key (RandomAccessIterator1 keys_first, RandomAccessIterator1 keys_last, RandomAccessIterator2 values_first)
 
template<typename RandomAccessIterator1 , typename RandomAccessIterator2 , typename StrictWeakOrdering >
void bolt::amp::sort_by_key (bolt::amp::control &ctl, RandomAccessIterator1 keys_first, RandomAccessIterator1 keys_last, RandomAccessIterator2 values_first, StrictWeakOrdering comp)
 This version of sort_by_key returns the sorted result of all the elements in the RandomAccessIterator between the the first and last elements key elements and corresponding values. The routine arranges the elements in an ascending order.
 
template<typename RandomAccessIterator1 , typename RandomAccessIterator2 , typename StrictWeakOrdering >
void bolt::amp::sort_by_key (RandomAccessIterator1 keys_first, RandomAccessIterator1 keys_last, RandomAccessIterator2 values_first, StrictWeakOrdering comp)
 

Detailed Description

Function Documentation

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

This version of sort_by_key returns the sorted result of all the elements in the RandomAccessIterator between the the first and last elements key elements and corresponding values. The routine arranges the elements in an ascending order.

Parameters
ctlOptional Control structure to control accelerator, debug, tuning, etc.See bolt::amp::control.
keys_firstThe first position in the sequence to be sorted.
keys_lastThe last position in the sequence to be sorted.
values_firstThe first position in the value sequence.
Returns
The sorted key,value pair that is available in place.
Template Parameters
RandomAccessIterator1Is a model of http://www.sgi.com/tech/stl/RandomAccessIterator.html
RandomAccessIterator2Is a model of http://www.sgi.com/tech/stl/RandomAccessIterator.html

The following code example shows the use of sort_by_key to sort the key,value pair in the ascending order.

int keys[8] = {2, 9, 3, 7, 5, 6, 3, 8};
int values[8] = {100, 200, 16, 50, 15, 8, 3, 5};
bolt::amp::sort_by_key(keys, keys+8,values);
//Output
//keys[8] = {2,3,3,5,6,7,8,9}
//values[8] = {100,16,3,15,8,50,5,200}
template<typename RandomAccessIterator1 , typename RandomAccessIterator2 , typename StrictWeakOrdering >
void bolt::amp::sort_by_key ( bolt::amp::control ctl,
RandomAccessIterator1  keys_first,
RandomAccessIterator1  keys_last,
RandomAccessIterator2  values_first,
StrictWeakOrdering  comp 
)

This version of sort_by_key returns the sorted result of all the elements in the RandomAccessIterator between the the first and last elements key elements and corresponding values. The routine arranges the elements in an ascending order.

This routine uses function object comp to compare the key objects.

Parameters
ctlOptional Control structure to control accelerator, debug, tuning, etc.See bolt::amp::control.
keys_firstThe first position in the sequence to be sorted.
keys_lastThe last position in the sequence to be sorted.
values_firstThe first position in the value sequence.
compThe comparison operation used to compare two values.
Returns
The sorted key,value pair that is available in place.
Template Parameters
RandomAccessIterator1Is a model of http://www.sgi.com/tech/stl/RandomAccessIterator.html
RandomAccessIterator2Is a model of http://www.sgi.com/tech/stl/RandomAccessIterator.html
StrictWeakOrderingIs a model of http://www.sgi.com/tech/stl/StrictWeakOrdering.html.

The following code example shows the use of sort_by_key to sort the key,value pair in the ascending order.

int keys[8] = {2, 9, 3, 7, 5, 6, 3, 8};
int values[8] = {100, 200, 16, 50, 15, 8, 3, 5};
// for arranging the elements in descending order, use bolt::amp::greater<int>()
//Output
//keys[8] = {9,8,7,6,5,3,3,2}
//values[8] = {200,5,50,8,15,3,16,100}