jdsl.core.api
Interface InspectableBinaryTree

All Known Subinterfaces:
BinaryTree, RestructurableBinaryTree

public abstract interface InspectableBinaryTree
extends InspectableTree

Interface for a binary tree, or a data structure that can be viewed as a binary tree. No methods that modify the tree are provided; the tree can only be viewed. For a binary tree, methods Container.elements() and PositionalContainer.positions() are guaranteed to return enumerations in preorder order.

Author:
Mark Handy

Method Summary
 Position leftChild(Position p)
          Gets the left child of p
 Position rightChild(Position p)
          Gets the right child of p.
 Position sibling(Position p)
          Gets the sibling Position of the Position passed in.
 
Methods inherited from interface jdsl.core.api.InspectableTree
children, isExternal, isInternal, isRoot, parent, root, siblings
 
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

leftChild

public Position leftChild(Position p)
                   throws InvalidPositionException,
                          BoundaryViolationException,
                          InvalidContainerException
Gets the left child of p
Parameters:
p - Any node of the tree
Returns:
left child of the given node
Throws:
BoundaryViolationException - If Position p is external
InvalidPositionException - If Position p is null or incompatible with this container
InvalidContainerException - If this container is invalid.

rightChild

public Position rightChild(Position p)
                    throws InvalidPositionException,
                           BoundaryViolationException,
                           InvalidContainerException
Gets the right child of p.
Parameters:
p - Any node of the tree
Returns:
right child of the given node
Throws:
BoundaryViolationException - If Position p is external
InvalidPositionException - If Position p is null or incompatible with this container
InvalidContainerException - If this container is invalid.

sibling

public Position sibling(Position p)
                 throws InvalidPositionException,
                        BoundaryViolationException,
                        InvalidContainerException
Gets the sibling Position of the Position passed in.
Parameters:
otherChild - Any node of the tree
Returns:
sibling of the given node (the other child of this node's parent)
Throws:
BoundaryViolationException - If Position p is the root
InvalidPositionException - If Position p is null or incompatible with this container
InvalidContainerException - If this container is invalid.