Trait TreeTraversal

Source
pub trait TreeTraversal<T> {
    // Required methods
    fn dfs(&self) -> Descendants<'_, T>;
    fn bfs(&self) -> BreadthFirstTraversal<'_, T> ;
    fn left_boundary(&self) -> impl Iterator<Item = Self>;
    fn right_boundary(&self) -> impl Iterator<Item = Self>;
}
Expand description

Extension trait adding traversal algorithms on trees.

Required Methods§

Source

fn dfs(&self) -> Descendants<'_, T>

Iterates over descendants of node in depth-first order.

Source

fn bfs(&self) -> BreadthFirstTraversal<'_, T>

Iterates over descendants of node in breadth-first order.

Source

fn left_boundary(&self) -> impl Iterator<Item = Self>

Iterates over left boundary of node.

Source

fn right_boundary(&self) -> impl Iterator<Item = Self>

Iterates over right boundary of node.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a, T: 'a> TreeTraversal<T> for NodeRef<'a, T>

Source§

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

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(&self) -> BreadthFirstTraversal<'a, T>

Implements the standard BFS algorithm using a queue.

Source§

fn left_boundary(&self) -> impl Iterator<Item = Self>

Source§

fn right_boundary(&self) -> impl Iterator<Item = Self>

Implementors§