1
0
mirror of https://gitlab.com/klmp200/LO27.git synced 2024-11-19 13:03:20 +00:00
LO27/LibAutomaton/CellElement.h

165 lines
2.9 KiB
C
Raw Normal View History

#ifndef CELLELMNT_H
#define CELLELMNT_H
/*---bool---
*@true : 1
*@false : 0
*/
typedef enum Bool{
2016-12-10 04:04:13 +00:00
true = 1,
2016-12-24 12:53:04 +00:00
false = 0,
ERROR = -1
} bool;
/*---cellElement---
*A cell of the matrix
*
*@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
int colIndex;
int rowIndex;
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-12-10 23:33:02 +00:00
/*---FreeCellElem---
*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-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-26 17:16:37 +00:00
/**
* Apply OR operator to a bool a and a bool b
* @param a a bool
* @param b a bool
* @return result a or b
*/
bool OR(bool a, bool b);
/**
* Apply AND operator to a bool a and a bool b
* @param a a bool
* @param b a bool
* @return result a and b
*/
bool AND(bool a, bool b);
2016-12-10 04:04:13 +00:00
#endif