#include #include #include using namespace std; #include "treesetbst.h" #include "treesetavl.h" #include "tvector.h" #include "ctimer.h" double stress(TreeSetBST * set, tvector& list) { CTimer timer; timer.Start(); for(int k=0; k < list.size(); k++){ set->insert(list[k]); } timer.Stop(); return timer.ElapsedTime(); } double join(TreeSetBST * toSet, TreeSetBST * fromSet) { CTimer timer; timer.Start(); toSet->insert(fromSet); timer.Stop(); return timer.ElapsedTime(); } int main(int argc, char * argv[]) { TreeSetBST * bstset1 = new TreeSetBST(); TreeSetBST * bstset2 = new TreeSetBST(); string word; string shake1 = "/u/ola/data/shakespeare/small.txt"; string shake2 = "/u/ola/data/shakespeare/macbeth.txt"; ifstream input1(shake1.c_str()); ifstream input2(shake2.c_str()); tvector list1,list2; while (input1 >> word) { list1.push_back(word); } while (input2 >> word) { list2.push_back(word); } double atime = stress(bstset1,list1); double btime = stress(bstset2,list2); cout << "tree1 " << atime << " " << bstset1->size() << endl; cout << "tree2 " << btime << " " << bstset2->size() << endl; double jtime = join(bstset2, bstset1); cout << "union " << jtime << " " << bstset2->size() << endl; }