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; + } }