jdsl
Interface BTNode


public abstract interface BTNode
extends Position


Method Summary
 void changeElement(java.lang.Object e)
          Changes the element of this Position.
 java.util.ArrayList elements(java.util.ArrayList v)
          Recursively enumerates the elements of this container.
 int getSize(int s)
          Recursively gets the size of this container.
 void invalidate()
          Makes this node invalid.
 boolean isExternal()
          Tests if this node is external.
 boolean isValid()
          Tests if this BTNode is valid.
 BTNode left()
          Returns this BTNode's left child.
 boolean onLeft()
          Tests if this node is a left child of its parent.
 BTNode parent()
          Returns the parent of this node.
 java.util.ArrayList positions(java.util.ArrayList v)
          Recursively enumerates the positions of this container.
 BTNode right()
          Returns this BTNode's left child.
 void setLeft(BTNode n)
          Changes this node's left child.
 void setParent(BTNode n)
          Changes this node's parent.
 void setRight(BTNode n)
          Changes this node's right child.
 void toExternal()
          Makes this node external
 void toInternal()
          Makes this node internal
 
Methods inherited from interface jdsl.Position
container, element
 

Method Detail

left

public BTNode left()
            throws InvalidPositionException,
                   BoundaryViolationException
Returns this BTNode's left child.
Returns:
the left child of this Position
Throws:
InvalidPositionException - if this position is invalid.
BoundaryViolationException - if this node is an external node.
See Also:
invalidate, checkValid

right

public BTNode right()
             throws InvalidPositionException,
                    BoundaryViolationException
Returns this BTNode's left child.
Returns:
the left child of this Position
Throws:
InvalidPositionException - if this position is invalid.
BoundaryViolationException - if this node is an external node.
See Also:
invalidate, checkValid

parent

public BTNode parent()
              throws InvalidPositionException,
                     BoundaryViolationException
Returns the parent of this node.
Returns:
this node's parent.
Throws:
InvalidPositionException - if this position is invalid.
BoundaryViolationException - if this node is an external node.
See Also:
invalidate, checkValid

changeElement

public void changeElement(java.lang.Object e)
                   throws InvalidElementException
Changes the element of this Position.
Throws:
InvalidPositionException - if this position is invalid.
See Also:
invalidate, checkValid

invalidate

public void invalidate()
                throws InvalidElementException
Makes this node invalid.
Throws:
InvalidPositionException - if this position is already invalid.
See Also:
checkValid

isValid

public boolean isValid()
Tests if this BTNode is valid.
Returns:
true if this BTNode is valid, false otherwise.

setLeft

public void setLeft(BTNode n)
             throws InvalidPositionException,
                    BoundaryViolationException
Changes this node's left child.
Throws:
InvalidPositionException - if this position is invalid
BoundaryViolationException - if this position is external
See Also:
invalidate, checkValid, setRight, setParent

setRight

public void setRight(BTNode n)
              throws InvalidPositionException,
                     BoundaryViolationException
Changes this node's right child.
Throws:
InvalidPositionException - if this position is invalid
BoundaryViolationException - if this position is external
See Also:
invalidate, isValid, setLeft, setParent

setParent

public void setParent(BTNode n)
               throws InvalidPositionException,
                      BoundaryViolationException
Changes this node's parent.
Throws:
InvalidPositionException - if this position is invalid
See Also:
invalidate, isValid, setLeft, setRight

onLeft

public boolean onLeft()
               throws InvalidPositionException
Tests if this node is a left child of its parent.
Returns:
true if this position is a left child, false otherwise.
Throws:
InvalidPositionException - if this node is invalid.
See Also:
isValid, invalidate

elements

public java.util.ArrayList elements(java.util.ArrayList v)
Recursively enumerates the elements of this container.
Parameters:
v - The ArrayLisy to store the elements in.
Returns:
a vector containing the elements of this subtree in pre-order order.

getSize

public int getSize(int s)
Recursively gets the size of this container.
Parameters:
size - the running total size of this container.
Returns:
the size with the addition of this subtree.

positions

public java.util.ArrayList positions(java.util.ArrayList v)
Recursively enumerates the positions of this container.
Parameters:
v - The ArrayList to store the positions in.
Returns:
an ArrayList containing the positions of this subtree in pre-order order.

isExternal

public boolean isExternal()
                   throws InvalidPositionException
Tests if this node is external.
Returns:
true if this position is external, false if not.
Throws:
InvalidPositionException - if this position is invalid.
See Also:
invalidate, isValid

toExternal

public void toExternal()
                throws InvalidPositionException
Makes this node external
Throws:
InvalidPositionException - if this position is invalid.
See Also:
invalidate, isValid

toInternal

public void toInternal()
                throws InvalidPositionException
Makes this node internal
Throws:
InvalidPositionException - if this position is invalid.
See Also:
invalidate, isValid