Constructor and Description |
---|
Node(Object data)
Creates a new Node.
|
Node(Tree.Node parent,
Object data)
Creates a new Node and adds it as a child of the specified Node
|
Modifier and Type | Method and Description |
---|---|
void |
add(Tree.Node child)
Adds the specified node as a new child node to this node.
|
boolean |
containsChild(Tree.Node child)
Returns true if this node contains the specified element.
|
boolean |
equals(Object obj)
Calls super.equals(), i.e, reference equality.
|
Tree.Node |
getChildContaining(Object obj)
Returns the first child node whose data object equals the specified
argument.
|
List |
getChildren()
Returns the children of this node.
|
Object |
getData()
Returns the Object representing the data for this node, null if
no data has been assigned.
|
int |
getLevel()
Gets the level of this node starting from the root (the root node is
at level 0)
|
int |
getMaxDepth()
Returns the maximum depth of the tree starting from this node and following
the deepest branch.
|
Tree.Node |
getParent()
Returns the parent of the TreeNode, null if there is no parent
|
Iterator |
getSiblings()
Returns the siblings of this node.
|
boolean |
isLeaf()
Returns true is this node has no children, false otherwise
|
boolean |
isNodeAncestor(Tree.Node ancestor)
Returns true if the specified node is an ancestor of this node
false otherwise.
|
boolean |
isNodeChild(Tree.Node child)
Returns true if the specified node is a child of this node
false otherwise.
|
boolean |
isNodeDescendant(Tree.Node descendent)
Returns true if the specified node is a descendent of this node
false otherwise.
|
boolean |
isNodeSibling(Tree.Node node)
Returns true if the specified node is a sibling of this node
false otherwise.
|
boolean |
isRoot()
Returns true if this node is the root node of the tree,
false otherwise.
|
Iterator |
iterator(Tree.IterationOrder order)
Returns an iterator for all the nodes in the tree, starting from this node
onwards.
|
int |
recursiveSize()
Returns the total number of all nodes reachable under this node.
|
boolean |
remove(Tree.Node child)
Removes a single instance of the specified element from this node's children,
if it is present.
|
String |
toString() |
boolean |
valEquals(Tree.Node one,
Tree.Node other)
Compares the values of 2 nodes.
|
public Node(Object data)
#setParent(TreeNode)
method.data
- the data object associated with this node.public boolean remove(Tree.Node child)
child
- child element to be removed from this node if present.public List getChildren()
public Tree.Node getChildContaining(Object obj)
obj
- the object against which the child nodes will be comparedpublic boolean containsChild(Tree.Node child)
Collection.contains(Object)
child
- node whose presence in this collection is to be tested.public Tree.Node getParent()
public Iterator getSiblings()
Returns an iterator with no elements if there are no siblings or if this is the root node (which can have no siblings).
public Object getData()
public int recursiveSize()
public boolean isRoot()
public boolean isNodeAncestor(Tree.Node ancestor)
public boolean isNodeChild(Tree.Node child)
public boolean isNodeDescendant(Tree.Node descendent)
public boolean isNodeSibling(Tree.Node node)
public boolean isLeaf()
public int getLevel()
public int getMaxDepth()
public Iterator iterator(Tree.IterationOrder order)
public boolean equals(Object obj)
public boolean valEquals(Tree.Node one, Tree.Node other)