From e0d7dfad8fc32a9879eeafc0dda27266445ca283 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 28 May 2022 17:54:16 +0300 Subject: Autocommit at 28.05.2022 @ 17:54 --- src/Generic/List/List.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/Generic') diff --git a/src/Generic/List/List.hpp b/src/Generic/List/List.hpp index 0b53033..f1919b3 100644 --- a/src/Generic/List/List.hpp +++ b/src/Generic/List/List.hpp @@ -32,6 +32,8 @@ protected: public: //! Copies all elements in given array List(const T* elements, unsigned elementsCount); + //! Allocates memory for the given length + List(unsigned length); //! Adds an element void add(const T& element); //! Inserts element at given index @@ -112,6 +114,15 @@ List::List(const T* elements, unsigned elementsCount) { this->elements[i] = elements[i]; } +template +List::List(unsigned length) { + this->length = length; + count = 0; + this->elements = new T[length]; + for (unsigned i = 0; i < count; i++) + this->elements[i] = elements[i]; +} + /*! * Resizes internal array if there is no space for additional elements. */ -- cgit v1.3.1-26-gb76a