Package com.github.mike10004.xvfbmanager
Interface TreeNode<T>
-
- Type Parameters:
T- node label type
- All Known Implementing Classes:
ListTreeNode
public interface TreeNode<T>Interface that represents a node in a tree data structure. Nodes of this type are aware of their parents and children.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceTreeNode.NodeTraversal<T>Interface defining a tree node traversal.static classTreeNode.UtilsStatic utility methods relating to tree nodes.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TreeNode<T>addChild(TreeNode<T> child)Adds a child to this node's children.TreeNode.NodeTraversal<T>breadthFirstTraversal()Gets an iterable that provides a breadth-first iteration of nodes in the tree rooted at this node.Iterable<TreeNode<T>>children()Gets an iterable of this node's childrenintgetChildCount()Gets the count of this node's children.TgetLabel()Gets this node's label.intgetLevel()Gets the level, which is the distance to the root.TreeNode<T>getParent()Gets this node's parent.booleanisLeaf()Checks whether this node is a leaf node.booleanisRoot()Checks whether this node is the root node of a tree.TreeNode<T>setParent(TreeNode<T> parent)Sets the parent of a given node.
-
-
-
Method Detail
-
children
Iterable<TreeNode<T>> children()
Gets an iterable of this node's children- Returns:
- an iterable of this node's children; never null
-
breadthFirstTraversal
TreeNode.NodeTraversal<T> breadthFirstTraversal()
Gets an iterable that provides a breadth-first iteration of nodes in the tree rooted at this node. The iteration includes this node.- Returns:
- an iterable
-
getLevel
int getLevel()
Gets the level, which is the distance to the root. The level of the root node is zero.- Returns:
- the level
-
getChildCount
int getChildCount()
Gets the count of this node's children.- Returns:
- the child count
-
getParent
TreeNode<T> getParent()
Gets this node's parent.- Returns:
- this node's parent node, or null if this is the root node
-
setParent
TreeNode<T> setParent(TreeNode<T> parent)
Sets the parent of a given node.- Parameters:
parent- the parent, or null to remove existing parent- Returns:
- the old parent, or null if no parent had been set
-
isRoot
boolean isRoot()
Checks whether this node is the root node of a tree.- Returns:
- true iff this node is the root node, meaning it has no parent
-
getLabel
T getLabel()
Gets this node's label.- Returns:
- the label; allowing null depends on the implementation
-
addChild
TreeNode<T> addChild(TreeNode<T> child)
Adds a child to this node's children. Returns this instance (to facilitate chaining).- Parameters:
child- the child to add- Returns:
- this instance
-
isLeaf
boolean isLeaf()
Checks whether this node is a leaf node. Leaf nodes have no children.- Returns:
- true iff this node is a leaf node
-
-