I'm coding the program that using linked list to store a sparse matrix. First I create a class "Node" contains the index of entry, value of entry and two pointers to next row and next column. Second I find on Google that I need to create the class Matrix like this code below but I don't understand the meaning of Node **rowList and node** columnList. Why they use a pointer to a pointer there and how could I implement a matrix from that? Thank you so much.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
class Node
{
public:
int iValue, jValue;
float value;
Node *rowPtr;
Node *colPtr;
};
class Matrix
{
Node **rowList; // rowList is the pointer to the array of rows
Node **columnList; // columnList is the pointer to the array of columns
int rows, cols; // number of rows and columns
}