From 7492b29aa88751c269a92e5c1636c5eef243cbd4 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, 10 Oct 2014 19:34:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90find=5Ffirst=5Fnot=5Fof?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TinySTL/String.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/TinySTL/String.h b/TinySTL/String.h index a175a84..ace24c0 100644 --- a/TinySTL/String.h +++ b/TinySTL/String.h @@ -617,6 +617,26 @@ namespace TinySTL{ size_t string::find_first_of(char c, size_t pos) const{ return find(c, pos); } + size_t string::find_first_not_of(const string& str, size_t pos) const{ + return find_first_not_of(str.begin(), pos, str.size() - pos); + } + size_t string::find_first_not_of(const char* s, size_t pos) const{ + return find_first_not_of(s, pos, size() - pos); + } + size_t string::find_first_not_of(const char* s, size_t pos, size_t n) const{ + for (size_t i = pos; i != pos + n; ++i){ + if (!isContained((*this)[i], s, s + strlen(s))) + return i; + } + return npos; + } + size_t string::find_first_not_of(char c, size_t pos) const{ + for (size_t i = pos; i != size(); ++i){ + if ((*this)[i] != c) + return i; + } + return npos; + } std::ostream& operator <<(std::ostream& os, const string&str){ for (const auto ch : str){ os << ch;