diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2013-02-07 17:08:04 -0500 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2013-02-07 20:18:15 -0500 |
| commit | d903231f1e7d7efb35405bdfdcbc451385e429b2 (patch) | |
| tree | 95cfb871e6bfd3742a4d4baa2bd45d21522c181b /src/libstd/priority_queue.rs | |
| parent | 6647a3402bf75368de1a692370c558d423f36940 (diff) | |
| download | rust-d903231f1e7d7efb35405bdfdcbc451385e429b2.tar.gz rust-d903231f1e7d7efb35405bdfdcbc451385e429b2.zip | |
add a BaseIter implementation for PriorityQueue
Diffstat (limited to 'src/libstd/priority_queue.rs')
| -rw-r--r-- | src/libstd/priority_queue.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index fcd9f8379b2..5248ab1742e 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -12,6 +12,7 @@ use core::container::{Container, Mutable}; use core::cmp::Ord; +use core::iter::BaseIter; use core::prelude::*; use core::ptr::addr_of; use core::vec; @@ -26,6 +27,14 @@ pub struct PriorityQueue<T> { priv data: ~[T], } +impl <T: Ord> PriorityQueue<T>: BaseIter<T> { + /// Visit all values in the underlying vector. + /// + /// The values are **not** visited in order. + pure fn each(&self, f: fn(&T) -> bool) { self.data.each(f) } + pure fn size_hint(&self) -> Option<uint> { self.data.size_hint() } +} + impl <T: Ord> PriorityQueue<T>: Container { /// Returns the length of the queue pure fn len(&self) -> uint { self.data.len() } |
