diff options
-rw-r--r-- | trie.c | 4 | ||||
-rw-r--r-- | trie.h | 10 |
2 files changed, 14 insertions, 0 deletions
@@ -218,6 +218,10 @@ static struct trie_leaf *trie_representative(const struct trie *trie, const void return trie_decode_leaf(ptr); } +struct trie_leaf *trie_first_leaf(const struct trie *trie) { + return trie_representative(trie, NULL, 0); +} + struct trie_leaf *trie_find_str(const struct trie *trie, const char *key) { return trie_find_mem(trie, key, strlen(key) + 1); } @@ -54,6 +54,16 @@ struct trie_leaf { void trie_init(struct trie *trie); /** + * Get the first (lexicographically earliest) leaf in the trie. + * + * @param trie + * The trie to search. + * @return + * The first leaf, or NULL if the trie is empty. + */ +struct trie_leaf *trie_first_leaf(const struct trie *trie); + +/** * Find the leaf for a string key. * * @param trie |