tt_dict_singleton
This commit is contained in:
parent
d80ff03821
commit
22c9a2d5a0
|
@ -125,13 +125,20 @@ static int set_walk(tt_arena_t *a,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tt_node_ptr_t tt_dict_singleton(tt_arena_t *a,
|
||||||
|
tt_atom_t key,
|
||||||
|
tt_node_ptr_t trie)
|
||||||
|
{
|
||||||
|
return tt_cons_dict(a, RET_IF_NO_PTR(tt_cons_leaf(a, trie, key)), 1);
|
||||||
|
}
|
||||||
|
|
||||||
tt_node_ptr_t tt_dict_set(tt_arena_t *a,
|
tt_node_ptr_t tt_dict_set(tt_arena_t *a,
|
||||||
tt_node_ptr_t t,
|
tt_node_ptr_t t,
|
||||||
tt_atom_t key,
|
tt_atom_t key,
|
||||||
tt_node_ptr_t trie)
|
tt_node_ptr_t trie)
|
||||||
{
|
{
|
||||||
if (TT_EMPTY_DICT_P(t)) {
|
if (TT_EMPTY_DICT_P(t)) {
|
||||||
return tt_cons_dict(a, RET_IF_NO_PTR(tt_cons_leaf(a, trie, key)), 1);
|
return tt_dict_singleton(a, key, trie);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(tt_ptr_tag(t) == TT_TAG_DICT);
|
assert(tt_ptr_tag(t) == TT_TAG_DICT);
|
||||||
|
|
|
@ -10,6 +10,12 @@ extern int tt_dict_size(tt_arena_t *a, tt_node_ptr_t t);
|
||||||
/* Returns TT_NO_PTR when key not present. Does not manipulate references. */
|
/* Returns TT_NO_PTR when key not present. Does not manipulate references. */
|
||||||
extern tt_node_ptr_t tt_dict_get(tt_arena_t *a, tt_node_ptr_t t, tt_atom_t key);
|
extern tt_node_ptr_t tt_dict_get(tt_arena_t *a, tt_node_ptr_t t, tt_atom_t key);
|
||||||
|
|
||||||
|
/* Returns TT_NO_PTR when allocation failed. Otherwise, a length-one dict.
|
||||||
|
Grabs `trie` if required. */
|
||||||
|
extern tt_node_ptr_t tt_dict_singleton(tt_arena_t *a,
|
||||||
|
tt_atom_t key,
|
||||||
|
tt_node_ptr_t trie);
|
||||||
|
|
||||||
/* Returns TT_NO_PTR when allocation failed. Otherwise, yields a dict.
|
/* Returns TT_NO_PTR when allocation failed. Otherwise, yields a dict.
|
||||||
Grabs `trie` if required. */
|
Grabs `trie` if required. */
|
||||||
extern tt_node_ptr_t tt_dict_set(tt_arena_t *a,
|
extern tt_node_ptr_t tt_dict_set(tt_arena_t *a,
|
||||||
|
|
Loading…
Reference in New Issue