Compare commits

..

No commits in common. "23e7860e43ec61f115054611d293435e1615993e" and "05d637acb5699444bd96490016ec374a267f8496" have entirely different histories.

4 changed files with 15 additions and 12 deletions

View File

@ -8,17 +8,17 @@ namespace Generic {
public: public:
DirectedNode(T value, std::shared_ptr<NodeType> left = nullptr, std::shared_ptr<NodeType> right = nullptr); DirectedNode(T value, std::shared_ptr<NodeType> left = nullptr, std::shared_ptr<NodeType> right = nullptr);
~DirectedNode(); ~DirectedNode();
T value;
std::shared_ptr<NodeType> left;
std::shared_ptr<NodeType> right;
protected: protected:
T mValue;
std::shared_ptr<NodeType> mLeft;
std::shared_ptr<NodeType> mRight;
}; };
template <typename T, typename NodeType> template <typename T, typename NodeType>
DirectedNode<T, NodeType>::DirectedNode(T value, std::shared_ptr<NodeType> left, std::shared_ptr<NodeType> right) { DirectedNode<T, NodeType>::DirectedNode(T value, std::shared_ptr<NodeType> left, std::shared_ptr<NodeType> right) {
this->value = value; this->mValue = value;
this->left = left; this->mLeft = left;
this->right = right; this->mRight = right;
} }
template <typename T, typename NodeType> template <typename T, typename NodeType>

View File

@ -8,14 +8,15 @@ namespace Generic {
public: public:
UndirectedNode(T value, std::shared_ptr<NodeType> next = nullptr); UndirectedNode(T value, std::shared_ptr<NodeType> next = nullptr);
~UndirectedNode(); ~UndirectedNode();
T value; protected:
std::shared_ptr<NodeType> next; T mValue;
std::shared_ptr<NodeType> mNext;
}; };
template <typename T, typename NodeType> template <typename T, typename NodeType>
UndirectedNode<T, NodeType>::UndirectedNode(T value, std::shared_ptr<NodeType> next) { UndirectedNode<T, NodeType>::UndirectedNode(T value, std::shared_ptr<NodeType> next) {
this->value = value; this->mValue = value;
this->next = next; this->mNext = next;
} }
template <typename T, typename NodeType> template <typename T, typename NodeType>

View File

@ -49,7 +49,7 @@ namespace Datastructures {
} }
//Add new node and set to tail. //Add new node and set to tail.
(*mTail).next = std::make_shared<Nodes::LinkedListNode<T>>(value); (*mTail).mNext = std::make_shared<Nodes::LinkedListNode<T>>(value);
mTail = (*mTail).next; mTail = (*mTail).mNext;
} }
} }

View File

@ -9,6 +9,8 @@ namespace Datastructures {
public: public:
//Inherit Constructor and destructor from generic Undirectetd Node //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: private:
}; };
} }