SGI Techpubs Library

IRIX 6.5  »  Books  »  Developer  »  
Standard Template Library Programmer's Guide
(document number: 007-3426-004 / published: 1999-05-21)    table of contents  |  additional info  |  download
find in page

SGI

remove_copy_if

Category: algorithms Component type: function

Prototype

template <class InputIterator, class OutputIterator, class Predicate>
OutputIterator remove_copy_if(InputIterator first, InputIterator last,
                              OutputIterator result, Predicate pred);

Description

Remove_copy_if copies elements from the range [first, last) to a range beginning at result, except that elements for which pred is true are not copied. The return value is the end of the resulting range. This operation is stable, meaning that the relative order of the elements that are copied is the same as in the range [first, last).

Definition

Defined in the standard header algorithm, and in the nonstandard backward-compatibility header algo.h.

Requirements on types

Preconditions

Complexity

Linear. Exactly last - first applications of pred, and at most last - first assignments.

Example

Fill a vector with the nonnegative elements of another vector.
vector<int> V1;
V.push_back(-2);
V.push_back(0);
V.push_back(-1);
V.push_back(0);
V.push_back(1);
V.push_back(2);

vector<int> V2;
remove_copy_if(V1.begin(), V1.end(), 
               back_inserter(V2),
               bind2nd(less<int>(), 0));

Notes

See also

copy, remove, remove_if, remove_copy, unique, unique_copy.
[Silicon Surf] [STL Home]
Copyright © 1999 Silicon Graphics, Inc. All Rights Reserved. TrademarkInformation

Standard Template Library Programmer's Guide
(document number: 007-3426-004 / published: 1999-05-21)    table of contents  |  additional info  |  download


home/search | what's new | help

Contact Us | Site Map | Trademarks | Privacy | Using this site means you accept its Terms of Use

Copyright © 1993-2007 SGI, Inc. All rights reserved.