コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        public static IEnumerable <Product> GetProducts(ProductCategory root)
        {
            var traverser = new Traverser <ProductCategory, Product>(
                pc => pc.Categories,
                pc => pc.Products);

            return(traverser.Traverse(root));
        }