|
@@ -0,0 +1,45 @@
|
|
|
+#include "List/List.h"
|
|
|
+#include <iostream>
|
|
|
+
|
|
|
+template <typename T>
|
|
|
+class CircleList: public List
|
|
|
+{
|
|
|
+ public:
|
|
|
+ Node<T>* get_start() {
|
|
|
+ return start;
|
|
|
+ }
|
|
|
+
|
|
|
+ void add(T value) {
|
|
|
+ Node<T>* node = new Node<T>;
|
|
|
+ node->value = value;
|
|
|
+ if(start==nullptr) {
|
|
|
+ start = node;
|
|
|
+ end = node;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ node->prev = end;
|
|
|
+ node->next = start;
|
|
|
+ end = node;
|
|
|
+ lenght++;
|
|
|
+ }
|
|
|
+
|
|
|
+ void pop() {
|
|
|
+ end->prev->next = start;
|
|
|
+ end = end->prev;
|
|
|
+ lenght--;
|
|
|
+ }
|
|
|
+
|
|
|
+ friend std::ostream &operator <<(std::ostream &os, CircleList &c)
|
|
|
+ {
|
|
|
+ os << "( ";
|
|
|
+ Node<T>* currentNode = c.start;
|
|
|
+ while (currentNode->next!=nullptr)
|
|
|
+ {
|
|
|
+ os << currentNode->value << " = ";
|
|
|
+ currentNode = currentNode->next;
|
|
|
+ }
|
|
|
+ os << currentNode->value << " )";
|
|
|
+ return os;
|
|
|
+ }
|
|
|
+
|
|
|
+};
|