Silicon Graphics, Inc.

find_if

Category: algorithms Component type: function

Prototype

template<class InputIterator, class Predicate>
InputIterator find_if(InputIterator first, InputIterator last,
                      Predicate pred);

Description

Returns the first iterator i in the range [first, last) such that pred(*i) is true. Returns last if no such iterator exists.

Definition

Defined in algo.h.

Requirements on types

Preconditions

Complexity

Linear: at most last - first applications of Pred.

Example

list<int> L;
L.push_back(-3);
L.push_back(0);
L.push_back(3);
L.push_back(-2);

list<int>::iterator result = find_if(L.begin(), L.end(),
                                     bind2nd(greater<int>(), 0));
assert(result == L.end() || *result > 0);

Notes

See also

find.
[Silicon Surf] [STL Home]
Copyright © 1996 Silicon Graphics, Inc. All Rights Reserved. TrademarkInformation