Library 3

added node-level operations in mytests and fixed error
This commit is contained in:
Alessandro Ferro
2021-05-09 22:23:09 +02:00
parent 33106bcee2
commit a66d40aab3
4 changed files with 111 additions and 30 deletions

View File

@ -245,7 +245,10 @@ void BinaryTree<Data>::FoldBreadth(const typename FoldableContainer<Data>::FoldF
template <typename Data>
BTPreOrderIterator<Data>::BTPreOrderIterator(const BinaryTree<Data>& tree){
curr = &tree.Root();
if(tree.Size() > 0)
curr = &tree.Root();
else
curr = nullptr;
}
template <typename Data>
@ -345,7 +348,10 @@ struct BinaryTree<Data>::Node* BTPostOrderIterator<Data>::DeepestLeftLeaf(struct
template <typename Data>
BTPostOrderIterator<Data>::BTPostOrderIterator(const BinaryTree<Data>& tree){
curr = DeepestLeftLeaf(&tree.Root());
if(tree.Size() > 0)
curr = DeepestLeftLeaf(&tree.Root());
else
curr = nullptr;
}
template <typename Data>
@ -441,7 +447,10 @@ struct BinaryTree<Data>::Node* BTInOrderIterator<Data>::MostLeftNode(struct Bina
template <typename Data>
BTInOrderIterator<Data>::BTInOrderIterator(const BinaryTree<Data>& tree){
curr = MostLeftNode(tree.Root());
if(tree.Size() > 0)
curr = MostLeftNode(tree.Root());
else
curr = nullptr;
}
template <typename Data>
@ -518,7 +527,10 @@ void BTInOrderIterator<Data>::operator++(){
template <typename Data>
BTBreadthIterator<Data>::BTBreadthIterator(const BinaryTree<Data>& tree){
curr = &(tree.Root());
if(tree.Size() > 0)
curr = &(tree.Root());
else
curr = nullptr;
}
template <typename Data>