mirror of
https://gitlab.com/klmp200/LO27.git
synced 2024-11-05 12:18:03 +00:00
97 lines
1.5 KiB
C
97 lines
1.5 KiB
C
/***
|
|
--- 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");
|
|
}
|
|
|
|
}
|
|
} |