I'm writing a sparse matrix class in C++ in which every row and column are arrays of linked lists from a class I created (aptly named: LinkedList).
I want to write a class that is a "smart" pointer to one cell in this matrix.
In that class, let say LIPointer
, I will implement a ++
operator function for moving in the linked lists of the matrix.
Is there an elegant way of doing this without moving the references of the matrix arrays and sized elements each time I create a linkedlistPointer
?
I can't use stl::array
etc. because I have to build them myself.
Here are the declarations:
class LinkedItem
{
private:
int Column, Row;
double Value;
LinkedItem* Right;
LinkedItem* Down;
public:
...
};
class SparseLinkedMatrix
{
private: //members
int ColSize;
int RowSize;
LinkedItem ** Columns;
LinkedItem ** Rows;
public: //functions
SparseLinkedMatrix();
...
};
class LIPointer;
private:
LinkedItem * CellPointer;
public:
LIPointer();
void operator++();//???
...
};
Any advice or direction would be appreciated.
Update: It needs to run on the whole matrix. That is why I think I need to move (by reference) the arrays and the size of the matrix. The intended effect is that this would from the last cell in the linked list of the first row to the first cell in the second row.