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:
parent
e76f3b452e
commit
7a75d22514
@ -132,12 +132,6 @@
|
|||||||
<ClInclude Include="src\LinkedList\linkedlist.h" />
|
<ClInclude Include="src\LinkedList\linkedlist.h" />
|
||||||
<ClInclude Include="src\LinkedList\linkedlistnode.h" />
|
<ClInclude Include="src\LinkedList\linkedlistnode.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="src\Generic\directednode.cpp" />
|
|
||||||
<ClCompile Include="src\Generic\undirectednode.cpp" />
|
|
||||||
<ClCompile Include="src\LinkedList\linkedlist.cpp" />
|
|
||||||
<ClCompile Include="src\LinkedList\linkedlistnode.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
@ -28,18 +28,4 @@
|
|||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="src\Generic\directednode.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Generic\undirectednode.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\LinkedList\linkedlist.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\LinkedList\linkedlistnode.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
@ -8,8 +8,9 @@ namespace Datastructures {
|
|||||||
public:
|
public:
|
||||||
LinkedList();
|
LinkedList();
|
||||||
~LinkedList();
|
~LinkedList();
|
||||||
|
|
||||||
private:
|
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>>
|
class LinkedListNode : public Generic::UndirectedNode<T, LinkedListNode<T>>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LinkedListNode(T value, std::shared_ptr<LinkedListNode<T>> next = nullptr);
|
//Inherit Constructor from generic Undirectetd Node
|
||||||
~LinkedListNode();
|
using Generic::UndirectedNode<T, LinkedListNode<T>>::UndirectedNode;
|
||||||
|
|
||||||
std::shared_ptr<LinkedListNode<T>> create(T value, std::shared_ptr<LinkedListNode<T>> next = nullptr);
|
std::shared_ptr<LinkedListNode<T>> create(T value, std::shared_ptr<LinkedListNode<T>> next = nullptr);
|
||||||
|
|
||||||
private:
|
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
|
//Creates a new node, returning a smart pointer to a stack allocated object
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::shared_ptr<LinkedListNode<T>> LinkedListNode<T>::create(T value, std::shared_ptr<LinkedListNode<T>> next) {
|
std::shared_ptr<LinkedListNode<T>> LinkedListNode<T>::create(T value, std::shared_ptr<LinkedListNode<T>> next) {
|
||||||
|
Loading…
Reference in New Issue
Block a user