I need to build some trie / tree and running into a problem.
Initially I need to build the tree with an owned childlist.
In a second phase I mark all identical subtrees (that I have got covered with hashing).
After de-duplication I need to reset the children pointer of nodes to the one and only unique children subtree.
After that I rebuild the tree (in a totally different memory layout)
I think I know how to relay that pointer, but how can I initialize the (owned) children safely?
const ChildList = std.ArrayListUnmanaged(Node);
pub const Node = struct
{
// ... data
is_reference: bool, // indicate we do not own this children anymore.
children: *ChildList,
pub init() Node
{
// now to init children safely.
}
}