jdsl.core.api
Interface RestructurableBinaryTree

All Known Implementing Classes:
RestructurableNodeBinaryTree

public abstract interface RestructurableBinaryTree
extends BinaryTree

Adds the ability of rotation to a BinaryTree


Method Summary
 Position restructure(Position grandchild)
          Applies a rotation to the given position, its parent, and its grandparent.
 
Methods inherited from interface jdsl.core.api.BinaryTree
cut, expandExternal, link, removeAboveExternal, replaceSubtree
 
Methods inherited from interface jdsl.core.api.InspectableBinaryTree
leftChild, rightChild, sibling
 
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

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.