Changeset 39 for trunk/src/helpers/tree.c
- Timestamp:
- Feb 23, 2001, 7:50:07 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/tree.c
r38 r39 922 922 * as a data pointer to some structure for whatever you like. 923 923 * 924 * WARNING: This function recurses and can use up a lot of 925 * stack. For very deep trees, traverse the tree using 926 * treeFirst and treeNext instead. See treeNext for a sample. 927 * 924 928 * "method" specifies in which order the nodes are traversed. 925 929 * This can be: … … 936 940 int method) // in: traversal mode 937 941 { 938 if ( (!tree)939 ||(tree == TREE_NULL))942 if ( (!tree) 943 || (tree == TREE_NULL)) 940 944 return; 941 945 … … 963 967 *@@ treeFirst: 964 968 * finds and returns the first node in a (sub-)tree. 969 * 970 * See treeNext for a sample usage for traversing a tree. 965 971 */ 966 972 … … 970 976 *current; 971 977 972 if ((!tree) 973 || (tree == TREE_NULL)) 978 if ( (!tree) 979 || (tree == TREE_NULL) 980 ) 974 981 return NULL; 975 982 … … 991 998 *current; 992 999 993 if ( (!tree)994 ||(tree == TREE_NULL))1000 if ( (!tree) 1001 || (tree == TREE_NULL)) 995 1002 return NULL; 996 1003 … … 1005 1012 *@@ treeNext: 1006 1013 * finds and returns the next node in a tree. 1014 * 1015 * Example for traversing a whole tree if you don't 1016 * want to use treeTraverse: 1017 * 1018 + TREE *TreeRoot; 1019 + ... 1020 + TREE* pNode = treeFirst(TreeRoot); 1021 + while (pNode) 1022 + { 1023 + ... 1024 + pNode = treeNext(pNode); 1025 + } 1026 * 1027 * This runs through the tree items in sorted order. 1007 1028 */ 1008 1029 … … 1013 1034 *child; 1014 1035 1015 if ((!tree) 1016 || (tree == TREE_NULL)) 1036 if ( (!tree) 1037 || (tree == TREE_NULL) 1038 ) 1017 1039 return NULL; 1018 1040 … … 1024 1046 current = tree; 1025 1047 child = TREE_NULL; 1026 while ((current->parent) 1027 && (current->right == child)) 1048 while ( (current->parent) 1049 && (current->right == child) 1050 ) 1028 1051 { 1029 1052 child = current; … … 1048 1071 *child; 1049 1072 1050 if ( (!tree)1051 ||(tree == TREE_NULL))1073 if ( (!tree) 1074 || (tree == TREE_NULL)) 1052 1075 return NULL; 1053 1076
Note:
See TracChangeset
for help on using the changeset viewer.