From 2c042b6d51089f78fe120849d1acf624ac597afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=93=E8=88=AA?= <1210603696@qq.com> Date: Fri, 17 Oct 2014 17:26:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90any=5Fof?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TinySTL/Algorithm.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/TinySTL/Algorithm.h b/TinySTL/Algorithm.h index 08104b4..00859a6 100644 --- a/TinySTL/Algorithm.h +++ b/TinySTL/Algorithm.h @@ -187,6 +187,16 @@ namespace TinySTL{ } return true; } + //********** [any_of] ************************* + //********* [Algorithm Complexity: O(N)] **************** + template + bool any_of(InputIterator first, InputIterator last, UnaryPredicate pred){ + for (; first != last; ++first){ + if (pred(*first)) + return true; + } + return false; + } }