Updated Linked List to inherit generic constructors.
Not sure how the create method will integrate. Might integrate it into the linked list class so that it can just append it straight into the relevant node.
This commit is contained in:
@ -8,8 +8,9 @@ namespace Datastructures {
|
||||
public:
|
||||
LinkedList();
|
||||
~LinkedList();
|
||||
|
||||
private:
|
||||
|
||||
Nodes::LinkedListNode<T> mHead;
|
||||
Nodes::LinkedListNode<T> mTail;
|
||||
int mCount;
|
||||
};
|
||||
}
|
@ -7,21 +7,12 @@ namespace Datastructures {
|
||||
class LinkedListNode : public Generic::UndirectedNode<T, LinkedListNode<T>>
|
||||
{
|
||||
public:
|
||||
LinkedListNode(T value, std::shared_ptr<LinkedListNode<T>> next = nullptr);
|
||||
~LinkedListNode();
|
||||
|
||||
//Inherit Constructor from generic Undirectetd Node
|
||||
using Generic::UndirectedNode<T, LinkedListNode<T>>::UndirectedNode;
|
||||
std::shared_ptr<LinkedListNode<T>> create(T value, std::shared_ptr<LinkedListNode<T>> next = nullptr);
|
||||
|
||||
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) {
|
||||
|
Reference in New Issue
Block a user