2016-11-15 13:13:50 +00:00
|
|
|
#ifndef CELLELMNT_H
|
|
|
|
#define CELLELMNT_H
|
|
|
|
|
|
|
|
|
|
|
|
/*---bool---
|
|
|
|
*@true : 1
|
|
|
|
*@false : 0
|
|
|
|
*/
|
|
|
|
typedef enum Bool{
|
2016-12-10 04:04:13 +00:00
|
|
|
|
|
|
|
true = 1,
|
|
|
|
false = 0
|
2016-11-15 13:13:50 +00:00
|
|
|
|
|
|
|
} bool;
|
|
|
|
|
|
|
|
|
|
|
|
/*---cellElement---
|
2016-12-13 14:55:42 +00:00
|
|
|
*A cell of the matrix
|
2016-11-15 13:13:50 +00:00
|
|
|
*
|
|
|
|
*@colIndex : index (int) of the column of this cell
|
|
|
|
*@rowIndex : index (int) of the row of this cell
|
|
|
|
*
|
|
|
|
*@value : a boolean that is the content of the cell
|
|
|
|
*
|
|
|
|
*@nextCol : pointer on the next cellElement in the same column
|
|
|
|
*@nextRow : pointer on the next cellElement in the same row
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
struct cellElement {
|
2016-12-10 20:11:46 +00:00
|
|
|
|
2016-11-15 13:13:50 +00:00
|
|
|
int colIndex;
|
|
|
|
int rowIndex;
|
|
|
|
|
|
|
|
bool value;
|
|
|
|
|
|
|
|
struct cellElement * nextCol;
|
|
|
|
struct cellElement * nextRow;
|
|
|
|
|
|
|
|
};
|
2016-12-10 20:11:46 +00:00
|
|
|
typedef struct cellElement cellElement;
|
|
|
|
|
2016-12-10 23:33:02 +00:00
|
|
|
/*---CreateCellElem---
|
|
|
|
*Allocates a cellElement and returns it
|
|
|
|
*
|
|
|
|
*@return : pointer on the allocated cellElement
|
|
|
|
*
|
|
|
|
*/
|
2016-12-10 20:11:46 +00:00
|
|
|
cellElement * CreateCellElem();
|
|
|
|
|
2016-12-10 23:33:02 +00:00
|
|
|
|
|
|
|
/*---AddNextCol---
|
|
|
|
*Allocates a cellElement and sets it as the NextCol of the tree
|
|
|
|
*
|
2016-12-11 03:01:27 +00:00
|
|
|
*@tree : pointer on an allocated cellElement
|
|
|
|
*
|
|
|
|
*@return ; error codes
|
2016-12-10 23:33:02 +00:00
|
|
|
*
|
|
|
|
*/
|
2016-12-10 20:11:46 +00:00
|
|
|
int AddNextCol(cellElement* tree);
|
2016-12-10 23:33:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*---AddNextRow---
|
|
|
|
*Allocates a cellElement and sets it as the NextRow of the tree
|
|
|
|
*
|
2016-12-11 03:01:27 +00:00
|
|
|
*@tree : a pointer on an allocated cellElement
|
|
|
|
*
|
|
|
|
*@return : error codes
|
2016-12-10 23:33:02 +00:00
|
|
|
*
|
|
|
|
*/
|
2016-12-10 20:11:46 +00:00
|
|
|
int AddNextRow(cellElement* tree);
|
|
|
|
|
2016-12-10 23:33:02 +00:00
|
|
|
/*---removeNextCol---
|
|
|
|
*Free the nextCol cellElement of the tree
|
|
|
|
*
|
2016-12-11 03:01:27 +00:00
|
|
|
*@tree : a pointer on an allocated cellElement
|
2016-12-10 23:33:02 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
void removeNextCol(cellElement* tree);
|
|
|
|
|
|
|
|
/*---removeNextRow---
|
|
|
|
*Free the nextRow cellElement of the tree
|
|
|
|
*
|
2016-12-11 03:01:27 +00:00
|
|
|
*@tree : a pointer on an allocated cellElement
|
2016-12-10 23:33:02 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
void removeNextRow(cellElement* tree);
|
2016-11-15 13:13:50 +00:00
|
|
|
|
2016-12-10 23:33:02 +00:00
|
|
|
|
|
|
|
/*---FreeCellElem---
|
2016-12-23 22:58:08 +00:00
|
|
|
*Frees a cellElement and returns it
|
2016-12-10 23:33:02 +00:00
|
|
|
*
|
2016-12-11 03:01:27 +00:00
|
|
|
*@element : pointer on the allocated cellElement
|
2016-12-10 23:33:02 +00:00
|
|
|
*
|
|
|
|
*/
|
2016-12-10 04:04:13 +00:00
|
|
|
void FreeCellElement(cellElement* element);
|
2016-11-15 13:13:50 +00:00
|
|
|
|
2016-12-11 02:25:21 +00:00
|
|
|
|
2016-12-11 03:01:27 +00:00
|
|
|
/*---is_leaf---
|
|
|
|
*Checks is the tree is a leaf
|
|
|
|
*
|
|
|
|
*@tree : a pointer on an allocated cellElement
|
|
|
|
*
|
|
|
|
*@return : a bool
|
|
|
|
*
|
|
|
|
*/
|
2016-12-11 02:25:21 +00:00
|
|
|
bool is_leaf(cellElement* tree);
|
2016-12-11 03:01:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*---SetPositionIndex---
|
|
|
|
*Allows you to set the colIndex and the rowIndex of the cellElement elem
|
|
|
|
*
|
|
|
|
*@elem : a pointer on an allocated cellElement
|
|
|
|
*@Col : the value for colIndex
|
|
|
|
*@Row : the value for rowIndex
|
|
|
|
*
|
|
|
|
*@return : error codes
|
|
|
|
*
|
|
|
|
*/
|
2016-12-11 02:25:21 +00:00
|
|
|
int SetPositionIndex(cellElement* elem,int Col,int Row);
|
2016-12-11 03:01:27 +00:00
|
|
|
|
|
|
|
/*---SetNextCol---
|
|
|
|
*Allows you to set the nextCol of the cellElement tree
|
|
|
|
*
|
|
|
|
*@tree : a pointer on the element you want to set
|
|
|
|
*@elem : a pointer on a cellElement
|
|
|
|
*
|
|
|
|
*@return : error codes
|
|
|
|
*
|
|
|
|
*/
|
2016-12-11 02:25:21 +00:00
|
|
|
int SetNextCol(cellElement* tree,cellElement* elem);
|
2016-12-11 03:01:27 +00:00
|
|
|
|
|
|
|
/*---SetNextRow---
|
|
|
|
*Allows you to set the nextRow of the cellElement elem
|
|
|
|
*
|
|
|
|
*@tree : a pointer on the element you want to set
|
|
|
|
*@elem : a pointer on a cellElement
|
|
|
|
*
|
|
|
|
*@return : error codes
|
|
|
|
*
|
|
|
|
*/
|
2016-12-11 02:25:21 +00:00
|
|
|
int SetNextRow(cellElement* tree,cellElement* elem);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void recursivePrint(cellElement * tree);
|
|
|
|
|
2016-12-10 04:04:13 +00:00
|
|
|
#endif
|