catlog::dbl::tree_algorithms

Trait TreeTraversal

Source
pub trait TreeTraversal<T> {
    // Required methods
    fn dfs<'a>(&'a self) -> Descendants<'a, T>
       where T: 'a;
    fn bfs<'a>(&'a self) -> BreadthFirstTraversal<'a, T> 
       where T: 'a;
}
Expand description

Extension trait adding traversal algorithms on trees.

Required Methods§

Source

fn dfs<'a>(&'a self) -> Descendants<'a, T>
where T: 'a,

Iterates over nodes of a tree in depth-first order.

Source

fn bfs<'a>(&'a self) -> BreadthFirstTraversal<'a, T>
where T: 'a,

Iterates over the nodes in a tree in breadth-first order.

Implementations on Foreign Types§

Source§

impl<T> TreeTraversal<T> for Tree<T>

Source§

fn dfs<'a>(&'a self) -> Descendants<'a, T>
where T: 'a,

Uses the built-in traversal algorithm, which is depth-first, though that is not documented: https://github.com/rust-scraper/ego-tree/issues/38

Source§

fn bfs<'a>(&'a self) -> BreadthFirstTraversal<'a, T>
where T: 'a,

Implements the standard BFS algorithm using a queue.

Implementors§