|
C Fundamentals
Algorithms · data structures · cryptography · systems — pure C11, zero deps
|
Go to the source code of this file.
Classes | |
| struct | trie |
| struct | trie_node |
Typedefs | |
| typedef struct trie_node | trie_node_t |
Functions | |
| static int | idx_of (char c) |
| static trie_node_t * | node_create (void) |
| static void | node_destroy (trie_node_t *n) |
| bool | trie_contains (const trie_t *t, const char *word) |
| trie_t * | trie_create (void) |
| void | trie_destroy (trie_t *t) |
| bool | trie_insert (trie_t *t, const char *word) |
| bool | trie_starts_with (const trie_t *t, const char *prefix) |
| static const trie_node_t * | walk (const trie_t *t, const char *s) |
| typedef struct trie_node trie_node_t |
|
static |
Definition at line 43 of file trie.c.
Referenced by trie_insert(), and walk().
|
static |
Definition at line 19 of file trie.c.
Referenced by trie_create(), and trie_insert().
|
static |
Definition at line 23 of file trie.c.
References trie_node::children, and node_destroy().
Referenced by node_destroy(), and trie_destroy().
| bool trie_contains | ( | const trie_t * | t, |
| const char * | word | ||
| ) |
Definition at line 76 of file trie.c.
References trie_node::terminal, and walk().
| trie_t * trie_create | ( | void | ) |
Definition at line 29 of file trie.c.
References node_create(), and trie::root.
| void trie_destroy | ( | trie_t * | t | ) |
Definition at line 37 of file trie.c.
References node_destroy(), and trie::root.
| bool trie_insert | ( | trie_t * | t, |
| const char * | word | ||
| ) |
Inserts a lowercase a-z word. Returns false on allocation failure or if the word contains a non-{a-z} character.
Definition at line 49 of file trie.c.
References trie_node::children, idx_of(), node_create(), trie::root, and trie_node::terminal.
| bool trie_starts_with | ( | const trie_t * | t, |
| const char * | prefix | ||
| ) |
|
static |
Definition at line 65 of file trie.c.
References trie_node::children, idx_of(), and trie::root.
Referenced by trie_contains(), and trie_starts_with().