Skip to content
Snippets Groups Projects
Commit 438b5cb9 authored by Marek Vavrusa's avatar Marek Vavrusa
Browse files

Updated hattrie_dup() to accept function to handle visited values.

This allows trie to modify duplicated nodes.
parent 818d2955
No related branches found
No related tags found
No related merge requests found
......@@ -251,7 +251,7 @@ void hattrie_free(hattrie_t* T)
free(T);
}
hattrie_t* hattrie_dup(const hattrie_t* T)
hattrie_t* hattrie_dup(const hattrie_t* T, value_t (*nval)(value_t))
{
hattrie_t *N = hattrie_create();
......@@ -262,7 +262,7 @@ hattrie_t* hattrie_dup(const hattrie_t* T)
hattrie_iter_t *i = hattrie_iter_begin(T, false);
while (!hattrie_iter_finished(i)) {
k = hattrie_iter_key(i, &l);
*hattrie_get(N, k, l) = *hattrie_iter_val(i);
*hattrie_get(N, k, l) = nval(*hattrie_iter_val(i));
hattrie_iter_next(i);
}
hattrie_iter_free(i);
......
......@@ -36,15 +36,18 @@ typedef struct hattrie_t_ hattrie_t;
hattrie_t* hattrie_create (void); //< Create an empty hat-trie.
void hattrie_free (hattrie_t*); //< Free all memory used by a trie.
hattrie_t* hattrie_dup (const hattrie_t*); //< Duplicate an existing trie.
void hattrie_clear (hattrie_t*); //< Remove all entries.
size_t hattrie_weight (hattrie_t*); //< Number of entries
/** Duplicate an existing trie.
*/
hattrie_t* hattrie_dup (const hattrie_t*, value_t (*nval)(value_t));
/** Build order index on all ahtable nodes in trie.
*/
void hattrie_build_index (hattrie_t*);
void hattrie_apply_rev(hattrie_t*, void (*f)(value_t,void*), void* d);
void hattrie_apply_rev (hattrie_t*, void (*f)(value_t,void*), void* d);
/** Find the given key in the trie, inserting it if it does not exist, and
* returning a pointer to it's key.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment