|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.princeton.cs.algs4.growingtree.framework.ShadowNode<P>
P
- NodeProperties subclass that parameterizes the treepublic class ShadowNode<P extends NodeProperties>
This class defines the nodes that interact directly with the
operators defined by the client. Primitives such as rotation
happen synchronously within the tree composed of these nodes,
whereas they occur asynchronously within the
GrowingTreeNode
tree.
Operators receive instances of these objects, though they are
cast to the appropriate interface. When an operator calls a
primitive, such as rotateLeft, it passed along to the
GrowingTreeNode
associated with this ShadowNode, so
that the animation can be queued up.
Field Summary | |
---|---|
IExperimentLogger<P> |
logger
|
Constructor Summary | |
---|---|
ShadowNode(double key,
P np,
ExperimentTree<P> et)
|
|
ShadowNode(GrowingTreeNode<P> node,
P np)
|
|
ShadowNode(GrowingTreeNode<P> node,
P np,
IExperimentLogger<P> logger)
|
Method Summary | |
---|---|
int |
compareTo(java.lang.Double other)
|
int |
compareTo(INode<P> other)
|
void |
freeze()
|
void |
freeze(double lengthMult)
Freezes the animation briefly and displays the current state of the tree. |
GrowingTreeNode<P> |
getGrowingNode()
|
java.lang.Double |
getKey()
|
ShadowNode<P> |
getLeft()
|
IExperimentLogger<P> |
getLogger()
|
P |
getNodeProperties()
|
ShadowNode<P> |
getParent()
|
ShadowNode<P> |
getPredecessor()
|
ShadowNode<P> |
getRight()
|
ShadowNode<P> |
getRoot()
|
ShadowNode<P> |
getSuccessor()
|
ShadowNode<P> |
insertLeft(INode<P> n)
This should only be called once per call to IInsertOperator.doInsert |
ShadowNode<P> |
insertRight(INode<P> n)
This should only be called once per call to IInsertOperator.doInsert |
boolean |
isBST()
|
void |
markFound()
This must be called on the node being sought in order to trigger the search animation. |
ShadowNode<P> |
predecessorHibbardDelete()
Identical to successorHibbardDelete, except swaps with predecessor. |
ShadowNode<P> |
rotateLeft()
Rotates the left child up. |
ShadowNode<P> |
rotateRight()
Rotates the right child up. |
ShadowNode<P> |
successorHibbardDelete()
This performs Hibbard deletion. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public IExperimentLogger<P extends NodeProperties> logger
Constructor Detail |
---|
public ShadowNode(GrowingTreeNode<P> node, P np)
public ShadowNode(GrowingTreeNode<P> node, P np, IExperimentLogger<P> logger)
public ShadowNode(double key, P np, ExperimentTree<P> et)
Method Detail |
---|
public java.lang.Double getKey()
public GrowingTreeNode<P> getGrowingNode()
public IExperimentLogger<P> getLogger()
getLogger
in interface INode<P extends NodeProperties>
public ShadowNode<P> getRight()
getRight
in interface IAlgorithmNode<P extends NodeProperties>
getRight
in interface IInsertingNode<P extends NodeProperties>
getRight
in interface ISearchingNode<P extends NodeProperties>
public ShadowNode<P> getLeft()
getLeft
in interface IAlgorithmNode<P extends NodeProperties>
getLeft
in interface IInsertingNode<P extends NodeProperties>
getLeft
in interface ISearchingNode<P extends NodeProperties>
public ShadowNode<P> getParent()
getParent
in interface IAlgorithmNode<P extends NodeProperties>
getParent
in interface IInsertingNode<P extends NodeProperties>
getParent
in interface ISearchingNode<P extends NodeProperties>
public ShadowNode<P> getRoot()
getRoot
in interface IAlgorithmNode<P extends NodeProperties>
public int compareTo(INode<P> other)
compareTo
in interface java.lang.Comparable<INode<P extends NodeProperties>>
public int compareTo(java.lang.Double other)
public P getNodeProperties()
getNodeProperties
in interface INode<P extends NodeProperties>
public ShadowNode<P> rotateLeft()
IAlgorithmNode
rotateLeft
in interface IAlgorithmNode<P extends NodeProperties>
rotateLeft
in interface IInsertingNode<P extends NodeProperties>
public ShadowNode<P> rotateRight()
IAlgorithmNode
rotateRight
in interface IAlgorithmNode<P extends NodeProperties>
rotateRight
in interface IInsertingNode<P extends NodeProperties>
public ShadowNode<P> insertLeft(INode<P> n)
IInsertingNode
IInsertOperator.doInsert
insertLeft
in interface IInsertingNode<P extends NodeProperties>
n
- 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
public ShadowNode<P> insertRight(INode<P> n)
IInsertingNode
IInsertOperator.doInsert
insertRight
in interface IInsertingNode<P extends NodeProperties>
n
- 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
public ShadowNode<P> getSuccessor()
getSuccessor
in interface IAlgorithmNode<P extends NodeProperties>
public ShadowNode<P> getPredecessor()
getPredecessor
in interface IAlgorithmNode<P extends NodeProperties>
public ShadowNode<P> successorHibbardDelete()
IDeletingNode
successorHibbardDelete
in interface IDeletingNode<P extends NodeProperties>
public ShadowNode<P> predecessorHibbardDelete()
IDeletingNode
predecessorHibbardDelete
in interface IDeletingNode<P extends NodeProperties>
public void markFound()
ISearchingNode
markFound
in interface ISearchingNode<P extends NodeProperties>
public boolean isBST()
public void freeze()
freeze
in interface IAlgorithmNode<P extends NodeProperties>
public void freeze(double lengthMult)
IAlgorithmNode
freeze
in interface IAlgorithmNode<P extends NodeProperties>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |