Added Create method to Linked List Node
This commit is contained in:
parent
9ec4e515f2
commit
deb58f03bb
@ -1,7 +1,7 @@
|
|||||||
#include "undirectednode.h"
|
#include "undirectednode.h"
|
||||||
|
|
||||||
namespace Generic {
|
namespace Generic {
|
||||||
template<typename T, typename NodeType>
|
template <typename T, typename NodeType>
|
||||||
UndirectedNode<T, NodeType>::UndirectedNode(T value, NodeType* left, NodeType* right){
|
UndirectedNode<T, NodeType>::UndirectedNode(T value, NodeType* left, NodeType* right){
|
||||||
this->value = value;
|
this->value = value;
|
||||||
this->next = next;
|
this->next = next;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
namespace Datastructures {
|
namespace Datastructures {
|
||||||
|
template <typename T>
|
||||||
class LinkedList
|
class LinkedList
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -9,12 +10,4 @@ namespace Datastructures {
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
LinkedList::LinkedList()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
LinkedList::~LinkedList()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -2,6 +2,16 @@
|
|||||||
|
|
||||||
namespace Datastructures {
|
namespace Datastructures {
|
||||||
namespace Nodes {
|
namespace Nodes {
|
||||||
|
template <typename T>
|
||||||
|
LinkedListNode<T>::LinkedListNode(T value, LinkedListNode<T>* next) {
|
||||||
|
this->value = value;
|
||||||
|
this->next = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Creates a new node, returning a pointer to a stack allocated object
|
||||||
|
template <typename T>
|
||||||
|
LinkedListNode<T>* LinkedListNode<T>::create(T value, LinkedListNode<T>* next) {
|
||||||
|
return new LinkedListNode(value, next);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,12 +4,14 @@
|
|||||||
namespace Datastructures {
|
namespace Datastructures {
|
||||||
namespace Nodes {
|
namespace Nodes {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class LinkedListNode : public Generic::UndirectedNode<T, LinkedListNode>
|
class LinkedListNode : public Generic::UndirectedNode<T, LinkedListNode<T>>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LinkedListNode();
|
LinkedListNode(T value, LinkedListNode<T>* next = nullptr);
|
||||||
~LinkedListNode();
|
~LinkedListNode();
|
||||||
|
|
||||||
|
LinkedListNode* create(T value, LinkedListNode<T>* next = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user