Книга: Standard Template Library Programmer
find_if
Разделы на этой странице:
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 the standard header algorithm, and in the nonstandard backward-compatibility header algo.h.
Requirements on types
• Predicate is a model of Predicate.
• InputIterator is a model of InputIterator.
• The value type of InputIterator is convertible to the argument type of Predicate.
Preconditions
• [first, last) is a valid range.
• For each iterator i in the range [first, last), *i is in the domain of Predicate.
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);
See also
find.
- Finding Files by Searching with find
- Finding Files from an Index with locate
- 6.4.5. Finding the Owner
- 6.4.6. Finding the Copies
- 13.2.3 Finding Free Blocks Quickly
- 14.4.4. Поиск по дереву и использование возвращенного указателя: tfind() и tsearch()
- Функция find_vma()
- Функция find_vma_prev()
- Функция find_vma_intersection()
- 1.4.3. Отображение содержимого окна Finder
- find
- 18. Test equipment and fault-finding