39 lines
922 B
C
39 lines
922 B
C
#include "../include/trie.h"
|
|
#include <stddef.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
int main(void){
|
|
TrieNode *root = NULL;
|
|
|
|
trie_insert(&root,"hello");
|
|
trie_insert(&root,"world");
|
|
trie_insert(&root,"test");
|
|
trie_insert(&root,"hi");
|
|
trie_insert(&root,"his");
|
|
trie_insert(&root,"history");
|
|
trie_insert(&root,"him");
|
|
trie_insert(&root,"hex");
|
|
trie_insert(&root,"hexed");
|
|
trie_insert(&root,"jam");
|
|
trie_insert(&root,"jamming");
|
|
TrieNode *test = find_node(root,"his");
|
|
Vec v;
|
|
vec_init(&v);
|
|
if(test == NULL){
|
|
printf("NULL");
|
|
} else {
|
|
print_trie(root);
|
|
printf("\n\n");
|
|
|
|
collect_leaves(test,(unsigned char*)"his",strlen("his"),&v);
|
|
}
|
|
for(int i = 0; i < v.len; i++){
|
|
printf("%d.) %s\n",i,(char *)v.items[i]);
|
|
}
|
|
vec_free(&v);
|
|
free_trienode(root);
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|