-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSource.cpp
74 lines (67 loc) · 1.89 KB
/
Source.cpp
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
68
69
70
71
72
73
74
#include <iostream>
#include <set>
#include "BStree.h"
#include <iterator>
#include <vector>
#include <list>
#include <algorithm>
#include <iterator>
#include <random>
using namespace std;
template<typename InputIter>
void print(InputIter first, InputIter last) {
if (std::is_same<iterator_traits<InputIter>::iterator_category, std::random_access_iterator_tag>::value) {
cout << "Random access iterator range : ";
while (first != last)
cout << *first++ << " ";
cout << endl;
}
else {
cout << "Any input iterator range : ";
while (first != last)
cout << *first++ << " ";
cout << endl;
}
}
int main() {
const size_t sz = 15;
vector<int> v;
v.reserve(sz);
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(0,+1000);
generate_n(back_inserter(v), sz, [&]() {return (dis(gen) % 5000); });
sort(v.begin(), v.end());
cout << "\n -------------------------------- \n";
copy(v.begin(), v.end(), ostream_iterator<int>(cout, " "));
cout << "\n -------------------------------- \n";
Binary_Search_Tree<int> bb(v.begin(), v.end());
bb.PrintTree();
cout << " -------------------------------- \n";
/*
Binary_Search_Tree<int> Tree = { 40,50,30,35,10,75,23,87,68 };
Tree.PrintTree();
cout << "=========================\n";
for (auto it = Tree.begin(); it != Tree.end(); ++it)
cout << *it << " ";
cout << endl;
cout << "First : " << *Tree.begin() << endl;
cout << " Last : " << *(--Tree.end()) << endl;
Tree.erase(10);
Tree.PrintTree();
cout << "First : " << *Tree.begin() << endl;
cout << " Last : " << *(--Tree.end()) << endl;
Tree.erase(40);
cout << "=========================\n";
Tree.PrintTree();
cout << "First : " << *Tree.begin() << endl;
cout << " Last : " << *(--Tree.end()) << endl;
Binary_Search_Tree<int>::iterator it = Tree.find(23);
Tree.insert(it, 111);
Tree.PrintTree();
*/
#ifdef _WIN32
system("pause");
#endif //_WIN32
return 0;
}