|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.princeton.cs.algs4.growingtree.experiments.ExperimentTree<P>
public class ExperimentTree<P extends NodeProperties>
This wraps around the actual tree, keeping track of the root, and passing along calls between the API and the tree (e.g. logging, insertion). It should not be instantiated by the client.
Field Summary |
---|
Fields inherited from interface edu.princeton.cs.algs4.growingtree.experiments.IExperimentLogger |
---|
HEIGHT_UPDATE, SIZE_UPDATE |
Constructor Summary | |
---|---|
ExperimentTree(java.lang.String name,
P p,
IInsertOperator<P> inserter,
ISearchOperator<P> searcher,
IDeleteOperator<P> deleter,
IExperimentLogger<P> logger)
|
Method Summary | |
---|---|
void |
delete(java.lang.Double key)
Deletes a node from the tree |
void |
insert(java.lang.Double key)
Insert a node into the tree |
void |
logDeletion(ShadowNode<P> n)
Called on IDeletingNode.predecessorHibbardDelete
and IDeletingNode.successorHibbardDelete PRIOR
to the actual deletion. |
void |
logInsertion(ShadowNode<P> n)
Called on IInsertNode.insertLeft
and IInsertNode.insertRight |
void |
logOther(IAlgorithmNode<P> n,
int event_id)
Catch-all logging function for anything missed by the others. |
void |
logRotation(ShadowNode<P> n)
Called on IAlgorithmNode.rotateLeft
and IAlgorithmNode.rotateRight PRIOR
to the actual rotation. |
void |
logSearchHit(ShadowNode<P> n)
Called on ISearchingNode.markFound |
void |
search(java.lang.Double key)
Perform a search for an element |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ExperimentTree(java.lang.String name, P p, IInsertOperator<P> inserter, ISearchOperator<P> searcher, IDeleteOperator<P> deleter, IExperimentLogger<P> logger)
name
- Name of the tree to be createdp
- Instance of the proper NodeProperties subclassinserter
- The IInsertOperator to be used for this treesearcher
- The ISearchOperator to be used for this treedeleter
- The IDeleteOperator to be used for this treelogger
- The IExperimentLogger to be used for this tree. This
will receive callbacks from the tree when operations occur.Method Detail |
---|
public void insert(java.lang.Double key)
key
- Key of the node to be insertedpublic void search(java.lang.Double key)
key
- Key of node to be soughtpublic void delete(java.lang.Double key)
key
- Key of node to be deletedpublic void logInsertion(ShadowNode<P> n)
IExperimentLogger
IInsertNode.insertLeft
and IInsertNode.insertRight
logInsertion
in interface IExperimentLogger<P extends NodeProperties>
n
- Node that was just insertedpublic void logRotation(ShadowNode<P> n)
IExperimentLogger
IAlgorithmNode.rotateLeft
and IAlgorithmNode.rotateRight
PRIOR
to the actual rotation.
logRotation
in interface IExperimentLogger<P extends NodeProperties>
n
- Node is being rotated down the treepublic void logDeletion(ShadowNode<P> n)
IExperimentLogger
IDeletingNode.predecessorHibbardDelete
and IDeletingNode.successorHibbardDelete
PRIOR
to the actual deletion.
logDeletion
in interface IExperimentLogger<P extends NodeProperties>
n
- Node being deletedpublic void logSearchHit(ShadowNode<P> n)
IExperimentLogger
ISearchingNode.markFound
logSearchHit
in interface IExperimentLogger<P extends NodeProperties>
n
- Node that has been foundpublic void logOther(IAlgorithmNode<P> n, int event_id)
IExperimentLogger
logOther
in interface IExperimentLogger<P extends NodeProperties>
n
- Node being loggedevent_id
- Used to identify the event this call represents
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |