diff options
Autocommit at 14.06.2022 @ 08:13
1 files changed, 10 insertions, 0 deletions
| -rw-r--r-- | src/Generic/List/List.hpp | 10 |
diff --git a/src/Generic/List/List.hpp b/src/Generic/List/List.hpp index f26e7d1..e0ae8e3 100644 --- a/src/Generic/List/List.hpp +++ b/src/Generic/List/List.hpp @@ -49,6 +49,8 @@ public: const T& operator[](unsigned index) const; //! Returns raw array of data const T* raw_data() const; + //! Removes all data + void clear(); //! Appends elements from other list List<T>& operator+=(const List<T> other); @@ -209,6 +211,14 @@ const T* List<T>::raw_data() const { } template <typename T> +void List<T>::clear() { + free(); + length = 8; + count = 0; + this->elements = new T[length]; +} + +template <typename T> List<T>& List<T>::operator+=(const List<T> other) { for (unsigned i = 0; i < other.length; i++) add(other[i]); |
