diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2019-03-04 23:30:33 -0800 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2019-03-04 23:35:04 -0800 |
commit | 47f232e8fd307794e20bf0d6c84152f48be18cb3 (patch) | |
tree | 279320689d2fdfe749695a436a58714877e6aafc /trie.h | |
parent | 21a9a9bb078c062b7cb13f8d176a3375d7b01eb2 (diff) | |
download | bfs-47f232e8fd307794e20bf0d6c84152f48be18cb3.tar.xz |
trie: Implement prefix/postfix search
Diffstat (limited to 'trie.h')
-rw-r--r-- | trie.h | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -80,6 +80,30 @@ struct trie_leaf *trie_find_str(const struct trie *trie, const char *key); struct trie_leaf *trie_find_mem(const struct trie *trie, const void *key, size_t length); /** + * Find the shortest leaf that starts with a given key. + * + * @param trie + * The trie to search. + * @param key + * The key to look up. + * @return + * A leaf that starts with the given key, or NULL. + */ +struct trie_leaf *trie_find_postfix(const struct trie *trie, const char *key); + +/** + * Find the leaf that is the longest prefix of the given key. + * + * @param trie + * The trie to search. + * @param key + * The key to look up. + * @return + * The longest prefix match for the given key, or NULL. + */ +struct trie_leaf *trie_find_prefix(const struct trie *trie, const char *key); + +/** * Insert a string key into the trie. * * @param trie |