Skip to content
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

Implement range tree iterator #4

Open
declanvk opened this issue Apr 2, 2022 · 0 comments
Open

Implement range tree iterator #4

declanvk opened this issue Apr 2, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@declanvk
Copy link
Owner

declanvk commented Apr 2, 2022

Problem

  • I need to iterate over subsets of a tree, instead of the entire thing.
  • The solution should be more efficient than just reading all leaves and skipping those outside the range I'm interested in.

Solution Sketch

  • The current tree iterator implementation uses a stack of in-progress iterators that range over the internal nodes.
    • The logic is that the tree iterator will progress the top most iterator and keep adding iterators onto the stack until it gets to a leaf node, then yield.
    • Once a node iterator is exhausted, it is popped off the stack.
  • One method for implementing a ranged version of the tree iterator is to pre-processes the iterator by skipping nodes from the front and back until the keys are inside of the range requested.
    • The downside to this solution is that it could require potentially O(n) work just to create and setup the iterator.
  • Another method would be to perform 2 iterative searches for the start and end of the range, and create the node iterators along the way.
@declanvk declanvk added the enhancement New feature or request label Apr 2, 2022
@declanvk declanvk self-assigned this Apr 2, 2022
@declanvk declanvk removed their assignment Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant