Added Create method to Linked List Node
This commit is contained in:
parent
9ec4e515f2
commit
deb58f03bb
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
namespace Datastructures {
|
||||
template <typename T>
|
||||
class LinkedList
|
||||
{
|
||||
public:
|
||||
@ -9,12 +10,4 @@ namespace Datastructures {
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
LinkedList::LinkedList()
|
||||
{
|
||||
}
|
||||
|
||||
LinkedList::~LinkedList()
|
||||
{
|
||||
}
|
||||
}
|
@ -2,6 +2,16 @@
|
||||
|
||||
namespace Datastructures {
|
||||
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 Nodes {
|
||||
template <typename T>
|
||||
class LinkedListNode : public Generic::UndirectedNode<T, LinkedListNode>
|
||||
class LinkedListNode : public Generic::UndirectedNode<T, LinkedListNode<T>>
|
||||
{
|
||||
public:
|
||||
LinkedListNode();
|
||||
LinkedListNode(T value, LinkedListNode<T>* next = nullptr);
|
||||
~LinkedListNode();
|
||||
|
||||
LinkedListNode* create(T value, LinkedListNode<T>* next = nullptr);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user