-2005-07-08
Files | |
| file | eg_ebtree.ex.c |
| file | eg_ebtree.h |
Data Structures | |
| struct | EGeBTree_t |
| Basic structure of a tree node, note that a node in a tree is in itself a (sub)tree. More... | |
Defines | |
| #define | EG_EBTREE_LEFT 1 |
| Left Child Index. | |
| #define | EG_EBTREE_PARENT 0 |
| Parent index. | |
| #define | EG_EBTREE_RIGHT 2 |
| Right Child Index. | |
| #define | EGeBTreeAddLeft(parent, child) |
| Add a left child to a node in a tree. | |
| #define | EGeBTreeAddRight(parent, child) |
| Add a right child to a node in a tree. | |
| #define | EGeBTreeClear(tn) |
| Free any internal memory (not allocated by the user) related to this structure. | |
| #define | EGeBTreeCut(member) |
| Cut the given node from the tree containing it (and so create a sub-tree). | |
| #define | EGeBTreeDel(leaf) |
| Erase a leaf node from a tree. | |
| #define | EGeBTreeGetFirst(node) |
| return the first node in the (sub-)tree (according to the in-order). | |
| #define | EGeBTreeGetLast(node) |
| return the last node in the (sub-)tree (according to the in-order). | |
| #define | EGeBTreeGetLeft(member) ((member)->cn[EG_EBTREE_LEFT]) |
| #define | EGeBTreeGetNext(node) |
| return the successor of the given node in it's tree according to the in-order ordering. | |
| #define | EGeBTreeGetParent(member) ((member)->cn[EG_EBTREE_PARENT]) |
| #define | EGeBTreeGetPrev(node) |
| return the predecesor of the given node in it's tree according to the in-order ordering. | |
| #define | EGeBTreeGetRight(member) ((member)->cn[EG_EBTREE_RIGHT]) |
| #define | EGeBTreeGetRoot(member) |
| return the root of the tree containing the given tree node. | |
| #define | EGeBTreeInit(tn) (*(tn) = (EGeBTree_t){{0,0,0}}) |
| Initialize a tree structure. It let it as a tree containing only itself. and allocate any internal memory (not allocated by the user). | |
| #define | EGeBTreeReplace(old, replacement) |
| Replace a node in a tree. | |
| #define | EGeBTreeReset(tn) EGeBTreeInit(tn) |
| Let a tree just as after an init call. | |
Typedefs | |
| typedef EGeBTree_t | EGeBTree_t |
| Basic structure of a tree node, note that a node in a tree is in itself a (sub)tree. | |
Functions | |
| static int | ebt_display (FILE *out_f, EGeBTree_t *root) |
| display the given tree in-order. | |
| static int | ebt_parseargs (int argc, char **argv, unsigned int *s, unsigned int *z) |
| parse external arguments. | |
| static void | ebt_usage (char const *const program) |
| usage function, if we give the wrong number of parameters, we return an error message and print a help. | |
| int | main (int argc, char **argv) |
| Tester program for the projection structure and functions. | |
Variables | |
| static int | verbose = 0 |
|
|
Left Child Index.
Definition at line 50 of file eg_ebtree.h. |
|
|
Parent index.
Definition at line 46 of file eg_ebtree.h. |
|
|
Right Child Index.
Definition at line 54 of file eg_ebtree.h. |
|
|
Value: ({\
EGeBTree_t*const __EGeparent = (parent);\
EGeBTree_t*const __EGechild = (child);\
__EGeparent->cn[EG_EBTREE_LEFT] ? (fprintf(stderr,"Can't add left child to "#parent" because it already has a left child, in %s:%s:%d\n",__func__,__FILE__,__LINE__),1): (__EGeparent->cn[EG_EBTREE_LEFT] = __EGechild, __EGechild->cn[EG_EBTREE_PARENT] = __EGeparent, 0);})
Definition at line 105 of file eg_ebtree.h. |
|
|
Value: ({\
EGeBTree_t*const __EGeparent = (parent);\
EGeBTree_t*const __EGechild = (child);\
__EGeparent->cn[EG_EBTREE_RIGHT] ? (fprintf(stderr,"Can't add right child to "#parent" because it already has a right child, in %s:%s:%d\n",__func__,__FILE__,__LINE__),1): (__EGeparent->cn[EG_EBTREE_RIGHT] = __EGechild, __EGechild->cn[EG_EBTREE_PARENT] = __EGeparent, 0);})
Definition at line 116 of file eg_ebtree.h. |
|
|
Free any internal memory (not allocated by the user) related to this structure.
Definition at line 97 of file eg_ebtree.h. |
|
|
Value: ({\
EGeBTree_t*const __EGeroot = (member);\
EGeBTree_t*const __EGepar = __EGeroot->cn[EG_EBTREE_PARENT];\
if(__EGepar) \
{\
__EGeroot->cn[EG_EBTREE_PARENT] = 0; \
if(__EGepar->cn[EG_EBTREE_LEFT] == __EGeroot)\
__EGepar->cn[EG_EBTREE_LEFT] = 0;\
else __EGepar->cn[EG_EBTREE_RIGHT] = 0;\
}\
0;})
Definition at line 292 of file eg_ebtree.h. |
|
|
Value: ({\
EGeBTree_t*const __EGelf = (leaf);\
EGeBTree_t*const __EGepar = __EGelf->cn[EG_EBTREE_PARENT];\
int __rval = 0;\
if(__EGelf->cn[EG_EBTREE_LEFT] || __EGelf->cn[EG_EBTREE_RIGHT]) __rval = 1;\
else if(__EGepar)\
{\
if(__EGepar->cn[EG_EBTREE_LEFT] == __EGelf) \
__EGepar->cn[EG_EBTREE_LEFT] = 0;\
else __EGepar->cn[EG_EBTREE_RIGHT] = 0;\
}\
__rval;})
Definition at line 273 of file eg_ebtree.h. |
|
|
Value: ({\
EGeBTree_t* __EGecn = (node);\
while(__EGecn->cn[EG_EBTREE_LEFT]) __EGecn = __EGecn->cn[EG_EBTREE_LEFT];\
__EGecn;})
Definition at line 252 of file eg_ebtree.h. |
|
|
Value: ({\
EGeBTree_t* __EGecn = (node);\
while(__EGecn->cn[EG_EBTREE_RIGHT]) __EGecn = __EGecn->cn[EG_EBTREE_RIGHT];\
__EGecn;})
Definition at line 262 of file eg_ebtree.h. |
|
|
Definition at line 135 of file eg_ebtree.h. |
|
|
Value: ({\
EGeBTree_t* __EGexn = (node);\
EGeBTree_t* __EGecn = __EGexn->cn[EG_EBTREE_RIGHT];\
if(__EGecn) while(__EGecn->cn[EG_EBTREE_LEFT])\
__EGecn = __EGecn->cn[EG_EBTREE_LEFT];\
else do __EGecn = __EGexn->cn[EG_EBTREE_PARENT]; while(__EGecn && \
__EGecn->cn[EG_EBTREE_RIGHT] == __EGexn && (__EGexn = __EGecn));\
__EGecn;})
Definition at line 204 of file eg_ebtree.h. |
|
|
Definition at line 127 of file eg_ebtree.h. |
|
|
Value: ({\
EGeBTree_t* __EGexn = (node);\
EGeBTree_t* __EGecn = __EGexn->cn[EG_EBTREE_LEFT];\
if(__EGecn) while(__EGecn->cn[EG_EBTREE_RIGHT])\
__EGecn = __EGecn->cn[EG_EBTREE_RIGHT];\
else do __EGecn = __EGexn->cn[EG_EBTREE_PARENT]; while(__EGecn && \
__EGecn->cn[EG_EBTREE_LEFT] == __EGexn && (__EGexn = __EGecn));\
__EGecn;})
Definition at line 238 of file eg_ebtree.h. |
|
|
Definition at line 143 of file eg_ebtree.h. |
|
|
Value: ({\
EGeBTree_t*__EGeroot = (member);\
while(__EGeroot->cn[EG_EBTREE_PARENT]) \
__EGeroot = __EGeroot->cn[EG_EBTREE_PARENT];\
__EGeroot;})
Definition at line 150 of file eg_ebtree.h. |
|
|
Initialize a tree structure. It let it as a tree containing only itself. and allocate any internal memory (not allocated by the user).
Definition at line 81 of file eg_ebtree.h. |
|
|
Value: ({\
EGeBTree_t*const __EGeold = (old);\
EGeBTree_t*const __EGenew = (replacement);\
EGeBTree_t*const __EGepar = __EGeold->cn[EG_EBTREE_PARENT];\
EGeBTree_t*const __EGelft = __EGeold->cn[EG_EBTREE_LEFT];\
EGeBTree_t*const __EGergt = __EGeold->cn[EG_EBTREE_RIGHT];\
*__EGenew = *__EGeold;\
if(__EGepar)\
{\
if(__EGepar->cn[EG_EBTREE_LEFT] == __EGeold)\
__EGepar->cn[EG_EBTREE_LEFT] = __EGenew;\
else __EGepar->cn[EG_EBTREE_RIGHT] = __EGenew;\
}\
if(__EGelft) __EGelft->cn[EG_EBTREE_PARENT] = __EGenew;\
if(__EGergt) __EGergt->cn[EG_EBTREE_PARENT] = __EGenew;\
0;})
Definition at line 162 of file eg_ebtree.h. |
|
|
Let a tree just as after an init call.
Definition at line 89 of file eg_ebtree.h. |
|
|
Basic structure of a tree node, note that a node in a tree is in itself a (sub)tree.
|
|
||||||||||||
|
display the given tree in-order.
Definition at line 104 of file eg_ebtree.ex.c. |
|
||||||||||||||||||||
|
parse external arguments.
Definition at line 59 of file eg_ebtree.ex.c. Here is the call graph for this function: ![]() |
|
|
usage function, if we give the wrong number of parameters, we return an error message and print a help.
Definition at line 40 of file eg_ebtree.ex.c. |
|
||||||||||||
|
Tester program for the projection structure and functions.
Definition at line 139 of file eg_ebtree.ex.c. Here is the call graph for this function: ![]() |
|
|
Definition at line 34 of file eg_ebtree.ex.c. |
1.4.5