删除指定值

template < class ForwardIterator, class T >
  ForwardIterator remove ( ForwardIterator first, ForwardIterator last,
                           const T& value ); <algorithm> 

Remove value from range

Removes from the range [first,last) the elements with a value equal to value and returns an iterator to the new end of the range, which now includes only the values not equal to value.

The behavior of this function template is equivalent to:
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;
}

posted on 2012-08-07 11:29  山本二十八  阅读(129)  评论(0编辑  收藏  举报

导航