heh
Diffstat (limited to 'src/util.rs')
| -rw-r--r-- | src/util.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/util.rs b/src/util.rs index c5b6c9b..eb0e11c 100644 --- a/src/util.rs +++ b/src/util.rs @@ -242,6 +242,26 @@ where } } +pub fn countg<N: Debug + PartialEq + Hash + Eq + Copy, I: Iterator<Item = N>>( + start: N, + graph: &mut impl Fn(N) -> I, + sum: &mut usize, + end: &mut impl Fn(N) -> bool, + has: &mut HashSet<N>, +) { + if end(start) { + *sum += 1; + } else { + graph(start) + .map(|x| { + if has.insert(x) { + countg(x, graph, sum, end, has); + } + }) + .Θ(); + } +} + pub fn iterg<N: Debug + Copy, I: Iterator<Item = N>>( start: N, graph: &mut impl Fn(N) -> I, |