1
0
mirror of https://gitlab.com/klmp200/LO27.git synced 2024-11-26 10:04:15 +00:00

Merge branch 'sli' into 'master'

Rebase and rebase

See merge request !3
This commit is contained in:
Antoine Bartuccio 2016-12-10 19:56:18 +00:00
commit 7e92854797
4 changed files with 143 additions and 15 deletions

View File

@ -1,14 +1,122 @@
/* /***
* @Author: klmp200 --- CellElemFunc ---
* @Date: 2016-12-10 01:32:50 ---Created by : Naej Doree ---
* @Last Modified by: klmp200 ***/
* @Last Modified time: 2016-12-10 04:29:48
*/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <CellElement.h> #include <CellElement.h>
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){
cellElement * elem = NULL;
elem = (cellElement*) malloc(sizeof(cellElement));
if (elem == NULL){
return -1;
}
printf("---insertNextCol---\n");
elem->value = true;
elem->nextCol = NULL;
elem->nextRow = NULL;
if (tree->nextCol == NULL){
tree->nextCol = elem;
}else{
return -2;
}
return 1;
}
int AddNextRow(cellElement* tree){
cellElement * elem = NULL;
elem = (cellElement*) malloc(sizeof(cellElement));
if (elem == NULL){
return -1;
}
printf("---insertNextRow---\n");
elem->value = true;
elem->nextRow = NULL;
elem->nextRow = NULL;
if (tree->nextRow == NULL){
tree->nextRow = elem;
}else{
return -2;
}
return 1;
}
void removeNextCol(cellElement* tree){
printf("---removeNextCol---\n");
if (tree->nextCol != NULL){
cellElement * elem = tree->nextCol;
free(elem);
elem = NULL;
tree->nextCol = NULL;
}
}
void removeNextRow(cellElement* tree){
printf("---removeNextRow---\n");
if (tree->nextRow != NULL){
cellElement* elem = tree->nextRow;
free(elem);
elem =NULL;
tree->nextRow = NULL;
}
}
void recursivePrint(cellElement * tree){
if (tree != NULL){
printf("Elem : x: %d y: %d \n",tree->colIndex,tree->rowIndex);
if (tree->nextCol != NULL){
recursivePrint(tree->nextCol);
}
if (tree->nextRow != NULL){
recursivePrint(tree->nextRow);
}
if (tree->nextCol == NULL && tree->nextCol == NULL){
printf("leaf\n");
}
}
}
void FreeCellElement(cellElement* element) { void FreeCellElement(cellElement* element) {
if (element != NULL){ if (element != NULL){
free(element); free(element);

View File

@ -37,8 +37,18 @@ struct cellElement {
struct cellElement * nextRow; struct cellElement * nextRow;
}; };
typedef struct cellElement * cellElement; typedef struct cellElement cellElement;
cellElement * CreateCellElem();
void freeCellElem(cellElement * elem);
int AddNextCol(cellElement* tree);
int AddNextRow(cellElement* tree);
void removeNextCol(cellElement* list);
void removeNextRow(cellElement* list);
void recursivePrint(cellElement * tree);
void FreeCellElement(cellElement* element); void FreeCellElement(cellElement* element);

View File

@ -17,15 +17,14 @@ SOURCECFILE=$(SOURCE:=.c)
SOURCEOFILE=$(SOURCE:=.o) SOURCEOFILE=$(SOURCE:=.o)
#Library variables #Library variables
DEPENDENCE=libCellElement.so # DEPENDENCE=libCellElement.so
DEPENDENCENAME=CellElement # DEPENDENCENAME=CellElement
DEPENDENCELIST=libList.so DEPENDENCELIST=libList.so
DEPENDENCENAMELIST=List DEPENDENCENAMELIST=List
all: $(TARGET) all: $(TARGET)
#Generating the main.exe #Generating the main.exe
$(TARGET): $(SOURCEOFILE) $(DEPENDENCELIST) lib $(TARGET): $(SOURCEOFILE) $(DEPENDENCELIST) lib
@echo "\n Generating the " $(TARGET) " binary" @echo "\n Generating the " $(TARGET) " binary"
@ -35,7 +34,7 @@ $(TARGET): $(SOURCEOFILE) $(DEPENDENCELIST) lib
lib: lib:
@echo "\n Generating the automaton library binary" @echo "\n Generating the automaton library binary"
mkdir -p Libs mkdir -p Libs
$(MAKE) -C LibCell # $(MAKE) -C LibCell
$(DEPENDENCELIST): $(DEPENDENCELIST):
@echo "\n Generating the list library binary" @echo "\n Generating the list library binary"
@ -54,4 +53,3 @@ clean:
rm -rf *.o ./Libs/*.so *.exe rm -rf *.o ./Libs/*.so *.exe
$(MAKE) -C LibCell clean $(MAKE) -C LibCell clean
$(MAKE) -C LibList clean $(MAKE) -C LibList clean

18
main.c
View File

@ -8,9 +8,21 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <CellElement.h>
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);
int main(int argc, char *argv[])
{
printf("Hello World\n");
return 0; return 0;
} }