1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
use super::*;
/// # Arguments
///
/// * `index`:
///
/// returns: Option<Cow<Self::Node>>
///
/// # Examples
///
/// ```
/// use graph_theory::GraphEngine;
/// ```
#[derive(Debug)]
pub struct GetNodesVisitor<'i, G: GraphEngine + ?Sized> {
graph: &'i G,
index: usize,
}
impl<'i, G: GraphEngine> Iterator for GetNodesVisitor<'i, G> {
type Item = Cow<'i, usize>;
fn next(&mut self) -> Option<Self::Item> {
if self.index >= self.graph.count_nodes() {
return None;
}
let _index = self.index;
self.index += 1;
// self.graph.get_node_id(index);
todo!()
}
}
impl<'i, G: GraphEngine> DoubleEndedIterator for GetNodesVisitor<'i, G> {
fn next_back(&mut self) -> Option<Self::Item> {
if self.index >= self.graph.count_nodes() {
return None;
}
let _index = self.graph.count_nodes() - self.index - 1;
self.index += 1;
// self.graph.get_node_id(index);
todo!()
}
}
impl<'i, G: GraphEngine + ?Sized> GetNodesVisitor<'i, G> {
/// # Arguments
///
/// * `index`:
///
/// returns: Option<Cow<Self::Node>>
///
/// # Examples
///
/// ```
/// use graph_theory::GraphEngine;
/// ```
pub fn new(graph: &'i G) -> Self {
Self { graph, index: 0 }
}
}