From af1a5f62139f9230b3db79a686c9fb5981b81ce3 Mon Sep 17 00:00:00 2001 From: Al Date: Tue, 7 Jul 2015 03:38:17 -0400 Subject: [PATCH] [trie] trie_set_data_node method --- src/trie.c | 5 +++++ src/trie.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/trie.c b/src/trie.c index 01cb6367..51fd68eb 100644 --- a/src/trie.c +++ b/src/trie.c @@ -708,6 +708,11 @@ inline trie_data_node_t trie_get_data_node(trie_t *self, trie_node_t node) { return data_node; } +inline bool trie_set_data_node(trie_t *self, uint32_t index, trie_data_node_t data_node) { + if (self == NULL || self->data == NULL || index >= self->data->n) return false; + self->data->a[index] = data_node; +} + trie_prefix_result_t trie_get_prefix_from_index(trie_t *self, char *key, size_t len, uint32_t start_index, size_t tail_pos) { if (key == NULL) { return NULL_PREFIX_RESULT; diff --git a/src/trie.h b/src/trie.h index b6e94272..51c7bab7 100644 --- a/src/trie.h +++ b/src/trie.h @@ -86,6 +86,7 @@ trie_node_t trie_get_root(trie_t *self); trie_node_t trie_get_free_list(trie_t *self); trie_data_node_t trie_get_data_node(trie_t *self, trie_node_t node); +bool trie_set_data_node(trie_t *self, uint32_t index, trie_data_node_t data_node); bool trie_tail_match(trie_t *self, char *str, uint32_t tail_index); uint32_t trie_add_transition(trie_t *self, uint32_t node_id, unsigned char c);