From 21a9a9bb078c062b7cb13f8d176a3375d7b01eb2 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Mon, 4 Mar 2019 23:30:17 -0800 Subject: trie: Implement removal --- trie.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'trie.h') diff --git a/trie.h b/trie.h index fd91f0c..8fcf04b 100644 --- a/trie.h +++ b/trie.h @@ -105,6 +105,32 @@ struct trie_leaf *trie_insert_str(struct trie *trie, const char *key); */ struct trie_leaf *trie_insert_mem(struct trie *trie, const void *key, size_t length); +/** + * Remove a string key from a trie. + * + * @param trie + * The trie to modify. + * @param key + * The key to remove. + * @return + * Whether the key was found. + */ +bool trie_remove_str(struct trie *trie, const char *key); + +/** + * Remove a fixed-size key from a trie. + * + * @param trie + * The trie to modify. + * @param key + * The key to remove. + * @param size + * The size of the key in bytes. + * @return + * Whether the key was found. + */ +bool trie_remove_mem(struct trie *trie, const void *key, size_t size); + /** * Destroy a trie and its contents. */ -- cgit v1.2.3