forked from SpatioTemporal/STARE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter.cpp
53 lines (43 loc) · 1005 Bytes
/
filter.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
#include <iostream> // cout
#include <fstream> // ifsteram
#include <iomanip> // setw()
#include <stdlib.h> // rand(), drand48() but on the mac osX there
// is no drand48 yet
#include <HtmRange.h>
#define SCANRANGE(x, y) scanf("%llu %llu", &x, &y)
/*
* For examples of exercising Range and Skiplists's methods, see a, b, c
* (a.cpp, etc)
*/
void skipCRLF(ifstream &in)
{
char c = in.peek();
while (c == 10 || c == 13) {
in.ignore();
c = in.peek();
}
}
int main(int argc, char *argv[])
{
// run as a filter only
uint64 lo, hi;
HtmRange_NameSpace::HtmRange ran;
int desire;
Key gapsize;
int lines = 0;
desire = 100;
if (argc > 1){
desire = atoi(argv[1]);
}
while(2 == SCANRANGE(lo, hi)){
ran.mergeRange(lo, hi);
lines++;
}
//cerr << "Lines read: " << lines << endl;
//cerr << ran;
gapsize = ran.bestgap(desire);
// cerr << "Gapsize = " << gapsize << endl;
ran.defrag(gapsize);
cout << ran;
return 0;
}