-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.cpp
67 lines (53 loc) · 1.52 KB
/
test.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
/*
License: GPL-3.0
Author: Gaspare Ferraro <[email protected]>
*/
#include <bits/stdc++.h>
#include "binary_search_intersection.hpp"
#include "merge_intersection.hpp"
#include "doubling_search.hpp"
#include "mutual_partitioning.hpp"
using namespace std;
int main()
{
random_device rd;
mt19937 rng(rd());
uniform_int_distribution<int> uni(1, 100);
set<int> sa, sb;
while( sa.size() < 50 ) sa.insert( uni(rng) );
while( sb.size() < 20 ) sb.insert( uni(rng) );
vector<int> a(sa.begin(), sa.end());
vector<int> b(sb.begin(), sb.end());
vector<int> c(20), d(20), e(20), f(20), g(20);
auto it = set_intersection(a.begin(), a.end(), b.begin(), b.end(), c.begin());
c.resize(it-c.begin());
printf("stl set_intersection:\n\t");
for(auto x : c)
printf("%d ", x);
printf("\n");
it = binary_search_intersection<int>(a, b, d.begin());
d.resize(it-d.begin());
printf("binary_search_intersection:\n\t");
for(auto x : d)
printf("%d ", x);
printf("\n");
it = merge_intersection<int>(a, b, e.begin());
e.resize(it-e.begin());
printf("merge_intersection:\n\t");
for(auto x : e)
printf("%d ", x);
printf("\n");
it = doubling_search_intersection<int>(a, b, f.begin());
f.resize(it-f.begin());
printf("doubling_search_intersection:\n\t");
for(auto x : f)
printf("%d ", x);
printf("\n");
it = mutual_partitioning_intersection<int>(a, b, g.begin());
g.resize(it-g.begin());
printf("mutual_partitioning:\n\t");
for(auto x : g)
printf("%d ", x);
printf("\n");
return 0;
}