-
Notifications
You must be signed in to change notification settings - Fork 399
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
feat(examples): add p/demo/avl/list #3324
Conversation
Signed-off-by: moul <94029+moul@users.noreply.github.com>
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
Signed-off-by: moul <94029+moul@users.noreply.github.com>
Signed-off-by: moul <94029+moul@users.noreply.github.com>
Signed-off-by: moul <94029+moul@users.noreply.github.com>
Signed-off-by: moul <94029+moul@users.noreply.github.com>
count := endIndex - startIndex | ||
result := make([]interface{}, count) | ||
|
||
// Fill the slice from end to start to maintain correct order |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this reversed?
l.tree.IterateByOffset(0, size, func(_ string, value interface{}) bool { | ||
values[i] = value | ||
i-- | ||
return false | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If reverse here is necessary, you can use ReverseIterateByOffset and call fn() directly
l.tree.IterateByOffset(0, size, func(_ string, value interface{}) bool { | ||
values[i] = value | ||
i-- | ||
return false | ||
}) | ||
|
||
// Add values to new list in correct order | ||
for _, value := range values { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similarly here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured out why the avl trees are reversed in IterateByOffset. It's a bug.
I'd say just use the Reverse functions for now, I'll make a PR to fix avl.
Signed-off-by: moul <94029+moul@users.noreply.github.com>
Signed-off-by: moul <94029+moul@users.noreply.github.com>
…o dev/moul/avllist
Signed-off-by: moul <94029+moul@users.noreply.github.com>
the tests were there, but apparently `slicesEqual` had a bug. lol. This comes from #3324, and makes it so that IterateByOffset and ReverseIterateByOffset use the correct order. I changed the `descending` argument of the underlying TraverseByOffset to match it with avl.Node.TraverseInRange. --------- Signed-off-by: moul <94029+moul@users.noreply.github.com> Co-authored-by: moul <94029+moul@users.noreply.github.com>
the tests were there, but apparently `slicesEqual` had a bug. lol. This comes from #3324, and makes it so that IterateByOffset and ReverseIterateByOffset use the correct order. I changed the `descending` argument of the underlying TraverseByOffset to match it with avl.Node.TraverseInRange. --------- Signed-off-by: moul <94029+moul@users.noreply.github.com> Co-authored-by: moul <94029+moul@users.noreply.github.com>
Could become the preferred method for managing top-level lists. It can likely be utilized extensively in the existing codebase, potentially for most instances involving a top-level slice or those involving an avl.Tree using a seqid. --------- Signed-off-by: moul <94029+moul@users.noreply.github.com> Co-authored-by: Morgan <morgan@morganbaz.com>
Could become the preferred method for managing top-level lists.
It can likely be utilized extensively in the existing codebase, potentially for most instances involving a top-level slice or those involving an avl.Tree using a seqid.