jdsl.core.api
Interface InspectableTree
- All Known Subinterfaces:
- BinaryTree, InspectableBinaryTree, RestructurableBinaryTree, Tree
- All Known Implementing Classes:
- AMSGraphTree, BCTree
- public abstract interface InspectableTree
- extends PositionalContainer
Interface that defines the properties of an InspectableTree
- Author:
- Mike Boilen (mgb)
isRoot
public boolean isRoot(Position p)
throws InvalidPositionException,
InvalidContainerException
- Parameters:
p - Any node of the tree- Returns:
- Whether the given node is the root of the tree
- Throws:
- InvalidPositionException - if p is null or is incompatible with
this container
- InvalidContainerException - if this container is invalid
isInternal
public boolean isInternal(Position p)
throws InvalidPositionException,
InvalidContainerException
- Parameters:
p - Any node of the tree- Returns:
- Whether the given node has at least one child
- Throws:
- InvalidPositionException - if p is null or is incompatible with
this container
- InvalidContainerException - if this container is invalid
isExternal
public boolean isExternal(Position p)
throws InvalidPositionException,
InvalidContainerException
- Parameters:
p - Any node of the tree- Returns:
- Whether the given node has zero children
- Throws:
- InvalidPositionException - if p is null or is incompatible with
this container
- InvalidContainerException - if this container is invalid
root
public Position root()
throws InvalidContainerException
- Note that trees always have at least one external node, so they always
have a root.
- Returns:
- The top node of the tree
- Throws:
- InvalidContainerException - if this container is invalid
parent
public Position parent(Position p)
throws InvalidPositionException,
BoundaryViolationException,
InvalidContainerException
- Parameters:
p - Any node of the tree- Returns:
- Parent Position of the given node
- Throws:
- BoundaryViolationException - If p is the root of the tree
- InvalidPositionException - if p is null or is incompatible with
this container
- InvalidContainerException - if this container is invalid
children
public java.util.Enumeration children(Position p)
throws InvalidPositionException,
InvalidContainerException
- The returned Enumeration is guaranteed to give the children in order from left to right.
- Parameters:
p - Any node of the tree- Returns:
- Enumeration of all the children of that node
- Throws:
- InvalidPositionException - if p is null or is incompatible with
this container
- InvalidContainerException - if this container is invalid
siblings
public java.util.Enumeration siblings(Position p)
throws InvalidPositionException,
InvalidContainerException
- The returned Enumeration is guaranteed to give the siblings in order from left to right.
- Parameters:
p - Any node of the tree- Returns:
- Enumeration of all the other children of the same parent
- Throws:
- InvalidPositionException - if p is null or is incompatible with
this container
- InvalidContainerException - if this container is invalid