Updated Linked List - Added append function (Doesn't have access to Node member variables)

This commit is contained in:
2022-11-13 14:34:00 +00:00
parent 462d1ccc83
commit 05d637acb5
5 changed files with 47 additions and 21 deletions

View File

@ -36,5 +36,20 @@ namespace Datastructures {
mTail = mHead;
}
template <typename T>
LinkedList<T>::~LinkedList() {}
template <typename T>
void LinkedList<T>::append(T value) {
mCount++;
if (mCount == 0) {
mHead = std::make_shared<Nodes::LinkedListNode<T>>(value);
mTail = mHead;
return;
}
//Add new node and set to tail.
(*mTail).mNext = std::make_shared<Nodes::LinkedListNode<T>>(value);
mTail = (*mTail).mNext;
}
}

View File

@ -9,7 +9,8 @@ namespace Datastructures {
public:
//Inherit Constructor and destructor from generic Undirectetd Node
using Generic::UndirectedNode<T, LinkedListNode<T>>::UndirectedNode;
using Generic::UndirectedNode<T, LinkedListNode<T>>::~UndirectedNode;
template <typename T>
friend class LinkedList;
private:
};
}