Library 3

fixed memory leak issues + optimization
This commit is contained in:
Alessandro Ferro 2021-05-08 01:08:12 +02:00
parent c32e658308
commit 2e4f7c3de8
3 changed files with 11 additions and 5 deletions

View File

@ -142,7 +142,11 @@ BinaryTreeLnk<Data>& BinaryTreeLnk<Data>::operator=(BinaryTreeLnk<Data>&& tree)
template <typename Data>
bool BinaryTreeLnk<Data>::operator==(const BinaryTreeLnk<Data>& tree) const noexcept{
if(size == tree.size){
return (Root() == tree.Root());
}else{
return false;
}
}
template <typename Data>

View File

@ -105,6 +105,7 @@ BinaryTreeVec<Data>::~BinaryTreeVec(){
template <typename Data>
BinaryTreeVec<Data>& BinaryTreeVec<Data>::operator=(const BinaryTreeVec<Data>& bt){
Clear();
size = bt.size;
tree.Resize(size);
for(ulong i=0 ; i<size ; ++i){
@ -116,6 +117,7 @@ BinaryTreeVec<Data>& BinaryTreeVec<Data>::operator=(const BinaryTreeVec<Data>& b
template <typename Data>
BinaryTreeVec<Data>& BinaryTreeVec<Data>::operator=(BinaryTreeVec<Data>&& bt) noexcept{
Clear();
std::swap(size, bt.size);
std::swap(tree, bt.tree);
for(ulong i=0 ; i<size ; ++i){

View File

@ -15,10 +15,10 @@ using namespace std;
void lasdtest() {
cout << endl << "~*~#~*~ Welcome to the LASD Test Suite ~*~#~*~ " << endl;
//testSimpleExercise1();
//testFullExercise1();
//testSimpleExercise2();
//testFullExercise2();
testSimpleExercise1();
testFullExercise1();
testSimpleExercise2();
testFullExercise2();
testSimpleExercise3();
testFullExercise3();
cout << endl << "Goodbye!" << endl;