Moved all function definitions into header files as required for templated classes/functions

This commit is contained in:
Luke Else 2022-11-12 23:34:32 +00:00
parent 5913fb8084
commit 96d5eb8071
8 changed files with 33 additions and 48 deletions

View File

@ -1,13 +0,0 @@
#include "directednode.h"
namespace Generic {
template <typename T, typename NodeType>
DirectedNode<T, NodeType>::DirectedNode(T value, std::shared_ptr<NodeType> left, std::shared_ptr<NodeType> right) {
this->value = value;
this->left = left;
this->right = right;
}
template <typename T, typename NodeType>
DirectedNode<T, NodeType>::~DirectedNode() {}
}

View File

@ -14,4 +14,14 @@ namespace Generic {
private:
};
template <typename T, typename NodeType>
DirectedNode<T, NodeType>::DirectedNode(T value, std::shared_ptr<NodeType> left, std::shared_ptr<NodeType> right) {
this->value = value;
this->left = left;
this->right = right;
}
template <typename T, typename NodeType>
DirectedNode<T, NodeType>::~DirectedNode() {}
}

View File

@ -1,12 +0,0 @@
#include "undirectednode.h"
namespace Generic {
template <typename T, typename NodeType>
UndirectedNode<T, NodeType>::UndirectedNode(T value, std::shared_ptr<NodeType> left, std::shared_ptr<NodeType> right){
this->value = value;
this->next = next;
}
template <typename T, typename NodeType>
UndirectedNode<T, NodeType>::~UndirectedNode() {}
}

View File

@ -13,4 +13,13 @@ namespace Generic {
private:
};
template <typename T, typename NodeType>
UndirectedNode<T, NodeType>::UndirectedNode(T value, std::shared_ptr<NodeType> left, std::shared_ptr<NodeType> right) {
this->value = value;
this->next = next;
}
template <typename T, typename NodeType>
UndirectedNode<T, NodeType>::~UndirectedNode() {}
}

View File

@ -1,6 +0,0 @@
#include "linkedlist.h"
#include "linkedlistnode.h"
namespace Datastructures {
}

View File

@ -1,4 +1,6 @@
#pragma once
#include "linkedlistnode.h"
namespace Datastructures {
template <typename T>
class LinkedList

View File

@ -1,17 +0,0 @@
#include "linkedlistnode.h"
namespace Datastructures {
namespace Nodes {
template <typename T>
LinkedListNode<T>::LinkedListNode(T value, std::shared_ptr<LinkedListNode<T>> next) {
this->value = value;
this->next = next;
}
//Creates a new node, returning a smart pointer to a stack allocated object
template <typename T>
std::shared_ptr<LinkedListNode<T>> LinkedListNode<T>::create(T value, std::shared_ptr<LinkedListNode<T>> next) {
return std::make_shared<LinkedListNode<T>>(value, next);
}
}
}

View File

@ -15,5 +15,17 @@ namespace Datastructures {
private:
};
template <typename T>
LinkedListNode<T>::LinkedListNode(T value, std::shared_ptr<LinkedListNode<T>> next) {
this->value = value;
this->next = next;
}
//Creates a new node, returning a smart pointer to a stack allocated object
template <typename T>
std::shared_ptr<LinkedListNode<T>> LinkedListNode<T>::create(T value, std::shared_ptr<LinkedListNode<T>> next) {
return std::make_shared<LinkedListNode<T>>(value, next);
}
}
}