// for test static void _tdump(struct cc_trie* tp, struct cc_node* node, uint32_t pos) { printf("pos[%d] count[%d] ud[%d] has_ud[%d]\n", pos, node->count, node->ud, node->has_ud); int i=0; for(i=0; i<node->count; i++) { int idx = node->list[i]; printf(" %c -> pos[%d]\n", idx2char[idx], node->childs[idx]); } for(i=0; i<node->count; i++) { int idx = node->list[i]; uint32_t pos = node->childs[idx]; _tdump(tp, pos2node(tp, pos), pos); } }
void trie_dump(struct cc_trie* tp) { _tdump(tp, pos2node(tp, tp->root), tp->root); }