Class Tree.Node
java.lang.Object
fc.util.Tree.Node
- Enclosing class:
Tree
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the specified node as a new child node to this node.booleancontainsChild(Tree.Node child) Returns true if this node contains the specified element.booleanCalls super.equals(), i.e, reference equality.getChildContaining(Object obj) Returns the first child node whose data object equals the specified argument.Returns the children of this node.getData()Returns the Object representing the data for this node, null if no data has been assigned.intgetLevel()Gets the level of this node starting from the root (the root node is at level 0)intReturns the maximum depth of the tree starting from this node and following the deepest branch.Returns the parent of the TreeNode, null if there is no parentReturns the siblings of this node.booleanisLeaf()Returns true is this node has no children, false otherwisebooleanisNodeAncestor(Tree.Node ancestor) Returns true if the specified node is an ancestor of this node false otherwise.booleanisNodeChild(Tree.Node child) Returns true if the specified node is a child of this node false otherwise.booleanisNodeDescendant(Tree.Node descendent) Returns true if the specified node is a descendent of this node false otherwise.booleanisNodeSibling(Tree.Node node) Returns true if the specified node is a sibling of this node false otherwise.booleanisRoot()Returns true if this node is the root node of the tree, false otherwise.iterator(Tree.IterationOrder order) Returns an iterator for all the nodes in the tree, starting from this node onwards.intReturns the total number of all nodes reachable under this node.booleanRemoves a single instance of the specified element from this node's children, if it is present.toString()booleanCompares the values of 2 nodes.
-
Constructor Details
-
Node
-
Node
-
-
Method Details
-
add
-
remove
Removes a single instance of the specified element from this node's children, if it is present. More formally, removes an element e such that (o==null ? e==null : o.equals(e)), if this node contains one or more such elements. Returns true if this node contained the specified element (or equivalently, if this collection changed as a result of the call).- Parameters:
child- child element to be removed from this node if present.- Returns:
- true if this node changed as a result of the call
-
getChildren
Returns the children of this node. The returned list is not a copy of this node's trees therefore any modification made to the returned object will be seen by this node. This is useful for reordering nodes etc. -
getChildContaining
Returns the first child node whose data object equals the specified argument. That is, returns child node where childnode.data.equals(obj) == true. Returns null is no matching child node is found.- Parameters:
obj- the object against which the child nodes will be compared
-
containsChild
Returns true if this node contains the specified element. Follows the contract ofCollection.contains(Object)- Parameters:
child- node whose presence in this collection is to be tested.- Returns:
- true if this node contains the specified child element
-
getParent
-
getSiblings
Returns the siblings of this node. A sibling is any node that is a child of this node's parent and is not the same as this node.Returns an iterator with no elements if there are no siblings or if this is the root node (which can have no siblings).
-
getData
-
recursiveSize
Returns the total number of all nodes reachable under this node. If there are no children, this method returns 1 (this node itself is of size 1) -
isRoot
Returns true if this node is the root node of the tree, false otherwise. -
isNodeAncestor
Returns true if the specified node is an ancestor of this node false otherwise. An ancestor is any node between thre root node and this node, not including this node itself. -
isNodeChild
Returns true if the specified node is a child of this node false otherwise. A node is not a child of itself. -
isNodeDescendant
Returns true if the specified node is a descendent of this node false otherwise. A node is not a descendent of itself. -
isNodeSibling
Returns true if the specified node is a sibling of this node false otherwise. A node is not a sibling of itself. -
isLeaf
Returns true is this node has no children, false otherwise -
getLevel
Gets the level of this node starting from the root (the root node is at level 0) -
getMaxDepth
Returns the maximum depth of the tree starting from this node and following the deepest branch. The ending depth is a node that contains only data (leaves) and no children. If this node has no children, this method returns 0 (i.e., this node itself is at depth 0). -
iterator
Returns an iterator for all the nodes in the tree, starting from this node onwards. -
equals
Calls super.equals(), i.e, reference equality. java.util.Collection operations like add/remove nodes etc., are defined in terms of equals(). It becomes very inefficient to have a full-fledged equals that compares both the data of this node and the exact number and structure of the children of this node. Subclasses can optionally redefine this method if necessary. -
valEquals
-
toString
-