Bolt  1.1
C++ template library with support for OpenCL
Functions
Amp-sort

Functions

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

Detailed Description

Function Documentation

template<typename RandomAccessIterator >
void bolt::amp::sort ( bolt::amp::control ctl,
RandomAccessIterator  first,
RandomAccessIterator  last 
)

This version of sort returns the sorted result of all the elements in the RandomAccessIterator between the the first and last elements. The routine arranges the elements in an ascending order. RandomAccessIterator's value_type must provide operator "<" overload.

The sort operation is analogus to the std::sort function. See http://www.sgi.com/tech/stl/sort.html

Template Parameters
RandomAccessIteratorIs a model of http://www.sgi.com/tech/stl/RandomAccessIterator.html,
RandomAccessIterator is mutable,
RandomAccessIterator's value_type is convertible to StrictWeakOrdering's
RandomAccessIterator's value_type is LessThanComparable http://www.sgi.com/tech/stl/LessThanComparable.html; i.e., the value _type must provide operator '<' overloaded.
Parameters
ctlOptional Bolt control object, to describe the environment under which the function will run.
firstThe first position in the sequence to be sorted.
lastThe last position in the sequence to be sorted.
Returns
The sorted data that is available in place.

The following code example shows the use of sort to sort the elements in the ascending order, specifying a specific accelerator.

#include <bolt/amp/sort.h>
int a[8] = {2, 9, 3, 7, 5, 6, 3, 8};
//Create an AMP Control object using the default accelerator
::Concurrency::accelerator accel(::Concurrency::accelerator::default_accelerator);
bolt::amp::control ctl(accel);
bolt::amp::sort(ctl, a, a+8);
template<typename RandomAccessIterator , typename StrictWeakOrdering >
void bolt::amp::sort ( bolt::amp::control ctl,
RandomAccessIterator  first,
RandomAccessIterator  last,
StrictWeakOrdering  comp 
)

sort returns the sorted result of all the elements in the inputIterator between the the first and last elements using the specified binary_op. You can arrange the elements in an ascending order, where the binary_op is the less<>() operator. This version of sort takes a bolt::amp::control structure as a first argument and compares objects using functor object defined by StrictWeakOrdering.

The sort operation is analogus to the std::sort function. See http://www.sgi.com/tech/stl/sort.html.

Template Parameters
RandomAccessIteratorIs a model of http://www.sgi.com/tech/stl/RandomAccessIterator.html,
RandomAccessIterator is mutable,
RandomAccessIterator's value_type is convertible to StrictWeakOrdering's
RandomAccessIterator's value_type is LessThanComparable http://www.sgi.com/tech/stl/LessThanComparable.html i.e the value _type should provide operator '<' overloaded.
StrictWeakOrderingIs a model of http://www.sgi.com/tech/stl/StrictWeakOrdering.html.
Parameters
ctlOptional Control structure to control command-queue, debug, tuning, etc. See bolt::amp::control.
firstThe first position in the sequence to be sorted.
lastThe last position in the sequence to be sorted.
compThe comparison operation used to compare two values.
Returns
The sorted data that is available in place.

The following code example shows the use of sort to sort the elements in the descending order, specifying a specific accelerator.

#include <bolt/amp/sort.h>
int a[8] = {2, 9, 3, 7, 5, 6, 3, 8};
//Create an AMP Control object using the default accelerator
::Concurrency::accelerator accel(::Concurrency::accelerator::default_accelerator);
bolt::amp::control ctl(accel);
// for arranging the elements in descending order, use bolt::amp::greater<int>()