add pop_back/pop_front/push_back/push_front to array, to make it according to doc, fixes #3040

This commit is contained in:
Juan Linietsky 2015-12-12 08:27:30 -03:00
parent a73cf7f794
commit b191e740d2
3 changed files with 29 additions and 1 deletions

View file

@ -222,6 +222,24 @@ void Array::invert(){
}
void Array::push_front(const Variant& p_value) {
_p->array.insert(0,p_value);
}
void Array::pop_back(){
if (!_p->array.empty())
_p->array.resize( _p->array.size() -1 );
}
void Array::pop_front(){
if (!_p->array.empty())
_p->array.remove(0);
}
Array::Array(const Array& p_from) {

View file

@ -75,6 +75,10 @@ public:
void erase(const Variant& p_value);
void push_front(const Variant& p_value);
void pop_back();
void pop_front();
Array(const Array& p_from);
Array(bool p_shared=false);
~Array();

View file

@ -450,6 +450,9 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM0(Array,clear);
VCALL_LOCALMEM0R(Array,hash);
VCALL_LOCALMEM1(Array,push_back);
VCALL_LOCALMEM1(Array,push_front);
VCALL_LOCALMEM0(Array,pop_back);
VCALL_LOCALMEM0(Array,pop_front);
VCALL_LOCALMEM1(Array,append);
VCALL_LOCALMEM1(Array,resize);
VCALL_LOCALMEM2(Array,insert);
@ -492,6 +495,9 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM2(ByteArray,set);
VCALL_LOCALMEM1R(ByteArray,get);
VCALL_LOCALMEM1(ByteArray,push_back);
VCALL_LOCALMEM1(ByteArray,push_front);
VCALL_LOCALMEM0(ByteArray,pop_back);
VCALL_LOCALMEM0(ByteArray,pop_front);
VCALL_LOCALMEM1(ByteArray,resize);
VCALL_LOCALMEM1(ByteArray,append);
VCALL_LOCALMEM1(ByteArray,append_array);