diff --git a/librerie/exercise3/binarytree/binarytree.cpp b/librerie/exercise3/binarytree/binarytree.cpp index 45ef9b8..b616cb7 100755 --- a/librerie/exercise3/binarytree/binarytree.cpp +++ b/librerie/exercise3/binarytree/binarytree.cpp @@ -75,41 +75,49 @@ bool BinaryTree::operator!=(const BinaryTree& toCompare) const noexcept{ template void BinaryTree::MapPreOrder(const typename MappableContainer::MapFunctor function, void* par){ + if(size == 0) return; MapPreOrder(function, par, &Root()); } template void BinaryTree::MapPostOrder(const typename MappableContainer::MapFunctor function, void* par){ + if(size == 0) return; MapPostOrder(function, par, &Root()); } template void BinaryTree::MapInOrder(const typename MappableContainer::MapFunctor function, void* par){ + if(size == 0) return; MapInOrder(function, par, &Root()); } template void BinaryTree::MapBreadth(const typename MappableContainer::MapFunctor function, void* par){ + if(size == 0) return; MapBreadth(function, par, &Root()); } template void BinaryTree::FoldPreOrder(const typename FoldableContainer::FoldFunctor function, const void* par, void* acc) const{ + if(size == 0) return; FoldPreOrder(function, par, acc, &Root()); } template void BinaryTree::FoldPostOrder(const typename FoldableContainer::FoldFunctor function, const void* par, void* acc) const{ + if(size == 0) return; FoldPostOrder(function, par, acc, &Root()); } template void BinaryTree::FoldInOrder(const typename FoldableContainer::FoldFunctor function, const void* par, void* acc) const{ + if(size == 0) return; FoldInOrder(function, par, acc, &Root()); } template void BinaryTree::FoldBreadth(const typename FoldableContainer::FoldFunctor function, const void* par, void* acc) const{ + if(size == 0) return; FoldBreadth(function, par, acc, &Root()); }