Individual constructors
This commit is contained in:
parent
eda162a8d1
commit
e835689abb
12
main.c
12
main.c
|
@ -25,16 +25,8 @@ int main(int argc, char *argv[]) {
|
|||
/* printf("======================================== LOOP ITERATION %d\n", outer); */
|
||||
/* tt_dump_arena_summary(&a); */
|
||||
for (i = 0; i < 1000000; i++) {
|
||||
tt_node_ptr_t leaf = tt_arena_cons(&a,
|
||||
TT_TAG_LEAF,
|
||||
0,
|
||||
TT_OK,
|
||||
1001);
|
||||
tt_node_ptr_t curr = tt_arena_cons(&a,
|
||||
TT_TAG_NODE,
|
||||
0,
|
||||
leaf,
|
||||
prev);
|
||||
tt_node_ptr_t leaf = tt_cons_leaf(&a, TT_OK, 1001);
|
||||
tt_node_ptr_t curr = tt_cons_node(&a, 0, leaf, prev);
|
||||
/* tt_dump_arena(&a); */
|
||||
prev = curr;
|
||||
}
|
||||
|
|
23
treetrie.h
23
treetrie.h
|
@ -95,6 +95,29 @@ extern tt_node_ptr_t tt_arena_cons(tt_arena_t *a,
|
|||
extern tt_node_ptr_t tt_grab(tt_arena_t *a, tt_node_ptr_t i);
|
||||
extern void tt_drop(tt_arena_t *a, tt_node_ptr_t i);
|
||||
|
||||
static inline tt_node_ptr_t tt_cons_tail(tt_arena_t *a, tt_node_ptr_t p) {
|
||||
return tt_arena_cons(a, TT_TAG_TAIL, 0, p, TT_NO_PTR);
|
||||
}
|
||||
|
||||
static inline tt_node_ptr_t tt_cons_branch(tt_arena_t *a,
|
||||
tt_node_ptr_t wildcard, /* trie */
|
||||
tt_node_ptr_t others) /* dict */
|
||||
{
|
||||
return tt_arena_cons(a, TT_TAG_BRANCH, 0, wildcard, others);
|
||||
}
|
||||
|
||||
static inline tt_node_ptr_t tt_cons_leaf(tt_arena_t *a, tt_node_ptr_t p, tt_atom_t atom) {
|
||||
return tt_arena_cons(a, TT_TAG_LEAF, 0, p, atom);
|
||||
}
|
||||
|
||||
static inline tt_node_ptr_t tt_cons_node(tt_arena_t *a,
|
||||
unsigned int index,
|
||||
tt_node_ptr_t zero,
|
||||
tt_node_ptr_t one)
|
||||
{
|
||||
return tt_arena_cons(a, TT_TAG_NODE, index, zero, one);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue