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.
- Version:
- $Revision: 1.3 $, $Date: 1998/07/07 19:27:44 $
- Author:
- Mike Boilen
-
cut(Position)
-
This tree is cut above the position passed in, and that position is replaced
with an external node with a null element.
-
link(Position, Tree)
-
Position mustBeExternal is removed from the tree, and its locator is
made uncontained.
-
replaceSubtree(Position, Tree)
-
Swap out the tree rooted at subtreeRoot and replace it with the
newSubtree passed in.
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
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
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