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)

Method Summary
 java.util.Enumeration children(Position p)
          The returned Enumeration is guaranteed to give the children in order from left to right.
 boolean isExternal(Position p)
           
 boolean isInternal(Position p)
           
 boolean isRoot(Position p)
           
 Position parent(Position p)
           
 Position root()
          Note that trees always have at least one external node, so they always have a root.
 java.util.Enumeration siblings(Position p)
          The returned Enumeration is guaranteed to give the siblings in order from left to right.
 
Methods inherited from interface jdsl.core.api.PositionalContainer
positions, replace, swap
 
Methods inherited from interface jdsl.core.api.Container
elements, newContainer
 
Methods inherited from interface jdsl.simple.api.SimpleContainer
isEmpty, size
 

Method Detail

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