2016-12-13 14:55:42 +00:00
|
|
|
#ifndef MTRXGAUD_H
|
|
|
|
#define MTRXGAUD_H
|
|
|
|
|
|
|
|
#include <CellElement.h>
|
|
|
|
#include <list.h>
|
|
|
|
|
|
|
|
/*---Matrix---
|
2016-12-13 14:12:55 +00:00
|
|
|
*Abstract type that describe a boolean matrix
|
2016-12-13 14:55:42 +00:00
|
|
|
*
|
|
|
|
*@colCount : the number of columns of the matrix
|
|
|
|
*@rowIndex : the number of rows of the matrix
|
|
|
|
*
|
|
|
|
*@rows : pointer on the first row that contains a true value
|
|
|
|
*@cols : pointer on the first col that contains a true value
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
typedef struct Matrix {
|
|
|
|
|
|
|
|
int colCount;
|
|
|
|
int rowCount;
|
|
|
|
|
|
|
|
List *cols;
|
|
|
|
List *rows;
|
|
|
|
|
|
|
|
}Matrix;
|
|
|
|
|
|
|
|
|
|
|
|
/*---applyRules---
|
|
|
|
*A function tha allows you to apply some rules n times on the matrix and returns it
|
|
|
|
*
|
|
|
|
*@matrix : A matrix on whitch you would apply the rules
|
|
|
|
*
|
|
|
|
*@Rules : Integer describing the rules
|
|
|
|
*
|
|
|
|
*@N : number of time the rules will be applied
|
|
|
|
*
|
|
|
|
*/
|
2016-12-13 16:28:13 +00:00
|
|
|
Matrix applyRules(Matrix matrix,int Rules, int N);
|
|
|
|
|
2016-12-23 22:58:08 +00:00
|
|
|
/**
|
|
|
|
*Create a void Matrix
|
|
|
|
*
|
|
|
|
*@return a matrix
|
|
|
|
*
|
|
|
|
*/
|
2016-12-13 16:28:13 +00:00
|
|
|
Matrix CreateMatrix();
|
2016-12-13 14:55:42 +00:00
|
|
|
|
2016-12-23 22:58:08 +00:00
|
|
|
/**
|
|
|
|
*Find and return the cell in the given matrix
|
|
|
|
*
|
|
|
|
*@param matrix the Matrix where we search
|
|
|
|
*@param ColPos an int indicating the column of the cell
|
|
|
|
*@param RowPos an int indicating the row of the cell
|
|
|
|
*
|
|
|
|
*@return a cellElement
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
cellElement * FindMatrixElem(Matrix matrix, int ColPos, int RowPos);
|
|
|
|
|
|
|
|
/**
|
|
|
|
*Create the cell in the given matrix
|
|
|
|
*
|
|
|
|
*@param matrix the Matrix
|
|
|
|
*@param ColPos an int indicating the column of the cell
|
|
|
|
*@param RowPos an int indicating the row of the cell
|
|
|
|
*
|
2016-12-24 15:41:06 +00:00
|
|
|
*@return a bool (error code)
|
2016-12-23 22:58:08 +00:00
|
|
|
*
|
|
|
|
*/
|
2016-12-24 12:53:04 +00:00
|
|
|
bool CreateMatrixElem(Matrix matrix, int ColPos, int RowPos);
|
2016-12-23 22:58:08 +00:00
|
|
|
|
2016-12-24 15:41:06 +00:00
|
|
|
/**
|
|
|
|
*Delete the cell in the given matrix
|
|
|
|
*
|
|
|
|
*@param matrix the Matrix
|
|
|
|
*@param ColPos an int indicating the column of the cell
|
|
|
|
*@param RowPos an int indicating the row of the cell
|
|
|
|
*
|
|
|
|
*@return an error code (int)
|
|
|
|
*
|
|
|
|
*/
|
2016-12-23 22:58:08 +00:00
|
|
|
int SupprMatrixElem(Matrix matrix, int ColPos, int RowPos);
|
|
|
|
|
2016-12-24 15:41:06 +00:00
|
|
|
/**
|
|
|
|
*Delete or create the cell in the given matrix to fit the value
|
|
|
|
*
|
|
|
|
*@param matrix the Matrix
|
|
|
|
*@param ColPos an int indicating the column of the cell
|
|
|
|
*@param RowPos an int indicating the row of the cell
|
|
|
|
*
|
|
|
|
*@return an error code (bool)
|
|
|
|
*
|
|
|
|
*/
|
2016-12-24 12:53:04 +00:00
|
|
|
bool SetCellValue(Matrix matrix, int ColPos, int RowPos, bool value);
|
2016-12-23 22:58:08 +00:00
|
|
|
|
2016-12-24 15:41:06 +00:00
|
|
|
/**
|
|
|
|
*Checks out the value of the cell in the given matrix
|
|
|
|
*
|
|
|
|
*@param matrix the Matrix
|
|
|
|
*@param ColPos an int indicating the column of the cell
|
|
|
|
*@param RowPos an int indicating the row of the cell
|
|
|
|
*
|
|
|
|
*@return the value (bool)
|
|
|
|
*
|
|
|
|
*/
|
2016-12-23 22:58:08 +00:00
|
|
|
bool GetCellValue(Matrix matrix, int ColPos, int RowPos);
|
2016-12-24 12:53:04 +00:00
|
|
|
|
2016-12-25 23:13:06 +00:00
|
|
|
/**
|
|
|
|
*Set the number of columns and rows of the matrix and returns it
|
|
|
|
*
|
|
|
|
*@param matrix the Matrix
|
|
|
|
*@param nbCols an int indicating the number of columns
|
|
|
|
*@param nbRows an int indicating the number of rows
|
|
|
|
*
|
|
|
|
*@return the matrix
|
|
|
|
*
|
|
|
|
*/
|
2016-12-24 14:18:19 +00:00
|
|
|
Matrix SetMatrixDim(Matrix matrix,int nbCols,int nbRows);
|
|
|
|
|
2016-12-25 23:13:06 +00:00
|
|
|
/**
|
|
|
|
*Basically print the Matrix in the standard output
|
|
|
|
*
|
|
|
|
*@param matrix the Matrix
|
|
|
|
*
|
|
|
|
*@return void
|
|
|
|
*
|
|
|
|
*/
|
2016-12-24 14:18:19 +00:00
|
|
|
void BasicPrintMatrix(Matrix matrix);
|
2016-12-24 12:53:04 +00:00
|
|
|
|
2016-12-25 23:06:54 +00:00
|
|
|
bool RecursiveFreeCol(Matrix matrix, cellElement * elem);
|
|
|
|
|
2016-12-24 15:07:50 +00:00
|
|
|
Matrix freeMatrix(Matrix matrix);
|
|
|
|
|
2016-12-25 23:06:54 +00:00
|
|
|
|
2016-12-13 14:55:42 +00:00
|
|
|
#endif
|
2016-12-13 14:12:55 +00:00
|
|
|
|