hattrie_t* hattrie_dup(const hattrie_t* T, value_t (*nval)(value_t)) { hattrie_t *N = hattrie_create_n(T->bsize, &T->mm); /* assignment */ if (!nval) nval = hattrie_setval; /*! \todo could be probably implemented faster */ size_t l = 0; const char *k = 0; 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) = nval(*hattrie_iter_val(i)); hattrie_iter_next(i); } hattrie_iter_free(i); return N; }
hattrie_t* hattrie_create() { mm_ctx_t mm; mm_ctx_init(&mm); return hattrie_create_n(TRIE_BUCKET_SIZE, &mm); }