#include <algorithm> template< class ForwardIterator, class T > ForwardIterator remove( ForwardIterator first, ForwardIterator last, const T& value );
Removes all elements equaling the given value value
from the range, defined by [first, last)
. Removing is done by shifting the elements in the range in such a way that required elements are overwritten. The elements between the old and the new ends of the range are left intact. Iterator to the new end of the range is returned.
first
, last
- the range of the elements to be processed
value
- value of the elements to remove
forward iterator to the new end of the range
template<class ForwardIterator, class T> ForwardIterator remove(ForwardIterator first, ForwardIterator last, const T& value) { ForwardIterator result = first; for (; first != last; ++first) if (!(*first == value)) { *result++ = *first; } } return result; }
linear in the distance between first
and last