mirror of
https://github.com/xfarrow/lasd.git
synced 2025-06-05 21:49:14 +02:00
Library 5
bugfix
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
g++-10 -g -o main \
|
g++ -g -o main \
|
||||||
zlasdtest/exercise1/simpletest.cpp zlasdtest/exercise1/fulltest.cpp \
|
zlasdtest/exercise1/simpletest.cpp zlasdtest/exercise1/fulltest.cpp \
|
||||||
zlasdtest/exercise2/simpletest.cpp zlasdtest/exercise2/fulltest.cpp \
|
zlasdtest/exercise2/simpletest.cpp zlasdtest/exercise2/fulltest.cpp \
|
||||||
zlasdtest/exercise3/simpletest.cpp zlasdtest/exercise3/fulltest.cpp \
|
zlasdtest/exercise3/simpletest.cpp zlasdtest/exercise3/fulltest.cpp \
|
||||||
|
@@ -61,18 +61,27 @@ MatrixCSR<Data>::~MatrixCSR(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
MatrixCSR<Data>& MatrixCSR<Data>::operator=(const MatrixCSR& toCopy){
|
MatrixCSR<Data>& MatrixCSR<Data>::operator=(const MatrixCSR<Data>& toCopy){
|
||||||
MatrixCSR<Data>* tmp = new MatrixCSR<Data>(toCopy);
|
MatrixCSR<Data> tmp(toCopy);
|
||||||
std::swap(*this, *tmp);
|
std::swap(tmp, *this);
|
||||||
delete tmp;
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Data>
|
template <typename Data>
|
||||||
MatrixCSR<Data>& MatrixCSR<Data>::operator=(MatrixCSR&& toMove) noexcept{
|
MatrixCSR<Data>& MatrixCSR<Data>::operator=(MatrixCSR<Data>&& toMove) noexcept{
|
||||||
MatrixCSR<Data>* tmp = new MatrixCSR<Data>(std::move(toMove));
|
Clear();
|
||||||
std::swap(*this, *tmp);
|
std::swap(rows, toMove.rows);
|
||||||
delete tmp;
|
std::swap(columns, toMove.columns);
|
||||||
|
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];
|
||||||
|
for(ulong i=0 ; i<R.Size() && R[i]==oldHead; ++i){
|
||||||
|
R[i] = &head;
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,15 +160,12 @@ void MatrixCSR<Data>::ColumnResize(const ulong& new_column_size){
|
|||||||
prev = &( (*(*ptr)).next );
|
prev = &( (*(*ptr)).next );
|
||||||
ptr = &( (*(*ptr)).next);
|
ptr = &( (*(*ptr)).next);
|
||||||
}else{
|
}else{
|
||||||
std::cout<<"\n\nSto cancellando "<<((*ptr)->value).first<<"\n\n";
|
|
||||||
toDelete = *ptr;
|
toDelete = *ptr;
|
||||||
toModify = &( (*(*ptr)).next );
|
toModify = &( (*(*ptr)).next );
|
||||||
*ptr = (*(*ptr)).next;
|
*ptr = (*(*ptr)).next;
|
||||||
delete toDelete;
|
delete toDelete;
|
||||||
--size;
|
--size;
|
||||||
|
|
||||||
//debug();
|
|
||||||
|
|
||||||
for(ulong j=i+1 ; j<R.Size() ; ++j){
|
for(ulong j=i+1 ; j<R.Size() ; ++j){
|
||||||
if(R[j] == toModify){
|
if(R[j] == toModify){
|
||||||
R[j] = prev;
|
R[j] = prev;
|
||||||
@@ -275,26 +281,26 @@ template <typename Data>
|
|||||||
void MatrixCSR<Data>::debug(){
|
void MatrixCSR<Data>::debug(){
|
||||||
std::cout<<std::endl;
|
std::cout<<std::endl;
|
||||||
|
|
||||||
// std::cout<<"rows: "<<rows<<" columns: "<<columns<<" size: "<<size<<"\n\n";
|
std::cout<<"rows: "<<rows<<" columns: "<<columns<<" size: "<<size<<"\n\n";
|
||||||
// Node* tmp = head;
|
Node* tmp = head;
|
||||||
//
|
|
||||||
// while(tmp!=nullptr){
|
while(tmp!=nullptr){
|
||||||
// std::cout<<(tmp->value).first<<"|"<< (tmp->value).second;
|
std::cout<<(tmp->value).first<<"|"<< (tmp->value).second;
|
||||||
// std::cout<<std::endl;
|
std::cout<<std::endl;
|
||||||
// std::cout<<&(tmp->next);
|
std::cout<<&(tmp->next);
|
||||||
//
|
|
||||||
// std::cout<<std::endl;
|
std::cout<<std::endl;
|
||||||
// std::cout<<std::endl;
|
std::cout<<std::endl;
|
||||||
//
|
|
||||||
// tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// std::cout << "R VECTOR:" << '\n';
|
std::cout << "R VECTOR:" << '\n';
|
||||||
// for(ulong i=0; i<R.Size();++i){
|
for(ulong i=0; i<R.Size();++i){
|
||||||
// std::cout << R[i] << '\n';
|
std::cout << R[i] << '\n';
|
||||||
// }
|
}
|
||||||
// std::cout<<std::endl;
|
std::cout<<std::endl;
|
||||||
// std::cout<<std::endl;
|
std::cout<<std::endl;
|
||||||
|
|
||||||
//// print
|
//// print
|
||||||
// for(int i=0; i<rows; ++i){
|
// for(int i=0; i<rows; ++i){
|
||||||
|
@@ -61,10 +61,10 @@ public: //CAMBIARE A PROTETTO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|||||||
/* ************************************************************************ */
|
/* ************************************************************************ */
|
||||||
|
|
||||||
// Copy assignment
|
// Copy assignment
|
||||||
MatrixCSR& operator=(const MatrixCSR&);
|
MatrixCSR& operator=(const MatrixCSR<Data>&);
|
||||||
|
|
||||||
// Move assignment
|
// Move assignment
|
||||||
MatrixCSR& operator=(MatrixCSR&&) noexcept;
|
MatrixCSR& operator=(MatrixCSR<Data>&&) noexcept;
|
||||||
|
|
||||||
/* ************************************************************************ */
|
/* ************************************************************************ */
|
||||||
|
|
||||||
|
@@ -78,7 +78,7 @@ void stestMatrixInt(Mat<long>& mat, uint& testnum, uint& testerr) {
|
|||||||
|
|
||||||
SetCell<long>(loctestnum, loctesterr, mat, true, 1, 4, 8);
|
SetCell<long>(loctestnum, loctesterr, mat, true, 1, 4, 8);
|
||||||
SetCell<long>(loctestnum, loctesterr, mat, true, 3, 4, 9); //33
|
SetCell<long>(loctestnum, loctesterr, mat, true, 3, 4, 9); //33
|
||||||
//mat.debug();
|
|
||||||
SetColumnNumber(loctestnum, loctesterr, mat, true, 3); //34
|
SetColumnNumber(loctestnum, loctesterr, mat, true, 3); //34
|
||||||
SetColumnNumber(loctestnum, loctesterr, mat, true, 4);
|
SetColumnNumber(loctestnum, loctesterr, mat, true, 4);
|
||||||
|
|
||||||
|
@@ -6,6 +6,21 @@
|
|||||||
#include<iostream>
|
#include<iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace lasd;
|
using namespace lasd;
|
||||||
|
|
||||||
|
|
||||||
|
void ciao (MatrixCSR<long>& a, MatrixCSR<long>& b)
|
||||||
|
{
|
||||||
|
std::cout << "A" << '\n';
|
||||||
|
MatrixCSR<long> c(std::move(a));
|
||||||
|
|
||||||
|
std::cout << "B" << '\n';
|
||||||
|
a=std::move(b);
|
||||||
|
a.debug();
|
||||||
|
|
||||||
|
std::cout << "C" << '\n';
|
||||||
|
b=std::move(c);
|
||||||
|
}
|
||||||
|
|
||||||
void menu(){
|
void menu(){
|
||||||
|
|
||||||
unsigned short int choice;
|
unsigned short int choice;
|
||||||
@@ -38,7 +53,7 @@ void menu(){
|
|||||||
|
|
||||||
mat.ColumnResize(2);
|
mat.ColumnResize(2);
|
||||||
|
|
||||||
mat.debug();
|
MatrixCSR<long> copmat;
|
||||||
|
copmat = std::move(mat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user