summaryrefslogtreecommitdiffstats
path: root/trie.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2019-03-04 23:30:33 -0800
committerTavian Barnes <tavianator@tavianator.com>2019-03-04 23:35:04 -0800
commit47f232e8fd307794e20bf0d6c84152f48be18cb3 (patch)
tree279320689d2fdfe749695a436a58714877e6aafc /trie.h
parent21a9a9bb078c062b7cb13f8d176a3375d7b01eb2 (diff)
downloadbfs-47f232e8fd307794e20bf0d6c84152f48be18cb3.tar.xz
trie: Implement prefix/postfix search
Diffstat (limited to 'trie.h')
-rw-r--r--trie.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/trie.h b/trie.h
index 8fcf04b..fcdd630 100644
--- a/trie.h
+++ b/trie.h
@@ -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