public static IEnumerable <Job> GetEndJobs(Job root) { var traverser = new Traverser <Job, Job>( job => job.Subjobs, job => job.Subjobs.Any() ? new Job[0] : new[] { job }); return(traverser.Traverse(root)); }
public static IEnumerable <T> GetBinaryTreeValues <T>(BinaryTree <T> root) { var traverser = new Traverser <BinaryTree <T>, T>( tree => new[] { tree.Left, tree.Right }, tree => tree.Right == null && tree.Left == null ? new[] { tree.Value } : new T[0]); return(traverser.Traverse(root)); }
public static IEnumerable <Product> GetProducts(ProductCategory root) { var traverser = new Traverser <ProductCategory, Product>( pc => pc.Categories, pc => pc.Products); return(traverser.Traverse(root)); }