JuliaCollections / LeftChildRightSiblingTrees.jl

Memory-efficient representation of a tree with arbitrary number of children/node
MIT License
16 stars 5 forks source link

Insert Nodes as Children/Siblings #14

Open SBuercklin opened 2 years ago

SBuercklin commented 2 years ago

Right now, addchild and addsibling require you to pass the data directly. Is it reasonable to add methods which allow you to specify child::Node{T}s rather than data::T?

I'm working with a problem where the end product is conveniently represented as a LCRS tree, but it's most sensible to build it from the bottom up, rather than the top down. This means I want to pass a subtree as a child rather than just the data, because that node has a collection of children/siblings already. Presumably we could do this with making Node{T}s which duplicate data and then graftchildren! to this duplicate node, but it seems like we could this more directly

E- This runs into the issue where you could add a Node from a tree to the tree again somewhere else, so it's not necessarily safe. That might be enough to disqualify this