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

data structure: implement pairing heap without use of shared_ptr #1713

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

jere8184
Copy link
Contributor

@jere8184 jere8184 commented Nov 24, 2024

Continuation of #1707 which was accidentally closed when I deleted my fork of openage

Copy link
Member

@heinezen heinezen left a comment

Choose a reason for hiding this comment

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

The sanity checks are not running through and you need to rebase again please.

void walk_tree(const element_t &root,
const std::function<void(const element_t &)> &func) const {
func(root);
Copy link
Member

Choose a reason for hiding this comment

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

Ah I didn't thought of that we have top do this for the deletion.

It's probably not a good idea to change the function like this because it effectively reverses the order of walking the tree (root will now be the last node that func is applied to). I guess the best solution then is to leave this function as-is and not use iter_all.

Instead, you can use the code you have written here in clear() but replace func(root) with delete root

Copy link
Contributor Author

@jere8184 jere8184 Nov 25, 2024

Choose a reason for hiding this comment

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

How about adding a reverse argument to walk tree? (see changes)

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think that is also a nice option.

I pushed a commit to your branch that additionally makes the reversing a compile-time option, making it faster to execute.

@heinezen
Copy link
Member

Looks like the amount of calls in the portal_a_star function almost halfed. Doesn't make it twice as fast, but it's a good progress. The event queue should also benefit from this change.

Copy link
Member

@heinezen heinezen left a comment

Choose a reason for hiding this comment

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

I'm going to merge. Well done!

@heinezen heinezen merged commit ed26812 into SFTtech:master Nov 25, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants