jdsl.core.api
Interface RestructurableBinaryTree
- All Known Implementing Classes:
- RestructurableNodeBinaryTree
- public abstract interface RestructurableBinaryTree
- extends BinaryTree
Adds the ability of rotation to a BinaryTree
restructure
public Position restructure(Position grandchild)
throws BoundaryViolationException,
InvalidPositionException
- Applies a rotation to the given position, its parent,
and its grandparent. Their in-order order will be preserved, along
with the in-order order of all their children.
- Parameters:
grandchild - the deepest of the three positions of this
restructuring- Returns:
- The position now at the root of the newly rotated subtree
- Throws:
- BoundaryViolationException - If Position grandchild
is not the grandchild of any Position -- that is, if Position
grandchild is a child of the root, or the root itself.
- InvalidPositionException - In addition to all the usual
cases when an IPE is thrown, one is thrown when restructure(.)
is called on an external node.