123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #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;
- }
- };
|