LO27/LibAutomaton/CellElement.h

180 lines
3.1 KiB
C

#ifndef CELLELMNT_H
#define CELLELMNT_H
/*---bool---
*@true : 1
*@false : 0
*/
typedef enum Bool{
true = 1,
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 {
int colIndex;
int rowIndex;
struct cellElement * nextCol;
struct cellElement * nextRow;
};
typedef struct cellElement cellElement;
/*---CreateCellElem---
*Allocates a cellElement and returns it
*
*@return : pointer on the allocated cellElement
*
*/
cellElement * CreateCellElem();
/*---AddNextCol---
*Allocates a cellElement and sets it as the NextCol of the tree
*
*@tree : pointer on an allocated cellElement
*
*@return ; error codes
*
*/
int AddNextCol(cellElement* tree);
/*---AddNextRow---
*Allocates a cellElement and sets it as the NextRow of the tree
*
*@tree : a pointer on an allocated cellElement
*
*@return : error codes
*
*/
int AddNextRow(cellElement* tree);
/*---removeNextCol---
*Free the nextCol cellElement of the tree
*
*@tree : a pointer on an allocated cellElement
*
*/
void removeNextCol(cellElement* tree);
/*---removeNextRow---
*Free the nextRow cellElement of the tree
*
*@tree : a pointer on an allocated cellElement
*
*/
void removeNextRow(cellElement* tree);
/*---FreeCellElem---
*Frees a cellElement and returns it
*
*@element : pointer on the allocated cellElement
*
*/
void FreeCellElement(cellElement* element);
/*---is_leaf---
*Checks is the tree is a leaf
*
*@tree : a pointer on an allocated cellElement
*
*@return : a bool
*
*/
bool is_leaf(cellElement* tree);
/*---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
*
*/
int SetPositionIndex(cellElement* elem,int Col,int Row);
/*---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
*
*/
int SetNextCol(cellElement* tree,cellElement* elem);
/*---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
*
*/
int SetNextRow(cellElement* tree,cellElement* elem);
void recursivePrint(cellElement * tree);
/**
* 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);
/**
* Apply XOR operator to a bool a and a bool b
* @param a a bool
* @param b a bool
* @return result a and b
*/
bool XOR(bool a, bool b);
/**
* Return false if the bool is ERROR
* @param x a bool
* @return result a bool
*/
bool ErrorToFalse(bool x);
#endif