-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.cpp
74 lines (59 loc) · 2.08 KB
/
client.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 <vector>
#include <algorithm>
using namespace std;
#include "segment_tree.hpp"
int main()
{
{
vector<int> a = {2, 3, 1, 6, 5};
segment_tree<int, operation::min<int> > tree1(a.begin(), a.end());
segment_tree<int, operation::min<int> >::iterator it = tree1.query(0,3);
segment_tree<int, operation::sum<int> > tree2(a.begin(), a.end());
int sum = tree2.query(0,3);
cout<<sum<<"\n";
}
{
vector<int> a = {2, 3, 1, 6, 5};
segment_tree<int, operation::min<int> > tree(a.begin(), a.end());
tree.update(2,15);
tree.display();
}
{
vector<int> a = {2, 3, 1, 6, 5};
segment_tree<int, operation::min<int> > tree(a.begin(), a.end());
tree.update(2,4,15);
tree.display();
}
{
vector<int> a = {2, 3, 1, 6, 5};
segment_tree<int, operation::max<int> > tree(a.begin(), a.end());
tree.add(2,4,10);
tree.display();
}
{
vector<int> b = {1,2,2,3,6};
segment_tree<int, operation::sum<int> > tree(b.begin(), b.end());
segment_tree<int, operation::sum<int> >::iterator it = lower_bound(tree.begin(), tree.end(), 2);
cout<<*it<<"\n";
}
{
vector<int> b = {1,2,2,3,6};
segment_tree<int, operation::sum<int> > tree(b.begin(), b.end());
segment_tree<int, operation::sum<int> >::iterator it = find(tree.begin(), tree.end(), 2);
cout<<*it<<"\n";
}
{
vector<int> b = {1,2,2,3,6};
segment_tree<int, operation::sum<int> > tree(b.begin(), b.end());
typedef segment_tree<int, operation::sum<int> >::iterator seg_tree_iter;
pair<seg_tree_iter, seg_tree_iter> p = equal_range(tree.begin(), tree.end(), 2);
cout<<*p.first<<" "<<*p.second<<"\n";
}
{
vector<int> b = {1,2,2,3,6};
segment_tree<int, operation::sum<int> > tree(b.begin(), b.end());
segment_tree<int, operation::sum<int> >::iterator it = find_if(tree.begin(), tree.end(), [](int x){return x%2 == 0;});
cout<<*it<<"\n";
}
}