diff --git a/core/array.cpp b/core/array.cpp index ab9f19d6a0a..41af460d83c 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -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) { diff --git a/core/array.h b/core/array.h index 904309b257f..c29b4355ca9 100644 --- a/core/array.h +++ b/core/array.h @@ -53,7 +53,7 @@ public: bool empty() const; void clear(); - bool is_shared() const; + bool is_shared() const; bool operator==(const Array& p_array) const; @@ -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(); diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 2d10cf4d44b..3b04edca1ed 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -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);