pub trait DfsIntoIterExt<'a, Item>: TraverseableNode<'a> {
fn dfs_iter(&'a self) -> DfsIterStateHolder<'a, Self::Item>;
}
impl<'a, T: TraverseableNode<'a>> DfsIntoIterExt<'a> for T
where TraverseableNode<Item=Self> {
fn dfs_iter(&'a self) -> DfsIterStateHolder<'a, Self::Item>
where
Self::Item: Eq + Hash,
{
let mut set = HashSet::new();
set.insert(self);
let mut bypass_buff = VecDeque::new();
bypass_buff.push_back(self);
return DfsIterStateHolder {
set: set,
bypass_buff: bypass_buff,
};
}
}
impl<'a, Item=Self, T> DfsIntoIterExt<'a> for T {
fn dfs_iter(&'a self) -> DfsIterStateHolder<'a, Self::Item>
where
Self::Item: Eq + Hash,
{
let mut set = HashSet::new();
set.insert(self);
let mut bypass_buff = VecDeque::new();
bypass_buff.push_back(self);
return DfsIterStateHolder {
set: set,
bypass_buff: bypass_buff,
};
}
}