pub trait GraphIterator<G: ?Sized>: Clone {
type Item;
// Required method
fn next(&mut self, g: &G) -> Option<Self::Item>;
// Provided methods
fn size_hint(&self, _g: &G) -> (usize, Option<usize>) { ... }
fn count(self, g: &G) -> usize { ... }
fn iter(self, g: &G) -> GraphIter<'_, G, Self> ⓘ
where G: Sized { ... }
}
Expand description
A graph iterator.
This is roughly the same interface as a standard iterator. However, all its method take additionally the graph itself as parameter. This allows the iterator to not contain a reference to internal graph data.
This might be useful for algorithms that need to store several iterators because they require less memory (they do not need to store a reference to the same graph, each!).
Required Associated Types§
Required Methods§
Provided Methods§
fn size_hint(&self, _g: &G) -> (usize, Option<usize>)
fn count(self, g: &G) -> usize
fn iter(self, g: &G) -> GraphIter<'_, G, Self> ⓘwhere
G: Sized,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.