void TSTree_traverse(TSTree *node, TSTree_traverse_cb cb, void *data) { if(!node) return; if(node->low) TSTree_traverse(node->low, cb, data); if(node->equal) TSTree_traverse(node->equal, cb, data); if(node->high) TSTree_traverse(node->high, cb, data); if(node->value) cb(node->value, data); }
char *test_traverse() { traverse_count = 0; TSTree_traverse(node, TSTree_traverse_test_cb, valueA); debug("traverse count is %d", traverse_count); mu_assert(traverse_count == 4, "Traverse count should be 4."); return NULL; }
void TSTree_traverse(TSTree *node, TSTree_traverse_cb cb, void *data) { check(data != NULL, "Data can't be NULL"); if(!node) return; if(node->low) TSTree_traverse(node->low, cb, data); if(node->equal) TSTree_traverse(node->equal, cb, data); if(node->high) TSTree_traverse(node->high, cb, data); if(!DArray_empty(node->values) && node != NULL) cb(node->values, data); error: return; }
void TSTree_traverse(TSTree* node, TSTree_traverse_cb cb, void* data) { if (!node) { return; } if (node->low) { TSTree_traverse(node->low, cb, data); } if (node->equal) { TSTree_traverse(node->equal, cb, data); } if (node->high) { TSTree_traverse(node->high, cb, data); } if (node->value) { cb(node->value, data); } }
void destroy_routes(TSTree * routes) { TSTree_traverse(routes, bdestroy_cb, NULL); TSTree_destroy(routes); }