diff --git a/src/trie.c b/src/trie.c index 3f9066db..f2800485 100644 --- a/src/trie.c +++ b/src/trie.c @@ -892,6 +892,12 @@ uint32_t trie_get(trie_t *self, char *word) { return trie_get_from_index(self, word, word_len, ROOT_NODE_ID); } + +inline uint32_t trie_num_keys(trie_t *self) { + if (self == NULL) return 0; + return self->num_keys; +} + /* Destructor */ diff --git a/src/trie.h b/src/trie.h index 1d673a66..4582fd91 100644 --- a/src/trie.h +++ b/src/trie.h @@ -124,6 +124,8 @@ uint32_t trie_get_from_index(trie_t *self, char *word, size_t len, uint32_t i); uint32_t trie_get_len(trie_t *self, char *word, size_t len); uint32_t trie_get(trie_t *self, char *word); +uint32_t trie_num_keys(trie_t *self); + typedef struct trie_prefix_result { uint32_t node_id; size_t tail_pos;