From 8f7716bc2d8a94dbba79b33365f22b72fa9e25a1 Mon Sep 17 00:00:00 2001 From: Alessandro Ferro <49845537+xfarrow@users.noreply.github.com> Date: Sun, 13 Jun 2021 12:07:06 +0200 Subject: [PATCH] Library 5 added some comments --- librerie/exercise5/matrix/csr/matrixcsr.cpp | 8 ++++---- librerie/exercise5/matrix/csr/matrixcsr.hpp | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/librerie/exercise5/matrix/csr/matrixcsr.cpp b/librerie/exercise5/matrix/csr/matrixcsr.cpp index affbfa3..41bc3e6 100755 --- a/librerie/exercise5/matrix/csr/matrixcsr.cpp +++ b/librerie/exercise5/matrix/csr/matrixcsr.cpp @@ -27,7 +27,7 @@ MatrixCSR::MatrixCSR(const MatrixCSR& toCopy) : MatrixCSR(toCopy.rows, toC in this way: The row index is represented by "i" (the variable that iterates over the R array), meanwhile the column index is represented by the second element in the pair of the node. - The actual element is stored in the first element in the pair of the node. + The current element is stored in the first element in the pair of the node. The update of the newely created R array is left to operator()(). */ for(ulong i=0 ; i < (toCopy.R.Size()-1) ; ++i){ @@ -150,15 +150,15 @@ void MatrixCSR::RowResize(const ulong& new_row_size){ template void MatrixCSR::ColumnResize(const ulong& new_column_size){ if(new_column_size < columns){ - Node** prev; + Node** prev; // in case an element must be deleted, this is its previous element. Node* toDelete; Node** toModify; for(ulong i=0 ; ivalue).second < new_column_size){ - prev = &( (*(*ptr)).next ); + prev = &( (*(*ptr)).next ); // This, alongside line 157 is redundant, but maybe it gives more clarity ptr = &( (*(*ptr)).next); }else{ toDelete = *ptr; diff --git a/librerie/exercise5/matrix/csr/matrixcsr.hpp b/librerie/exercise5/matrix/csr/matrixcsr.hpp index 6ae30e5..5279dd8 100755 --- a/librerie/exercise5/matrix/csr/matrixcsr.hpp +++ b/librerie/exercise5/matrix/csr/matrixcsr.hpp @@ -13,6 +13,12 @@ namespace lasd { +/* +** Although MatrixCSR inherits from List, it's not safe to use List methods here. +** For example, insertAtBack() is both a logical (why would you need to create +** a separate case for inserting at back in a matrix?) and a functional problem +** (the tail gets never updated). +*/ template class MatrixCSR : virtual public List>, virtual public Matrix{ // Must extend Matrix