Website Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit16a916c1fc7ecf89bfbf910445740fb4596aae8f (patch)
Author
 Stoycho Kyosev <68247567+stoychoX@users.noreply.github.com>
2022-11-09 01:20:01 +0200
Committer
 GitHub <noreply@github.com>
2022-11-09 01:20:01 +0200
Files442d8012a4119e20287dfdfc1121f2d8575524cb
Data-structures-and-algorithms-16a916c1fc7ecf89bfbf910445740fb4596aae8f.tar
Data-structures-and-algorithms-16a916c1fc7ecf89bfbf910445740fb4596aae8f.tar.gz
Data-structures-and-algorithms-16a916c1fc7ecf89bfbf910445740fb4596aae8f.zip
Parentfa1a9b5a698bbc0d282697cbc6e57f11a8ba687f (diff)
fix minor problems
1 files changed, 15 insertions, 15 deletions
-rw-r--r--Seminar05/LinkedList.hpp30
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<T>&);
- void move(LinkedList<T>&&);
public:
class Iterator {
private:
@@ -167,23 +166,18 @@ void LinkedList<T>::copy(const LinkedList<T>& other) {
}
template<class T>
-void LinkedList<T>::move(LinkedList<T>&& other) {
- head = other.head;
- tail = other.tail;
- sizeOfList = other.sizeOfList;
-
- other.tail = other.head = nullptr;
- other.sizeOfList = 0;
-}
-
-template<class T>
-LinkedList<T>::LinkedList(const LinkedList<T>& other) {
+LinkedList<T>::LinkedList(const LinkedList<T>& other) : head {nullptr}, tail{ nullptr } {
copy(other);
}
template<class T>
LinkedList<T>::LinkedList(LinkedList<T>&& other) {
- move(other);
+ head = other.head;
+ tail = other.tail;
+ sizeOfList = other.sizeOfList;
+
+ other.head = other.tail = nullptr;
+ other.sizeOfList = 0;
}
template<class T>
@@ -199,7 +193,13 @@ template<class T>
LinkedList<T>& LinkedList<T>::operator=(LinkedList<T>&& 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<T>::~LinkedList() {
free();
}
-#endif \ No newline at end of file
+#endif