Class AbstractTreeForTreeLayout<TreeNode>

    • Constructor Detail

      • AbstractTreeForTreeLayout

        public AbstractTreeForTreeLayout​(TreeNode root)
    • Method Detail

      • getParent

        public abstract TreeNode getParent​(TreeNode node)
        Returns the parent of a node, if it has one.

        Time Complexity: O(1)

        Parameters:
        node -  
        Returns:
        [nullable] the parent of the node, or null when the node is a root.
      • getChildrenList

        public abstract java.util.List<TreeNode> getChildrenList​(TreeNode node)
        Return the children of a node as a List.

        Time Complexity: O(1)

        Also the access to an item of the list must have time complexity O(1).

        A client must not modify the returned list.

        Parameters:
        node -  
        Returns:
        the children of the given node. When node is a leaf the list is empty.
      • isLeaf

        public boolean isLeaf​(TreeNode node)
        Description copied from interface: TreeForTreeLayout
        Tells if a node is a leaf in the tree.

        Time Complexity: O(1)

        Specified by:
        isLeaf in interface TreeForTreeLayout<TreeNode>
        Parameters:
        node -  
        Returns:
        true iff node is a leaf in the tree, i.e. has no children.
      • isChildOfParent

        public boolean isChildOfParent​(TreeNode node,
                                       TreeNode parentNode)
        Description copied from interface: TreeForTreeLayout
        Tells if a node is a child of a given parentNode.

        Time Complexity: O(1)

        Specified by:
        isChildOfParent in interface TreeForTreeLayout<TreeNode>
        Parameters:
        node -  
        parentNode -  
        Returns:
        true iff the node is a child of the given parentNode
      • getChildren

        public java.lang.Iterable<TreeNode> getChildren​(TreeNode node)
        Description copied from interface: TreeForTreeLayout
        Returns the children of a parent node.

        Time Complexity: O(1)

        Specified by:
        getChildren in interface TreeForTreeLayout<TreeNode>
        Parameters:
        node - [!isLeaf(parentNode)]
        Returns:
        the children of the given parentNode, from first to last
      • getChildrenReverse

        public java.lang.Iterable<TreeNode> getChildrenReverse​(TreeNode node)
        Description copied from interface: TreeForTreeLayout
        Returns the children of a parent node, in reverse order.

        Time Complexity: O(1)

        Specified by:
        getChildrenReverse in interface TreeForTreeLayout<TreeNode>
        Parameters:
        node - [!isLeaf(parentNode)]
        Returns:
        the children of given parentNode, from last to first