adjacency_list/sparse_edges/
one_way_iter.rs1use crate::utils::ShortEdge;
2use graph_types::IndeterminateEdge;
3use std::collections::{btree_map, btree_set, btree_set::Iter, BTreeMap, BTreeSet};
4
5#[derive(Debug)]
6pub struct EdgeFirstAllNodes<'i> {
7 pub(crate) nodes: btree_set::Iter<'i, u32>,
8}
9#[derive(Debug)]
10pub struct EdgeFirstAllEdges<'i> {
11 pub(crate) edges: btree_map::Iter<'i, u32, ShortEdge>,
12}
13
14#[derive(Debug)]
15pub struct EdgeFirstAllBridges<'i> {
16 pub(crate) edges: btree_map::Iter<'i, u32, ShortEdge>,
17}
18
19#[derive(Debug)]
20pub struct EdgeFirstFindBridges<'i> {
21 pub(crate) edges: btree_map::Iter<'i, u32, ShortEdge>,
22 pub(crate) target: ShortEdge,
23}
24
25#[derive(Debug)]
26pub struct EdgeFirstFindNeighbors<'i> {
27 pub(crate) edges: btree_map::Iter<'i, u32, ShortEdge>,
28 pub(crate) target: u32,
29}
30
31impl<'i> Iterator for EdgeFirstAllNodes<'i> {
32 type Item = usize;
33
34 fn next(&mut self) -> Option<Self::Item> {
35 self.nodes.next().map(|x| *x as usize)
36 }
37}
38
39impl<'i> DoubleEndedIterator for EdgeFirstAllNodes<'i> {
40 fn next_back(&mut self) -> Option<Self::Item> {
41 self.nodes.next_back().map(|x| *x as usize)
42 }
43}
44
45impl<'i> Iterator for EdgeFirstAllEdges<'i> {
46 type Item = usize;
47
48 fn next(&mut self) -> Option<Self::Item> {
49 self.edges.next().map(|(x, _)| *x as usize)
50 }
51}
52
53impl<'i> DoubleEndedIterator for EdgeFirstAllEdges<'i> {
54 fn next_back(&mut self) -> Option<Self::Item> {
55 self.edges.next_back().map(|(x, _)| *x as usize)
56 }
57}
58
59impl<'i> Iterator for EdgeFirstAllBridges<'i> {
60 type Item = IndeterminateEdge;
61
62 fn next(&mut self) -> Option<Self::Item> {
63 self.edges.next().map(|(_, y)| y.as_indeterminate())
64 }
65}
66
67impl<'i> DoubleEndedIterator for EdgeFirstAllBridges<'i> {
68 fn next_back(&mut self) -> Option<Self::Item> {
69 self.edges.next_back().map(|(_, y)| y.as_indeterminate())
70 }
71}
72
73impl<'i> Iterator for EdgeFirstFindBridges<'i> {
74 type Item = IndeterminateEdge;
75
76 fn next(&mut self) -> Option<Self::Item> {
77 let (id, edge) = self.edges.next()?;
78 if self.target.eq(edge) { Some(edge.as_indeterminate()) } else { self.next() }
79 }
80}
81
82impl<'i> DoubleEndedIterator for EdgeFirstFindBridges<'i> {
83 fn next_back(&mut self) -> Option<Self::Item> {
84 let (id, edge) = self.edges.next_back()?;
85 if self.target.eq(edge) { Some(edge.as_indeterminate()) } else { self.next_back() }
86 }
87}
88
89impl<'i> Iterator for EdgeFirstFindNeighbors<'i> {
90 type Item = usize;
91
92 fn next(&mut self) -> Option<Self::Item> {
93 todo!()
94 }
95}
96
97impl<'i> DoubleEndedIterator for EdgeFirstFindNeighbors<'i> {
98 fn next_back(&mut self) -> Option<Self::Item> {
99 todo!()
100 }
101}