Interface TreeForTreeLayout<TreeNode>

  • Type Parameters:
    TreeNode - Type of elements used as nodes in the tree
    All Known Implementing Classes:
    AbstractTreeForTreeLayout, DefaultTreeForTreeLayout

    public interface TreeForTreeLayout<TreeNode>
    Represents a tree to be used by the TreeLayout.

    The TreeForTreeLayout interface is designed to best match the implemented layout algorithm and to ensure the algorithm's time complexity promises in all possible cases. However in most situation a client must not deal with all details of this interface and can directly use the AbstractTreeForTreeLayout to implement this interface or even use the DefaultTreeForTreeLayout class directly.

    Also see this overview.
    • Method Detail

      • getRoot

        TreeNode getRoot()
        Returns the the root of the tree.

        Time Complexity: O(1)

        Returns:
        the root of the tree
      • isLeaf

        boolean isLeaf​(TreeNode node)
        Tells if a node is a leaf in the tree.

        Time Complexity: O(1)

        Parameters:
        node -  
        Returns:
        true iff node is a leaf in the tree, i.e. has no children.
      • isChildOfParent

        boolean isChildOfParent​(TreeNode node,
                                TreeNode parentNode)
        Tells if a node is a child of a given parentNode.

        Time Complexity: O(1)

        Parameters:
        node -  
        parentNode -  
        Returns:
        true iff the node is a child of the given parentNode
      • getChildren

        java.lang.Iterable<TreeNode> getChildren​(TreeNode parentNode)
        Returns the children of a parent node.

        Time Complexity: O(1)

        Parameters:
        parentNode - [!isLeaf(parentNode)]
        Returns:
        the children of the given parentNode, from first to last
      • getChildrenReverse

        java.lang.Iterable<TreeNode> getChildrenReverse​(TreeNode parentNode)
        Returns the children of a parent node, in reverse order.

        Time Complexity: O(1)

        Parameters:
        parentNode - [!isLeaf(parentNode)]
        Returns:
        the children of given parentNode, from last to first
      • getFirstChild

        TreeNode getFirstChild​(TreeNode parentNode)
        Returns the first child of a parent node.

        Time Complexity: O(1)

        Parameters:
        parentNode - [!isLeaf(parentNode)]
        Returns:
        the first child of the parentNode
      • getLastChild

        TreeNode getLastChild​(TreeNode parentNode)
        Returns the last child of a parent node.

        Time Complexity: O(1)

        Parameters:
        parentNode - [!isLeaf(parentNode)]
        Returns:
        the last child of the parentNode