From b36cac388fb17a3bcfe27c9c47b4ae0e6da95f6b Mon Sep 17 00:00:00 2001 From: Alessandro Ferro <49845537+xfarrow@users.noreply.github.com> Date: Fri, 7 May 2021 08:07:17 +0200 Subject: [PATCH] Library 3 --- librerie/exercise3/binarytree/binarytree.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) 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()); }