Library 5

bugfix
This commit is contained in:
Alessandro Ferro 2021-06-10 18:04:44 +02:00
parent 4d524d6df2
commit e9091bd403
3 changed files with 14 additions and 5 deletions

View File

@ -1,7 +1,7 @@
#! /bin/bash
g++-10 -g -o main \
g++ -O3 -o main \
zlasdtest/exercise1/simpletest.cpp zlasdtest/exercise1/fulltest.cpp \
zlasdtest/exercise2/simpletest.cpp zlasdtest/exercise2/fulltest.cpp \
zlasdtest/exercise3/simpletest.cpp zlasdtest/exercise3/fulltest.cpp \

View File

@ -73,13 +73,22 @@ MatrixCSR<Data>& MatrixCSR<Data>::operator=(MatrixCSR<Data>&& toMove) noexcept{
std::swap(size, toMove.size);
std::swap(head, toMove.head);
std::swap(R, toMove.R);
toMove.R.Resize(1);
toMove.R[0] = &toMove.head;
Node** oldHead = R[0];
// Fix of the R vector after the swap, both in (*this) and in toMove
Node** oldHead;
oldHead = R[0];
for(ulong i=0 ; i<R.Size() && R[i]==oldHead; ++i){
R[i] = &head;
}
oldHead = toMove.R[0];
for(ulong j=0 ; j<toMove.R.Size() && toMove.R[j]==oldHead ; ++j){
toMove.R[j] = &(toMove.head);
}
return *this;
}

View File

@ -594,7 +594,7 @@ string generateRandomString(ulong dim){
ulong getDimension(){
ulong dimension;
std::cout<<" How many elements you'd like to insert? ";
std::cout<<" How many elements would you like to insert? ";
std::cin>>dimension;
return dimension;
}