diff options
author | Matheus Lima Cunha <matheus.limacunha@hotmail.com> | 2021-02-25 11:10:39 -0300 |
---|---|---|
committer | Matheus Lima Cunha <matheus.limacunha@hotmail.com> | 2021-04-21 11:33:53 -0300 |
commit | efd27a63c138ceef89d4ed2586651ea61898f5c7 (patch) | |
tree | d2e0b2327d2786e4b8d8d941cd3358248cbe09d1 /core/templates | |
parent | e271dba9cb0b52698c23f5d61f3b8e72f2b7d29d (diff) |
Add fill method to Arrays and PackedArrays
Diffstat (limited to 'core/templates')
-rw-r--r-- | core/templates/vector.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/core/templates/vector.h b/core/templates/vector.h index a56a941dbc..499cc32453 100644 --- a/core/templates/vector.h +++ b/core/templates/vector.h @@ -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 |