jezvgg 1 rok pred
commit
7f17a90229
3 zmenil súbory, kde vykonal 56 pridanie a 0 odobranie
  1. 45 0
      CircleList.h
  2. 1 0
      List
  3. 10 0
      main.cpp

+ 45 - 0
CircleList.h

@@ -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;
+    }
+
+};

+ 1 - 0
List

@@ -0,0 +1 @@
+Subproject commit ce67e9f754b4f724bb1afc8c024bbedddb513ef4

+ 10 - 0
main.cpp

@@ -0,0 +1,10 @@
+#include "CircleList.h"
+
+using namespace std;
+
+int main() {
+    CircleList<int> l;
+    for(int i = 0; i < 10; i++) l.add(i);
+    cout << l;
+    return 0;
+}