id-tree icon indicating copy to clipboard operation
id-tree copied to clipboard

Mutable iterators

Open spearman opened this issue 6 years ago • 3 comments

Would like to mutably iterate over node data. So far my attempts at adapting the immutable iterators runsinto E0495 problems. Maybe it will compile when the related pull request is merged.

spearman avatar Dec 22 '18 17:12 spearman

My workaround for now is traversing over node ids: https://github.com/spearman/id-tree/tree/traverse-ids

spearman avatar Dec 22 '18 22:12 spearman

I believe I've needed this before as well. I think I ended up dealing in NodeIds just like you have above as my solution at that time, but it looks like I never added that to id-tree (although I thought I had).

I'd be happy to accept a PR with those types of things implemented if you're willing to create one.


However, I'd like to also point you to an experimental tree implementation that I've been working on alongside id-tree called slab-tree.

There are several differences between the two projects, but one of them that you might care about is how you deal with Nodes and their relatives in slab-tree. While I haven't actually written any of them yet, I believe these iterators (both mutable and immutable) should be much easier to implement in slab-tree.

Please note: slab-tree is currently not fully documented, and is only at v-0.1.3. I do plan to keep working on it and publishing new versions, but I can't say for certain when I expect a 1.0 version to go live.

iwburns avatar Dec 22 '18 23:12 iwburns

Thanks, opened a pull request. I'll keep an eye on slab-tree as well.

spearman avatar Dec 22 '18 23:12 spearman