From 16a916c1fc7ecf89bfbf910445740fb4596aae8f Mon Sep 17 00:00:00 2001 From: Stoycho Kyosev <68247567+stoychoX@users.noreply.github.com> Date: Wed, 9 Nov 2022 01:20:01 +0200 Subject: fix minor problems --- Seminar05/LinkedList.hpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Seminar05/LinkedList.hpp b/Seminar05/LinkedList.hpp index 4f12000..6242b13 100644 --- a/Seminar05/LinkedList.hpp +++ b/Seminar05/LinkedList.hpp @@ -15,7 +15,6 @@ private: void free(); void copy(const LinkedList&); - void move(LinkedList&&); public: class Iterator { private: @@ -167,23 +166,18 @@ void LinkedList::copy(const LinkedList& other) { } template -void LinkedList::move(LinkedList&& other) { - head = other.head; - tail = other.tail; - sizeOfList = other.sizeOfList; - - other.tail = other.head = nullptr; - other.sizeOfList = 0; -} - -template -LinkedList::LinkedList(const LinkedList& other) { +LinkedList::LinkedList(const LinkedList& other) : head {nullptr}, tail{ nullptr } { copy(other); } template LinkedList::LinkedList(LinkedList&& other) { - move(other); + head = other.head; + tail = other.tail; + sizeOfList = other.sizeOfList; + + other.head = other.tail = nullptr; + other.sizeOfList = 0; } template @@ -199,7 +193,13 @@ template LinkedList& LinkedList::operator=(LinkedList&& other) { if(this != &other) { free(); - move(other); + + head = other.head; + tail = other.tail; + sizeOfList = other.sizeOfList; + + other.head = other.tail = nullptr; + other.sizeOfList = 0; } return *this; } @@ -304,4 +304,4 @@ LinkedList::~LinkedList() { free(); } -#endif \ No newline at end of file +#endif -- cgit v1.3.1-23-gd82d