std::find, std::find_if, std::find_if_not函数原型!
一:find searches for an element equal to value
template<class InputIt, class T>InputIt find(InputIt first, InputIt last, const T& value)
{
for (; first != last; ++first) {
if (*first == value) {
return first;
}
}
return last;
}
二:find_if searches for an element for which predicate p returns true
template<class InputIt, class UnaryPredicate>
InputIt find_if(InputIt first, InputIt last, UnaryPredicate p)
{for (; first != last; ++first) {
if (p(*first)) {
return first;
}
}
return last;
}
三: find_if_not searches for an element for which predicate q returns false
template<class InputIt, class UnaryPredicate>
InputIt find_if_not(InputIt first, InputIt last, UnaryPredicate q)
{
for (; first != last; ++first) {
if (!q(*first)) {
return first;
}
}
return last;
}