From 4e3993404c3a5d9c6ae1037e49b01eb563759dd1 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:25:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90all=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 eb3c327..08104b4 100644 --- a/TinySTL/Algorithm.h +++ b/TinySTL/Algorithm.h @@ -177,6 +177,16 @@ namespace TinySTL{ } return true; } + //********** [all_of] ************************* + //********* [Algorithm Complexity: O(N)] **************** + template + bool all_of(InputIterator first, InputIterator last, UnaryPredicate pred){ + for (; first != last; ++first){ + if (!pred(*first)) + return false; + } + return true; + } }