From 4c2cf224027f7a3bc5e0fc0a83545938c6b89624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=93=E8=88=AA?= <1210603696@qq.com> Date: Sat, 18 Oct 2014 19:55:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90for=5Feach?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TinySTL/Algorithm.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/TinySTL/Algorithm.h b/TinySTL/Algorithm.h index ca5450b..ff07e60 100644 --- a/TinySTL/Algorithm.h +++ b/TinySTL/Algorithm.h @@ -207,6 +207,14 @@ namespace TinySTL{ } return true; } + //********** [for_each] ************************* + //********* [Algorithm Complexity: O(N)] **************** + template + Function for_each(InputIterator first, InputIterator last, Function fn){ + for (; first != last; ++first) + fn(*first); + return fn; + } }