thrust::remove
Defined in thrust/remove.h
- 
template<typename DerivedPolicy, typename ForwardIterator, typename T>
 ForwardIterator thrust::remove(const thrust::detail::execution_policy_base<DerivedPolicy> &exec, ForwardIterator first, ForwardIterator last, const T &value)
- removeremoves from the range- [first, last)all elements that are equal to- value. That is,- removereturns an iterator- new_lastsuch that the range- [first, new_last)contains no elements equal to- value. The iterators in the range- [new_first,last)are all still dereferenceable, but the elements that they point to are unspecified.- removeis stable, meaning that the relative order of elements that are not equal to- valueis unchanged.- The algorithm’s execution is parallelized as determined by - exec.- The following code snippet demonstrates how to use - removeto remove a number of interest from a range using the- thrust::hostexecution policy for parallelization:- #include <thrust/remove.h> #include <thrust/execution_policy.h> ... const int N = 6; int A[N] = {3, 1, 4, 1, 5, 9}; int *new_end = thrust::remove(A, A + N, 1); // The first four values of A are now {3, 4, 5, 9} // Values beyond new_end are unspecified - See also - remove_if - See also - remove_copy - See also - remove_copy_if - Note - The meaning of “removal” is somewhat subtle. - removedoes not destroy any iterators, and does not change the distance between- firstand- last. (There’s no way that it could do anything of the sort.) So, for example, if- Vis a device_vector,- remove(V.begin(), V.end(), 0)does not change- V.size():- Vwill contain just as many elements as it did before.- removereturns an iterator that points to the end of the resulting range after elements have been removed from it; it follows that the elements after that iterator are of no interest, and may be discarded. If you are removing elements from a Sequence, you may simply erase them. That is, a reasonable way of removing elements from a Sequence is- S.erase(remove(S.begin(), S.end(), x), S.end()).- Parameters
- exec – The execution policy to use for parallelization. 
- first – The beginning of the range of interest. 
- last – The end of the range of interest. 
- value – The value to remove from the range - [first, last). Elements which are equal to value are removed from the sequence.
 
- Template Parameters
- DerivedPolicy – The name of the derived execution policy. 
- ForwardIterator – is a model of Forward Iterator, and - ForwardIteratoris mutable.
- T – is a model of Equality Comparable, and objects of type - Tcan be compared for equality with objects of- ForwardIterator's- value_type.
 
- Returns
- A - ForwardIteratorpointing to the end of the resulting range of elements which are not equal to- value.