Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. Note that the iteration order is arbitrary (as before with PriorityQueue::each), and _not_ the order you get when you pop() repeatedly. Add an in-file test to guard this. Reported-by: Daniel Micay <danielmicay@gmail.com> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
- Loading branch information