#include "List/List.h" #include template class CircleList: public List { public: Node* get_start() { return this->start; } CircleList() {} ~CircleList() { Node* currentNode = this->start; for(int i = 0; i < this->lenght; i++) { std::cout << currentNode->value << std::endl; currentNode = currentNode->next; delete currentNode->prev; } this->start = nullptr; this->end = nullptr; } void add (T value) { Node* node = new Node; node->value = value; if(this->start==nullptr) { this->start = node; this->end = node; return; } node->prev = this->end; node->next = this->start; this->end->next = node; this->start->prev = node; this->end = node; this->lenght++; } void add (T value, int index) { this->List::add(value, index); } void pop(Node* n) { this->List::pop(n); } void pop() { this->end->prev->next = this->start; this->end = this->end->prev; this->lenght--; } void pop(int index) { this->List::pop(index); } friend std::ostream &operator <<(std::ostream &os, CircleList &c) { os << "( "; Node* currentNode = c.start; for(int i = 0; i < c.lenght; i++) { os << currentNode->value << " = "; currentNode = currentNode->next; } os << currentNode->value << "... )"; return os; } };