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
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.