thrust::remove_if
Defined in thrust/remove.h
- 
template<typename ForwardIterator, typename InputIterator, typename Predicate>
 ForwardIterator thrust::remove_if(ForwardIterator first, ForwardIterator last, InputIterator stencil, Predicate pred)
- remove_ifremoves from the range- [first, last)every element- xsuch that- pred(x)is- true. That is,- remove_ifreturns an iterator- new_lastsuch that the range- [first, new_last)contains no elements for which- predof the corresponding stencil value is- true. The iterators in the range- [new_last,last)are all still dereferenceable, but the elements that they point to are unspecified.- remove_ifis stable, meaning that the relative order of elements that are not removed is unchanged.- The following code snippet demonstrates how to use - remove_ifto remove specific elements from an array of integers.- #include <thrust/remove.h> ... const int N = 6; int A[N] = {1, 4, 2, 8, 5, 7}; int S[N] = {0, 1, 1, 1, 0, 0}; int *new_end = thrust::remove_if(A, A + N, S, ::cuda::std::identity{}); // The first three values of A are now {1, 5, 7} // Values beyond new_end are unspecified - See also - remove - See also - remove_copy - See also - remove_copy_if - Note - The range - [first, last)is not permitted to overlap with the range- [stencil, stencil + (last - first)).- Parameters
- first – The beginning of the range of interest. 
- last – The end of the range of interest. 
- stencil – The beginning of the stencil sequence. 
- pred – A predicate to evaluate for each element of the range - [stencil, stencil + (last - first)). Elements for which- predevaluates to- trueare removed from the sequence- [first, last)
 
- Template Parameters
- ForwardIterator – is a model of Forward Iterator and - ForwardIteratoris mutable.
- InputIterator – is a model of Input Iterator, and - InputIterator's- value_typeis convertible to- Predicate'sargument type.
- Predicate – is a model of Predicate. 
 
- Returns
- A ForwardIterator pointing to the end of the resulting range of elements for which - predevaluated to- true.
- Pre
- The range - [first, last)shall not overlap the range- [result, result + (last - first)).
- Pre
- The range - [stencil, stencil + (last - first))shall not overlap the range- [result, result + (last - first)).