-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathc_example.cpp
More file actions
70 lines (60 loc) · 1.73 KB
/
c_example.cpp
File metadata and controls
70 lines (60 loc) · 1.73 KB
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
#include "k_merge_tree.h"
#include <vector>
#include <iostream>
using namespace std;
/*
A trivial example that sorts 4 vectors of sequential ints
*/
void main(void)
{
vector<int> v1;
vector<int> v2;
vector<int> v3;
vector<int> v4;
for ( int i = 0; i < 40; ++i )
{
switch ( i / 10 )
{
default:
case 0:
{
v1.push_back(i);
break;
}
case 1:
{
v2.push_back(i);
break;
}
case 2:
{
v3.push_back(i);
break;
}
case 3:
{
v4.push_back(i);
break;
}
}
}
kmerge_tree_c<int, vector<int>::iterator> merge(4);
merge.add(v1.begin(), v1.end());
merge.add(v2.begin(), v2.end());
merge.add(v3.begin(), v3.end());
merge.add(v4.begin(), v4.end());
merge.execute();
for(;;)
{
vector<int>::iterator i;
if ( !merge.get_top(i) )
{
break;
}
cout << *i << "\n";
merge.next();
}
cout << "\n";
cout << "Press <RETURN>...";
getchar();
}