edu.princeton.cs.algs4.growingtree.interfaces
Interface IInsertingNode<P extends NodeProperties>

Type Parameters:
P -
All Superinterfaces:
java.lang.Comparable<INode<P>>, IAlgorithmNode<P>, INode<P>
All Known Implementing Classes:
ShadowNode

public interface IInsertingNode<P extends NodeProperties>
extends IAlgorithmNode<P>

This interface is for use by an IInsertOperator to traverse and manipulate the tree. Some functions from IAlgorithmNode are redeclared here with return type IInsertingNode so as to avoid the need to cast in client code.

Author:
Josh Israel

Method Summary
 IInsertingNode<P> getLeft()
           
 IInsertingNode<P> getParent()
           
 IInsertingNode<P> getRight()
           
 IAlgorithmNode<P> insertLeft(INode<P> newNode)
          This should only be called once per call to IInsertOperator.doInsert
 IAlgorithmNode<P> insertRight(INode<P> newNode)
          This should only be called once per call to IInsertOperator.doInsert
 IInsertingNode<P> rotateLeft()
          Rotates the left child up.
 IInsertingNode<P> rotateRight()
          Rotates the right child up.
 
Methods inherited from interface edu.princeton.cs.algs4.growingtree.interfaces.IAlgorithmNode
freeze, freeze, getPredecessor, getRoot, getSuccessor
 
Methods inherited from interface edu.princeton.cs.algs4.growingtree.interfaces.INode
getLogger, getNodeProperties
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

insertLeft

IAlgorithmNode<P> insertLeft(INode<P> newNode)
This should only be called once per call to IInsertOperator.doInsert

Parameters:
newNode - Node to be inserted as the left child of this one. It should not be any node other than the newNode argument to IInsertOperator.doInsert
Returns:
The node just inserted into the tree

insertRight

IAlgorithmNode<P> insertRight(INode<P> newNode)
This should only be called once per call to IInsertOperator.doInsert

Parameters:
newNode - Node to be inserted as the left child of this one. It should not be any node other than the newNode argument to IInsertOperator.doInsert
Returns:
The node just inserted into the tree

rotateLeft

IInsertingNode<P> rotateLeft()
Description copied from interface: IAlgorithmNode
Rotates the left child up.

Specified by:
rotateLeft in interface IAlgorithmNode<P extends NodeProperties>
Returns:
The new parent of the node (the former left child).

rotateRight

IInsertingNode<P> rotateRight()
Description copied from interface: IAlgorithmNode
Rotates the right child up.

Specified by:
rotateRight in interface IAlgorithmNode<P extends NodeProperties>
Returns:
The new parent of the node (the former right child).

getLeft

IInsertingNode<P> getLeft()
Specified by:
getLeft in interface IAlgorithmNode<P extends NodeProperties>

getRight

IInsertingNode<P> getRight()
Specified by:
getRight in interface IAlgorithmNode<P extends NodeProperties>

getParent

IInsertingNode<P> getParent()
Specified by:
getParent in interface IAlgorithmNode<P extends NodeProperties>