Translations of this page?:

remove

#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.

Parameters

first, last - the range of the elements to be processed

value - value of the elements to remove

Return value

forward iterator to the new end of the range

Equivalent function

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;
}

Complexity

linear in the distance between first and last

See also

 
• • • SitemapRecent changesRSScc