-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request: remove_children
and detach_children
#53
Comments
Issue-Label Bot is automatically applying the label Links: app homepage, dashboard and code for this bot. |
indextree allows toplevel nodes to have siblings, so |
@lo48576 Then the following two codes will behave differently: fn detach_children<T>(self, arena: &mut Arena<T>) {
for child in self.children(arena) {
let node = arena[child];
node.parent = None;
}
let node = arena[self];
node.first_child = None;
node.last_child = None;
} for child in self.children(arena) {
child.detach(arena);
} I don't know it is needed to keep the relation between detached children. But at least it should be mentioned on document in order not to get the user confused. |
Yes, I think the name |
I also need remove_children method to make a graph. |
When dealing with the tree structure, sometimes we want to remove the all children nodes of a specific node but keeping the node itself. For example, removing anything between tags
<p>
and</p>
.Here is a snippet demonstrating how to implement
detach_children
with indextree:I haven't tried it yet, so it may not be compiled.
The text was updated successfully, but these errors were encountered: