|
@@ -11,7 +11,20 @@ class CircleList: public List<T>
|
|
|
|
|
|
CircleList() {}
|
|
|
|
|
|
- void add (T value) override{
|
|
|
+ ~CircleList()
|
|
|
+ {
|
|
|
+ Node<T>* 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<T>* node = new Node<T>;
|
|
|
node->value = value;
|
|
|
if(this->start==nullptr) {
|
|
@@ -27,13 +40,12 @@ class CircleList: public List<T>
|
|
|
this->lenght++;
|
|
|
}
|
|
|
|
|
|
- void add (T value, int index) override{
|
|
|
- static_cast<List<T>*>(this)->add(value, index);
|
|
|
- return;
|
|
|
+ void add (T value, int index) {
|
|
|
+ this->List<int>::add(value, index);
|
|
|
}
|
|
|
|
|
|
void pop(Node<T>* n) {
|
|
|
- this->pop(n);
|
|
|
+ this->List<int>::pop(n);
|
|
|
}
|
|
|
|
|
|
void pop() {
|
|
@@ -43,7 +55,7 @@ class CircleList: public List<T>
|
|
|
}
|
|
|
|
|
|
void pop(int index) {
|
|
|
- this->pop(index);
|
|
|
+ this->List<int>::pop(index);
|
|
|
}
|
|
|
|
|
|
friend std::ostream &operator <<(std::ostream &os, CircleList &c)
|