Add fill method to Array and PoolArrays

Co-authored-by: Matheus Lima Cunha <matheus.limacunha@hotmail.com>
This commit is contained in:
Haoyu Qiu
2022-04-22 18:45:34 +08:00
parent 3ba980379d
commit 77b6f7595a
14 changed files with 98 additions and 0 deletions

View File

@ -64,6 +64,7 @@ private:
public:
bool push_back(T p_elem);
void fill(T p_elem);
void remove(int p_index) { _cowdata.remove(p_index); }
void erase(const T &p_val) {
@ -156,4 +157,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