List(const List<T>& rhs) {
copy(rhs);
}
List(const List<T>&& rhs) {
move(std::move(rhs));
}
List& operator=(const List<T>& rhs) {
copy(rhs);
return *this;
}
List& operator=(const List<T>&& rhs) {
move(std::move(rhs));
return *this;
}
void copy(const List<T>& rhs) {
clear();
for(auto value : rhs) {
push_back(value);
}
}
void move(const List<T>&& rhs) {
head = std::move(rhs.head);
tail = std::move(rhs.tail);
}
void clear() {
std::shared_ptr<Node> temp = head;
std::shared_ptr<Node> next;
do {
if(temp) {
next = temp->next;
}
temp = nullptr;
} while(next);
}
~List() {
}