mozilla/rust — pull request #7404 by artagnon (2013-06-26 10:31:44+00:00)
Title: priority_queue: implement simple iterator

Remove PriorityQueue::each and replace it with PriorityQueue::iter,
which ultimately calls into vec::VecIterator via PriorityQueueIterator.
Implement iterator::Iterator for PriorityQueueIterator. Now you should
be able to do:

extern mod extra;
let mut pq = extra::priority_queue::PriorityQueue::new();
pq.push(5);
pq.push(6);
pq.push(3);
for pq.iter().advance |el| {
println(fmt!("%d", *el));
}

just like you iterate over vectors, hashmaps, hashsets etc.

Add an in-file test to guard this.

Reported-by: Daniel Micay
Signed-off-by: Ramkumar Ramachandra