Skip to content

No way to iterate without consuming the queue? #82

Description

@fabiensanglard

Is it a conscious design decision to not allow user to iterate over a queue without consuming it?

use priority_queue::PriorityQueue;

let mut pq = PriorityQueue::new();

assert!(pq.is_empty());
pq.push("Apples", 5);

for (item, _) in pq.into_sorted_iter() {
    println!("{}", item); // Will print Bananas, Strawberries, Apples
}

pq.change_priority("Bananas", 25); // ERROR

Why not have a sorted_iter method?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions