about summary refs log tree commit diff
path: root/src/rt/rust_kernel.cpp
diff options
context:
space:
mode:
authorRamkumar Ramachandra <artagnon@gmail.com>2013-06-26 15:49:21 +0530
committerCorey Richardson <corey@octayn.net>2013-06-26 18:08:43 -0400
commitf4621cab6859ee0f8ddacea0ece98e4a4c00d5a6 (patch)
treed3ad3130071576b79c40cf2e3b0069a0c916bf36 /src/rt/rust_kernel.cpp
parent2b17e4775c816b59d92e166b8a8db039aaa7ba85 (diff)
downloadrust-f4621cab6859ee0f8ddacea0ece98e4a4c00d5a6.tar.gz
rust-f4621cab6859ee0f8ddacea0ece98e4a4c00d5a6.zip
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>
Diffstat (limited to 'src/rt/rust_kernel.cpp')
0 files changed, 0 insertions, 0 deletions