public interface TreeNode
| Modifier and Type | Method and Description |
|---|---|
void |
addChild(TreeNode child)
Add a child node below this node.
|
TreeNode |
getChild(int index)
Get child node by position in the list of siblings.
|
List<TreeNode> |
getChildren()
Get all child nodes of this node
|
TreeNode |
getParent()
Get the parent of this node
|
TreeNode |
getRoot()
Get the root of the tree
|
boolean |
isChild()
Check whether this node is a child node
|
boolean |
isFirstSibling()
Check whether a child is the first in the list of siblings
|
boolean |
isRoot()
Check whether this node is the root of the tree.
|
TreeNode getRoot()
TreeNode getParent()
void addChild(TreeNode child)
Important: this also automatically creates a link in the opposite direction. All implementations must adhere to this rule.
child - child nodeTreeNode getChild(int index)
index - position in the list of siblingsIndexOutOfBoundsException - if the index is out of range (index < 0 || index ≥ size())boolean isRoot()
true if this node is the rootboolean isChild()
true if the node is a child of another nodeboolean isFirstSibling()
true if the child is the first in the list of siblingsCopyright © 2018–2019. All rights reserved.