Iterate starting at X #185
Labels
No labels
bug
discussion
documentation
duplicate
ignore
new feature
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
golibs/gms-gods#185
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
For structures like the btree, it would be useful to be able to specify a node to start from that is not the start or end of the tree. For example how google's btree has the
AscendRangefunction, it would be nice to be able to efficiently move to a node, and start iterating from there.@danthegoodman1 you do have access to the internal nodes if you look at how the iterators work, and the nodes are exposed so you could implement your own transversal: https://pkg.go.dev/github.com/emirpasic/[email protected]/trees/btree
In short, each Node is a subtree, so as long you reach some Node you can create an iterator at that level to iterate over the sub-tree. Let me know if I can help here to provide some more general solutions if the above does not satisfy your needs.
Hey Emir, thanks for the quick response!
Yes having to implement a custom traversal was something I was hoping to avoid, I know it's relatively trivial, maybe I was just being a bit lazy :P
Maybe having
.Next()and.Prev()functions on the nodes would make this easier too, but I guess I can just pull a bunch of code from theIteratorand do this myself.@danthegoodman1 it is probably trivial but this is all relative depending on the experience one has with this. It is hard to provide a generic solution to satisfy all requirements here, so your custom implementation would perhaps be the best option here. Let me know if you hit a snag with it and if I can help out.
I appreciate the extended hand, thanks!