1 /* 2 Copyright 2011-2016 David Robillard <http://drobilla.net> 3 4 Permission to use, copy, modify, and/or distribute this software for any 5 purpose with or without fee is hereby granted, provided that the above 6 copyright notice and this permission notice appear in all copies. 7 8 THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 #ifndef ZIX_TRIE_H 18 #define ZIX_TRIE_H 19 20 #include "zix/common.h" 21 22 /** 23 @addtogroup zix 24 @{ 25 @name Trie 26 @{ 27 */ 28 29 typedef struct _ZixTrie ZixTrie; 30 31 /** 32 Construct a new Trie. 33 */ 34 ZIX_API ZixTrie* 35 zix_trie_new(void); 36 37 /** 38 Destroy `t`. 39 */ 40 ZIX_API void 41 zix_trie_free(ZixTrie* t); 42 43 /** 44 Print a DOT description of `t` to `fd`. 45 */ 46 ZIX_API void 47 zix_trie_print_dot(const ZixTrie* t, FILE* fd); 48 49 /** 50 Insert `str` into `t`. 51 */ 52 ZIX_API ZixStatus 53 zix_trie_insert(ZixTrie* t, const char* str, size_t len); 54 55 /** 56 Search for `str` in `t`. 57 */ 58 ZIX_API ZixStatus 59 zix_trie_find(const ZixTrie* t, const char* str, const char** match); 60 61 /** 62 @} 63 @} 64 */ 65 66 #endif /* ZIX_TRIE_H */ 67