-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstats.h
79 lines (68 loc) · 1.74 KB
/
stats.h
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
75
76
77
78
#ifndef __STATS_H
#define __STATS_H
#include<iostream>
#include "GArray.h"
class iterstat{
public:
iterstat(int nc=0, int nl=0, double tt=0.0):
numcand(nc),numlarge(nl),time(tt){}
int numcand;
int numlarge;
double time;
};
class Stats: public GArray<iterstat *>{
public:
static double tottime;
static int totcand;
static int totlarge;
Stats(int sz=2): GArray<iterstat *>(sz){}
void add(iterstat *is){
GArray<iterstat*>::add(is);
tottime += is->time;
totcand += is->numcand;
totlarge += is->numlarge;
}
void setcand(int pos, int cand){
(*this)[pos]->numcand = cand;
totcand += cand;
}
void incrcand(int pos){
if (size() <= pos){
for(int i = size(); i <= pos; i++){
iterstat *is = new iterstat;
add(is);
}
}
(*this)[pos]->numcand++;
totcand ++;
}
void setlarge(int pos, int lar){
(*this)[pos]->numlarge = lar;
totlarge += lar;
}
void incrlarge(int pos){
if (size() <= pos){
for(int i = size(); i <= pos; i++){
iterstat *is = new iterstat;
add(is);
}
}
(*this)[pos]->numlarge++;
totlarge ++;
}
void settime(int pos, double time){
(*this)[pos]->time = time;
tottime += time;
}
friend ostream& operator << (ostream& fout, Stats& stats){
for (int i=0; i<stats.size(); i++){
fout << "[ " << i+1 << " " << stats[i]->numcand << " "
<< stats[i]->numlarge << " " << stats[i]->time << " ] ";
}
fout << "[ TOT " << totcand << " " << totlarge << " "
<< tottime << " ]";
return fout;
}
};
extern Stats stats;
#endif