From bc6ff339d908d65795a51648689422219968e392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=93=E8=88=AA?= <1210603696@qq.com> Date: Sun, 12 Oct 2014 12:49:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90find?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TinySTL/Algorithm.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/TinySTL/Algorithm.h b/TinySTL/Algorithm.h index 12d8cf0..661e5bd 100644 --- a/TinySTL/Algorithm.h +++ b/TinySTL/Algorithm.h @@ -4,7 +4,7 @@ #include namespace TinySTL{ - //********* fill ******************** + //********* [fill] ******************** template void fill(ForwardIterator first, ForwardIterator last, const T& value) { @@ -19,7 +19,7 @@ namespace TinySTL{ { memset(first, static_cast(value), (last - first) * sizeof(wchar_t)); } - //********* fill_n ******************** + //********* [fill_n] ******************** template OutputIterator fill_n(OutputIterator first, Size n, const T& value) { @@ -39,6 +39,15 @@ namespace TinySTL{ memset(first, static_cast(value), n * sizeof(wchar_t)); return first + n; } + //************ [find] **************** + template + InputIterator find(InputIterator first, InputIterator last, const T& val){ + for (; first != last; ++first){ + if (*first == val) + break; + } + return first; + } } #endif \ No newline at end of file