diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/array.cpp | 4 | ||||
-rw-r--r-- | core/array.h | 2 | ||||
-rw-r--r-- | core/variant_call.cpp | 4 | ||||
-rw-r--r-- | core/vector.h | 10 |
4 files changed, 10 insertions, 10 deletions
diff --git a/core/array.cpp b/core/array.cpp index 1d283a14aa..146e56b7f8 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -150,9 +150,9 @@ void Array::erase(const Variant& p_value) { _p->array.erase(p_value); } -int Array::find(const Variant& p_value) const { +int Array::find(const Variant& p_value, int p_from) const { - return _p->array.find(p_value); + return _p->array.find(p_value, p_from); } int Array::find_last(const Variant& p_value) const { diff --git a/core/array.h b/core/array.h index 9472a6dd21..4fb22a4dcc 100644 --- a/core/array.h +++ b/core/array.h @@ -71,7 +71,7 @@ public: void sort_custom(Object *p_obj,const StringName& p_function); void invert(); - int find(const Variant& p_value) const; + int find(const Variant& p_value, int p_from=0) const; int find_last(const Variant& p_value) const; int count(const Variant& p_value) const; diff --git a/core/variant_call.cpp b/core/variant_call.cpp index d427a80541..6c16d8cba0 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -464,7 +464,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1(Array,resize); VCALL_LOCALMEM2(Array,insert); VCALL_LOCALMEM1(Array,remove); - VCALL_LOCALMEM1R(Array,find); + VCALL_LOCALMEM2R(Array,find); VCALL_LOCALMEM1R(Array,find_last); VCALL_LOCALMEM1R(Array,count); VCALL_LOCALMEM1(Array,erase); @@ -1453,7 +1453,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC2(ARRAY,NIL,Array,insert,INT,"pos",NIL,"value",varray()); ADDFUNC1(ARRAY,NIL,Array,remove,INT,"pos",varray()); ADDFUNC1(ARRAY,NIL,Array,erase,NIL,"value",varray()); - ADDFUNC1(ARRAY,INT,Array,find,NIL,"value",varray()); + ADDFUNC2(ARRAY,INT,Array,find,NIL,"what",INT,"from",varray(0)); ADDFUNC1(ARRAY,INT,Array,find_last,NIL,"value",varray()); ADDFUNC1(ARRAY,INT,Array,count,NIL,"value",varray()); ADDFUNC0(ARRAY,NIL,Array,pop_back,varray()); 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) { |