Library 3

added tests on iterators, cleaner menu, fixes.
This commit is contained in:
Alessandro Ferro
2021-05-09 16:07:20 +02:00
parent 2e4f7c3de8
commit 33106bcee2
6 changed files with 128 additions and 36 deletions

View File

@ -50,7 +50,7 @@ bool BinaryTreeVec<Data>::NodeVec::HasRightChild() const noexcept{
}
template <typename Data>
struct BinaryTree<Data>::Node& BinaryTreeVec<Data>::NodeVec::LeftChild() const{
struct BinaryTreeVec<Data>::NodeVec& BinaryTreeVec<Data>::NodeVec::LeftChild() const{
if(index*2+1 < ReferenceToTree->size)
return *((ReferenceToTree->tree)[index*2+1]);
else
@ -58,7 +58,7 @@ struct BinaryTree<Data>::Node& BinaryTreeVec<Data>::NodeVec::LeftChild() const{
}
template <typename Data>
struct BinaryTree<Data>::Node& BinaryTreeVec<Data>::NodeVec::RightChild() const{
struct BinaryTreeVec<Data>::NodeVec& BinaryTreeVec<Data>::NodeVec::RightChild() const{
if(index*2+2 < ReferenceToTree->size)
return *((ReferenceToTree->tree)[index*2+2]);
else

View File

@ -26,8 +26,8 @@ protected:
bool IsLeaf() const noexcept override; // (concrete function should not throw exceptions)
bool HasLeftChild() const noexcept override; // (concrete function should not throw exceptions)
bool HasRightChild() const noexcept override; // (concrete function should not throw exceptions)
struct BinaryTree<Data>::Node& LeftChild() const override; // (concrete function must throw std::out_of_range when not existent)
struct BinaryTree<Data>::Node& RightChild() const override; // (concrete function must throw std::out_of_range when not existent)
struct NodeVec& LeftChild() const override; // (concrete function must throw std::out_of_range when not existent)
struct NodeVec& RightChild() const override; // (concrete function must throw std::out_of_range when not existent)
friend class BinaryTreeVec<Data>;
};