uk.ed.inf.tree
Interface ITreeNode<T extends ITreeNode<T>>

All Known Subinterfaces:
ICompoundNode<N,E>
All Known Implementing Classes:
ArchetypalCompoundNode, BaseCompoundNode, CompoundNode

public interface ITreeNode<T extends ITreeNode<T>>

Defines the node in a tree. The tree is defined from the root node. Each node can have any number of children. To obtain tree-wide information and to manipulate the tree use the GeneralTree class.

Author:
smoodie

Method Summary
 java.util.Iterator<T> ancestorIterator()
          Iterator that traverses directly from this node up to the root node.
 java.util.Iterator<T> childIterator()
          Iterator over the immediate children of this node.
 int getIndex()
          Get the index (unique identifier) of this node.
 T getParent()
          Get the parent node of this node.
 T getRoot()
          Get the root node for the tree that this node belongs to.
 boolean isChild(T childNode)
          Tests if childNode is a child of this node.
 boolean isParent(T parentNode)
          Is the given node the parent node of this one?
 java.util.Iterator<T> levelOrderIterator()
          Iterator that traverses down the tree in level-order, starting at this node.
 

Method Detail

getIndex

int getIndex()
Get the index (unique identifier) of this node. The node must be unique within this tree (as define by the root node).

Returns:
the identifier.

getRoot

T getRoot()
Get the root node for the tree that this node belongs to.

Returns:
The root node, cannot be null.

isParent

boolean isParent(T parentNode)
Is the given node the parent node of this one?

Parameters:
parentNode - The node to test as a parent. Can be null.
Returns:
true if it is the parent, false otherwise.

getParent

T getParent()
Get the parent node of this node. If this is the root node then its parent is itself.

Returns:
The parent node, cannot be null.

isChild

boolean isChild(T childNode)
Tests if childNode is a child of this node.

Parameters:
childNode - The node to test, can be null.
Returns:
true if it is a child of this node, false otherwise.

childIterator

java.util.Iterator<T> childIterator()
Iterator over the immediate children of this node.

Returns:
An iterator to this nodes children.

ancestorIterator

java.util.Iterator<T> ancestorIterator()
Iterator that traverses directly from this node up to the root node.

Returns:
a new iterator instance, which cannot be null.

levelOrderIterator

java.util.Iterator<T> levelOrderIterator()
Iterator that traverses down the tree in level-order, starting at this node.

Returns:
a new instance of the iterator, which cannot be null.