Package org.abego.treelayout
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.
-
Method Summary
Modifier and TypeMethodDescriptiongetChildren
(TreeNode parentNode) Returns the children of a parent node.getChildrenReverse
(TreeNode parentNode) Returns the children of a parent node, in reverse order.getFirstChild
(TreeNode parentNode) Returns the first child of a parent node.getLastChild
(TreeNode parentNode) Returns the last child of a parent node.getRoot()
Returns the the root of the tree.boolean
isChildOfParent
(TreeNode node, TreeNode parentNode) Tells if a node is a child of a given parentNode.boolean
Tells if a node is a leaf in the tree.
-
Method Details
-
getRoot
TreeNode getRoot()Returns the the root of the tree.Time Complexity: O(1)
- Returns:
- the root of the tree
-
isLeaf
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
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
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
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
Returns the first child of a parent node.Time Complexity: O(1)
- Parameters:
parentNode
- [!isLeaf(parentNode)]- Returns:
- the first child of the parentNode
-
getLastChild
Returns the last child of a parent node.Time Complexity: O(1)
- Parameters:
parentNode
- [!isLeaf(parentNode)]- Returns:
- the last child of the parentNode
-