-
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
Iterate over Arena in Depth-first order #67
Comments
Note that this is implemented to NodeId, not arena, because the arena can have multiple unordered top-level nodes. |
Creating virtual root nodes and using it as the parent of actual top-level nodes would be a workaround. |
Makes sense.
Having a top level (virtual) l node would still require tracking (passing around) an entity that is external to the arena. Wish there was an easier way to track/get the toplevel nodes, but, this works for now :) Edit: Added virtual to make clear that the node to be tracked is virtual |
I was wondering if arena could have this functionality built in. I can workaround this issue with the above mentioned virtual root node trick or tracking top level nodes methods, but is this really that hard to implement into the crate itself? Can arena maybe have a method to return all top level nodes maybe? Then I can simply call descendants on those top level nodes. |
It would be possible to create a newtype for #[repr(transparent)]
struct IndexTree<T>(Arena<T>); It would take some planning to make it ergonomic, but it's theoretically possible.
This would require a lot of changes. |
Hi,
Is there anyway to iterate over all the nodes in an Arena in a depth-first order (
iter
seems to be in storage order). At the moment, I'm tracking all the root nodeid's (during insertion) in a separate vec, and, then iterating over each of their descendants. I was wondering, if there is a better way to do this? ThanksThe text was updated successfully, but these errors were encountered: