Changeset 54 for trunk/src/helpers/tree.c
- Timestamp:
- Apr 4, 2001, 4:39:06 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/tree.c
r39 r54 91 91 * The order of nodes in the tree is determined by calling a 92 92 * node comparison function provided by the caller 93 * (which you must write). This takes two TREE pointers and 94 * must return: 95 * 96 + 0: tree1 == tree2 97 + -1: tree1 < tree2 98 + +1: tree1 > tree2 93 * (which you must write). This must be declared as: 94 * 95 + int TREEENTRY fnMyCompareNodes(TREE *t1, TREE *t2); 96 * 97 * It obviously receives two TREE pointers, which it must 98 * compare and return: 99 * 100 + 0: tree1 == tree2 101 + -1: tree1 < tree2 102 + +1: tree1 > tree2 99 103 * 100 104 * -- The "ID" functions (e.g. treeInsertID) do not require … … 197 201 */ 198 202 199 int fnCompareIDs(unsigned long id1, unsigned long id2)203 int TREEENTRY fnCompareIDs(unsigned long id1, unsigned long id2) 200 204 { 201 205 if (id1 < id2) … … 259 263 BOOL fAllowDuplicates) // in: whether duplicates with the same ID are allowed 260 264 { 261 TREE 262 *current, 263 *parent; 264 int 265 last_comp = 0; 265 TREE *current, 266 *parent; 267 int last_comp = 0; 266 268 267 269 // find where node belongs … … 276 278 case -1: current = current->left; break; 277 279 case 1: current = current->right; break; 278 default: if (fAllowDuplicates)279 current = current->left;280 else281 return TREE_DUPLICATE;282 280 default: 281 if (fAllowDuplicates) 282 current = current->left; 283 else 284 return TREE_DUPLICATE; 283 285 } 284 286 } … … 691 693 *@@ treeFindEQID: 692 694 * finds a node with ID exactly matching that provided. 695 * Returns NULL if not found. 693 696 */ 694 697 … … 698 701 TREE 699 702 *current = *root, 700 *found; 701 702 found = NULL; 703 *found = NULL; 704 703 705 while (current != TREE_NULL) 704 706 switch (fnCompareIDs(current->id, id))
Note:
See TracChangeset
for help on using the changeset viewer.