jdsl
Interface InspectableTree

All Known Subinterfaces:
BinaryTree, RestructurableBinaryTree, Tree
All Known Implementing Classes:
AMSGraphTree, BCTree

public abstract interface InspectableTree
extends PositionalContainer

Interface that defines the properties of an InspectableTree


Method Summary
 java.util.Iterator children(Position p)
          The returned Iterator 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.Iterator siblings(Position p)
          The returned Iterator is guaranteed to give the siblings in order from left to right.
 
Methods inherited from interface jdsl.PositionalContainer
positions, replace, swap
 
Methods inherited from interface jdsl.Container
elements, isEmpty, newContainer, 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.Iterator children(Position p)
                            throws InvalidPositionException,
                                   InvalidContainerException
The returned Iterator is guaranteed to give the children in order from left to right.
Parameters:
p - Any node of the tree
Returns:
Iterator 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.Iterator siblings(Position p)
                            throws InvalidPositionException,
                                   InvalidContainerException
The returned Iterator is guaranteed to give the siblings in order from left to right.
Parameters:
p - Any node of the tree
Returns:
Iterator 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