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

Functions

template<typename ForwardIterator , typename Predicate >
ForwardIterator bolt::amp::remove_if (control &ctl, ForwardIterator first, ForwardIterator last, Predicate pred)
 
template<typename ForwardIterator , typename Predicate >
ForwardIterator bolt::amp::remove_if (ForwardIterator first, ForwardIterator last, Predicate pred)
 
template<typename ForwardIterator , typename InputIterator , typename Predicate >
ForwardIterator bolt::amp::remove_if (control &ctl, ForwardIterator first, ForwardIterator last, InputIterator stencil, Predicate pred)
 
template<typename ForwardIterator , typename InputIterator , typename Predicate >
ForwardIterator bolt::amp::remove_if (ForwardIterator first, ForwardIterator last, InputIterator stencil, Predicate pred)
 
template<typename ForwardIterator , typename T >
ForwardIterator bolt::amp::remove (control &ctl, ForwardIterator first, ForwardIterator last, const T &value)
 
template<typename ForwardIterator , typename T >
ForwardIterator bolt::amp::remove (ForwardIterator first, ForwardIterator last, const T &value)
 
template<typename InputIterator , typename OutputIterator , typename Predicate >
OutputIterator bolt::amp::remove_copy_if (control &ctl, InputIterator first, InputIterator last, OutputIterator result, Predicate pred)
 
template<typename InputIterator , typename OutputIterator , typename Predicate >
OutputIterator bolt::amp::remove_copy_if (InputIterator first, InputIterator last, OutputIterator result, Predicate pred)
 
template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator , typename Predicate >
OutputIterator bolt::amp::remove_copy_if (control &ctl, InputIterator1 first, InputIterator1 last, InputIterator2 stencil, OutputIterator result, Predicate pred)
 
template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator , typename Predicate >
OutputIterator bolt::amp::remove_copy_if (InputIterator1 first, InputIterator1 last, InputIterator2 stencil, OutputIterator result, Predicate pred)
 
template<typename InputIterator , typename OutputIterator , typename T >
OutputIterator bolt::amp::remove_copy (control &ctl, InputIterator first, InputIterator last, OutputIterator result, const T &value)
 
template<typename InputIterator , typename OutputIterator , typename T >
OutputIterator bolt::amp::remove_copy (InputIterator first, InputIterator last, OutputIterator result, const T &value)
 

Detailed Description

Function Documentation

template<typename InputIterator , typename OutputIterator , typename Predicate >
OutputIterator bolt::amp::remove_copy_if ( control &  ctl,
InputIterator  first,
InputIterator  last,
OutputIterator  result,
Predicate  pred 
)

This version of remove_copy / remove_copy_if copies elements from the range [first, last) to the range [result, result + (last-first)), except that any element equal to value or that which satisfies the predicate is not 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.
OutputIteratoris a model of OutputIterator
valueThe value present in input sequence that needs to be removed.
predThe predicate to test on every value of the range [first,last).
Returns
OutputIterator result is returned.
Template Parameters
InputIteratoris a model of InputIterator and InputIterator's value_type is convertible to UnaryFunction's
Tis a model of Assignable.
       The following code snippet demonstrates how to use \p remove_copy and \p remove_copy_if.
int input[10] = {-5, 0, 2, 3, 2, 4, -2, 1, 2, 3};
int output[10];
//Create an AMP Control object using the default accelerator
::Concurrency::accelerator accel(::Concurrency::accelerator::default_accelerator);
bolt::amp::control ctl(accel);
template <typename T>
struct is_even
{
bool operator()(T x) const restrict(amp, cpu)
{
if (((int)x) % 2)
return true;
else
return false;
}
};
bolt::amp::remove_copy(ctl, input, input + 10, output, 3);
// output is now {-5, 0, 2, 2, 4, -2, 1, 2, 0, 0};
bolt::amp::remove_copy_if(ctl, input, input + 10, output, is_even<int>());
// output is now {-5, 1, 0, 0, 0, 0, 0, 0, 0, 0};
See Also
http://www.sgi.com/tech/stl/remove.html
template<typename ForwardIterator , typename Predicate >
ForwardIterator bolt::amp::remove_if ( control &  ctl,
ForwardIterator  first,
ForwardIterator  last,
Predicate  pred 
)

This version of remove / remove_if removes every element in input sequence that is equal to value or that which satisfies the predicate and stores the result in the corresponding position in input sequence itself. The iterators in the range [new_last,last) are all still dereferenceable, but the elements that they point to are unspecified. It is stable, meaning that the relative order of elements that are not removed is unchanged.

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.
valueThe value present in input sequence that needs to be removed.
stencilThe beginning of the stencil sequence.
predThe predicate to test on every value of the range [first,last).
Returns
InputIterator. Input itself is modified and returned.
Template Parameters
InputIteratoris a model of InputIterator and InputIterator's value_type is convertible to UnaryFunction's
Tis a model of Assignable.
       The following code snippet demonstrates how to use \p replace and \p replace_if.
int input[10] = {-5, 0, 2, 3, 2, 4, -2, 1, 2, 3};
int stencil[10] = {0, 1, 1, 1, 0, 1, 1, 1, 0, 1};
//Create an AMP Control object using the default accelerator
::Concurrency::accelerator accel(::Concurrency::accelerator::default_accelerator);
bolt::amp::control ctl(accel);
template <typename T>
struct is_even
{
bool operator()(T x) const restrict(amp, cpu)
{
if (((int)x) % 2)
return true;
else
return false;
}
};
bolt::amp::remove(ctl, input, input + 10, 3);
// As this is inplace call, input array will become {-5, 0, 2, 2, 4, -2, 1, 2, 0, 0};
bolt::amp::remove_if(ctl, input, input + 10, is_even<int>());
// Applying remove_if on above input array after applying remove call
will change input array to {-5, 1, 0, 0, 0, 0, 0, 0, 0, 0};
bolt::amp::remove_if(ctl, input, input + 10, stencil, bolt::amp::identity<int>(), 10);
// input array after remove_if with stencil is {-5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
See Also
http://www.sgi.com/tech/stl/replace.html