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

[PriorityQueue] Custom comparator for priorities #121

Open
enumag opened this issue Aug 23, 2018 · 5 comments
Open

[PriorityQueue] Custom comparator for priorities #121

enumag opened this issue Aug 23, 2018 · 5 comments

Comments

@enumag
Copy link

enumag commented Aug 23, 2018

I'd like to use the PriorityQueue but in my case the values I need to use for ordering are dates and I need the oldest one first. This means I can't use PriorityQueue because the order would be reversed.

In my opinion PriorityQueue should accept an optional comparator callback to decide the order.

@rtheunissen
Copy link
Member

Could you use -timestamp for the priority?

@enumag
Copy link
Author

enumag commented Sep 23, 2018

Negative timestamp huh? Yeah, I guess that could work. It feels like a dirty workaround rather than proper solution though.

@rtheunissen
Copy link
Member

It feels like a dirty workaround rather than proper solution though.

I agree. 2.0 will have a Heap with an optional comparator that would work here.

@enumag
Copy link
Author

enumag commented Nov 29, 2018

Would it be possible to have another similar internally-ordered structure with custom comparator and non-destructive iteration?

@rtheunissen
Copy link
Member

Like a binary search tree? There is one on the way. 👍

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

No branches or pull requests

2 participants