From f8f2233088dc9a7c62bad2ecfec0f607e6961d91 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:56:57 +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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/TinySTL/Algorithm.h b/TinySTL/Algorithm.h index ff07e60..9d855e1 100644 --- a/TinySTL/Algorithm.h +++ b/TinySTL/Algorithm.h @@ -215,6 +215,16 @@ namespace TinySTL{ fn(*first); return fn; } + //********** [find] ************************* + //********* [Algorithm Complexity: O(N)] **************** + template + InputIterator find(InputIterator first, InputIterator last, const T& val){ + for (; first != last; ++first){ + if (*first == val) + break; + } + return first; + } }