]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/old/testtree.cc
update download target update for octopus release
[ceph.git] / ceph / src / test / old / testtree.cc
1
2
3 #include "../crush/BinaryTree.h"
4 using namespace crush;
5
6 #include <iostream>
7 #include <vector>
8 using namespace std;
9
10 int main()
11 {
12 BinaryTree t;
13
14 vector<int> nodes;
15
16 for (int i=0; i<30; i++) {
17 cout << "adding " << i << endl;
18 int n = t.add_node(1);
19 nodes.push_back(n);
20 //cout << t << endl;
21 }
22 cout << t << endl;
23
24 for (int k=0; k<10000; k++) {
25 if (rand() % 2) {
26 cout << "adding" << endl;
27 nodes.push_back( t.add_node(1) );
28 } else {
29 if (!nodes.empty()) {
30 //for (int i=0; i<nodes.size(); i++) {
31 int p = rand() % nodes.size();
32 int n = nodes[p];
33 assert (t.exists(n));
34 cout << "removing " << n << endl;
35 t.remove_node(n);
36
37 for (int j=p; j<nodes.size(); j++)
38 nodes[j] = nodes[j+1];
39 nodes.pop_back();
40 }
41 }
42 cout << t << endl;
43 }
44
45
46 }