Updated Generic nodes to incorporate smart pointers
This commit is contained in:
parent
deb58f03bb
commit
2da0705577
@ -2,7 +2,7 @@
|
||||
|
||||
namespace Generic {
|
||||
template <typename T, typename NodeType>
|
||||
DirectedNode<T, NodeType>::DirectedNode(T value, NodeType* left, NodeType* right) {
|
||||
DirectedNode<T, NodeType>::DirectedNode(T value, std::shared_ptr<NodeType> left, std::shared_ptr<NodeType> right) {
|
||||
this->value = value;
|
||||
this->left = left;
|
||||
this->right = right;
|
||||
|
@ -1,15 +1,16 @@
|
||||
#pragma once
|
||||
#include <memory>
|
||||
|
||||
namespace Generic {
|
||||
template <typename T, typename NodeType>
|
||||
class DirectedNode
|
||||
{
|
||||
public:
|
||||
DirectedNode(T value, NodeType* left = nullptr, NodeType* right = nullptr);
|
||||
DirectedNode(T value, std::shared_ptr<NodeType> left = nullptr, std::shared_ptr<NodeType> right = nullptr);
|
||||
~DirectedNode();
|
||||
T value;
|
||||
NodeType* left;
|
||||
NodeType* right;
|
||||
std::shared_ptr<NodeType> left;
|
||||
std::shared_ptr<NodeType> right;
|
||||
private:
|
||||
|
||||
};
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace Generic {
|
||||
template <typename T, typename NodeType>
|
||||
UndirectedNode<T, NodeType>::UndirectedNode(T value, NodeType* left, NodeType* right){
|
||||
UndirectedNode<T, NodeType>::UndirectedNode(T value, std::shared_ptr<NodeType> left, std::shared_ptr<NodeType> right){
|
||||
this->value = value;
|
||||
this->next = next;
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
#pragma once
|
||||
#include <memory>
|
||||
|
||||
namespace Generic {
|
||||
template <typename T, typename NodeType>
|
||||
class UndirectedNode
|
||||
{
|
||||
public:
|
||||
UndirectedNode(T value, NodeType* left = nullptr, NodeType* right = nullptr);
|
||||
UndirectedNode(T value, std::shared_ptr<NodeType> left = nullptr, std::shared_ptr<NodeType> right = nullptr);
|
||||
~UndirectedNode();
|
||||
T value;
|
||||
NodeType* next;
|
||||
std::shared_ptr<NodeType> next;
|
||||
private:
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user