Merge pull request #5524 from pkowal1982/master
Array has(var value) function
This commit is contained in:
commit
c9d0053754
3 changed files with 7 additions and 0 deletions
|
@ -200,6 +200,10 @@ int Array::count(const Variant& p_value) const {
|
|||
return amount;
|
||||
}
|
||||
|
||||
bool Array::has(const Variant& p_value) const {
|
||||
return _p->array.find(p_value, 0) != -1;
|
||||
}
|
||||
|
||||
void Array::remove(int p_pos) {
|
||||
|
||||
_p->array.remove(p_pos);
|
||||
|
|
|
@ -75,6 +75,7 @@ public:
|
|||
int rfind(const Variant& p_value, int p_from=-1) const;
|
||||
int find_last(const Variant& p_value) const;
|
||||
int count(const Variant& p_value) const;
|
||||
bool has(const Variant& p_value) const;
|
||||
|
||||
void erase(const Variant& p_value);
|
||||
|
||||
|
|
|
@ -474,6 +474,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
|
|||
VCALL_LOCALMEM2R(Array,rfind);
|
||||
VCALL_LOCALMEM1R(Array,find_last);
|
||||
VCALL_LOCALMEM1R(Array,count);
|
||||
VCALL_LOCALMEM1R(Array,has);
|
||||
VCALL_LOCALMEM1(Array,erase);
|
||||
VCALL_LOCALMEM0(Array,sort);
|
||||
VCALL_LOCALMEM2(Array,sort_custom);
|
||||
|
@ -1516,6 +1517,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
|
|||
ADDFUNC2(ARRAY,INT,Array,rfind,NIL,"what",INT,"from",varray(-1));
|
||||
ADDFUNC1(ARRAY,INT,Array,find_last,NIL,"value",varray());
|
||||
ADDFUNC1(ARRAY,INT,Array,count,NIL,"value",varray());
|
||||
ADDFUNC1(ARRAY,BOOL,Array,has,NIL,"value",varray());
|
||||
ADDFUNC0(ARRAY,NIL,Array,pop_back,varray());
|
||||
ADDFUNC0(ARRAY,NIL,Array,pop_front,varray());
|
||||
ADDFUNC0(ARRAY,NIL,Array,sort,varray());
|
||||
|
|
Loading…
Reference in a new issue