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

@ -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){