1
0
mirror of https://gitlab.com/klmp200/LO27.git synced 2024-11-22 11:13:20 +00:00

Renommage de fonction et plus de doc

This commit is contained in:
Antoine Bartuccio 2017-01-02 00:37:47 +01:00
parent 4648c34686
commit ec0f959f5e
7 changed files with 48 additions and 56 deletions

View File

@ -22,7 +22,7 @@
#include <stdlib.h>
#include <CellElement.h>
cellElement * CreateCellElem(){
cellElement * createCellElem(){
cellElement * elem = NULL;
elem = (cellElement*) malloc(sizeof(cellElement));
if (elem == NULL){
@ -35,7 +35,7 @@ cellElement * CreateCellElem(){
return elem;
}
bool is_leaf(cellElement* tree){
bool isLeaf(cellElement* tree){
if (tree->nextCol == NULL && tree->nextRow == NULL){
return true;
} else {
@ -43,7 +43,7 @@ bool is_leaf(cellElement* tree){
}
}
int SetPositionIndex(cellElement* elem,int Col,int Row){
int setPositionIndex(cellElement* elem,int Col,int Row){
if (elem != NULL){
elem->colIndex = Col;
elem->rowIndex = Row;
@ -53,7 +53,7 @@ int SetPositionIndex(cellElement* elem,int Col,int Row){
return 1;
}
int SetNextCol(cellElement* tree,cellElement* elem){
int setNextCol(cellElement* tree,cellElement* elem){
if (tree->nextCol == NULL){
tree->nextCol = elem;
}else{
@ -62,7 +62,7 @@ int SetNextCol(cellElement* tree,cellElement* elem){
return 1;
}
int SetNextRow(cellElement* tree,cellElement* elem){
int setNextRow(cellElement* tree,cellElement* elem){
if (tree->nextRow == NULL){
tree->nextRow = elem;
}else{
@ -71,30 +71,30 @@ int SetNextRow(cellElement* tree,cellElement* elem){
return 1;
}
int AddNextCol(cellElement* tree){
int addNextCol(cellElement* tree){
cellElement * elem = NULL;
elem = CreateCellElem();
elem = createCellElem();
if (elem == NULL){
return -1;
}
return(SetNextCol(tree,elem));
return(setNextCol(tree,elem));
}
int AddNextRow(cellElement* tree){
int addNextRow(cellElement* tree){
cellElement * elem = NULL;
elem = CreateCellElem();
elem = createCellElem();
if (elem == NULL){
return -1;
}
return(SetNextRow(tree,elem));
return(setNextRow(tree,elem));
}
@ -119,7 +119,7 @@ void removeNextRow(cellElement* tree){
void recursivePrint(cellElement * tree){
if (tree != NULL){
printf("Elem : x: %d y: %d \n",tree->colIndex,tree->rowIndex);
if (is_leaf(tree)){
if (isLeaf(tree)){
printf("leaf\n");
} else {
if (tree->nextCol != NULL){
@ -132,7 +132,7 @@ void recursivePrint(cellElement * tree){
}
}
void FreeCellElement(cellElement* element) {
void freeCellElement(cellElement* element) {
if (element != NULL){
free(element);
@ -167,7 +167,7 @@ bool XOR(bool a, bool b){
}
}
bool ErrorToFalse(bool x){
bool errorToFalse(bool x){
if (x == ERROR){
return false;
}

View File

@ -48,7 +48,7 @@ typedef enum Bool{
* @param nextCol is pointer on the next cellElement in the same column
* @param nextRow is pointer on the next cellElement in the same row
*
* @see CreateCellElem to allocate one and FreeCellElement to free one
* @see createCellElem to allocate one and freeCellElement to free one
*/
struct cellElement {
@ -67,7 +67,7 @@ typedef struct cellElement cellElement;
* @return pointer on the allocated cellElement
*
*/
cellElement * CreateCellElem();
cellElement * createCellElem();
/**
@ -78,7 +78,7 @@ cellElement * CreateCellElem();
* @return int error codes
*
*/
int AddNextCol(cellElement* tree);
int addNextCol(cellElement* tree);
/**
@ -89,13 +89,12 @@ int AddNextCol(cellElement* tree);
* @return int error codes
*
*/
int AddNextRow(cellElement* tree);
int addNextRow(cellElement* tree);
/**
* Free the nextCol cellElement of the tree
*
* @param tree is a pointer on an allocated cellElement
* @return void
*
*/
void removeNextCol(cellElement* tree);
@ -104,7 +103,6 @@ void removeNextCol(cellElement* tree);
* Free the nextRow cellElement of the tree
*
* @param tree is a pointer on an allocated cellElement
* @return void
*
*/
void removeNextRow(cellElement* tree);
@ -114,10 +112,9 @@ void removeNextRow(cellElement* tree);
* Frees a cellElement and returns it
*
* @param element is pointer on the allocated cellElement
* @return void
*
*/
void FreeCellElement(cellElement* element);
void freeCellElement(cellElement* element);
/**
@ -125,10 +122,10 @@ void FreeCellElement(cellElement* element);
*
* @param tree is a pointer on an allocated cellElement
*
* @return a bool (true/false)
* @return bool (true/false)
*
*/
bool is_leaf(cellElement* tree);
bool isLeaf(cellElement* tree);
/**
@ -141,7 +138,7 @@ bool is_leaf(cellElement* tree);
* @return int error codes
*
*/
int SetPositionIndex(cellElement* elem,int Col,int Row);
int setPositionIndex(cellElement* elem,int Col,int Row);
/**
* Allows you to set the nextCol of the cellElement tree
@ -152,7 +149,7 @@ int SetPositionIndex(cellElement* elem,int Col,int Row);
* @return int error codes
*
*/
int SetNextCol(cellElement* tree,cellElement* elem);
int setNextCol(cellElement* tree,cellElement* elem);
/**
* Allows you to set the nextRow of the cellElement elem
@ -163,14 +160,13 @@ int SetNextCol(cellElement* tree,cellElement* elem);
* @return int error codes
*
*/
int SetNextRow(cellElement* tree,cellElement* elem);
int setNextRow(cellElement* tree,cellElement* elem);
/**
* A debug function that recursively prints a tree, don't use it in not tree structured cellElements (may cause endless loops)
*
* @param tree a pointer on a cell element
*
* @return void
*/
void recursivePrint(cellElement * tree);
@ -181,7 +177,7 @@ void recursivePrint(cellElement * tree);
* @param a a bool
* @param b a bool
*
* @return result a or b
* @return bool
*/
bool OR(bool a, bool b);
@ -191,7 +187,7 @@ bool OR(bool a, bool b);
* @param a a bool
* @param b a bool
*
* @return result a and b
* @return bool
*/
bool AND(bool a, bool b);
@ -201,7 +197,7 @@ bool AND(bool a, bool b);
* @param a a bool
* @param b a bool
*
* @return result a and b
* @return bool
*/
bool XOR(bool a, bool b);
@ -210,8 +206,8 @@ bool XOR(bool a, bool b);
*
* @param x a bool
*
* @return result a bool
* @return bool
*/
bool ErrorToFalse(bool x);
bool errorToFalse(bool x);
#endif

View File

@ -148,7 +148,7 @@ int popPtnList(List *list, ListElement *element){
}
if (element->data != NULL){
FreeCellElement(element->data);
freeCellElement(element->data);
}
free(element);
list->size = list->size - 1;

View File

@ -87,8 +87,8 @@ bool createMatrixElem(Matrix matrix, int ColPos, int RowPos){
if (matrix.colCount <= ColPos || matrix.rowCount <= RowPos ){
return ERROR;
}
elem = CreateCellElem();
SetPositionIndex(elem,ColPos,RowPos);
elem = createCellElem();
setPositionIndex(elem,ColPos,RowPos);
Row = getElementPos(matrix.rows,RowPos);
if (Row != NULL && Row->data != NULL){
@ -144,7 +144,7 @@ bool createMatrixElem(Matrix matrix, int ColPos, int RowPos){
if (error != 0){
FreeCellElement(elem);
freeCellElement(elem);
return true;
}else{
return false;
@ -234,7 +234,7 @@ int deleteMatrixElem(Matrix matrix, int ColPos, int RowPos){
removeElementPos(matrix.cols,ColPos);
}
FreeCellElement(elem);
freeCellElement(elem);
return 1;
}
@ -516,39 +516,39 @@ bool MXOR(int n, bool bools[]){
}
bool firstRule(Matrix m, int ColPos, int RowPos){
return ErrorToFalse(getCellValue(m, ColPos, RowPos));
return errorToFalse(getCellValue(m, ColPos, RowPos));
}
bool leftRule(Matrix m, int ColPos, int RowPos){
return ErrorToFalse(getCellValue(m, ColPos + 1, RowPos));
return errorToFalse(getCellValue(m, ColPos + 1, RowPos));
}
bool rightRule(Matrix m, int ColPos, int RowPos){
return ErrorToFalse(getCellValue(m, ColPos - 1, RowPos));
return errorToFalse(getCellValue(m, ColPos - 1, RowPos));
}
bool topRule(Matrix m, int ColPos, int RowPos){
return ErrorToFalse(getCellValue(m, ColPos, RowPos + 1));
return errorToFalse(getCellValue(m, ColPos, RowPos + 1));
}
bool bottomRule(Matrix m, int ColPos, int RowPos){
return ErrorToFalse(getCellValue(m, ColPos, RowPos - 1));
return errorToFalse(getCellValue(m, ColPos, RowPos - 1));
}
bool topLeftRule(Matrix m, int ColPos, int RowPos){
return ErrorToFalse(getCellValue(m, ColPos + 1, RowPos + 1));
return errorToFalse(getCellValue(m, ColPos + 1, RowPos + 1));
}
bool topRightRule(Matrix m, int ColPos, int RowPos){
return ErrorToFalse(getCellValue(m, ColPos - 1, RowPos + 1));
return errorToFalse(getCellValue(m, ColPos - 1, RowPos + 1));
}
bool bottomLeftRule(Matrix m, int ColPos, int RowPos){
return ErrorToFalse(getCellValue(m, ColPos + 1, RowPos - 1));
return errorToFalse(getCellValue(m, ColPos + 1, RowPos - 1));
}
bool bottomRightRule(Matrix m, int ColPos, int RowPos){
return ErrorToFalse(getCellValue(m, ColPos - 1, RowPos - 1));
return errorToFalse(getCellValue(m, ColPos - 1, RowPos - 1));
}
bool * getFromRules(Matrix m, int ColPos, int RowPos, int n, int rules[]){

View File

@ -87,8 +87,6 @@ BooleanMatrix randomizeBooleanMatrix(BooleanMatrix matrix);
* Free a BooleanMatrix
*
* @param matrix a BooleanMatrix
*
* @return void
*/
void freeBooleanMatrix(BooleanMatrix matrix);
@ -197,8 +195,6 @@ Matrix setMatrixDim(Matrix matrix,int nbCols,int nbRows);
*
* @param matrix the Matrix
*
* @return void
*
*/
void printMatrix(Matrix matrix);

View File

@ -37,7 +37,7 @@ int main(){
Matrix m2;
BooleanMatrix bmatrix;
useSDL = inputYesOrNo("Do you want to use SDL library for matrix display ?");
useSDL = inputYesOrNo("Do you want to use SDL library for matrix display ( interesting for big matrix only ) ?");
printf("A random matrix will be generated\n");
printf("Enter the number of columns of this matrix\n");
col = safeNumberInput(1, 30000);

View File

@ -88,8 +88,8 @@ createMatrixElem( matrix:Matrix, ColPos:integer, RowPos:integer):bool
createMatrixElem <- ERROR /* out of bounds */
endif
elem <- CreateCellElem()
SetPositionIndex(elem,ColPos,RowPos)
elem <- createCellElem()
setPositionIndex(elem,ColPos,RowPos)
Row <- getElementPos(rows(matrix),RowPos)
if (Row != NULL AND data(Row) != NULL)
@ -156,7 +156,7 @@ createMatrixElem( matrix:Matrix, ColPos:integer, RowPos:integer):bool
if (error != 0)
/* if the element already exists, free it */
FreeCellElement(elem)
freeCellElement(elem)
createMatrixElem <- true
else
createMatrixElem <- false
@ -247,7 +247,7 @@ BEGIN
removeElementPos(cols(matrix),ColPos)
endif
FreeCellElement(elem)
freeCellElement(elem)
deleteMatrixElem <- 1
END