Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions LittleTemplateLibrary.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\Array.cpp" />
<ClCompile Include="src\List.cpp" />
<ClCompile Include="src\main.cpp" />
<ClCompile Include="src\Queue.cpp" />
<ClCompile Include="src\Stack.cpp" />
Expand All @@ -150,6 +151,7 @@
<ClInclude Include="src\List.h" />
<ClInclude Include="src\Queue.h" />
<ClInclude Include="src\Stack.h" />
<ClInclude Include="src\Tree.h" />
<ClInclude Include="src\Util.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Expand Down
6 changes: 6 additions & 0 deletions LittleTemplateLibrary.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<ClCompile Include="src\Array.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\List.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\Stack.h">
Expand All @@ -47,5 +50,8 @@
<ClInclude Include="src\Container.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\Tree.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Ltl
T Array<T>::operator[](const int index)
{
//Bounds checking
if ((index => 0) && (index !> len-1))
if ((index >= 0) && !(index > len-1))
{
return body[index];
}
Expand Down
43 changes: 43 additions & 0 deletions src/List.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include "List.h"

namespace Ltl
{
template<class T>
LinkedList<T>::LinkedList()
{
//The head is the first element and it points to nothing in this case
head = new Node(T(), nullptr, nullptr);
}

template<class T>
inline int Ltl::LinkedList<T>::size()
{
return len;
}

template<class T>
bool LinkedList<T>::empty()
{
if (len > 0)
{
return false;
}
return true;
}

template<class T>
void LinkedList<T>::push(const T value)
{
Node next;

for (int i = 0; i < len; i++)
{

}

if (head.next == nullptr)
{
next = new Node(value, &head, nullptr);
}
}
}
72 changes: 27 additions & 45 deletions src/List.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,38 @@
namespace Ltl
{
template <class T>
class List
class LinkedList
{
public:
//Constructor
List<T>(){}
List<T>(const int& size);
void operator=(const List<T>& s);

//Destructor
~List();

#pragma region Access Functions
/// <returns>The first element in the list</returns>
T front();
/// <returns>The last element in the list</returns>
T back();
#pragma endregion Functions for accessing the elements of the container

#pragma region Member Functions
/// <returns>The size of the container</returns>
/// <summary>Default Constructor</summary>
LinkedList();

int size();
/// <returns>True if the container is empty, false otherwise</returns>
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<T> merge(List<T> 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

/// <summary>Creates a new node item</summary>
/// <param name="_value">Value to store in the node</param>
/// <param name="_prev">Pointer to the previous element</param>
/// <param name="_next">Pointer to the next element or back to the head</param>
Node(const T _value, Node* _prev, Node* _next)
{
value = _value;
prev = _prev;
next = _next;
}
};

#pragma region Operator Overload
bool operator==(List<T>& s);
bool operator<=(List<T>& s);
bool operator>=(List<T>& s);
bool operator<(List<T>& s);
bool operator>(List<T>& s);
bool operator!=(List<T>& s);
#pragma endregion Overloading Functions
Node head; //Represents the begining of the list
int len = 0;
};
}
25 changes: 25 additions & 0 deletions src/Tree.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

namespace Ltl
{
template<class T>
class Tree
{
public:
Tree(){}

private:
class Node
{
public:
Node()
{
L = nullptr;
R = nullptr;
}

T Value;
Node* L, R;
};
};
}
2 changes: 2 additions & 0 deletions src/Util.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#include "Array.h"
#include "Queue.h"

namespace Ltl
{
Expand Down