diff --git a/LittleTemplateLibrary.vcxproj b/LittleTemplateLibrary.vcxproj index bfd3ad7..75ac64d 100644 --- a/LittleTemplateLibrary.vcxproj +++ b/LittleTemplateLibrary.vcxproj @@ -140,6 +140,7 @@ + @@ -150,6 +151,7 @@ + diff --git a/LittleTemplateLibrary.vcxproj.filters b/LittleTemplateLibrary.vcxproj.filters index e2f10ff..b876bb1 100644 --- a/LittleTemplateLibrary.vcxproj.filters +++ b/LittleTemplateLibrary.vcxproj.filters @@ -27,6 +27,9 @@ Source Files + + Source Files + @@ -47,5 +50,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/src/Array.cpp b/src/Array.cpp index 7b961bb..7fde5e5 100644 --- a/src/Array.cpp +++ b/src/Array.cpp @@ -29,7 +29,7 @@ namespace Ltl T Array::operator[](const int index) { //Bounds checking - if ((index => 0) && (index !> len-1)) + if ((index >= 0) && !(index > len-1)) { return body[index]; } diff --git a/src/List.cpp b/src/List.cpp new file mode 100644 index 0000000..f6974c2 --- /dev/null +++ b/src/List.cpp @@ -0,0 +1,43 @@ +#include "List.h" + +namespace Ltl +{ + template + LinkedList::LinkedList() + { + //The head is the first element and it points to nothing in this case + head = new Node(T(), nullptr, nullptr); + } + + template + inline int Ltl::LinkedList::size() + { + return len; + } + + template + bool LinkedList::empty() + { + if (len > 0) + { + return false; + } + return true; + } + + template + void LinkedList::push(const T value) + { + Node next; + + for (int i = 0; i < len; i++) + { + + } + + if (head.next == nullptr) + { + next = new Node(value, &head, nullptr); + } + } +} \ No newline at end of file diff --git a/src/List.h b/src/List.h index 825fcef..de6a4b6 100644 --- a/src/List.h +++ b/src/List.h @@ -3,56 +3,38 @@ namespace Ltl { template - class List + class LinkedList { public: - //Constructor - List(){} - List(const int& size); - void operator=(const List& s); - - //Destructor - ~List(); - - #pragma region Access Functions - /// The first element in the list - T front(); - /// The last element in the list - T back(); - #pragma endregion Functions for accessing the elements of the container - - #pragma region Member Functions - /// The size of the container + /// Default Constructor + LinkedList(); + int size(); - /// True if the container is empty, false otherwise bool empty(); - #pragma endregion - #pragma region Modifier Functions - void insert(const T& value, const int& position); - void clear(); - void resize(const int& size); - void swap(); - void emplace_back(const T& value); - void emplace_front(const T& value); - void push_back(const T& value); - void push_front(const T& value); - void pop_back(); - void pop_front(); - #pragma endregion Modifies the container elements - - #pragma region Operations - List merge(List s); - void sort(); - #pragma endregion Operations on the container class + void push(const T value); + + private: + class Node + { + public: + T value; //Value of the current element + Node* prev; //A pointer to the previous element + Node* next; //A pointer to the next element + + /// Creates a new node item + /// Value to store in the node + /// Pointer to the previous element + /// Pointer to the next element or back to the head + Node(const T _value, Node* _prev, Node* _next) + { + value = _value; + prev = _prev; + next = _next; + } + }; - #pragma region Operator Overload - bool operator==(List& s); - bool operator<=(List& s); - bool operator>=(List& s); - bool operator<(List& s); - bool operator>(List& s); - bool operator!=(List& s); - #pragma endregion Overloading Functions + Node head; //Represents the begining of the list + int len = 0; }; } \ No newline at end of file diff --git a/src/Tree.h b/src/Tree.h new file mode 100644 index 0000000..3326d2b --- /dev/null +++ b/src/Tree.h @@ -0,0 +1,25 @@ +#pragma once + +namespace Ltl +{ + template + class Tree + { + public: + Tree(){} + + private: + class Node + { + public: + Node() + { + L = nullptr; + R = nullptr; + } + + T Value; + Node* L, R; + }; + }; +} \ No newline at end of file diff --git a/src/Util.h b/src/Util.h index 8067331..b196913 100644 --- a/src/Util.h +++ b/src/Util.h @@ -1,4 +1,6 @@ #pragma once +#include "Array.h" +#include "Queue.h" namespace Ltl {