net.junaraki.libtree
Interface TreeNode<T>

Type Parameters:
T - the type of an element maintained by this tree node
All Superinterfaces:
Node<T>
All Known Subinterfaces:
BinaryTreeNode<T>, RootedTreeNode<T>
All Known Implementing Classes:
AbstractBinaryTreeNode, AbstractOrderedTreeNode, AbstractRootedTreeNode, AbstractTreeNode, BinarySearchTreeNode, OrderedTreeNode, UnorderedTreeNode

public interface TreeNode<T>
extends Node<T>

An interface for a tree node.

Author:
Jun Araki

Method Summary
 void addChild(TreeNode<T> child)
          Appends the specified node to the children of this node.
 java.util.List<TreeNode<T>> getAncestors()
          Returns a list of all the ancestors of this node, i.e., all the nodes on the unique simple path from the root to this node.
 java.util.Collection<TreeNode<T>> getChildren()
          Returns all the children of this node.
 int getDepth()
          Returns the depth of this node.
 TreeNode<T> getDescendant(java.lang.Object o)
          Returns the descendant of this node with the specified element.
 java.util.Set<TreeNode<T>> getDescendants()
          Returns a set of all the descendants of this node.
 int getHeight()
          Returns the height of this node.
 TreeNode<T> getParent()
          Returns the parent of this node.
 java.util.List<TreeNode<T>> getProperAncestors()
          Returns a list of all the proper ancestors of this node, i.e., all the nodes on the unique simple path from the root to the parent of this node.
 java.util.List<TreeNode<T>> getSiblings()
          Returns a list of all the siblings of this node.
 boolean hasAncestor(java.lang.Object o)
          Returns true if this node has an ancestor with the specified element; otherwise returns false.
 boolean hasChild()
          Returns true if this node has some child; otherwise returns false.
 boolean hasChild(java.lang.Object o)
          Returns true if this node has a child with the specified element; otherwise returns false.
 boolean hasDescendant(java.lang.Object o)
          Returns true if this node has a descendant with the specified element; otherwise returns false.
 boolean hasParent()
          Returns true if this node has some parent; otherwise returns false.
 boolean hasParent(java.lang.Object o)
          Returns true if this node has a parent with the specified element; otherwise returns false.
 boolean hasProperAncestor(java.lang.Object o)
          Returns true if this node has a proper ancestor with the specified element; otherwise returns false.
 boolean hasSibling()
          Returns true if this node has some sibling; otherwise returns false.
 boolean hasSibling(java.lang.Object o)
          Returns true if this node has a sibling with the specified element; otherwise returns false.
 boolean isLeaf()
          Returns true if this node is a leaf node; otherwise returns false.
 void setChildren(java.util.Collection<TreeNode<T>> children)
          Sets the collection of the specified nodes to the children of this node.
 void setParent(TreeNode<T> parent)
          Sets the specified node to the parent of this node.
 int size()
          Returns the size of this node, i.e., the number of its descendants including itself.
 
Methods inherited from interface net.junaraki.libtree.Node
getDegree, getElement, hasElement, hasElement, setElement
 

Method Detail

size

int size()
Returns the size of this node, i.e., the number of its descendants including itself.

Returns:
the size of this node

isLeaf

boolean isLeaf()
Returns true if this node is a leaf node; otherwise returns false.

Returns:
true if this node is a leaf node

getDepth

int getDepth()
Returns the depth of this node.

Returns:
the depth of this node

getHeight

int getHeight()
Returns the height of this node.

Returns:
the height of this node

getParent

TreeNode<T> getParent()
Returns the parent of this node.

Returns:
the parent of this node

setParent

void setParent(TreeNode<T> parent)
Sets the specified node to the parent of this node.

Parameters:
parent -

hasParent

boolean hasParent(java.lang.Object o)
Returns true if this node has a parent with the specified element; otherwise returns false.

Parameters:
o -
Returns:
true if this node has a parent with the specified element

hasParent

boolean hasParent()
Returns true if this node has some parent; otherwise returns false.

Returns:
true if this node has some parent

getChildren

java.util.Collection<TreeNode<T>> getChildren()
Returns all the children of this node.

Returns:
all the children of this node

setChildren

void setChildren(java.util.Collection<TreeNode<T>> children)
Sets the collection of the specified nodes to the children of this node.

Parameters:
children -

addChild

void addChild(TreeNode<T> child)
Appends the specified node to the children of this node.

Parameters:
child -

hasChild

boolean hasChild(java.lang.Object o)
Returns true if this node has a child with the specified element; otherwise returns false.

Parameters:
o -
Returns:
true if this node has a child with the specified element

hasChild

boolean hasChild()
Returns true if this node has some child; otherwise returns false.

Returns:
true if this node has some child

getAncestors

java.util.List<TreeNode<T>> getAncestors()
Returns a list of all the ancestors of this node, i.e., all the nodes on the unique simple path from the root to this node.

Returns:
a list of all the ancestors of this node

getProperAncestors

java.util.List<TreeNode<T>> getProperAncestors()
Returns a list of all the proper ancestors of this node, i.e., all the nodes on the unique simple path from the root to the parent of this node.

Returns:
a list of all the proper ancestors of this node

hasAncestor

boolean hasAncestor(java.lang.Object o)
Returns true if this node has an ancestor with the specified element; otherwise returns false.

Parameters:
o -
Returns:
true if this node has an ancestor with the specified element

hasProperAncestor

boolean hasProperAncestor(java.lang.Object o)
Returns true if this node has a proper ancestor with the specified element; otherwise returns false.

Parameters:
o -
Returns:
true if this node has a proper ancestor with the specified element

getDescendants

java.util.Set<TreeNode<T>> getDescendants()
Returns a set of all the descendants of this node.

Returns:
a set of all the descendants of this node

getDescendant

TreeNode<T> getDescendant(java.lang.Object o)
Returns the descendant of this node with the specified element.

Returns:
the descendant of this node with the specified element

hasDescendant

boolean hasDescendant(java.lang.Object o)
Returns true if this node has a descendant with the specified element; otherwise returns false.

Parameters:
o -
Returns:
true if this node has a descendant with the specified element

getSiblings

java.util.List<TreeNode<T>> getSiblings()
Returns a list of all the siblings of this node.

Returns:
a list of all the siblings of this node

hasSibling

boolean hasSibling(java.lang.Object o)
Returns true if this node has a sibling with the specified element; otherwise returns false.

Parameters:
o -
Returns:
true if this node has a sibling with the specified element

hasSibling

boolean hasSibling()
Returns true if this node has some sibling; otherwise returns false.

Returns:
true if this node has some sibling