You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Add 'from' argument to Array.find()
This commit is contained in:
@@ -150,9 +150,9 @@ void Array::erase(const Variant& p_value) {
|
|||||||
_p->array.erase(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 {
|
int Array::find_last(const Variant& p_value) const {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public:
|
|||||||
void sort_custom(Object *p_obj,const StringName& p_function);
|
void sort_custom(Object *p_obj,const StringName& p_function);
|
||||||
void invert();
|
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 find_last(const Variant& p_value) const;
|
||||||
int count(const Variant& p_value) const;
|
int count(const Variant& p_value) const;
|
||||||
|
|
||||||
|
|||||||
@@ -464,7 +464,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
|
|||||||
VCALL_LOCALMEM1(Array,resize);
|
VCALL_LOCALMEM1(Array,resize);
|
||||||
VCALL_LOCALMEM2(Array,insert);
|
VCALL_LOCALMEM2(Array,insert);
|
||||||
VCALL_LOCALMEM1(Array,remove);
|
VCALL_LOCALMEM1(Array,remove);
|
||||||
VCALL_LOCALMEM1R(Array,find);
|
VCALL_LOCALMEM2R(Array,find);
|
||||||
VCALL_LOCALMEM1R(Array,find_last);
|
VCALL_LOCALMEM1R(Array,find_last);
|
||||||
VCALL_LOCALMEM1R(Array,count);
|
VCALL_LOCALMEM1R(Array,count);
|
||||||
VCALL_LOCALMEM1(Array,erase);
|
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());
|
ADDFUNC2(ARRAY,NIL,Array,insert,INT,"pos",NIL,"value",varray());
|
||||||
ADDFUNC1(ARRAY,NIL,Array,remove,INT,"pos",varray());
|
ADDFUNC1(ARRAY,NIL,Array,remove,INT,"pos",varray());
|
||||||
ADDFUNC1(ARRAY,NIL,Array,erase,NIL,"value",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,find_last,NIL,"value",varray());
|
||||||
ADDFUNC1(ARRAY,INT,Array,count,NIL,"value",varray());
|
ADDFUNC1(ARRAY,INT,Array,count,NIL,"value",varray());
|
||||||
ADDFUNC0(ARRAY,NIL,Array,pop_back,varray());
|
ADDFUNC0(ARRAY,NIL,Array,pop_back,varray());
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
template <class T_val>
|
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);
|
void set(int p_index,T p_elem);
|
||||||
T get(int p_index) const;
|
T get(int p_index) const;
|
||||||
@@ -238,13 +238,13 @@ void Vector<T>::_copy_on_write() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T> template<class T_val>
|
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;
|
int ret = -1;
|
||||||
if (size() == 0)
|
if (p_from < 0 || size() == 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
for (int i=0; i<size(); i++) {
|
for (int i=p_from; i<size(); i++) {
|
||||||
|
|
||||||
if (operator[](i) == p_val) {
|
if (operator[](i) == p_val) {
|
||||||
ret = i;
|
ret = i;
|
||||||
@@ -253,7 +253,7 @@ int Vector<T>::find(const T_val &p_val) const {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
};
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
Error Vector<T>::resize(int p_size) {
|
Error Vector<T>::resize(int p_size) {
|
||||||
|
|||||||
Reference in New Issue
Block a user