All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface jdsl.core.api.Tree

public interface Tree
extends InspectableTree
Seperates the methods cut, link, and replaceSubtree out of BinaryTree so that faster implementations of BinaryTree can be created.


Method Index

 o cut(Position)
This tree is cut above the position passed in, and that position is replaced with an external node with a null element.
 o link(Position, Tree)
Position mustBeExternal is removed from the tree, and its locator is made uncontained.
 o replaceSubtree(Position, Tree)
Swap out the tree rooted at subtreeRoot and replace it with the newSubtree passed in.

Methods

 o cut
 public abstract Tree cut(Position root) throws InvalidPositionException
This tree is cut above the position passed in, and that position is replaced with an external node with a null element. The subtree cut off at that point is returned to the user as a new Tree.

Parameters:
root - The position above which to make the cut; will be the root of the tree passed back
Returns:
the subtree cut off of the tree.
Throws: InvalidPositionException
if position is null or incompatible with this container
 o link
 public abstract void link(Position mustBeExternal,
                           Tree newSubtree) throws InvalidPositionException
Position mustBeExternal is removed from the tree, and its locator is made uncontained. The root of newSubtree, with all its children and associated locators and elements, is attached as the new child of mustBeExternal's parent. newSubtree becomes invalid.

Parameters:
root - The position to insert the new Subtree.
newSubtree - The subtree to insert at the position.
Throws: InvalidPositionException
if position is null or incompatible with this container
 o replaceSubtree
 public abstract Tree replaceSubtree(Position subtreeRoot,
                                     Tree newSubtree) throws InvalidPositionException
Swap out the tree rooted at subtreeRoot and replace it with the newSubtree passed in. The subtree removed is returned as a new Tree. The Tree passed in becomes invalid.

Parameters:
subtreeRoot - A position in the DynamicBinaryTree on which the method is called
newSubtree - The subtree which is to be inserted in the place subTreeRoot currently occupies.
Returns:
A new tree, with subtreeRoot as its root
Throws: InvalidPositionException
if position is null or incompatible with this container

All Packages  Class Hierarchy  This Package  Previous  Next  Index