mirror of
https://gitlab.com/klmp200/LO27.git
synced 2024-11-23 02:43:19 +00:00
tests et complètion des fx
This commit is contained in:
parent
0996ce834d
commit
a99b593863
@ -8,14 +8,50 @@
|
|||||||
#include <CellElement.h>
|
#include <CellElement.h>
|
||||||
|
|
||||||
int main(int argc, char **argv){
|
int main(int argc, char **argv){
|
||||||
|
cellElement * tree = NULL;
|
||||||
|
tree = CreateCellElem();
|
||||||
|
tree->colIndex = 1;
|
||||||
|
AddNextRow(tree);
|
||||||
|
tree->nextRow->colIndex = 2;
|
||||||
|
AddNextCol(tree);
|
||||||
|
tree->nextCol->colIndex = 3;
|
||||||
|
recursivePrint(tree);
|
||||||
|
removeNextRow(tree);
|
||||||
|
removeNextCol(tree);
|
||||||
|
|
||||||
|
recursivePrint(tree);
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cellElement * CreateCellElem(){
|
||||||
|
cellElement * elem = NULL;
|
||||||
|
elem = (cellElement*) malloc(sizeof(cellElement));
|
||||||
|
|
||||||
|
if (elem == NULL){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("---Created cellElement---\n");
|
||||||
|
|
||||||
|
elem->value = true;
|
||||||
|
elem->nextCol = NULL;
|
||||||
|
elem->nextRow = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
return elem;
|
||||||
|
}
|
||||||
|
|
||||||
|
void freeCellElem(cellElement * elem){
|
||||||
|
free(elem);
|
||||||
|
elem = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int AddNextCol(cellElement* tree){
|
int AddNextCol(cellElement* tree){
|
||||||
|
|
||||||
cellElement elem = NULL;
|
cellElement * elem = NULL;
|
||||||
elem = (cellElement*) malloc(sizeof(cellElement));
|
elem = (cellElement*) malloc(sizeof(cellElement));
|
||||||
|
|
||||||
if (elem == NULL){
|
if (elem == NULL){
|
||||||
@ -27,19 +63,20 @@ int AddNextCol(cellElement* tree){
|
|||||||
elem->value = true;
|
elem->value = true;
|
||||||
elem->nextCol = NULL;
|
elem->nextCol = NULL;
|
||||||
elem->nextRow = NULL;
|
elem->nextRow = NULL;
|
||||||
|
|
||||||
if (tree->nextCol == NULL){
|
if (tree->nextCol == NULL){
|
||||||
tree->nextCol = elem;
|
tree->nextCol = elem;
|
||||||
return 1;
|
|
||||||
}else{
|
}else{
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int AddNextRow(cellElement* tree){
|
int AddNextRow(cellElement* tree){
|
||||||
|
|
||||||
cellElement elem = NULL;
|
cellElement * elem = NULL;
|
||||||
elem = (cellElement*) malloc(sizeof(cellElement));
|
elem = (cellElement*) malloc(sizeof(cellElement));
|
||||||
|
|
||||||
if (elem == NULL){
|
if (elem == NULL){
|
||||||
@ -53,19 +90,20 @@ int AddNextRow(cellElement* tree){
|
|||||||
elem->nextRow = NULL;
|
elem->nextRow = NULL;
|
||||||
if (tree->nextRow == NULL){
|
if (tree->nextRow == NULL){
|
||||||
tree->nextRow = elem;
|
tree->nextRow = elem;
|
||||||
return 1;
|
|
||||||
}else{
|
}else{
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeNextCol(cellElement* tree){
|
void removeNextCol(cellElement* tree){
|
||||||
printf("---removeNextCol---\n");
|
printf("---removeNextCol---\n");
|
||||||
|
|
||||||
if (tree->nextCol != NULL){
|
if (tree->nextCol != NULL){
|
||||||
DLinkedListElement* elem = tree->nextCol;
|
cellElement * elem = tree->nextCol;
|
||||||
free(elem);
|
free(elem);
|
||||||
elem =NULL;
|
elem = NULL;
|
||||||
|
tree->nextCol = NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,9 +113,10 @@ void removeNextRow(cellElement* tree){
|
|||||||
printf("---removeNextRow---\n");
|
printf("---removeNextRow---\n");
|
||||||
|
|
||||||
if (tree->nextRow != NULL){
|
if (tree->nextRow != NULL){
|
||||||
DLinkedListElement* elem = tree->nextRow;
|
cellElement* elem = tree->nextRow;
|
||||||
free(elem);
|
free(elem);
|
||||||
elem =NULL;
|
elem =NULL;
|
||||||
|
tree->nextRow = NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,11 +124,13 @@ void removeNextRow(cellElement* tree){
|
|||||||
void recursivePrint(cellElement * tree){
|
void recursivePrint(cellElement * tree){
|
||||||
if (tree != NULL){
|
if (tree != NULL){
|
||||||
printf("Elem : x: %d y: %d \n",tree->colIndex,tree->rowIndex);
|
printf("Elem : x: %d y: %d \n",tree->colIndex,tree->rowIndex);
|
||||||
if (tree->nextCol != NUll){
|
if (tree->nextCol != NULL){
|
||||||
recursivePrint(tree->nextCol);
|
recursivePrint(tree->nextCol);
|
||||||
}else if (tree->nextRow != NUll){
|
}
|
||||||
|
if (tree->nextRow != NULL){
|
||||||
recursivePrint(tree->nextRow);
|
recursivePrint(tree->nextRow);
|
||||||
}else{
|
}
|
||||||
|
if (tree->nextCol == NULL && tree->nextCol == NULL){
|
||||||
printf("leaf\n");
|
printf("leaf\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
CellElemFunc.o
Normal file
BIN
CellElemFunc.o
Normal file
Binary file not shown.
@ -7,7 +7,11 @@
|
|||||||
*@false : 0
|
*@false : 0
|
||||||
*/
|
*/
|
||||||
typedef enum Bool{
|
typedef enum Bool{
|
||||||
|
<<<<<<< 0996ce834deca07fbf19d0b5de5f3c8b568185e6:LibList/CellElement.h
|
||||||
|
|
||||||
|
=======
|
||||||
|
|
||||||
|
>>>>>>> tests et complètion des fx:CellElement.h
|
||||||
true = 1,
|
true = 1,
|
||||||
false = 0
|
false = 0
|
||||||
|
|
||||||
@ -39,6 +43,9 @@ struct cellElement {
|
|||||||
};
|
};
|
||||||
typedef struct cellElement cellElement;
|
typedef struct cellElement cellElement;
|
||||||
|
|
||||||
|
cellElement * CreateCellElem();
|
||||||
|
void freeCellElem(cellElement * elem);
|
||||||
|
|
||||||
int AddNextCol(cellElement* tree);
|
int AddNextCol(cellElement* tree);
|
||||||
int AddNextRow(cellElement* tree);
|
int AddNextRow(cellElement* tree);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user