From 0996ce834deca07fbf19d0b5de5f3c8b568185e6 Mon Sep 17 00:00:00 2001 From: Naej <0mindstorming@gmail.com> Date: Sat, 10 Dec 2016 02:42:03 +0100 Subject: [PATCH] Added funcs about CellElement --- CellElemFunc.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 CellElemFunc.c diff --git a/CellElemFunc.c b/CellElemFunc.c new file mode 100644 index 0000000..9032683 --- /dev/null +++ b/CellElemFunc.c @@ -0,0 +1,97 @@ +/*** +--- CellElemFunc --- +---Created by : Naej Doree --- +***/ + +#include +#include +#include + +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"); + } + + } +} \ No newline at end of file