blob: d4c5ed3892fb820c2217c8b113e469a874c52735 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/*
* main.cpp
*
* Created on: Jan 25, 2017
* Author: jonas
*/
#include <iostream>
#include <string>
#include <sstream>
#include "cTree.h"
using namespace std;
int main (void)
{
cTree* a = new cTree();
cout << "Filling with data..." << endl;
for (char b = ' '; b <= '~'; b++) //insert some data into tree
{
for(char c = ' '; c<= '~'; c++)
{
stringstream ss;
ss << b;
ss << c;
a->insert(ss.str());
}
}
//a->draw();
cout << "size: "<< a->size() << endl << "Unbalance: " << a->gradeOfUnbalance() << endl << "Depth: " << a->depth() << endl;
cout << "deleting element" << endl;
a->remove((*a)[100]);
cout << "Balancing..." << endl;
a->draw();
a->sort();
cout << "size: "<< a->size() << endl << "Unbalance: " << a->gradeOfUnbalance() << endl << "Depth: " << a->depth() << endl;
//
cout << "-------------------" << endl;
a->draw();
/*for(unsigned int i = 0; i < a->size(); i++)
{
cout << (*a)[i]->getData() << ", ";
}
cout << endl;*/
/*while(1)
{
for (char i = ' '; i <= '~'; i ++)
{
string s(&i);
a->insert(&s[0]);
}
a->sort();
a->clear();
}*/
delete a;
return 0;
}
|