From bc3b45e6e7cfba9251f80e498c87aadbf9b5e7b8 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 14 Jun 2022 08:13:42 +0300 Subject: Autocommit at 14.06.2022 @ 08:13 --- src/Generic/List/List.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/Generic') 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& operator+=(const List other); @@ -208,6 +210,14 @@ const T* List::raw_data() const { return elements; } +template +void List::clear() { + free(); + length = 8; + count = 0; + this->elements = new T[length]; +} + template List& List::operator+=(const List other) { for (unsigned i = 0; i < other.length; i++) -- cgit v1.3.1-26-gb76a