mirror of
https://github.com/xfarrow/lasd.git
synced 2025-02-17 04:30:41 +01:00
parent
8e56f33808
commit
5e58c3e7f4
@ -30,14 +30,12 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
Data data;
|
Data data;
|
||||||
|
|
||||||
// Comparison operators
|
// Comparison operators
|
||||||
bool operator==(const Node&) const noexcept; // Comparison of abstract types is possible, but should not be visible.
|
bool operator==(const Node&) const noexcept; // Comparison of abstract types is possible, but should not be visible.
|
||||||
bool operator!=(const Node&) const noexcept; // Comparison of abstract types is possible, but should not be visible.
|
bool operator!=(const Node&) const noexcept; // Comparison of abstract types is possible, but should not be visible.
|
||||||
|
|
||||||
bool EqualNodes(const Node&, const Node&) const;
|
bool EqualNodes(const Node&, const Node&) const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
friend class BinaryTree<Data>;
|
friend class BinaryTree<Data>;
|
||||||
|
@ -151,7 +151,7 @@ bool BinaryTreeLnk<Data>::operator!=(const BinaryTreeLnk<Data>& tree) const noex
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
struct BinaryTree<Data>::Node& BinaryTreeLnk<Data>::Root() const{
|
struct BinaryTreeLnk<Data>::NodeLnk& BinaryTreeLnk<Data>::Root() const{
|
||||||
if(size==0) throw std::length_error("Empty tree!");
|
if(size==0) throw std::length_error("Empty tree!");
|
||||||
return *root;
|
return *root;
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,13 @@ class BinaryTreeLnk : virtual public BinaryTree<Data>{ // Must extend BinaryTree
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
struct NodeLnk : virtual protected BinaryTree<Data>::Node { // Must extend Node
|
struct NodeLnk : virtual public BinaryTree<Data>::Node { // Must extend Node
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
using BinaryTree<Data>::Node::data;
|
using BinaryTree<Data>::Node::data;
|
||||||
struct NodeLnk* left;
|
struct NodeLnk* left = nullptr;
|
||||||
struct NodeLnk* right;
|
struct NodeLnk* right = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct NodeLnk& operator=(const NodeLnk&); // Copy assignment of abstract types should not be possible.
|
struct NodeLnk& operator=(const NodeLnk&); // Copy assignment of abstract types should not be possible.
|
||||||
@ -56,7 +56,7 @@ public:
|
|||||||
|
|
||||||
// Specific member functions (inherited from BinaryTree)
|
// Specific member functions (inherited from BinaryTree)
|
||||||
|
|
||||||
struct BinaryTree<Data>::Node& Root() const override; // Override BinaryTree member (throw std::length_error when empty)
|
NodeLnk& Root() const override; // Override BinaryTree member (throw std::length_error when empty)
|
||||||
|
|
||||||
// Specific member functions (inherited from Container)
|
// Specific member functions (inherited from Container)
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ bool BinaryTreeVec<Data>::operator!=(const BinaryTreeVec& bt) const noexcept{
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
struct BinaryTree<Data>::Node& BinaryTreeVec<Data>::Root() const{
|
struct BinaryTreeVec<Data>::NodeVec& BinaryTreeVec<Data>::Root() const{
|
||||||
if(size==0) throw std::length_error("Empty tree!");
|
if(size==0) throw std::length_error("Empty tree!");
|
||||||
return *(tree.Front());
|
return *(tree.Front());
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ class BinaryTreeVec : virtual public BinaryTree<Data>{ // Must extend BinaryTree
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
struct NodeVec : virtual protected BinaryTree<Data>::Node { // Must extend Node
|
struct NodeVec : virtual public BinaryTree<Data>::Node { // Must extend Node
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
using BinaryTree<Data>::Node::data;
|
using BinaryTree<Data>::Node::data;
|
||||||
@ -54,7 +54,7 @@ public:
|
|||||||
|
|
||||||
// Specific member functions (inherited from BinaryTree)
|
// Specific member functions (inherited from BinaryTree)
|
||||||
|
|
||||||
struct BinaryTree<Data>::Node& Root() const override; // Override BinaryTree member (throw std::length_error when empty)
|
NodeVec& Root() const override; // Override BinaryTree member (throw std::length_error when empty)
|
||||||
|
|
||||||
// Specific member functions (inherited from Container)
|
// Specific member functions (inherited from Container)
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ void menu(){
|
|||||||
|
|
||||||
BinaryTreeLnk<string> bt1(vec);
|
BinaryTreeLnk<string> bt1(vec);
|
||||||
BinaryTreeLnk<string> bt2(vec);
|
BinaryTreeLnk<string> bt2(vec);
|
||||||
// if(bt1 == bt2) cout<<"uguali";
|
if(bt1 == bt2) cout<<"uguali";
|
||||||
|
else cout<<"NON UGUALI!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user