|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.princeton.cs.algs4.growingtree.experiments.TreeExperiment
public class TreeExperiment
This is the class analogous to TreeVisualization
for experiments.
It stores a set of trees and provides a simple API to perform operations on all
of them simultaneously, with callbacks for logging.
Included is an example of how it can be used to log the number of rotations at
each height of the tree.
Constructor Summary | |
---|---|
TreeExperiment()
|
Method Summary | ||
---|---|---|
|
addTree(java.lang.String name,
P p,
IInsertOperator<P> inserter,
ISearchOperator<P> searcher,
IDeleteOperator<P> deleter,
IExperimentLogger<P> logger)
Adds a tree to the set of trees to run the experiment on. |
|
void |
delete(double d)
Deletes a node from the tree |
|
void |
insert(double d)
Insert an element into each of the trees |
|
static void |
main(java.lang.String[] args)
|
|
void |
search(double d)
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 TreeExperiment()
Method Detail |
---|
public <P extends NodeProperties> void addTree(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.public void insert(double d)
d
- Key of the node to be insertedpublic void search(double d)
d
- Key of node to be soughtpublic void delete(double d)
d
- Key of node to be deletedpublic static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |