00001 /* 00002 00003 Copyright (c) 2005-2008, Simon Howard 00004 00005 Permission to use, copy, modify, and/or distribute this software 00006 for any purpose with or without fee is hereby granted, provided 00007 that the above copyright notice and this permission notice appear 00008 in all copies. 00009 00010 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 00011 WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 00012 WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 00013 AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 00014 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 00015 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 00016 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 00017 CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00018 00019 */ 00020 00040 #ifndef ALGORITHM_TRIE_H 00041 #define ALGORITHM_TRIE_H 00042 00043 #ifdef __cplusplus 00044 extern "C" { 00045 #endif 00046 00051 typedef struct _Trie Trie; 00052 00057 typedef void *TrieValue; 00058 00063 #define TRIE_NULL ((void *) 0) 00064 00073 Trie *trie_new(void); 00074 00081 void trie_free(Trie *trie); 00082 00094 int trie_insert(Trie *trie, char *key, TrieValue value); 00095 00105 TrieValue trie_lookup(Trie *trie, char *key); 00106 00116 int trie_remove(Trie *trie, char *key); 00117 00125 int trie_num_entries(Trie *trie); 00126 00127 #ifdef __cplusplus 00128 } 00129 #endif 00130 00131 #endif /* #ifndef ALGORITHM_TRIE_H */ 00132