1
0
mirror of https://gitlab.com/klmp200/LO27.git synced 2024-11-23 06:53:19 +00:00

Added funcs about CellElement

This commit is contained in:
Naej 2016-12-10 02:42:03 +01:00 committed by klmp200
parent 1f9341efae
commit 0996ce834d

97
CellElemFunc.c Normal file
View File

@ -0,0 +1,97 @@
/***
--- CellElemFunc ---
---Created by : Naej Doree ---
***/
#include <stdio.h>
#include <stdlib.h>
#include <CellElement.h>
int main(int argc, char **argv){
}
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;
return 1;
}else{
return -2;
}
}
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;
return 1;
}else{
return -2;
}
}
void removeNextCol(cellElement* tree){
printf("---removeNextCol---\n");
if (tree->nextCol != NULL){
DLinkedListElement* elem = tree->nextCol;
free(elem);
elem =NULL;
}
}
void removeNextRow(cellElement* tree){
printf("---removeNextRow---\n");
if (tree->nextRow != NULL){
DLinkedListElement* elem = tree->nextRow;
free(elem);
elem =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);
}else if (tree->nextRow != NUll){
recursivePrint(tree->nextRow);
}else{
printf("leaf\n");
}
}
}