32 lines
610 B
C
32 lines
610 B
C
#ifndef TREE_H
|
|
#define TREE_H
|
|
typedef struct tnode_ tnode_t;
|
|
typedef struct tnode_* tnode_ptr;
|
|
typedef enum { INT, UINT, CHAR, FLOAT, DOUBLE, CHAR_PTR, VOID_PTR } tnode_value_t;
|
|
|
|
typedef struct tnode_ {
|
|
int type;
|
|
union {
|
|
int vi;
|
|
unsigned int vui;
|
|
char vc;
|
|
float vf;
|
|
double vd;
|
|
char* vcp;
|
|
void *vptr;
|
|
};
|
|
tnode_ptr parent;
|
|
tnode_ptr left_leaf;
|
|
tnode_ptr right_leaf;
|
|
} tnode_t;
|
|
|
|
|
|
tnode_t* tree_root(tnode_t* leaf)
|
|
{
|
|
tnode_t* current = leaf;
|
|
|
|
while(current = current->parent && current->parent);
|
|
return current;
|
|
}
|
|
|
|
#endif //TREE_H
|