diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-06-11 12:29:33 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-11 12:29:33 -0300 |
commit | 0bda0fcb3e8985fe613b696761ab5f211316faf7 (patch) | |
tree | 359747451ac186ecd81a98cbf509945fcd594d0d /core/vector.h | |
parent | f5aadad7ae58d2eec06e7b6fff29a9ca2d035063 (diff) | |
parent | 6ce5876c63ffd7bc21b38197c4fa89713a77ceb5 (diff) |
Merge pull request #5148 from vnen/pr-array-find
Add Array.find(what, from) and Array.rfind(what, from)
Diffstat (limited to 'core/vector.h')
-rw-r--r-- | core/vector.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/core/vector.h b/core/vector.h index 87248ccf68..cafb4a4aa3 100644 --- a/core/vector.h +++ b/core/vector.h @@ -120,7 +120,7 @@ public: template <class T_val> - int find(const T_val& p_val) const; + int find(const T_val& p_val, int p_from=0) const; void set(int p_index,T p_elem); T get(int p_index) const; @@ -238,13 +238,13 @@ void Vector<T>::_copy_on_write() { } template<class T> template<class T_val> -int Vector<T>::find(const T_val &p_val) const { +int Vector<T>::find(const T_val &p_val, int p_from) const { int ret = -1; - if (size() == 0) + if (p_from < 0 || size() == 0) return ret; - for (int i=0; i<size(); i++) { + for (int i=p_from; i<size(); i++) { if (operator[](i) == p_val) { ret = i; @@ -253,7 +253,7 @@ int Vector<T>::find(const T_val &p_val) const { }; return ret; -}; +} template<class T> Error Vector<T>::resize(int p_size) { |