diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-01-07 19:58:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-07 19:58:36 +0100 |
commit | 270eae0a05bbcb3795bca63217d0c969c4c9a234 (patch) | |
tree | 5480e3214e237a11049275b9be1515647a3f7b27 /core/cowdata.h | |
parent | f8eaa2fc596f33fb18d12b6a4b6d0a53d1baeee8 (diff) | |
parent | cbb396c0064d77ec50a524241d22746c8b69bbdb (diff) |
Merge pull request #24823 from ibrahn/fix-string-lrstrip-2
Repair String lstrip and rstrip.
Diffstat (limited to 'core/cowdata.h')
-rw-r--r-- | core/cowdata.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/cowdata.h b/core/cowdata.h index 319e61d261..3e40ad0f4b 100644 --- a/core/cowdata.h +++ b/core/cowdata.h @@ -179,6 +179,8 @@ public: return OK; }; + int find(const T &p_val, int p_from = 0) const; + _FORCE_INLINE_ CowData(); _FORCE_INLINE_ ~CowData(); _FORCE_INLINE_ CowData(CowData<T> &p_from) { _ref(p_from); }; @@ -316,6 +318,24 @@ Error CowData<T>::resize(int p_size) { } template <class T> +int CowData<T>::find(const T &p_val, int p_from) const { + int ret = -1; + + if (p_from < 0 || size() == 0) { + return ret; + } + + for (int i = p_from; i < size(); i++) { + if (get(i) == p_val) { + ret = i; + break; + } + } + + return ret; +} + +template <class T> void CowData<T>::_ref(const CowData *p_from) { _ref(*p_from); } |