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::toArray does not return items in prioritized order #21

Open
boesing opened this issue Mar 3, 2021 · 3 comments
Open
Milestone

Comments

@boesing
Copy link
Member

boesing commented Mar 3, 2021

Feature Request

Q A
New Feature yes
RFC no
BC Break yes

Summary

I've recently used the PriorityQueue and realized, that PriorityQueue::toArray does not return items in prioritized order.
Is that intended and if so, why?
I switched to iterator_to_array instead but I wonder for what PriorityQueue::toArray is for.

Feedback welcome.

@boesing boesing changed the title PriorityQueue::toArray returns items in prioritized order PriorityQueue::toArray does not return items in prioritized order Jun 11, 2022
@gsteel
Copy link
Member

gsteel commented Sep 13, 2023

@weierophinney

Can you shed any light on this?

I'm currently trying to get through #102 for a future v4 so it'd be a good time to change this behaviour if it no longer makes sense.

@gsteel gsteel added this to the 4.0.0 milestone Sep 13, 2023
@weierophinney
Copy link
Member

@gsteel The docblock specifically notes that it's not returned in priority order:

     * By default, returns only the item data, and in the order registered (not
     * sorted). You may provide one of the EXTR_* flags as an argument, allowing
     * the ability to return priorities or both data and priority.

I honestly do not recall why I wrote it like that; I mean, it was 13 years ago! But based on the implementation, I think the main idea around the method was primarily to allow serialization of the data, optionally with priorities. But it does seem that the data should be in priority order, regardless of the flags provided, as deserialization should return the data in the order it is meant to be iterated. I'd totally support that change.

@boesing
Copy link
Member Author

boesing commented Sep 14, 2023

Yah I would expect the correct order as well. I mean, thats why we even add priorities in the first place 😬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants