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

Functions

template<typename ForwardIterator >
ForwardIterator bolt::amp::unique (control &ctl, ForwardIterator first, ForwardIterator last)
 
template<typename ForwardIterator >
ForwardIterator bolt::amp::unique (ForwardIterator first, ForwardIterator last)
 
template<typename ForwardIterator , typename BinaryPredicate >
ForwardIterator bolt::amp::unique (control &ctl, ForwardIterator first, ForwardIterator last, BinaryPredicate binary_pred)
 
template<typename ForwardIterator , typename BinaryPredicate >
ForwardIterator bolt::amp::unique (ForwardIterator first, ForwardIterator last, BinaryPredicate binary_pred)
 
template<typename InputIterator , typename OutputIterator >
OutputIterator bolt::amp::unique_copy (control &ctl, InputIterator first, InputIterator last, OutputIterator output)
 
template<typename InputIterator , typename OutputIterator >
OutputIterator bolt::amp::unique_copy (InputIterator first, InputIterator last, OutputIterator output)
 
template<typename InputIterator , typename OutputIterator , typename BinaryPredicate >
OutputIterator bolt::amp::unique_copy (control &ctl, InputIterator first, InputIterator last, OutputIterator output, BinaryPredicate binary_pred)
 
template<typename InputIterator , typename OutputIterator , typename BinaryPredicate >
OutputIterator bolt::amp::unique_copy (InputIterator first, InputIterator last, OutputIterator output, BinaryPredicate binary_pred)
 

Detailed Description

Function Documentation

template<typename ForwardIterator >
ForwardIterator bolt::amp::unique ( control &  ctl,
ForwardIterator  first,
ForwardIterator  last 
)

This version of unique removes all but the first element of the group in a group of consecutive elements in the range [first, last) with the same value. The return value is an iterator new_last such that no two consecutive elements in the range [first, new_last) are equal. unique_copy copies elements from the range [first, last) to a range beginning with output, except that in a consecutive group of duplicate elements only the first one is copied. The return value is the end of the range to which the elements are copied.

Parameters
ctlOptional Control structure to control accelerator, debug, tuning, etc.See bolt::amp::control.
firstThe beginning of the first input sequence.
lastThe end of the first input sequence.
predThe predicate to test on every value of the range [first,last).
Returns
ForwardIterator or OutputIterator
Template Parameters
ForwardIteratoris a model of InputIterator and InputIterator's value_type is convertible to UnaryFunction's

The following code snippet demonstrates how to use replace and replace_if.

int input1[10] = {-5, 0, 0, 3, 3, 3, 3, 1, 1, 1};
int input2[10] = {-5, 0, 0, 3, 3, 3, 3, 1, 1, 1};
int output[10];
//Create an AMP Control object using the default accelerator
::Concurrency::accelerator accel(::Concurrency::accelerator::default_accelerator);
bolt::amp::control ctl(accel);
bolt::amp::unique(ctl, input1, input1 + 10, bolt::amp::equal_to<int>());
// input1 is now {-5, 0, 3, 1};
bolt::amp::unique_copy(ctl, input2, input2 + 10, output, bolt::amp::equal_to<int>()));
// output is now {-5, 0, 3, 1};
See Also
http://www.sgi.com/tech/stl/unique.html