void applyinorder(NV *treep, void (*fn)(NV*, void*), void *arg) { if (treep == NULL) return; applyinorder(treep->left, fn, arg); (*fn)(treep, arg); applyinorder(treep->right, fn, arg); }
void test_insert() { Nameval *treep; treep = NULL; treep = insert(treep, newitem("dsjung", 29)); treep = insert(treep, newitem("wwlee", 30)); treep = insert(treep, newitem("arkim", 24)); treep = insert(treep, newitem("shjo", 31)); treep = insert(treep, newitem("dhkim", 33)); applyinorder(treep, printnv, "%s: %d\n"); freeall(treep); }