-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
std: Make std.PriorityQueue
and std.PriorityDequeue
unmanaged containers
#25559
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
base: master
Are you sure you want to change the base?
std: Make std.PriorityQueue
and std.PriorityDequeue
unmanaged containers
#25559
Conversation
… and update tests
…ecked`, `peekMin`, `removeMin`, and `removeMax`
…d `removeMax` to `popMax`; update tests
Unrelated to these changes, but it seems theres'a typo in the doc comment: (The wording is a bit clunky imo, I'd personally just replace the last part with "otherwise", or drop it since it's logically implied - but up to you or maintainers to decide.) |
Summary of changesPriority Dequeue
Priority Queue
Moved Priority Dequeue into Priority DequeTODO (this part will be edited based on progress, feedback, and observation)
|
… `.empty` value and use it in tests
Since there's already |
I think so too, pushing |
…st) and `capacity` method to `getCapacity`
lib/std/priority_dequeue.zig
Outdated
/// Returns `true` if the queue is empty and `false if not. | ||
pub fn isEmpty(self: Self) bool { | ||
return if (self.len > 0) false else true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO we should not move simple checks like self.len > 0
to a function. It would have been needed if the empty
state was complex or required some additional checks. Because it is just a length check, by adding this helper function we are actually making code slower, but without substantial readability improvements.
http://ithare.com/wp-content/uploads/part101_infographics_v08.png
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small functions can (and are expected to) be trivially inlined by the compiler's optimization pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding an isEmpty
method was intentional because its commonly used in general purpose programming. After adding it, I thought of actually using it in existing methods.
…`, add `.empty` value and use it in tests
…ethods and tests to deque, add doc comments for fields
This PR is ready for review (updated the summary of changes). |
#23431 had been dormant for a while.
This PR revives #21433 and resolves #21432.