diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-04-28 16:52:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-28 16:52:31 +0200 |
commit | 9e9ac9f6ad470be968233a021f54744ad4735c54 (patch) | |
tree | d3d13d411e24a280fde7e6c3b0b818134891c41d /core/templates | |
parent | f505a2679808ddb95a552d9ad8ce9a0f9aa3b285 (diff) | |
parent | efd27a63c138ceef89d4ed2586651ea61898f5c7 (diff) |
Merge pull request #46476 from DarknessCatt/master
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 4cd68aeb5c..dae8874a87 100644 --- a/core/templates/vector.h +++ b/core/templates/vector.h @@ -65,6 +65,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) { @@ -222,4 +223,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 |