mirror of https://github.com/xfarrow/lasd.git
parent
828a41dd72
commit
b7c12b8c8a
|
@ -61,9 +61,13 @@ const Data& BinaryTree<Data>::Node::Element() const{
|
|||
/* ----- end of struct Node ----- */
|
||||
|
||||
template <typename Data>
|
||||
bool BinaryTree<Data>::operator==(const BinaryTree& toCompare) const noexcept{
|
||||
if(size!=toCompare.size) return false;
|
||||
return(Root() == toCompare.Root());
|
||||
bool BinaryTree<Data>::operator==(const BinaryTree& tree) const noexcept{
|
||||
if(size == tree.size){
|
||||
if(size == 0) return true;
|
||||
else return (Root() == tree.Root());
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Data>
|
||||
|
|
|
@ -140,14 +140,15 @@ BinaryTreeLnk<Data>& BinaryTreeLnk<Data>::operator=(BinaryTreeLnk<Data>&& tree)
|
|||
return *this;
|
||||
}
|
||||
|
||||
/*
|
||||
** operator== and operator!= can be removed from BinaryTreeLnk since they are
|
||||
** inherited from BinaryTree. They're here just for clarity and because they're
|
||||
** in the template.
|
||||
** Maybe you can make them more optimized here.
|
||||
*/
|
||||
template <typename Data>
|
||||
bool BinaryTreeLnk<Data>::operator==(const BinaryTreeLnk<Data>& tree) const noexcept{
|
||||
if(size == tree.size){
|
||||
if(size == 0) return true;
|
||||
else return (Root() == tree.Root());
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
return (BinaryTree<Data>::operator==(tree));
|
||||
}
|
||||
|
||||
template <typename Data>
|
||||
|
|
|
@ -15,11 +15,10 @@ protected:
|
|||
protected:
|
||||
|
||||
using BinaryTree<Data>::Node::data;
|
||||
|
||||
public:
|
||||
struct NodeLnk* left = nullptr;
|
||||
struct NodeLnk* right = nullptr;
|
||||
|
||||
public:
|
||||
struct NodeLnk& operator=(const NodeLnk&); // Copy assignment of abstract types should not be possible.
|
||||
struct NodeLnk& operator=(NodeLnk&&) noexcept; // Move assignment of abstract types should not be possible.
|
||||
bool IsLeaf() const noexcept override; // (concrete function should not throw exceptions)
|
||||
|
|
Loading…
Reference in New Issue