Defines | |
| #define | trie_state_is_terminal(s) trie_state_is_walkable((s),TRIE_CHAR_TERM) |
| Check for terminal state. | |
| #define | trie_state_is_leaf(s) (trie_state_is_single(s) && trie_state_is_terminal(s)) |
| Check for leaf state. | |
Typedefs | |
| typedef struct _Trie | Trie |
| Trie data type. | |
| typedef Bool(* | TrieEnumFunc )(const AlphaChar *key, TrieData key_data, void *user_data) |
| Trie enumeration function. | |
| typedef struct _TrieState | TrieState |
| Trie walking state. | |
Functions | |
| Trie * | trie_new (const AlphaMap *alpha_map) |
| Create a new trie. | |
| Trie * | trie_new_from_file (const char *path) |
| Create a new trie by loading from a file. | |
| void | trie_free (Trie *trie) |
| Free a trie object. | |
| int | trie_save (Trie *trie, const char *path) |
| Save a trie to file. | |
| Bool | trie_is_dirty (const Trie *trie) |
| Check pending changes. | |
| Bool | trie_retrieve (const Trie *trie, const AlphaChar *key, TrieData *o_data) |
| Retrieve an entry from trie. | |
| Bool | trie_store (Trie *trie, const AlphaChar *key, TrieData data) |
| Store a value for an entry to trie. | |
| Bool | trie_delete (Trie *trie, const AlphaChar *key) |
| Delete an entry from trie. | |
| Bool | trie_enumerate (const Trie *trie, TrieEnumFunc enum_func, void *user_data) |
| Enumerate entries in trie. | |
| TrieState * | trie_root (const Trie *trie) |
| Get root state of a trie. | |
| TrieState * | trie_state_clone (const TrieState *s) |
| Clone a trie state. | |
| void | trie_state_copy (TrieState *dst, const TrieState *src) |
| Copy trie state to another. | |
| void | trie_state_free (TrieState *s) |
| Free a trie state. | |
| void | trie_state_rewind (TrieState *s) |
| Rewind a trie state. | |
| Bool | trie_state_walk (TrieState *s, AlphaChar c) |
| Walk the trie from the state. | |
| Bool | trie_state_is_walkable (const TrieState *s, AlphaChar c) |
| Test walkability of character from state. | |
| Bool | trie_state_is_single (const TrieState *s) |
| Check for single path. | |
| TrieData | trie_state_get_data (const TrieState *s) |
| Get data from leaf state. | |
| #define trie_state_is_leaf | ( | s | ) | (trie_state_is_single(s) && trie_state_is_terminal(s)) |
Check for leaf state.
| s | : the state to check |
| #define trie_state_is_terminal | ( | s | ) | trie_state_is_walkable((s),TRIE_CHAR_TERM) |
Check for terminal state.
| s | : the state to check |
| typedef Bool(* TrieEnumFunc)(const AlphaChar *key, TrieData key_data, void *user_data) |
Trie enumeration function.
| key | : the key of the entry | |
| data | : the data of the entry |
Delete an entry from trie.
| trie | : the trie | |
| key | : the key for the entry to delete |
| Bool trie_enumerate | ( | const Trie * | trie, | |
| TrieEnumFunc | enum_func, | |||
| void * | user_data | |||
| ) |
Enumerate entries in trie.
| trie | : the trie | |
| enum_func | : the callback function to be called on each key | |
| user_data | : user-supplied data to send as an argument to enum_func |
| void trie_free | ( | Trie * | trie | ) |
Free a trie object.
| trie | : the trie object to free |
| Bool trie_is_dirty | ( | const Trie * | trie | ) |
Check pending changes.
| trie | : the trie object |
Create a new trie.
| alpha_map | : the alphabet set for the trie |
The created object must be freed with trie_free().
| Trie* trie_new_from_file | ( | const char * | path | ) |
Create a new trie by loading from a file.
| path | : the path to the file |
The created object must be freed with trie_free().
Retrieve an entry from trie.
| trie | : the trie | |
| key | : the key for the entry to retrieve | |
| o_data | : the storage for storing the entry data on return |
Get root state of a trie.
| trie | : the trie |
The returned state is allocated and must be freed with trie_state_free()
| int trie_save | ( | Trie * | trie, | |
| const char * | path | |||
| ) |
Save a trie to file.
| trie | : the trie | |
| path | : the path to the file |
Clone a trie state.
| s | : the state to clone |
The returned state is allocated and must be freed with trie_state_free()
Copy trie state to another.
| dst | : the destination state | |
| src | : the source state |
| void trie_state_free | ( | TrieState * | s | ) |
Free a trie state.
| s | : the state to free |
Get data from leaf state.
| s | : a leaf state |
| Bool trie_state_is_single | ( | const TrieState * | s | ) |
Check for single path.
| s | : the state to check |
Test walkability of character from state.
| s | : the state to check | |
| c | : the input character |
| void trie_state_rewind | ( | TrieState * | s | ) |
Rewind a trie state.
| s | : the state to rewind |
Walk the trie from the state.
| s | : current state | |
| c | : key character for walking |
Store a value for an entry to trie.
| trie | : the trie | |
| key | : the key for the entry to retrieve | |
| data | : the data associated to the entry |
1.5.7