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

feat(examples): add p/demo/avl/list #3324

Merged
merged 19 commits into from
Dec 21, 2024
Merged

Conversation

moul
Copy link
Member

@moul moul commented Dec 11, 2024

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>
@moul moul self-assigned this Dec 11, 2024
@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Dec 11, 2024
@moul moul marked this pull request as ready for review December 11, 2024 08:26
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Dec 11, 2024

🛠 PR Checks Summary

All Automated Checks passed. ✅

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
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:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 The pull request was created from a fork (head branch repo: moul/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

Copy link

codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

moul added 2 commits December 11, 2024 09:28
Signed-off-by: moul <94029+moul@users.noreply.github.com>
Signed-off-by: moul <94029+moul@users.noreply.github.com>
moul added 3 commits December 11, 2024 21:32
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this reversed?

Comment on lines 245 to 249
l.tree.IterateByOffset(0, size, func(_ string, value interface{}) bool {
values[i] = value
i--
return false
})
Copy link
Member

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

Comment on lines 285 to 292
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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly here

Copy link
Member

@thehowl thehowl left a 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.

moul added 4 commits December 20, 2024 23:28
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>
thehowl added a commit that referenced this pull request Dec 20, 2024
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>
@moul moul merged commit 88fb8cb into gnolang:master Dec 21, 2024
11 checks passed
@moul moul deleted the dev/moul/avllist branch December 21, 2024 00:44
albttx pushed a commit that referenced this pull request Jan 10, 2025
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>
albttx pushed a commit that referenced this pull request Jan 10, 2025
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: ✅ Done
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants