Add fill method to Arrays and PackedArrays

This commit is contained in:
Matheus Lima Cunha
2021-02-25 11:10:39 -03:00
parent e271dba9cb
commit efd27a63c1
14 changed files with 127 additions and 0 deletions

View File

@ -66,6 +66,7 @@ private:
public:
bool push_back(T p_elem);
_FORCE_INLINE_ bool append(const T &p_elem) { return push_back(p_elem); } //alias
void fill(T p_elem);
void remove(int p_index) { _cowdata.remove(p_index); }
void erase(const T &p_val) {
@ -223,4 +224,12 @@ bool Vector<T>::push_back(T p_elem) {
return false;
}
template <class T>
void Vector<T>::fill(T p_elem) {
T *p = ptrw();
for (int i = 0; i < size(); i++) {
p[i] = p_elem;
}
}
#endif // VECTOR_H