rust-scraper / ego-tree

Vec-backed ID-tree
https://docs.rs/ego-tree
ISC License
45 stars 16 forks source link

Remove support? #11

Closed RazrFalcon closed 6 years ago

RazrFalcon commented 6 years ago

What about nodes remove support? I understand that with a current architecture it's not really possible because it will invalidate NodeId, but what if I really-really have to remove a node?

UPD: I just noticed that you rewrote the whole thing...

causal-agent commented 6 years ago

What does "remove" mean that detach doesn't cover? Dropping items could be done with Tree<Option<T>> or similar, but reclaiming storage in the Vec invalidates the entire tree.

RazrFalcon commented 6 years ago

Do'h. I missed it.

But what about values() iter? It will return detached nodes anyway (it doesn't matter for my case, but still).

RazrFalcon commented 6 years ago

but reclaiming storage in the Vec invalidates the entire tree

You can store a list of free "nodes" so a new node will take a free space and will not expand the vector. But it will break the NodeId.

causal-agent commented 6 years ago

Yeah Values and Nodes iterators can't really do anything about the structure of the tree.

Maintaining a free list really sounds like it would complicate the structure to the point where it would make sense to use a different tree representation.

RazrFalcon commented 6 years ago

I see. Then I'm closing it for now. I thought maybe this is a planned feature.