Class JTrees


  • public class JTrees
    extends Object
    Created by tchemit on 11/10/17.
    Author:
    Tony Chemit - dev@tchemit.fr
    • Constructor Detail

      • JTrees

        public JTrees()
    • Method Detail

      • initUI

        public static void initUI​(JScrollPane selectedTreePane,
                                  JTree tree)
      • preorderStream

        public static Stream<TreeNode> preorderStream​(TreeNode node)
        Creates a stream of tree node using the Depth-first search (DSF) algorithm with preorder vertex ordering starting on given node.

        Note: the stream is not parallel.

        Parameters:
        node - node ot walk through
        Returns:
        stream of nodes in correct order.
      • preorderStream

        public static Stream<TreeNode> preorderStream​(TreeNode node,
                                                      boolean parallel)
        Creates a stream of tree node using the Depth-first search (DSF) algorithm with preorder vertex ordering starting on given node.
        Parameters:
        node - node ot walk through
        parallel - to set parallel on the stream
        Returns:
        stream of nodes in correct order.
      • postorderStream

        public static Stream<TreeNode> postorderStream​(TreeNode node)
        Creates a stream of tree node using the Depth-first search (DSF) algorithm with postorder vertex ordering starting on given node.

        Note: the stream is not parallel.

        Parameters:
        node - node ot walk through
        Returns:
        stream of nodes in correct order.
      • postorderStream

        public static Stream<TreeNode> postorderStream​(TreeNode node,
                                                       boolean parallel)
        Creates a stream of tree node using the Depth-first search (DSF) algorithm with postorder vertex ordering starting on given node.
        Parameters:
        node - node ot walk through
        parallel - to set parallel on the stream
        Returns:
        stream of nodes in correct order.
      • breadthFirstStream

        public static Stream<TreeNode> breadthFirstStream​(TreeNode node)
        Creates a stream of tree node using the Breadth-first search (BFS) algorithm with preorder vertex ordering starting on given node.

        Note: the stream is not parallel.

        Parameters:
        node - node ot walk through
        Returns:
        stream of nodes in correct order.
      • breadthFirstStream

        public static Stream<TreeNode> breadthFirstStream​(TreeNode node,
                                                          boolean parallel)
        Creates a stream of tree node using the Breadth-first search (BFS) algorithm with preorder vertex ordering starting on given node.
        Parameters:
        node - node ot walk through
        parallel - to set parallel on the stream
        Returns:
        stream of nodes in correct order.