Library 3

cleaner code
This commit is contained in:
Alessandro Ferro
2021-05-05 22:37:45 +02:00
parent 2b6dcf6700
commit 8e56f33808
8 changed files with 138 additions and 271 deletions

View File

@ -1,7 +1,8 @@
namespace lasd {
/* ************************************************************************** */
/* ----- begin of struct NodeVec ----- */
template <typename Data>
BinaryTreeVec<Data>::NodeVec::NodeVec(Data& dat, ulong idx, BinaryTreeVec<Data>* ref){
data = dat;
@ -64,6 +65,10 @@ struct BinaryTree<Data>::Node& BinaryTreeVec<Data>::NodeVec::RightChild() const{
throw std::out_of_range("Right child does not exist!");
}
/* ----- end of struct NodeVec ----- */
/* ----- begin of class BinaryTreeVec ----- */
template <typename Data>
BinaryTreeVec<Data>::BinaryTreeVec(const LinearContainer<Data>& lc){
tree.Resize(lc.Size());
@ -137,6 +142,7 @@ bool BinaryTreeVec<Data>::operator!=(const BinaryTreeVec& bt) const noexcept{
template <typename Data>
struct BinaryTree<Data>::Node& BinaryTreeVec<Data>::Root() const{
if(size==0) throw std::length_error("Empty tree!");
return *(tree.Front());
}