com.discoversites.util.collections.tree
Interface TreeNode<T>
- Type Parameters:
T
- The type of element to be stored in the TreeNode
- All Superinterfaces:
- Serializable
- All Known Subinterfaces:
- TreeRoot<T>
- All Known Implementing Classes:
- ArrayTreeNode, ArrayTreeRoot, SetTreeNode, SetTreeRoot
public interface TreeNode<T>
- extends Serializable
Interface for a single node of a Tree
- Author:
- Mark
getRoot
TreeRoot<T> getRoot()
- Returns:
- The root node of the tree this node belongs to.
getParent
TreeNode<T> getParent()
- Returns:
- The parent node of this node.
addNode
void addNode(TreeNode<T> node)
- Parameters:
node
- A node to be added as a child to this node.
addNode
void addNode(TreeRoot<T> root)
- Parameters:
root
- A node to be added as a child to this node.
addElement
TreeNode<T> addElement(T element)
- Parameters:
element
- An element to be added as a child node to this node.
- Returns:
- The node that was created to store the element.
removeNode
void removeNode(TreeNode<T> node)
- Parameters:
node
- A child node of this node, that is to be removed from this node.
setElement
void setElement(T element)
- Parameters:
element
- An element to be stored in this node, replacing the current element if one exists.
getElement
T getElement()
- Returns:
- The element stored in this node.
addAll
void addAll(Collection<TreeNode<T>> nodes)
- Parameters:
nodes
- One or more nodes to be added as children to this node.
getChildren
Collection<TreeNode<T>> getChildren()
- Returns:
- The child nodes of this node.
getSiblings
Collection<TreeNode<T>> getSiblings()
- Returns:
- The sibling nodes of this node.
isLeaf
boolean isLeaf()
- Returns:
- True if this is a leaf node (i.e. it has no children), false otherwise.
isRoot
boolean isRoot()
- Returns:
- True if this is a root node (i.e. it has no parents), false otherwise.
getDepth
int getDepth()
- Returns:
- The depth (i.e. level) that this node occupies in it's parent
Tree
.
getTree
Tree<T> getTree()
- Returns:
- The
Tree
that this node belongs to.