提交 c6bb6420 编写于 作者: 邹晓航

完成find_if和find_if_not

上级 f8f22330
......@@ -225,6 +225,26 @@ namespace TinySTL{
}
return first;
}
//********** [find_if] *************************
//********* [Algorithm Complexity: O(N)] ****************
template <class InputIterator, class UnaryPredicate>
InputIterator find_if(InputIterator first, InputIterator last, UnaryPredicate pred){
for (; first != last; ++first){
if (pred(*first))
break;
}
return first;
}
//********** [find_if_not] *************************
//********* [Algorithm Complexity: O(N)] ****************
template <class InputIterator, class UnaryPredicate>
InputIterator find_if_not(InputIterator first, InputIterator last, UnaryPredicate pred){
for (; first != last; ++first){
if (!pred(*first))
break;
}
return first;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册