-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Main example for priority queue using dijkstra's algorithm. #15857
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
Conversation
//! #[deriving(Eq, PartialEq)] | ||
//! struct State { | ||
//! cost: uint, | ||
//! pos: uint |
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.
bikeshed alert: wonder if this shouldn't be a full position
instead. It's not that much longer.
I really like this idea. |
Great! Thanks for the pointers. |
//! | ||
//! // Examine the frontier with lower cost nodes first (min-heap) | ||
//! while !pq.is_empty() { | ||
//! let State { position: u, cost: curr_cost } = pq.pop().unwrap(); |
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.
This could be
loop {
let State { position, cost } = match pq.pop() {
None => break, // empty
Some(s) => s
};
// ...
}
This is a fantastic example, nice job! This looks good to go with two minor comments and some squashings, thanks! |
Cool, thanks! |
I wanted to have a slightly larger example compared to the method examples, but I'm unsure how it worked out. Feedback would nice.
fix: remove parenthesis should ensure space close rust-lang/rust-analyzer#15844
I wanted to have a slightly larger example compared to the method examples, but I'm unsure how it worked out.
Feedback would nice.