diff --git a/DataStructures/src/LinkedList/linkedlist.h b/DataStructures/src/LinkedList/linkedlist.h index b522f4e..3fde77c 100644 --- a/DataStructures/src/LinkedList/linkedlist.h +++ b/DataStructures/src/LinkedList/linkedlist.h @@ -7,10 +7,34 @@ namespace Datastructures { { public: LinkedList(); + LinkedList(T value); ~LinkedList(); + void append(T value); + bool insert(T value, int index); + bool remove(int index); + int count() const; + private: - Nodes::LinkedListNode mHead; - Nodes::LinkedListNode mTail; + std::shared_ptr> mHead; + std::shared_ptr> mTail; int mCount; }; + + //Generic Class constructor for the Linked List + template + LinkedList::LinkedList() { + mCount = 0; + mHead = nullptr; + mTail = nullptr; + } + + //Class constructor for the Linked List, taking a preset value to go into the head of the list + template + LinkedList::LinkedList(T value) { + mCount = 1; + mHead = std::make_shared>(value); + mTail = mHead; + } + + } \ No newline at end of file diff --git a/DataStructures/src/LinkedList/linkedlistnode.h b/DataStructures/src/LinkedList/linkedlistnode.h index 78c3630..9e5e734 100644 --- a/DataStructures/src/LinkedList/linkedlistnode.h +++ b/DataStructures/src/LinkedList/linkedlistnode.h @@ -7,16 +7,10 @@ namespace Datastructures { class LinkedListNode : public Generic::UndirectedNode> { public: - //Inherit Constructor from generic Undirectetd Node + //Inherit Constructor and destructor from generic Undirectetd Node using Generic::UndirectedNode>::UndirectedNode; - std::shared_ptr> create(T value, std::shared_ptr> next = nullptr); + using Generic::UndirectedNode>::~UndirectedNode; private: }; - - //Creates a new node, returning a smart pointer to a stack allocated object - template - std::shared_ptr> LinkedListNode::create(T value, std::shared_ptr> next) { - return std::make_shared>(value, next); - } } } \ No newline at end of file