Skip to content

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

Merged
heinezen merged 2 commits into
SFTtech:masterfrom
jere8184:paring_heap
Nov 25, 2024
Merged

data structure: implement pairing heap without use of shared_ptr#1713
heinezen merged 2 commits into
SFTtech:masterfrom
jere8184:paring_heap

Conversation

@jere8184

@jere8184 jere8184 commented Nov 24, 2024

Copy link
Copy Markdown
Contributor

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

@heinezen heinezen left a comment

Copy link
Copy Markdown
Member

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.

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

Copy link
Copy Markdown
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

@jere8184 jere8184 Nov 25, 2024

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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
Copy Markdown
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.

@heinezen heinezen left a comment

Copy link
Copy Markdown
Member

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
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